Solved

Resizing the window

Posted on 1998-06-05
18
479 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:mauling
  • 6
  • 5
  • 3
  • +4
18 Comments
 
LVL 1

Expert Comment

by:chacko
ID: 1316079
Try MoveWindow function.
0
 

Author Comment

by:mauling
ID: 1316080
It just not function!!!!
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1316081
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 3

Expert Comment

by:tma050898
ID: 1316082
Accidentally clicked Comment instead of Answer. See my comment below for proposed answer...
0
 

Author Comment

by:mauling
ID: 1316083
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
 
LVL 2

Expert Comment

by:kinkajou
ID: 1316084
"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
 

Author Comment

by:mauling
ID: 1316085
Well, what I want is always a square window.
0
 
LVL 3

Expert Comment

by:shaig
ID: 1316086
Override the OnSizing member. there do adjustments with cx and cyy.
0
 

Author Comment

by:mauling
ID: 1316087
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
 
LVL 3

Expert Comment

by:tma050898
ID: 1316088
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
 
LVL 3

Expert Comment

by:tma050898
ID: 1316089
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
 
LVL 1

Expert Comment

by:amby
ID: 1316090
I think I have an answer for you...
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1316091
mauling,

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

Thanks,
Tom
0
 
LVL 1

Expert Comment

by:amby
ID: 1316092
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
 
LVL 2

Expert Comment

by:jonalee
ID: 1316093
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
 

Author Comment

by:mauling
ID: 1316094
Hey, Amby, answer again in order for me to give you the point, OK.
0
 
LVL 1

Accepted Solution

by:
amby earned 50 total points
ID: 1316095
I am Amby and I am Happy...


0
 

Author Comment

by:mauling
ID: 1316096
Amby, Thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 76
windows 10 how make picture as desktop background 2 62
withoutTen challenge 14 119
Problem to App 4 78
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now