WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Panel Placement Manager.


; 30/07/2003
; Steffen Fraas
;
;Panel Placement Manager.
;
; This little prog can be used to place panels anywhere on the screen during run-time!
;
; Add  panel_Placement(Myini,Panelheader,"Mydialog",1)
; just before the dialog("Mydialog") statement.
; The 1 indicates that this in panel number 1, etc.
; Look out for the small number in the bottom right-hand corner.
;
; Function Panel_Manager can be used to control the placement of panels.
;
; Allocate an ini file and give it a spin. (A solution looking for a problem?)


         Myini=" your ini file "
         Panelheader="Panel"



         #DefineFunction panel_Data(Myini,Panelheader,Pdpanel_number,Pdpanel_prefixx,Pdpanel_prefixy,Pdpanel_prefixwidth,Pdpanel_prefixheight) ;{{{#DEFINEFUNCTION Panel_Data}}} ; From 64
            Pdreturn=StrCat(Pdpanel_prefixx,@Tab,Pdpanel_prefixy) ; Default return code.
            If IniReadPvt(Panelheader,StrCat("Panel",Pdpanel_number),"",Myini)=="" Then Return Pdreturn
            Pdx=IniReadPvt(Panelheader,StrCat("Panel",Pdpanel_number),"",Myini)
            Pdx=ItemReplace(Pdpanel_prefixx,1,Pdx,",")     ; For showing X.
            Pdx=ItemReplace(Pdpanel_prefixy,2,Pdx,",")     ; For showing Y.
            Pdx=ItemReplace(Pdpanel_prefixwidth,3,Pdx,",") ; For showing width.
            Pdx=ItemReplace(Pdpanel_prefixheight,4,Pdx,",") ; For showing height.
            IniWritePvt(Panelheader,StrCat("Panel",Pdpanel_number),Pdx,Myini)
            Pdy=ItemExtract(6,Pdx,",")
            Pdx=ItemExtract(5,Pdx,",")
            If IsNumber(Pdx) Then Pdx=WinMetrics(0)/WinMetrics(-6)*Pdx/1000
            If IsNumber(Pdy) Then Pdy=WinMetrics(1)/WinMetrics(-5)*Pdy/1000
            If Pdx=="random" Then Pdx=Random(WinMetrics(0)/WinMetrics(-6)/2)+1
            If Pdy=="random" Then Pdy=Random(WinMetrics(1)/WinMetrics(-5)/2)+1
            If Pdx=="centred" Then Pdx=WinMetrics(0)/WinMetrics(-6)/2-Pdpanel_prefixwidth/2
            If Pdy=="centred" Then Pdy=WinMetrics(1)/WinMetrics(-5)/2-Pdpanel_prefixheight/2
            If Pdx=="left" Then Pdx=1
            If Pdy=="top" Then Pdy=1
            If Pdx=="right" Then Pdx=WinMetrics(0)/WinMetrics(-6)
            If Pdy=="bottom" Then Pdy=WinMetrics(1)/WinMetrics(-5)
            If Pdx=="as last" Then Pdx=Intcontrol(75,1,0,0,0)
            If Pdy=="as last" Then Pdy=Intcontrol(75,2,0,0,0)
            If Pdx+Pdpanel_prefixwidth>=WinMetrics(0)/WinMetrics(-6) Then Pdx=WinMetrics(0)/WinMetrics(-6)-Pdpanel_prefixwidth-1
            If Pdy+Pdpanel_prefixheight>=WinMetrics(1)/WinMetrics(-5)-15 Then Pdy=WinMetrics(1)/WinMetrics(-5)-15-Pdpanel_prefixheight
            Return StrCat(Pdx,@Tab,Pdy)
         #EndFunction                                      ; Panel_data.
         #DefineSubRoutine panel_Placement(Myini,Panelheader,Pppanel_prefix,Pppanel_number) ;{{{#DEFINEFUNCTION Panel_Placement}}} ; From 97 177
            %pppanel_prefix%numcontrols=%pppanel_prefix%numcontrols+1 ; Increment control numbers.
            Pppanel_number_length=StrLen(Pppanel_number)   ; String length of panel number.
            If Pppanel_number_length==1
               Pppanel_placement_x=%pppanel_prefix%width-5 ; X Location of single digit panel #.
               Pppanel_placement_y=%pppanel_prefix%height-7 ; Y Location of single digit panel #.
             Else                                          ; ! Pppanel_number_length==1.
               Pppanel_placement_x=%pppanel_prefix%width-7 ; X Location of double digit panel #.
               Pppanel_placement_y=%pppanel_prefix%height-7 ; Y location of double digit panel #.
            EndIf                                          ; Pppanel_number_length==1.
            Pppanel_newline=StrCat("%Pppanel_prefix%",StrFixLeft(%pppanel_prefix%numcontrols,"0",3),"=`",Pppanel_placement_x,",")
            Pppanel_newline=StrCat(Pppanel_newline,Pppanel_placement_y,",012,008,STATICTEXT,DEFAULT,",Pppanel_number)
            Pppanel_newline=StrCat(Pppanel_newline,",DEFAULT,2,DEFAULT,""Times New Roman|4277|40|18"",""0|0|0"",DEFAULT`")
            %pppanel_newline%                              ; Complete last dialog variable.
            Pppanel_location=panel_Data(Myini,Panelheader,Pppanel_number,%pppanel_prefix%x,%pppanel_prefix%y,%pppanel_prefix%width,%pppanel_prefix%height) ; Line 23
            %pppanel_prefix%x=ItemExtract(1,Pppanel_location,@Tab) ; Set possible new X coordinate.
            %pppanel_prefix%y=ItemExtract(2,Pppanel_location,@Tab) ; Set possible new Y corodinate.
            DropWild("ppPanel_*")                          ; Clean up.
            Return
         #EndSubRoutine                                    ; Panel_placement.




         For X=1 To 3
            Mydialogformat=`WWWDLGED,6.1`

            Mydialogcaption=`WIL Dialog 1`
            Mydialogx=002
            Mydialogy=053
            Mydialogwidth=201
            Mydialogheight=257
            Mydialognumcontrols=005
            Mydialogprocedure=`DEFAULT`
            Mydialogfont=`DEFAULT`
            Mydialogtextcolor=`DEFAULT`
            Mydialogbackground=`DEFAULT,DEFAULT`
            Mydialogconfig=0

            Mydialog001=`044,180,033,011,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
            Mydialog002=`129,180,033,011,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            Mydialog003=`023,038,145,010,STATICTEXT,DEFAULT,"Click three times",DEFAULT,3,DEFAULT,"Microsoft Sans Serif|8192|40|34","0|0|0",DEFAULT`
            Mydialog004=`012,062,129,010,STATICTEXT,DEFAULT,"Set X and Y to Random for new id # 1",DEFAULT,4,DEFAULT,"Microsoft Sans Serif|7373|40|34","0|0|0",DEFAULT`
            Mydialog005=`007,098,177,011,STATICTEXT,DEFAULT,"...and rerun program to see this panel move about!",DEFAULT,5,DEFAULT,"Microsoft Sans Serif|7373|40|34","0|0|0",DEFAULT`

