15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Window Size & Position

Mark Parr -- markp@e9.com
Thursday, December 28, 1995


I added the following to my CMainFrame::OnCreate()

     SetWindowPos(&wndTop, 1, 1, 100, 300, SWP_DRAWFRAME);			

and determined that it sets my window size.  However, it does not appear
to take into accout the borders, title, menu, & status bars.  I really
need my view window to 100/300.  Is there anyway to take the other sizes
into account and adding them in or is there another way to set the window
size that will let me set my view window to 100/300.

Thanks,
Mark

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Mark Parr -- markp@e9.com | People think my friend George is weird because
 Application Data Systems  | he wears sideburns...behind his ears.  I think
 Southaven, MS             | he's weird because he wears false teeth...with 
 (601) 393-2046            | braces on them.   ---   Steven Wright         
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Mark Parr -- markp@e9.com | People think my friend George is weird because
 Application Data Systems  | he wears sideburns...behind his ears.  I think
 Southaven, MS             | he's weird because he wears false teeth...with 
 (601) 393-2046            | braces on them.   ---   Steven Wright         
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




Ray Marshall -- ray@newton.apple.com
Friday, December 29, 1995

[Mini-digest: 2 responses]

Yes. Call GetSystemMetrics to get the size of each these items and add them
accordingly. For example, to get the extra space for a normal dialog do:

xExtra = GetSystemMetrics( SM_CXDLGFRAME ) * 2;

// get size of the title bar
yExtra = GetSystemMetrics( SM_CYCAPTION );
// add the size of the borders
yExtra += GetSystemMetrics( SM_CYDLGFRAME ) * 2;

HTH,
//Ray


-----From: Brad Wilson 

>> However, it does not appear
>> to take into accout the borders, title, menu, & status bars.

GetSystemMetrics() will return the CX and CY size of all the
items you want, except for the status bar.  The status bar
is a window, of course, so you can get it's size by calling
CStatusBar::GetWindowRect() on it and using the resulting
CRect's Height() and Width() methods.

Brad



DangTN@ccmail.PE-Nelson.COM
Tuesday, January 02, 1996

     
How about CWnd::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)

I hope this helps.

Trung Dang.

______________________________ Reply Separator _________________________________
Subject: Re: Window Size & Position
Author:  mfc-l@netcom.com at SMTPLINK-PEN
Date:    12/29/95 2:28 PM


[Mini-digest: 2 responses]
     
Yes. Call GetSystemMetrics to get the size of each these items and add them 
accordingly. For example, to get the extra space for a normal dialog do:
     
xExtra = GetSystemMetrics( SM_CXDLGFRAME ) * 2;
     
// get size of the title bar
yExtra = GetSystemMetrics( SM_CYCAPTION ); 
// add the size of the borders
yExtra += GetSystemMetrics( SM_CYDLGFRAME ) * 2;
     
HTH,
//Ray
     
     
-----From: Brad Wilson 
     
>> However, it does not appear
>> to take into accout the borders, title, menu, & status bars.
     
GetSystemMetrics() will return the CX and CY size of all the 
items you want, except for the status bar.  The status bar 
is a window, of course, so you can get it's size by calling 
CStatusBar::GetWindowRect() on it and using the resulting 
CRect's Height() and Width() methods.
     
Brad




Deepak Saxena -- deepak@ecn.purdue.edu
Saturday, December 30, 1995

> I added the following to my CMainFrame::OnCreate()
> 
>      SetWindowPos(&wndTop, 1, 1, 100, 300, SWP_DRAWFRAME);			
> 
> and determined that it sets my window size.  However, it does not appear
> to take into accout the borders, title, menu, & status bars.  I really
> need my view window to 100/300.  Is there anyway to take the other sizes
> into account and adding them in or is there another way to set the window
> size that will let me set my view window to 100/300.

If you have any toolbars or a statusbar, you can call GetWindowRect for each
window and that will return the screen coordinates for the windows from which
you can determine the size.  You can use the API GetSystemMetrics() call to
get the default Scroll bar height and width, title bar height, etc..

> Thanks,
> Mark

-- 
Deepak Saxena -- deepak@ecn.purdue.edu -- http://cernan.ecn.purdue.edu/~deepak
Pinky, are you pondering what I'm pondering?
Uh, I think so, Brain, but this time, you wear the tutu.




| Вернуться в корень Архива |