Assembly Posted May 12, 2011 Share Posted May 12, 2011 Below is a drop in function I'm testing. Use at your own risk... working alright for me so far. This function can be used with an event enabled button. Basic dialog that looks at external file to build a Symbol Resource. It will import the symbol into the current file and place in the folder name. I'd like to refine and build a specific list from an external files symbol folder rather than one large list. Can anyone point me to some documentation that might help. Thanks Function ImportSymbol(FolderID:INTEGER;FolderName:STRING):Handle; CONST kStartStringAt = 3000; kOK = 1; kCancel = 2; kImagePopup15 = 15; kStaticText28 = 28; kStaticText29 = 29; kRight = 1; kBottom = 2; kLeft = 3; kResize = 0; kShift = 1; VAR dialog1 :INTEGER; gImagePopup15Int :INTEGER; gImagePopup15Str :STRING; defConListID :LONGINT; defConResType :INTEGER; defConFoldID :INTEGER; defConCount :LONGINT; xmlID :LONGINT; cnt :INTEGER; int :INTEGER; boo :BOOLEAN; str :STRING; ndx :INTEGER; iImage:INTEGER; FUNCTION ResourceIsOK :BOOLEAN; BEGIN IF SetVSResourceFile('IP Resources') THEN ResourceIsOK := TRUE ELSE Message('The "IP Resources" file was not found.'); END; FUNCTION GetPlugInString(ndx :INTEGER) :STRING; BEGIN CASE ndx OF {Static Text} 3001: GetPlugInString := 'OK'; 3002: GetPlugInString := 'Cancel'; 3003: GetPlugInString := 'Untitled Dialog'; 3028: GetPlugInString := 'Image:'; 3029: GetPlugInString := 'Import Symbol:'c; {Help Text} 4001: GetPlugInString := 'Accepts dialog data.'; 4002: GetPlugInString := 'Cancels operation without changes.'; 4015: GetPlugInString := 'An image popup control.'; 4028: GetPlugInString := 'Static text control.'; 4029: GetPlugInString := 'Static text control.'; END; END; FUNCTION GetStr(ndx :INTEGER) :STRING; BEGIN GetStr := GetPlugInString(ndx + kStartStringAt); END; PROCEDURE dialog1_Setup; BEGIN dialog1 := CreateLayout(GetStr( 3), True, GetStr(kOK), GetStr(kCancel)); CreateControl (dialog1, kImagePopup15, 10, '', 0); CreateStaticText (dialog1, kStaticText28, GetStr(kStaticText28), 12); CreateStaticText (dialog1, kStaticText29, GetStr(kStaticText29), 12); SetFirstLayoutItem(dialog1, kStaticText29); SetBelowItem (dialog1, kStaticText29, kStaticText28, 0, 0); SetRightItem (dialog1, kStaticText28, kImagePopup15, 0, 0); AlignItemEdge(dialog1, kImagePopup15, kLeft, 222, kShift); FOR cnt := 1 TO 6 DO SetHelpString(cnt, GetStr(cnt + 1000)); END; PROCEDURE dialog1_Handler(VAR item :LONGINT; data :LONGINT); BEGIN CASE item OF SetupDialogC: BEGIN defConResType := 16; defConFoldID := FolderID; defConListID := BuildResourceList(defConResType, defConFoldID, '', defConCount); FOR cnt := 1 TO defConCount DO BEGIN int := InsertImagePopupResource(dialog1, kImagePopup15, defConListID, cnt); END; END; kOK: BEGIN iImage:=GetImagePopupSelectedItem(dialog1, kImagePopup15); ImportSymbol:=ImportResourceToCurrentFile(defConListID, iImage); IF GetObject(FolderName)=NIL Then Begin; NameObject(FolderName); BeginFolder; EndFolder; END; InsertSymbolInFolder(GetObject(FolderName),ImportSymbol) END; END; END; BEGIN gImagePopup15Int := 0; gImagePopup15Str := ''; IF ResourceIsOK THEN dialog1_Setup; IF RunLayoutDialog(dialog1, dialog1_Handler) = 1 then BEGIN END; END; Quote Link to comment
Assembly Posted May 12, 2011 Author Share Posted May 12, 2011 Got it. BuildResourceList(defConResType, defConFoldID, '', defConCount); The '' is for a sub folder. I created a subfolder in the user directory and included the folder name. BuildResourceList(defConResType, defConFoldID, 'Basin', defConCount); This now loads only the symbols from basins. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.