; call Panel_Placement to set Mydialogx and Mydialogy variables if controlled by Panel_Manager.
;
            panel_Placement(Myini,Panelheader,"Mydialog",1) ; This is panel number id # 1. ; Line 50

            Buttonpushed=Dialog("MyDialog")

         Next                                              ; X=1 To 3.

















         #DefineFunction panel_Manager(Myini,Panelheader)  ; From 294
            Intcontrol(72,2,0,0,0)
            Cancel=0
            Dispid=1
            Panel_id=""
            GoSub CLEARALL                                 ; Line 226
            While @True
               Pplaceformat=`WWWDLGED,6.1`
               Pplacecaption=`Panel Placement`
               Pplacex=-1
               Pplacey=-1
               Pplacewidth=205
               Pplaceheight=152
               Pplacenumcontrols=038
               Pplaceprocedure=`DEFAULT`
               Pplacefont=`DEFAULT`
               Pplacetextcolor=`DEFAULT`
               Pplacebackground=`DEFAULT,DEFAULT`
               Pplaceconfig=0
               Pplacebackground=`DEFAULT,"230|255|255"`
               Pplace001=`004,007,041,011,STATICTEXT,DEFAULT,"Panel id:",DEFAULT,5,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace002=`034,007,052,011,VARYTEXT,Panel_id,"",DEFAULT,6,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace003=`050,007,015,011,STATICTEXT,DEFAULT,"X:",DEFAULT,7,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace004=`057,007,020,011,VARYTEXT,Panel_X,"",DEFAULT,8,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace005=`087,007,015,011,STATICTEXT,DEFAULT,"Y:",DEFAULT,9,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace006=`097,007,025,010,VARYTEXT,Panel_Y,"",DEFAULT,10,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace007=`122,007,025,011,STATICTEXT,DEFAULT,"Width:",DEFAULT,11,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace008=`142,007,025,011,VARYTEXT,Panel_width,"",DEFAULT,12,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace009=`162,007,025,011,STATICTEXT,DEFAULT,"Height:",DEFAULT,13,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace010=`183,007,025,010,VARYTEXT,Panel_height,"",DEFAULT,14,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace011=`073,023,064,011,STATICTEXT,DEFAULT,"Location for X",DEFAULT,15,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace012=`001,034,038,011,CHECKBOX,Panel_xra,"Random",1,16,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace013=`038,034,033,011,CHECKBOX,Panel_xc,"Centred",1,17,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace014=`073,034,024,011,CHECKBOX,Panel_xl,"Left",1,18,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace015=`099,034,024,011,CHECKBOX,Panel_xr,"Right",1,19,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace016=`134,034,033,011,CHECKBOX,Panel_xa,"As last",1,20,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace017=`169,034,015,011,EDITBOX,Panel_newx,DEFAULT,DEFAULT,11,DEFAULT,DEFAULT,DEFAULT,"206|255|206"`
               Pplace018=`189,035,054,011,STATICTEXT,DEFAULT,"X",DEFAULT,21,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace019=`073,055,064,011,STATICTEXT,DEFAULT,"Location for Y",DEFAULT,22,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace020=`001,064,038,011,CHECKBOX,Panel_yra,"Random",1,23,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace021=`038,064,033,011,CHECKBOX,Panel_yc,"Centred",1,24,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace022=`073,064,024,011,CHECKBOX,Panel_yl,"Top",1,25,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace023=`099,064,030,011,CHECKBOX,Panel_yr,"Bottom",1,26,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace024=`134,064,033,011,CHECKBOX,Panel_ya,"As last",1,27,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace025=`169,064,015,011,EDITBOX,Panel_newy,"",DEFAULT,28,DEFAULT,DEFAULT,DEFAULT,"206|255|206"`
               Pplace026=`189,065,054,011,STATICTEXT,DEFAULT,"Y",DEFAULT,29,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace027=`002,090,040,011,STATICTEXT,DEFAULT,"Display id # ",DEFAULT,30,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace028=`040,090,011,010,EDITBOX,Panel_dispid,DEFAULT,DEFAULT,31,DEFAULT,DEFAULT,DEFAULT,"206|255|206"`
               Pplace029=`075,090,040,011,STATICTEXT,DEFAULT,"Delete id # ",DEFAULT,32,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace030=`113,090,011,010,EDITBOX,Panel_delid,DEFAULT,DEFAULT,33,DEFAULT,DEFAULT,DEFAULT,"206|255|206"`
               Pplace031=`150,090,040,011,STATICTEXT,DEFAULT,"New id # ",DEFAULT,34,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT`
               Pplace032=`180,090,011,010,EDITBOX,Panel_newid,DEFAULT,DEFAULT,35,DEFAULT,DEFAULT,DEFAULT,"206|255|206"`
               Pplace033=`003,102,044,011,PUSHBUTTON,DEFAULT,"Display #",5,5,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"`
               Pplace034=`078,102,044,011,PUSHBUTTON,DEFAULT,"Delete #",4,4,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"`
               Pplace035=`150,102,044,011,PUSHBUTTON,DEFAULT,"New #",3,3,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"`
               Pplace036=`038,119,034,011,PUSHBUTTON,DEFAULT,"Cancel",2,2,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"`
               Pplace037=`115,119,034,011,PUSHBUTTON,DEFAULT,"OK",1,1,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"`
               Pplace038=`002,135,244,011,VARYTEXT,Panel_error,"",DEFAULT,31,DEFAULT,"MS Sans Serif|5632|70|34","255|0|0",DEFAULT`
               panel_Placement(Myini,Panelheader,"Pplace",2) ; Line 50
               Btn=Dialog("Pplace")
               Panel_error=""
               If Btn==Cancel || Btn==2 || Btn==1 Then Break ; Exit.
               If Btn==5 Then GoSub DISPLAYIT              ; Line 244
               If Btn==4 Then GoSub DELETE                 ; Line 274
               If Btn==3 Then GoSub SAVEIT                 ; Line 186
            EndWhile                                       ; @True.
            Return
