Record position of a Dialog box

Started by mcvpjd3, February 24, 2014, 09:34:44 AM

Previous topic - Next topic

mcvpjd3

Hi folks, quick question.

I've got an application that uses a simple dialog (not currently a Dynamic Dialog). It appears at a set point on the display when you run it. Is there any way to record if a user moves it to another part of the screen so that when the dialog is called again it can go back to the place the user moved it to rather than the original location?

Thanks

Deana

Not sure if you are aware but the x and y coordinates of the dialog can contain values with special meaning. i.e. 9999 or -1.

Specify 9999 to always force the dialog to center, or specify -1 to center but remember user placement for re-display.

Does that fit your needs?
Deana F.
Technical Support
Wilson WindowWare Inc.

kdmoyers

I've used this scheme before (in pseudo code)
Code (winbatch) Select
L = position from ini file
set box position L

master timer loop
.
.
.
P = current box position
if P != L
L = P
store L position in ini file
endif
.
.
.
end master timer loop


the idea is, the program repeatedly queries it's own position,  and if it detects change, write the new position to an ini file.  On startup, it retrieves and uses the position from the ini file.
The mind is everything; What you think, you become.

td

A crude example showing one simple way to save and restore a WIL Dialog's size and location.
Code (winbatch) Select

;; Ini file with dialog position info.
strLocIni = DirScript():"LocateMe.ini"

;;; Save current dialog location to ini file.
#DefineFunction PlacementSave(strCaption, strLocIni)
   strRect = WinPlaceGet(@Normal, strCaption)
   IniWritePvt("Position", "rect",  strRect, strLocIni)
   return 1
#EndFunction

;;; Position dialog based on saved position in ini file.
#DefineFunction PlacementRestore(strCaption, strLocIni)
   strRect = IniREadPvt("Position", "rect",  "-1", strLocIni)
   if strRect != "-1" then WinPlaceSet(@Normal, strCaption, strRect)
   then return 1
   else return 0
#EndFunction

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Rough example of UDF that can both save
;; and restore a dialogs location .
#DefineSubroutine LocateCallback(LocateMe_Handle,LocateMe_Message,LocateMe_Name,LocateMe_EventInfo,LocateMe_ChangeInfo)
   switch LocateMe_Message                                 
      case 0   ;; Initialize.
         PlacementRestore(LocateMeCaption, strLocIni)                                 
         DialogProcOptions(LocateMe_Handle,2,@TRUE)  ; Button clicks.
         ;;DialogProcOptions(LocateMe_Handle,11,@TRUE) ; System menu Close.
         break
      case 2   ;; Button pressed
      ;;case 11  ;; System menu close. (Uncomment for close system menu.)
            PlacementSave(LocateMeCaption, strLocIni)
          break
   endswitch                                               
   return(-1)
#EndSubroutine                                             

LocateMeFormat=`WWWDLGED,6.2`

LocateMeCaption=`Locate Me`
LocateMeX=-1
LocateMeY=-1
LocateMeWidth=326
LocateMeHeight=245
LocateMeNumControls=002
LocateMeProcedure=`LocateCallback`
LocateMeFont=`DEFAULT`
LocateMeTextColor=`DEFAULT`
LocateMeBackground=`DEFAULT,DEFAULT`
LocateMeConfig=0

LocateMe001=`079,230,033,010,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
LocateMe002=`201,230,033,010,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("LocateMe")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade