- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to recall the position and size of the window the next time the application is run, by storing the position and size in the registry.
I have just about got it working, but I am having problems on a Windows XP machine.
I am getting the position from the WM_MOVE and the size from the WM_SIZE calls.
If I move the window slightly (by clicking ob the caption bar and moving the window) I can then get the correct values for the position.
I therefore think I need to force a WM_MOVE call, I tried this using iret=SendMessage(hWnd,WM_MOVE,0,0) but it didn't work.
As you can see I'm confused - any help would be appreciated.
Regards,
David
I have just about got it working, but I am having problems on a Windows XP machine.
I am getting the position from the WM_MOVE and the size from the WM_SIZE calls.
If I move the window slightly (by clicking ob the caption bar and moving the window) I can then get the correct values for the position.
I therefore think I need to force a WM_MOVE call, I tried this using iret=SendMessage(hWnd,WM_MOVE,0,0) but it didn't work.
As you can see I'm confused - any help would be appreciated.
Regards,
David
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Um, didn't work? What do you mean "didn't work"? It is supposed to work.
But, why don't you take and store window size and position at program termination? Handler of WM_CLOSE for the main window looks like a better place to put that code. Doing it on every WM_MOVE/WM_SIZE looks like an overkill.
Jugoslav
But, why don't you take and store window size and position at program termination? Handler of WM_CLOSE for the main window looks like a better place to put that code. Doing it on every WM_MOVE/WM_SIZE looks like an overkill.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am saving the position & size on the WM_CLOSE.
But am determining the position & size from the WM_MOVE & WM_SIZE calls - as I don't know how else to get them.
I found with Windows XP, I have had to make a WM_MOVE call after displaying the window which wasn't required on Windows NT /95/98
It is more complex than this as I have to add/subtract caption heights, the frame size etc.
You set values in CreateWindowEx, it would be good if you could recall the new values on exit as WM_MOVE/SIZE are giving different things.
Thanks,
David
But am determining the position & size from the WM_MOVE & WM_SIZE calls - as I don't know how else to get them.
I found with Windows XP, I have had to make a WM_MOVE call after displaying the window which wasn't required on Windows NT /95/98
iret = ShowWindow(hWndMain,SW_SHOWDEFAULT) iret=SendMessage(hWndMain,WM_MOVE,0,MakeLparam(WindowX,WindowY)) ! required for XP
It is more complex than this as I have to add/subtract caption heights, the frame size etc.
You set values in CreateWindowEx, it would be good if you could recall the new values on exit as WM_MOVE/SIZE are giving different things.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Erm, how 'bout GetWindowRect followed by MapWindowPoints or ScreenToClient (if necessary)?
Happy New Year,
Jugoslav
Happy New Year,
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav,
Thanks for the suggestion, using GetWindowRect was just what I needed. It is much simpler. I don't know why I never thought of it as I use it in lots of other places.
Thanks,
David
Thanks for the suggestion, using GetWindowRect was just what I needed. It is much simpler. I don't know why I never thought of it as I use it in lots of other places.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1:0 for you David ;-)... I have thought that GetWindowRect was so bleeding obvious that you must have had a very good reason not to use it...
All the best,
Jugoslav
All the best,
Jugoslav

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page