:SAVEIT                                                    ; From 183
            Panel_error="New id # missing"
            If Panel_newid=="" Then Return
            Panel_error="New id # not valid"
            If !IsNumber(Panel_newid) Then Return
            Panel_error="No data for X or Y entered"
            If !(Panel_xra || Panel_xc || Panel_xl || Panel_xr || Panel_xa) && Panel_newx==""  || !(Panel_yra || Panel_yc || Panel_yl || Panel_yr || Panel_ya) && Panel_newy=="" Then Return
            Panel_error="Check only one value for X and one value for Y"
            If Panel_xra + Panel_xc + Panel_xl + Panel_xr + Panel_xa >1 || Panel_yra + Panel_yc + Panel_yl + Panel_yr + Panel_ya >1 Then Return
            Panel_error="Enter only one value for X and one value for Y"
            If ((Panel_xra || Panel_xc || Panel_xl || Panel_xr || Panel_xa) && Panel_newx<>"") || ((Panel_yra || Panel_yc || Panel_yl || Panel_yr || Panel_ya) && Panel_newy<>"") Then Return
            Panel_error="Value entered for X is not numeric"
            If Panel_newx<>"" && !IsNumber(Panel_newx) Then Return
            Panel_error="Value entered for Y is not numeric"
            If Panel_newy<>"" && !IsNumber(Panel_newy) Then Return
            Panel_error="Value entered for X outside range (1-999)"
            If Panel_newx<>"" && Panel_newx>999 Then Return
            Panel_error="Value entered for Y outside range (1-999)"
            If Panel_newy<>"" && Panel_newy>999 Then Return
            Pdx=",,,,"                                     ; Place holders for x, y, width and height.
            If Panel_newx<>"" Then Pdx=StrCat(Pdx,Panel_newx,",")
            If Panel_xra Then Pdx=StrCat(Pdx,"random,")
            If Panel_xc Then Pdx=StrCat(Pdx,"centred,")
            If Panel_xl Then Pdx=StrCat(Pdx,"left,")
            If Panel_xr Then Pdx=StrCat(Pdx,"right,")
            If Panel_xa Then Pdx=StrCat(Pdx,"as last,")
            If Panel_newy<>"" Then Pdx=StrCat(Pdx,Panel_newy)
            If Panel_yra Then Pdx=StrCat(Pdx,"random")
            If Panel_yc Then Pdx=StrCat(Pdx,"centred")
            If Panel_yl Then Pdx=StrCat(Pdx,"top")
            If Panel_yr Then Pdx=StrCat(Pdx,"bottom")
            If Panel_ya Then Pdx=StrCat(Pdx,"as last")
            IniWritePvt(Panelheader,StrCat("Panel",Panel_newid),Pdx,Myini)
            Panel_error=StrCat("Data saved for panel id # ",Panel_newid)
            Panel_id=Panel_newid
            Panel_x=""
            Panel_y=""
            Panel_width=""
            Panel_height=""
            Return
