Resizing the window

How could I resize the window at the same ratio?
Which the message I should attach to match this purpose?
And what I should do, just changing the cx and cy member?
maulingAsked:
Who is Participating?
 
ambyConnect With a Mentor Commented:
I am Amby and I am Happy...


0
 
chackoCommented:
Try MoveWindow function.
0
 
maulingAuthor Commented:
It just not function!!!!
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
tma050898Commented:
The SetWindowPos function can be used to size and/or move the window...

if you have a CWnd object for the window being moved...
   pYourWindow->SetWindowPos(&wndTop, 0, 0, 100, 200, SWP_NOMOVE);      

if you are moving the window from within the CWnd object's code
   SetWindowPos(&wndTop, 0, 0, 100, 200, SWP_NOMOVE);      

if you don't have a CWnd object for the window being moved (for example, the window belongs to another app)...
 CWnd wnd;
 wnd.Attach(hwndOfDesiredWindow);
 wnd.SetWindowPos(&wndTop, 0, 0, 100, 200, SWP_NOMOVE);      
 wnd.Detach();

The second and third parameters are the x and y (for moving) positions of the window. However, if you pass SWP_NOMOVE in the last argument, the window only will be resized and not moved. The cx and cy (for sizing) values are the third and fourth arguments, respectively.

Tom

0
 
tma050898Commented:
Accidentally clicked Comment instead of Answer. See my comment below for proposed answer...
0
 
maulingAuthor Commented:
Sorry, Tom, I think I didn't make the question clear.
What I need is be able to resize the client window at the same ratio when resizing it with the mouse. I am using the MFC. I had tried the following code.

void CTst::OnSize(UINT nType, int cx, int cy)
{
      
      int min;
      if (cx>cy)
            min = cy;
      else
            min = cx;

      CView::OnSize(nType, min, min);
}

But the client window keep with the size cx and cy.

Ps: I tried your answer putting it just before CView::OnSize, but unfornately it didn't function yet.

Thanks for your attention.


0
 
kinkajouCommented:
"How could I resize the window at the same ratio?"

What do you mean resize at the same ratio? Do you mean you only want cx to move the same amount as cy when using a mouse? Please be more specific.
0
 
maulingAuthor Commented:
Well, what I want is always a square window.
0
 
shaigCommented:
Override the OnSizing member. there do adjustments with cx and cyy.
0
 
maulingAuthor Commented:
What I want to do is unable the resizing by dragging on the vertical border or horizontal border of the window with the mouse. But would be enable dragging on the corner of the window.
0
 
tma050898Commented:
Sorry, mauling, but that won't work either. That was the first thing I thought about. However, if you will notice, when you size from the corner, you are not restricted to sizing cx and cy equally.
0
 
tma050898Commented:
I have no idea how the hell that turned up as an answer. My connection dropped last night while I was attempting to make a *comment*. Please reject that, as it was only intended as an observation of something you said.
0
 
ambyCommented:
I think I have an answer for you...
0
 
tma050898Commented:
mauling,

Please reject my inadvertant "answer" so that the question can be "opened" up to other experts.

Thanks,
Tom
0
 
ambyCommented:
you can handle the WM_WINDOWPOSCHANGING message,

the parameter of this message is a structure containing window position, try modifying the parameters of this structure
0
 
jonaleeCommented:
If you want always a square window. Just try the following code. Is the CTst the Parent Frame of the CView? If so, then you only needs to resize the Parent Frame, the client will automatically resize.

void CTst::OnSize(UINT nType, int cx, int cy)
{

     int min;
     if (cx>cy)
      min = cy;
     else
      min = cx;

     SetWindowPos(0, 0, min, min, SWP_NOMOVE);
}

0
 
maulingAuthor Commented:
Hey, Amby, answer again in order for me to give you the point, OK.
0
 
maulingAuthor Commented:
Amby, Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.