Link to home
Start Free TrialLog in
Avatar of hansw77041
hansw77041

asked on

How to allow resize of a dialog but limit the size to muliples of 253 pixels

I'm using VS 6.0 with MFC and have a dialog that can be resized.

I want to set the Client area size to multiples of 253 pixels in the X direction.

Example: If the user drags the size to be  520 pixels wide and lets go of the mouse button,  the program should force a client area of 506 pixels.


As I'm using MFC I'm not sure where I need to call SetWindowsPos()  

Is it in the OnSize() ?
Avatar of kaylanreilor
kaylanreilor
Flag of Luxembourg image

Of course, OnSize() which handles WM_SIZE.
Avatar of hansw77041
hansw77041

ASKER

Well Yes of course is not much help   !

OnSize() has these words in the help file.

Quote" If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function." end quote

So I'm confused about when and where and if I should be using SetWindowsPos() from within the OnSize()
Using   SetWindowPos(0,0,0,506,cy, SWP_NOMOVE | SWP_NOZORDER);  form inside of OnSize() blows the stack. !

So it's NOT      Yes Of Course      

Please don't reply if you don't know the answer and save us all some time...
WM_SIZE is followed by WM_PAINT, so probably you could store the coordinates in OnSize to draw your window in OnPaint().
ASKER CERTIFIED SOLUTION
Avatar of alb66
alb66
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks that did the trick.