
that's the side track I didn't want. Because technically there are 3 different Dialogs, with 3 different titles, in 2 different EXE that use this coordinates. So the builtin -1 is not enough. I need to be able to record where the dialog is using my own process and return all of the 3 dialogs to that same point.
Like I said, I am achieving the results I need... I just would like to avoid the flashing pop that happens when the Dialog is first created and when the Winplace moves it. But I for the life of me cannot get the math to work.
The issue lies on the fact that I create a very simple dialog
WinPosition says the UpperLeftX = 312 and the UpperLeftY = 555
but the MyDialog says UpperLeftX = 250 and UpperLeftY = 250
So how do I reconcile what WinPosition recorded and translate it into what the DialogX and DialogY want
====
Gosub UDFs
; **************************************************************************************************
; BEGIN MAIN()
; **************************************************************************************************
IntControl(12,5,"",0,0) ; Allow Close and "logout/shutdown" without any dialog/prompts from Winbatch
IntControl(1002, 0, 0, 0, 0) ; HIDE WinBatch Icon
IntControl(1008,0,0,0,0) ; Disable Close via Menu
IntControl(1003, 0, 0, 0, 0) ; Prevents the WinBatch ICON from being opened
MyExe = IntControl(1004, 0, 0, 0, 0) ; Get fully qualified name of the current WB program
MyMD5 = FileDigest(MyExe,"MD5",0)
MyVersion = Strreplace(FileVerInfo(MyExe, "", "#FileVersion" ),",",".")
MyFolder = strLower(FilePath(MyExe))
MyExt = FileExtension(MyExe)
if strLower(MyExt) == "wbt" then
MyVersion = "DEBUG"
MyFolder = "P:\Applications\PeopleSearch\bin"
DirChange(MyFolder)
end if
if RegExistValue(@REGCURRENT,"Software\MyCompany\MyProduct[LastCoords]") then
ShouldbeWinPos_Coords = RegQueryValue(@REGCURRENT,"Software\MyCompany\MyProduct[LastCoords]")
ShouldbeX = ItemExtract(1,ShouldbeWinPos_Coords,",")
ShouldbeY = ItemExtract(2,ShouldbeWinPos_Coords,",")
if ItemCount(ShouldbeWinPos_Coords,",") != 4 || !isInt(ShouldbeX) || !isInt(ShouldbeY) then
ShouldbeWinPos_Coords = ""
end if
else
ShouldbeWinPos_Coords = ""
end if
; this helps us control the soon to be create Dialog, in a real script these would be deduced from sometting more complex
ThisDialogCoordsX = 250
ThisDialogCoordsY = 250
ThisDialogWidth = 200
ThisDialogHeight = 80
ThisDialogTitle = "Test Dialog v" : MyVersion
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`Test Dialog v10.10.10.10`
MyDialogX=250
MyDialogY=250
MyDialogWidth=196
MyDialogHeight=074
MyDialogNumControls=004
MyDialogProcedure=`TestDialogProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`095,055,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`141,055,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",999,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`015,005,156,012,VARYTEXT,"Dialog_Coords",Dialog_Coords,DEFAULT,DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`015,021,156,012,VARYTEXT,"WinPos_Coords",WinPos_Coords,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
;ButtonPushed=Dialog("MyDialog")
; ^ Preserved to allow Clipboard import and export into WIL Dialog Editor
MyDialogCaption = ThisDialogTitle
MyDialogX = ThisDialogCoordsX
MyDialogY = ThisDialogCoordsY
MyDialogWidth = ThisDialogWidth
MyDialogHeight = ThisDialogHeight
Dialog_Coords = MyDialogX : "," : MyDialogY : "," : MyDialogWidth : "," : MyDialogHeight
ButtonPushed=Dialog("MyDialog")
Exit
; **************************************************************************************************
; END MAIN()
; **************************************************************************************************
; **********************************************
; BEGIN OF UDFs Definition Block
; **********************************************
:UDFs
#DefineSubroutine TestDialogProc(Handle,DialogMessage,ControlName,EventInfo,ChangeInfo)
Switch DialogMessage
Case 0 ; Init dialog
WinPos_Coords = WinPosition(ThisDialogTitle)
DialogProcOptions( Handle, 1002, 2) ; Enable Close and Minimize buttons in titlebar
DialogProcOptions( handle, 1, 333) ; we Care about Timer Ticks of 333ms
DialogProcOptions( handle, 2, 1) ; we Care about Buttons
DialogProcOptions( Handle, 11, 1) ; We care about the Close button "X" in Titlebar
DialogControlSet(handle,"WinPos_Coords",4,WinPos_Coords)
; ***********************************************************************************************
; If we can't find a way to calculate MyDialogX and MyDialogY based on ShouldbeWinPos_Coords then
if ShouldbeWinPos_Coords != "" then
WinPlace(%ShouldbeWinPos_Coords%,ThisDialogTitle)
end if
;************************************************************************************************'
Return(-2)
break
Case 1 ; Timer
NewWinPos_Coords = WinPosition(ThisDialogTitle)
if NewWinPos_Coords != WinPos_Coords then
WinPos_Coords = NewWinPos_Coords
DialogControlSet(handle,"WinPos_Coords",4,WinPos_Coords)
end if
;I cannot find a way to query the dialog for its coords in the same format that
;MyDialogX= and MyDialogY= uses
;NewDialog_Coords = ?
;if NewDialog_Coords != Dialog_Coords then
; Dialog_Coords = NewDialog_Coords
; DialogControlSet(handle,"Dialog_Coords",4,Dialog_Coords)
;end if
Case 2; Button
if ControlName == "PushButton_Cancel" then
WinPos_Coords = WinPosition(ThisDialogTitle)
LastCoords = ItemExtract(1,WinPos_Coords,",") : "," : ItemExtract(2,WinPos_Coords,",") : ",@NORESIZE,@NORESIZE"
RegSetValue(@REGCURRENT,"Software\MyCompany\MyProduct[LastCoords]",LastCoords)
Return(0)
end if
return(-2)
break
Case 11 ; Close Button in Title
WinPos_Coords = WinPosition(ThisDialogTitle)
LastCoords = ItemExtract(1,WinPos_Coords,",") : "," : ItemExtract(2,WinPos_Coords,",") : ",@NORESIZE,@NORESIZE"
RegSetValue(@REGCURRENT,"Software\MyCompany\MyProduct[LastCoords]",LastCoords)
Return(0)
break
; End Cases
End Switch
Return (-2)
#EndSubroutine
return
; **********************************************
; END OF UDFs Definition Block
; **********************************************