WM_MOVE question

WM_MOVE question

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

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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

Jugoslav
www.xeffort.com

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

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

Erm, how 'bout GetWindowRect followed by MapWindowPoints or ScreenToClient (if necessary)?

Happy New Year,
Jugoslav

Jugoslav
www.xeffort.com

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

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

Jugoslav
www.xeffort.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today