:CLEARALL                                                  ; From 124 284
            Panel_x=""
            Panel_y=""
            Panel_width=""
            Panel_height=""
            Panel_xra=0
            Panel_xc=0
            Panel_xl=0
            Panel_xr=0
            Panel_xa=0
            Panel_newx=""
            Panel_yra=0
            Panel_yc=0
            Panel_yl=0
            Panel_yr=0
            Panel_ya=0
            Panel_newy=""
            Return
:DISPLAYIT                                                 ; From 181
            Panel_error="Display id # missing"
            If Panel_dispid=="" Then Return
            Panel_error="Display id # not valid"
            If !IsNumber(Panel_dispid) Then Return
            Pdx=IniReadPvt(Panelheader,StrCat("Panel",Panel_dispid),"",Myini)
            Panel_error=StrCat("Panel id # ",Panel_dispid," not found")
            If Pdx=="" Then Return
            Panel_error=""
            Panel_id=Panel_dispid
            Panel_x=ItemExtract(1,Pdx,",")
            Panel_y=ItemExtract(2,Pdx,",")
            Panel_width=ItemExtract(3,Pdx,",")
            Panel_height=ItemExtract(4,Pdx,",")
            Iddata=StrLower(ItemExtract(5,Pdx,","))
            If StrClean(Iddata,"0123456789","",@True,1)=="" Then Panel_newx=Iddata
            If Iddata=="random" Then Panel_xra=1
            If Iddata=="centred" Then Panel_xc=1
            If Iddata=="left" Then Panel_xl=1
            If Iddata=="right" Then Panel_xr=1
            If Iddata=="as last" Then Panel_xa=1
            Iddata=StrLower(ItemExtract(6,Pdx,","))
            If StrClean(Iddata,"0123456789","",@True,1)=="" Then Panel_newy=Iddata
            If Iddata=="random" Then Panel_yra=1
            If Iddata=="centred" Then Panel_yc=1
            If Iddata=="top" Then Panel_yl=1
            If Iddata=="bottom" Then Panel_yr=1
            If Iddata=="as last" Then Panel_ya=1
            Panel_id=Panel_dispid
            Return
:DELETE                                                    ; From 182
            Panel_error="Delete id # mssing"
            If Panel_delid=="" Then Return
            Panel_error="Delete id # not valid"
            If !IsNumber(Panel_delid) Then Return
            Panel_error=StrCat("Data for id # ",Panel_delid," not found")
            If IniReadPvt(Panelheader,StrCat("Panel",Panel_delid),"",Myini)=="" Then Return
            Panel_error=StrCat("Data deleted for id # ",Panel_id)
            IniDeletePvt(Panelheader,StrCat("Panel",Panel_delid),Myini)
            Panel_id=""
            GoSub CLEARALL                                 ; Line 226
            Return
:CANCEL
            Intcontrol(72,2,0,0,0)
            Cancel=1
            Return
         #EndFunction                                      ; Panel_manager.


; call manager to set x and y for numbered panels.
         panel_Manager(Myini,Panelheader)                  ; Line 119

Article ID:   W15922
File Created: 2004:03:30:15:41:42
Last Updated: 2004:03:30:15:41:42