Jump to content

How to Allow users to reposition GUI Winodws


Recommended Posts

Hi,

I have created a GUI Control with various items within it.

In addition I use MSGBOX, Progress and other notification boxes to interact with the user.

How can I allow the user to reposition the Main GUI window as well as any 'notification' type windows spawned from this GUI?

This is required as some times the default placement covers information the user needs to see in order to move onto the next step of the process.

Thanx

Link to comment
Share on other sites

I use Msgbox

Msgbox will always open centered. Use WinMove() to move it elsewhere (more details below)

How can I allow the user to reposition the Main GUI window...

That should be just "grab the title bar and drag", like any non-maximized window. Thus since you asked, please explain if there's some reason that won't work for you.

How can I allow the user to reposition ... my 'notification' type windows spawned from this GUI?

GuiCreate them youself, or WinMove() them

Let me just ramble on as I am wont to do, in case you find something useful among my comments.

-- would you like to save your window position between executions? (i.e. the user goes "grumble grumble", and drags you window so it doesn't cover what he needs to see?

If so you might consider "watching" your own window position with a "$a = WinList()" function, then grab you x/y and write it to a file (or a registry entry, or ini file or whatever).

Then when your program starts up, instead of it taking the default of where windows says to open it, you open it at the same coordinates it was when it was last closed. (might have a button "save window position", or just do it yourself at window close time).

-- would you like "popups" to go where the user last moved them?

Again, when you do a popup, record its position with winlist(), then when the user closes it, do another winlist() and see if the user moved it before closing it (presumably to uncover something). Again, you can then pop it up NEXT TIME where it last was. ... and even REMEMBER where the user did it across invocations of your program if you save it externally somewhere.

Use WinMove() to move your MsgBox out of the center, to where the USER last moved it.

Logic is something like this:

set $msgbox_x and $msgbox_y to -1 and -1

bring up the msg box

IF the values of $msgbox_x and $msgbox_y are NOT -1,

Use winlist() to find your window, and

use winmove() to move the msg box to that coordinate.

when the msg box is closed, record its coordinates before closing and see if the user moved it. (*)

If the user moved it, record this in $msgbox_x and $msgbox_y

(*) maybe the msgbox is closed when you get back the "OK" or other signal. Hmm.. In that case you could do a winlist on the msgbox in a loop looking to see if the coordinates are changing, and if so record them in $msgbox_x and $msgbox_y, such that when the window IS closed, you have recorded its last position very recently.

Thus, when the msg box pops up, if the user had moved it before, you'll "quickly" move it to that location from its default centered location. if the user moves it again before closing, the next msgbox will move from the middle to that NEW user-defined position.

Again, you could have a "save window positions" that explicitly writes out to a file that is read the next time the program is run, etc.

I hope you found something useful above. I welcome comments and improvements or corrections.

Link to comment
Share on other sites

Thanx for your ramblings. :-)

What I am looking for is someway for the user to move the dialog boxes being generated (Progress, Splash, Msgbox, GUI, etc)

Thanx to your note I looked further at the options for the creation of the these dialogs and found a 'move' option in the call.

Problem solved!

Thanx!

Msgbox will always open centered. Use WinMove() to move it elsewhere (more details below)

That should be just "grab the title bar and drag", like any non-maximized window. Thus since you asked, please explain if there's some reason that won't work for you.

GuiCreate them youself, or WinMove() them

Let me just ramble on as I am wont to do, in case you find something useful among my comments.

-- would you like to save your window position between executions? (i.e. the user goes "grumble grumble", and drags you window so it doesn't cover what he needs to see?

If so you might consider "watching" your own window position with a "$a = WinList()" function, then grab you x/y and write it to a file (or a registry entry, or ini file or whatever).

Then when your program starts up, instead of it taking the default of where windows says to open it, you open it at the same coordinates it was when it was last closed. (might have a button "save window position", or just do it yourself at window close time).

-- would you like "popups" to go where the user last moved them?

Again, when you do a popup, record its position with winlist(), then when the user closes it, do another winlist() and see if the user moved it before closing it (presumably to uncover something). Again, you can then pop it up NEXT TIME where it last was. ... and even REMEMBER where the user did it across invocations of your program if you save it externally somewhere.

Use WinMove() to move your MsgBox out of the center, to where the USER last moved it.

Logic is something like this:

set $msgbox_x and $msgbox_y to -1 and -1

bring up the msg box

IF the values of $msgbox_x and $msgbox_y are NOT -1,

Use winlist() to find your window, and

use winmove() to move the msg box to that coordinate.

when the msg box is closed, record its coordinates before closing and see if the user moved it. (*)

If the user moved it, record this in $msgbox_x and $msgbox_y

(*) maybe the msgbox is closed when you get back the "OK" or other signal. Hmm.. In that case you could do a winlist on the msgbox in a loop looking to see if the coordinates are changing, and if so record them in $msgbox_x and $msgbox_y, such that when the window IS closed, you have recorded its last position very recently.

Thus, when the msg box pops up, if the user had moved it before, you'll "quickly" move it to that location from its default centered location. if the user moves it again before closing, the next msgbox will move from the middle to that NEW user-defined position.

Again, you could have a "save window positions" that explicitly writes out to a file that is read the next time the program is run, etc.

I hope you found something useful above. I welcome comments and improvements or corrections.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...