Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
Quite frankly, I don't know how much more time I'm willing to put into the GUI. I've managed to implement drag selection of controls and simply moving them but that's was the easy part. Maybe I'll just leave it and add these feature to the text based macros.
The Macros.
Renumber/Set Tabs >BR?
If you want to change the tab order of controls just cut and paste
the definitions to suite the desired order. Select the definitions and they will be
renumbered and retabbed. Even if you don't need to reorder the definitions you can
still use this macro to set your tabs sequentially.
Well Formed - (control number + 99)==(API control ID)
The Dialog Editor lists definitions in the order that they were added to
the template, moving controls or adding a Groupbox does not update the tab order. To
avoid the pain/drudgery of having to manually edit the tab order use this macro to
automatically arrange the controls in row order. It will ensure that controls within
Groupboxes are placed properly (Radiobuttons with the same variable will be together as
will Groupboxes inside Groupboxes). If the order is not quite what you want it's easy
to cut and paste properly ordered groups controls and renumber them with
"Renumber/Set Tabs".
Expand Definitions
If you're manually editing your control definitions, changing the font of a number of
controls for example, it can be confusing as to which field is which. So EXPAND the
definitions then COLLAPSE them when your finished.
Space and Size
You have a row/column of buttons for example, adjust the first and last buttons to where you
want them then select and choose the desired action.
Nudge is as nudge does. Before I discovered the arrow keys by accident in the Dialog Editor, I used to use these macros a lot.
The menu calls needed are at the top of the attached script.
Thanks
George Vagenas
DIALOGTOOLS.WBT
; A collection of Studio macros for tweaking and nudging dialog templates. ; Uncomment and add the following lines to "WSP-USER.MNU" or "WSPOPUP.MNU". You'll have ; to modify the menu calls to work in your environment. ; Dialog Tools ; Renumber/Set Tabs ; call('DialogTools.wbt', 'RenumberDefs') ; Well Formed ; call('DialogTools.wbt', 'WellFormed') ; Expand Definitions ; call('DialogTools.wbt', 'Expand') ; Collapse Definitions ; call('DialogTools.wbt', 'Collapse') ; Space and Size ; Space and Size Horizontal ; call('DialogTools.wbt', 'MakeEqualH') ; Space Horizontally ; call('DialogTools.wbt', 'SpaceEqualH') ; Space and Size Vertical ; call('DialogTools.wbt', 'MakeEqualV') ; Space Vertical ; call('DialogTools.wbt', 'SpaceEqualV') ; Nudge ; Left ; call('DialogTools.wbt', 'Nudge Left') ; Right ; call('DialogTools.wbt', 'Nudge Right') ; Up ; call('DialogTools.wbt', 'Nudge Up') ; Down ; call('DialogTools.wbt', 'Nudge Down') ; Apart from indentation and trailing comments the control definitions must have the same ; format as templates created with the Dialog Editor. No blank lines, no commented out ; lines, no substitution! ; NB! This script will replace the selected lines and trash your clipboard. Save your ; script or copy the definitions prior to using these macros. ; The easiest way to work with these macros is to save your template to a "WDL" file and ; copy it into your script when your finished. By using Ctrl-F7 you can verify your ; edits and return to Studio by clicking any button. ; The Tools. ; Renumber/Set Tabs ; If you want to change the tab order of controls just cut and paste ; the definitions to suite the desired order. Select the definitions and they will be ; renumbered and retabbed. Even if you don't need to reorder the definitions you can ; still use this macro to set your tabs sequentially. ; Well Formed - (control number + 99)==(API control ID) ; The Dialog Editor lists definitions in the order that they were added to ; the template, moving controls or adding a Groupbox does not update the tab order. To ; avoid the pain/drudgery of having to manually edit the tab order use this macro to ; automatically arrange the controls in row order. It will ensure that controls within ; Groupboxes are placed properly (Radiobuttons with the same variable will be together as ; will Groupboxes inside Groupboxes). If the order is not quite what you want it's easy ; to cut and paste properly ordered groups controls and renumber them with ; "Renumber/Set Tabs". ; Expand Definitions ; If you're manually editing your control definitions, changing the font of a number of ; controls for example, it can be confusing as to which field is which. So EXPAND the ; definitions then COLLAPSE them when your finished. ; Space and Size ; You have a row/column of buttons for example, adjust the first and last buttons to where you ; want them then select and choose the desired action. ; Nudge is as nudge does. Before I discovered the arrow keys by accident in the ; Dialog Editor, I used to use these macros a lot. ; That's it, enjoy! ; Tue 8/30/2005 ; George Vagenas gvag@shaw.ca If param0<1 Then Return ; Watch out! Don't let this line get too long. If StrIndexNC('RenumberDefs Collapse Expand MakeEqualH MakeEqualV Nudge SpaceEqualH SpaceEqualV WellFormed', param1, 1, @FWDSCAN)==0 Then Return If !wGetSelstate() Display(3, '%param1%', 'No selection') Return EndIf wCopy() Goto %param1% ;------------------------------------------------------------------------------------------ :RenumberDefs Defs = ClipGet() Var = ItemExtract(1, Defs, '=') Var = StrSub(Var, 1, StrLen(Var)-3) While StrSub(Defs, StrLen(Defs)-1, 2)==@CRLF Defs = StrSub(Defs, 1, StrLen(Defs)-2) EndWhile Cnts = ItemCount(Defs, @LF) For Cnt = 1 To Cnts Def = ItemReplace(Cnt, 9, ItemReplace(StrCat(Var, StrFixLeft(Cnt, '0', 3)), 1, ItemExtract(Cnt, Defs, @LF), '='), ',') Defs = ItemReplace(Def, Cnt, Defs, @LF) Next Defs = StrCat(Defs, @CRLF) ClipPut(Defs) wPaste() ClipPut(StrFixLeft(Cnts, '0', 3)) wFind('NumControls=', 0, 0, 0, 0) wClearSel() wSelEnd() wPaste() Drop(Cnt, Cnts, Def, Defs, Var) Return ;------------------------------------------------------------------------------------------ :Expand ; Def0 = '00X,00Y,0CX,0CY,CtrlType,Var,Tit/Pre,RetVal,Tab,Style,DEFAULT,"FgClr","BgClr"' Sep = Num2Char(182) Var0 = '; nnn=' Def0 = '00X,00Y,0CX,0CY,CtrlType,Var,Tit/Pre,RetVal,Tab,Style,N|Z|S|P,"FgClr","BgClr"' DefLns = StrReplace(ClipGet(), @CRLF, Sep) Cnts = ItemCount(DefLns, Sep)-1 For Cnt = 1 To Cnts DefLn = ItemExtract(Cnt, DefLns, Sep) Var%Cnt% = ItemExtract(1, DefLn, '`') Def%Cnt% = ItemExtract(2, DefLn, '`') Next For Cnt = 0 To Cnts For i = 1 To 13 If !IsDefined(Max%i%) Then Max%i% = 0 Max%i% = Max(Max%i%, StrLen(ItemExtract(i, Def%Cnt%, ','))) Next Next DefLns = '' For Cnt = 0 To Cnts For i = 1 To 13 Fld = ItemExtract(i, Def%Cnt%, ',') If Fld=='' Then Break ; Calendar control only has eleven fields. Def%Cnt% = ItemRemove(i, Def%Cnt%, ',') Def%Cnt% = ItemInsert(StrFixLeft(Fld, ' ', Max%i%+1), i-1, Def%Cnt%, ',') Next DefLns = StrCat(DefLns, Var%Cnt%, '`', Def%Cnt%, '`', @CRLF) Next ClipPut(DefLns) wPaste() DropWild('Def*') DropWild('Var*') Drop(Cnt, Cnts, Fld, i, Sep) Return :Collapse Defs = ClipGet() While StrIndex(Defs, ', ', 1, @FWDSCAN)!=0 Defs = StrReplace(Defs, ', ', ',') EndWhile Defs = StrReplace(Defs, '` ', '`') ClipPut(Defs) wPaste() Return ;------------------------------------------------------------------------------------------ :SpaceEqualV Sep = @LF Defs = StrSub(ClipGet(), 1, StrLen(ClipGet())-1) Cnts = ItemCount(Defs, Sep) First = 10000 Last = 0 ttlHeight = 0 For Cnt = 1 To Cnts Def = ItemExtract(2, ItemExtract(Cnt, Defs, Sep), '`') ttlHeight = ttlHeight + StrTrim(ItemExtract(4, Def, ',')) Test = StrTrim(ItemExtract(2, Def, ',')) First = Min(First, Test) If Last<Test Last = Test LastPt = Cnt EndIf Next LastDef = ItemExtract(2, ItemExtract(LastPt, Defs, Sep), '`') Pad = Last + StrTrim(ItemExtract(4, LastDef, ',')) - First - ttlHeight Pad = Pad/(Cnts-1) ttlHeight = 0 For Cnt = 1 To Cnts Ln = ItemExtract(Cnt, Defs, Sep) Def = ItemExtract(2, Ln, '`') Y1 = StrFixLeft(First + Pad*(Cnt-1) + ttlHeight, '0', 3) ttlHeight = ttlHeight + ItemExtract(4, Def, ',') Def = ItemRemove(2, Def, ',') Def = ItemInsert(Y1, 1, Def, ',') Ln = ItemRemove(2, Ln, '`') Ln = ItemInsert(Def, 1, Ln, '`') Defs = ItemRemove(Cnt, Defs, Sep) Defs = ItemInsert(Ln, Cnt-1, Defs, Sep) Next ClipPut(StrCat(Defs, Sep)) wPaste() Drop(Cnt, Cnts, Def, Defs, First, Last, LastDef, LastPt, Ln, Sep, Spread) Drop(Test, Width, X1) Return ;------------------------------------------------------------------------------------------ :MakeEqualV Sep = @LF Defs = StrSub(ClipGet(), 1, StrLen(ClipGet())-1) Cnts = ItemCount(Defs, Sep) First = 10000 Last = 0 For Cnt = 1 To Cnts Def = ItemExtract(2, ItemExtract(Cnt, Defs, Sep), '`') Test = StrTrim(ItemExtract(2, Def, ',')) First = Min(First, Test) If Last<Test Last = Test LastPt = Cnt EndIf Next LastDef = ItemExtract(2, ItemExtract(LastPt, Defs, Sep), '`') Spread = Last + StrTrim(ItemExtract(4, LastDef, ',')) - First Height = Spread/Cnts For Cnt = 1 To Cnts Ln = ItemExtract(Cnt, Defs, Sep) Def = ItemExtract(2, Ln, '`') Y1 = StrFixLeft(First + Height*(Cnt-1)+Cnt-1, '0', 3) Def = ItemRemove(2, Def, ',') Def = ItemInsert(Y1, 1, Def, ',') Def = ItemRemove(4, Def, ',') Def = ItemInsert(Height, 3, Def, ',') Ln = ItemRemove(2, Ln, '`') Ln = ItemInsert(Def, 1, Ln, '`') Defs = ItemRemove(Cnt, Defs, Sep) Defs = ItemInsert(Ln, Cnt-1, Defs, Sep) Next ClipPut(StrCat(Defs, Sep)) wPaste() Drop(Cnt, Cnts, Def, Defs, First, Last, LastDef, LastPt, Ln, Sep, Spread) Drop(Test, Width, X1) Return ;------------------------------------------------------------------------------------------ :MakeEqualH Sep = @LF Defs = StrSub(ClipGet(), 1, StrLen(ClipGet())-1) Cnts = ItemCount(Defs, Sep) First = 10000 Last = 0 For Cnt = 1 To Cnts Def = ItemExtract(2, ItemExtract(Cnt, Defs, Sep), '`') Test = StrTrim(ItemExtract(1, Def, ',')) First = Min(First, Test) If Last<Test Last = Test LastPt = Cnt EndIf Next LastDef = ItemExtract(2, ItemExtract(LastPt, Defs, Sep), '`') Spread = Last + StrTrim(ItemExtract(3, LastDef, ',')) - First Width = Spread/Cnts For Cnt = 1 To Cnts Ln = ItemExtract(Cnt, Defs, Sep) Def = ItemExtract(2, Ln, '`') X1 = StrFixLeft(First + Width*(Cnt-1)+Cnt-1, '0', 3) Def = ItemRemove(1, Def, ',') Def = ItemInsert(X1, 0, Def, ',') Def = ItemRemove(3, Def, ',') Def = ItemInsert(Width, 2, Def, ',') Ln = ItemRemove(2, Ln, '`') Ln = ItemInsert(Def, 1, Ln, '`') Defs = ItemRemove(Cnt, Defs, Sep) Defs = ItemInsert(Ln, Cnt-1, Defs, Sep) Next ClipPut(StrCat(Defs, Sep)) wPaste() Drop(Cnt, Cnts, Def, Defs, First, Last, LastDef, LastPt, Ln, Sep, Spread) Drop(Test, Width, X1) Return ;------------------------------------------------------------------------------------------ :SpaceEqualH Sep = @LF Defs = StrSub(ClipGet(), 1, StrLen(ClipGet())-1) Cnts = ItemCount(Defs, Sep) First = 10000 Last = 0 ttlWidth = 0 For Cnt = 1 To Cnts Def = ItemExtract(2, ItemExtract(Cnt, Defs, Sep), '`') f00 = StrTrim(ItemExtract(3, Def, ',')) ttlWidth = ttlWidth + StrTrim(ItemExtract(3, Def, ',')) Test = StrTrim(ItemExtract(1, Def, ',')) First = Min(First, Test) If Last<Test Last = Test LastPt = Cnt EndIf Next LastDef = ItemExtract(2, ItemExtract(LastPt, Defs, Sep), '`') Pad = Last + StrTrim(ItemExtract(3, LastDef, ',')) - First - ttlWidth Pad = Pad/(Cnts-1) ttlWidth = 0 For Cnt = 1 To Cnts Ln = ItemExtract(Cnt, Defs, Sep) Def = ItemExtract(2, Ln, '`') X1 = StrFixLeft(First + Pad*(Cnt-1) + ttlWidth, '0', 3) ttlWidth = ttlWidth + ItemExtract(3, Def, ',') Def = ItemRemove(1, Def, ',') Def = ItemInsert(X1, 0, Def, ',') Ln = ItemRemove(2, Ln, '`') Ln = ItemInsert(Def, 1, Ln, '`') Defs = ItemRemove(Cnt, Defs, Sep) Defs = ItemInsert(Ln, Cnt-1, Defs, Sep) Next ClipPut(StrCat(Defs, Sep)) wPaste() Drop(Cnt, Cnts, Def, Defs, First, Last, LastDef, LastPt, Ln, Sep, Spread) Drop(Test, Width, X1) Return ;------------------------------------------------------------------------------------------ :Nudge If param1==1 Msg = 'No direction specified!' Return EndIf If StrIndexNC('Left Right Up Down', param2, 1, @FWDSCAN)==0 Msg = 'Bad direction string!%@crlf%%param2%' Return EndIf Nudge = AskLine('Nudging %param2%', 'Nudge by?', 2) If StrLower(param2)=='left' || StrLower(param2)=='right' If StrLower(param2)=='left' Then Nudge = -Nudge Pt = 1 Else If StrLower(param2)=='up' Then Nudge = -Nudge Pt = 2 EndIf Sep = @LF Defs = StrSub(ClipGet(), 1, StrLen(ClipGet())-1) Cnts = ItemCount(Defs, Sep) For Cnt = 1 To Cnts Ln = ItemExtract(Cnt, Defs, Sep) Def = ItemExtract(2, Ln, '`') Coord = StrFixLeft(ItemExtract(Pt, Def, ',')+Nudge, '0', 3) Def = ItemRemove(Pt, Def, ',') Def = ItemInsert(Coord, Pt-1, Def, ',') Ln = ItemRemove(2, Ln, '`') Ln = ItemInsert(Def, 1, Ln, '`') Defs = ItemRemove(Cnt, Defs, Sep) Defs = ItemInsert(Ln, Cnt-1, Defs, Sep) Next ClipPut(StrCat(Defs, Sep)) wPaste() Drop(Cnt, Cnts, Coord, Def, Defs, Ln, Nudge, Pt, Sep) Return ;------------------------------------------------------------------------------------------ :WellFormed chkUPs = IntControl(77, 103, 0, 0, 0) ; Get list of loaded functions. If !ItemLocate('udflalistsort', chkUPS, @TAB) Then GoSub LoadUPs ClipPut(wbsWellFormedDlg(ClipGet())) wPaste() Return :LoadUPs #DefineFunction udfLAListSort(Recs, fSep, rSep, Keys) IntControl(73, 2, 0, 0, 0) ; GoSub WBERRORHANDLER AddExtender("laffd34i.dll") ; Do some quick checking here. If fSep=='' || rSep=='' Then Return '' FldCnt = ItemCount(ItemExtract(1, Recs, rSep), fSep) RecCnt = ItemCount(Recs, rSep)-1 KeyCnt = ItemCount(Keys, ',') Db = dbOpen('', 0, 1, FldCnt+1, 0, fSep, '') ; Comma delimited, one based column numbers least to most important sort order. ; A negative number indicates a descending sort for that column. Keys = StrReplace(Keys, ' ', '') Ascends = '' For k = 1 To KeyCnt n = ItemExtract(k, Keys, ',') If !IsInt(n) Then Return '' If n<0 Then Ascends = ItemInsert(0, -1, Ascends, ',') Else Ascends = ItemInsert(1, -1, Ascends, ',') Next Keys = StrReplace(Keys, '-', '') ; Bind columns to variables. For Fld = 1 To FldCnt+1 Err = dbBindCol(Db, Fld, StrCat('Col', Fld)) If Err!=1 Then Goto Getout Next For Row = 0 To RecCnt Rec = ItemExtract(Row+1, Recs, rSep) For Fld = 1 To FldCnt Col%Fld% = ItemExtract(Fld, Rec, fSep) ; Load record data into bound variables. Next Err = dbSetEntireRecord(Db, 0, 2|4) ; Add new record. If Err!=Row Then Goto Getout ; Caller beware!. Next ; Time to sort. For Srt = 1 To KeyCnt Key = ItemExtract(Srt, Keys, ',') Ascend = ItemExtract(Srt, Ascends, ',') Err = dbSort(DB, %Key%, Ascend) If Err!=1 Then Goto Getout Next Recs = '' For Row = 0 To RecCnt Err = dbGetEntireRecord(Db, Row, 2) ; Variable record number. If Err!=1 Then Goto Getout Rec = '' For Fld = 1 To FldCnt Rec = ItemInsert(Col%Fld%, -1, Rec, fSep) Next ; Fld Recs = ItemInsert(Rec, -1, Recs, rSep) Next ; Row dbClose(Db) Return Recs :Getout dbClose(Db) Return '' :WBERRORHANDLER wError = LastError() wErrStr = IntControl(34,wError,0,0,0) wErrLine = wberrorhandlerline wErrOffset = wberrorhandleroffset wErrAssign = wberrorhandlerassignment wErrMsg = StrCat(`wError = `, wError, @CRLF, `wErrStr = `, wErrStr, @CRLF, `wErrLine = `, wErrLine, @CRLF, `wErrAssign = `, wErrAssign) Pause(`Error in udfLAListSort`, wErrMsg) Exit #EndFunction ;udfLAListSort #DefineFunction wbsWellFormedDlg(Defs) If Defs=='' Then Return 0 User32 = StrCat(DirWindows(1), 'User32.dll') Tol = 3 ; Tolerance for row match. Var = StrTrim(ItemExtract(1, Defs, '=')) Var = StrSub(Var, 1, StrLen(Var)-3) ; Remove trailing @CRLFs. While StrIndex(Defs, @CRLF, 0, @BACKSCAN)==StrLen(Defs)-1 Defs = StrSub(Defs, 1, StrLen(Defs)-2) EndWhile Defs = StrReplace(StrReplace(Defs, '=`', '=`,'), @CRLF, @LF) Defs = udfLAListSort(Defs, ',', @LF, '2,3') Cnts = ItemCount(Defs, @LF) GoSub CheckTolerance GoSub CheckGroupbox GoSub CheckOptions Indent = StrFill(' ', StrLen(ItemExtract(1, Defs, ','))-StrLen(StrTrim(ItemExtract(1, Defs, ',')))) For Cnt = 1 To Cnts Def = ItemExtract(Cnt, Defs, @LF) Def= ItemReplace(StrCat(Indent, Var, StrFixLeft(Cnt, '0', 3), '=`'), 1, Def, ',') Def= ItemReplace(Cnt, 10, Def, ',') Defs = ItemReplace(Def, Cnt, Defs, @LF) Next ;Cnt Defs = StrCat(StrReplace(StrReplace(Defs, @LF, @CRLF), '=`,', '=`'), @CRLF) Return Defs :CheckTolerance ; Check controls in tolerance range. For Cnt = 1 To Cnts-1 Swap = @FALSE Def = ItemExtract(Cnt, Defs, @LF) Ctl = StrUpper(ItemExtract(6, Def, ',')) y = ItemExtract(3, Def, ',')+Tol x = ItemExtract(2, Def, ',') Chk = Cnt+1 While y>=ItemExtract(3, ItemExtract(Chk, Defs, @LF), ',') && x>ItemExtract(2, ItemExtract(Chk, Defs, @LF), ',') Swap = @TRUE Defs = ItemRemove(Chk-1, Defs, @LF) Defs = ItemInsert(Def, Chk-1, Defs, @LF) :Skip Chk = Chk+1 EndWhile If Swap Then Cnt = Cnt-1 Next ;Cnt Return :CheckGroupbox grpNdx = 0 RECT = BinaryAlloc(16) Start = 1 While 1 grpNdx = StrIndexNC(Defs, 'GROUPBOX', grpNdx, @FWDSCAN) If grpNdx==0 Then Break For Cnt = Start To Cnts-1 Def = ItemExtract(Cnt, Defs, @LF) If StrUpper(ItemExtract(6, Def, ','))=='GROUPBOX' Then Break Next ;Cnt If Cnt>Cnts Then Break ; False flag. BinaryPoke4(RECT, 0, ItemExtract(2, Def, ',')) BinaryPoke4(RECT, 4, ItemExtract(3, Def, ',')) BinaryPoke4(RECT, 8, ItemExtract(2, Def, ',')+ItemExtract(4, Def, ',')) BinaryPoke4(RECT, 12, ItemExtract(3, Def, ',')+ItemExtract(5, Def, ',')) Start = Cnt+1 Chk = Cnt grpRow = Cnt For Cnt = grpRow+1 To Cnts Def = ItemExtract(Cnt, Defs, @LF) x = ItemExtract(2, Def, ',') y = ItemExtract(3, Def, ',') If DllCall(User32, long:"PtInRect", lpbinary:RECT, long:x, long:y)!=0 Defs = ItemRemove(Cnt, Defs, @LF) Defs = ItemInsert(Def, Chk, Defs, @LF) Chk = Chk+1 EndIf Next ;Cnt grpNdx = grpNdx+1 EndWhile BinaryFree(RECT) Return :CheckOptions optNdx = 0 Start = 1 While 1 optNdx = StrIndexNC(Defs, 'RADIOBUTTON', optNdx, @FWDSCAN) If optNdx==0 Then Return For Cnt = Start To Cnts-1 Def = ItemExtract(Cnt, Defs, @LF) If StrUpper(ItemExtract(6, Def, ','))=='RADIOBUTTON' Then Break Next ;Cnt If Cnt>Cnts Then Return ; False flag. optNdx = StrIndex(Defs, @LF, optNdx, @FWDSCAN)+2 ; Move past the last good definition. optVar = StrLower(ItemExtract(7, Def, ',')) Start = Cnt+1 Chk = Cnt optRow = Cnt For Cnt = optRow+1 To Cnts Def = ItemExtract(Cnt, Defs, @LF) f00Var = StrLower(ItemExtract(7, Def, ',')) If f00Var==optVar Start = Start+1 optNdx = StrIndex(Defs, @LF, optNdx, @FWDSCAN)+2 Defs = ItemRemove(Cnt, Defs, @LF) Defs = ItemInsert(Def, Chk, Defs, @LF) Chk = Chk+1 EndIf Next ;Cnt EndWhile Return #EndFunction ;wbsWellFormedDlg Return ;LoadUPs
Article ID: W17249
File Created: 2007:07:03:14:29:00
Last Updated: 2007:07:03:14:29:00