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() ?
hansw77041Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kaylanreilorCommented:
Of course, OnSize() which handles WM_SIZE.
0
hansw77041Author Commented:
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()
0
hansw77041Author Commented:
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...
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

kaylanreilorCommented:
WM_SIZE is followed by WM_PAINT, so probably you could store the coordinates in OnSize to draw your window in OnPaint().
0
alb66Commented:
You can handle WM_SIZING message instead without any call to SetWindowPos:

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
      ON_WM_SIZING()
END_MESSAGE_MAP()

void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
{
      CFrameWnd::OnSizing(fwSide, pRect);

      int nWidth = pRect->right - pRect->left;
      
      nWidth = ( nWidth / 253 ) * 253;

      switch ( fwSide )
      {
      case WMSZ_BOTTOMRIGHT:
      case WMSZ_RIGHT:
      case WMSZ_TOPRIGHT:
            pRect->right = pRect->left + nWidth;
            break;
      default:
            pRect->left = pRect->right - nWidth;
            break;
      }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hansw77041Author Commented:
Thanks that did the trick.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.