How to set the default Win size of a SDI? 
Author Message
 How to set the default Win size of a SDI?

Hi,there!

    I've written a project using SDI structure which can open a
bitmap file and show it in a View. I want to modify the default
frame window's size to make it closely wrap the bitmap image.

    I tried the following method:

    In my "MVView.cpp" file, added following lines, but fail to
get what I want.

   void CMVView::OnInitialUpdate()
   {
        ... ...
        ... ...
        // int cxIdeal: Bitmap's width;
        // int cyIdeal: Bitmap's height.

        CWnd* pFrmWnd;
        pFrmWnd=GetParent();
        RECT rc;
        pFrmWnd->GetClientRect(&rc);
        pFrmWnd->ClientToScreen(&rc);
        WINDOWPLACEMENT wp;
        pFrmWnd->GetWindowPlacement(&wp);
        cxIdeal+=wp.rcNormalPosition.right-
                 wp.rcNormalPosition.left-rc.right+rc.left;
        cyIdeal+=wp.rcNormalPosition.bottom-
                 wp.rcNormalPosition.top-rc.bottom+rc.top;
        wp.rcNormalPosition.right=wp.rcNormalPosition.left+
                                  cxIdeal;
        wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+
                                   cyIdeal;
        pFrmWnd->SetWindowPlacement(&wp);
        pFrmWnd->CenterWindow();
        ... ...
        ... ...
   }

   Any comments will be greatly appreciated!

Best Regards,
Wayne,
24 Feb 99

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.*-*-*.com/ ;  The website for Visual C++ programmers.



Sun, 12 Aug 2001 03:00:00 GMT  
 How to set the default Win size of a SDI?
Look at my reply in microsoft.public.vc.mfc.

Ajay

Quote:

>Hi,there!

>    I've written a project using SDI structure which can open a
>bitmap file and show it in a View. I want to modify the default
>frame window's size to make it closely wrap the bitmap image.

>    I tried the following method:

>    In my "MVView.cpp" file, added following lines, but fail to
>get what I want.

>   void CMVView::OnInitialUpdate()
>   {
>        ... ...
>        ... ...
> // int cxIdeal: Bitmap's width;
> // int cyIdeal: Bitmap's height.

>        CWnd* pFrmWnd;
> pFrmWnd=GetParent();
> RECT rc;
> pFrmWnd->GetClientRect(&rc);
> pFrmWnd->ClientToScreen(&rc);
> WINDOWPLACEMENT wp;
> pFrmWnd->GetWindowPlacement(&wp);
> cxIdeal+=wp.rcNormalPosition.right-
>                 wp.rcNormalPosition.left-rc.right+rc.left;
> cyIdeal+=wp.rcNormalPosition.bottom-
>                 wp.rcNormalPosition.top-rc.bottom+rc.top;
>        wp.rcNormalPosition.right=wp.rcNormalPosition.left+
>                                  cxIdeal;
>        wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+
>                                   cyIdeal;
> pFrmWnd->SetWindowPlacement(&wp);
> pFrmWnd->CenterWindow();
>        ... ...
>        ... ...
>   }

>   Any comments will be greatly appreciated!

>Best Regards,
>Wayne,
>24 Feb 99

>-----------------** -- Posted from CodeGuru -- **-----------------
>http://www.codeguru.com/    The website for Visual C++ programmers.



Sun, 12 Aug 2001 03:00:00 GMT  
 How to set the default Win size of a SDI?

Hi, Ajay Kalra!

Thanks for your kind response. You have provided another way to
modify a window's default size. But it didn't solve my problem.
Actually my problem is that I want to set an application's
default window size to make the client area size of its view
just same as the bitmap image size.

Use "SetWindowPlacement(&wp)" or your method only affect the
Outside window size. Do you know how to calculate the outside
window size base on the inner client area size or directly
set the inner client area size?

Best wishes!
wayne,
24 Feb 99

Quote:

>Look at my reply in microsoft.public.vc.mfc.>
>Ajay


>>Hi,there!

>>    I've written a project using SDI structure which can open a
>>bitmap file and show it in a View. I want to modify the default
>>frame window's size to make it closely wrap the bitmap image.

>>    I tried the following method:

>>    In my "MVView.cpp" file, added following lines, but fail to
>>get what I want.

>>   void CMVView::OnInitialUpdate()
>>   {
>>        ... ...
>>        ... ...
>> // int cxIdeal: Bitmap's width;
>> // int cyIdeal: Bitmap's height.

>>        CWnd* pFrmWnd;
>> pFrmWnd=GetParent();
>> RECT rc;
>> pFrmWnd->GetClientRect(&rc);
>> pFrmWnd->ClientToScreen(&rc);
>> WINDOWPLACEMENT wp;
>> pFrmWnd->GetWindowPlacement(&wp);
>> cxIdeal+=wp.rcNormalPosition.right-
>>                 wp.rcNormalPosition.left-rc.right+rc.left;
>> cyIdeal+=wp.rcNormalPosition.bottom-
>>                 wp.rcNormalPosition.top-rc.bottom+rc.top;
>>        wp.rcNormalPosition.right=wp.rcNormalPosition.left+
>>                                  cxIdeal;
>>        wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+
>>                                   cyIdeal;
>> pFrmWnd->SetWindowPlacement(&wp);
>> pFrmWnd->CenterWindow();
>>        ... ...
>>        ... ...
>>   }

>>   Any comments will be greatly appreciated!

>>Best Regards,
>>Wayne,
>>24 Feb 99

>>-----------------** -- Posted from CodeGuru -- **-----------------
>>http://www.codeguru.com/    The website for Visual C++ programmers.

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/    The website for Visual C++ programmers.


Sun, 12 Aug 2001 03:00:00 GMT  
 How to set the default Win size of a SDI?
I had the same problem before. But I found it that as OnInitialUpdate()
is called, the window has not  shown yet, and I can not get client rect
correctly. My solution is to put the resize windows code in OnDraw
and just call once. My solution is   getting  view client rect, and
MainFrame windows size, get the difference and resize the mainframe window
according the required client rect.

Hope this can help you.

YC

Quote:

>Hi,there!

>    I've written a project using SDI structure which can open a
>bitmap file and show it in a View. I want to modify the default
>frame window's size to make it closely wrap the bitmap image.

>    I tried the following method:

>    In my "MVView.cpp" file, added following lines, but fail to
>get what I want.

>   void CMVView::OnInitialUpdate()
>   {
>        ... ...
>        ... ...
> // int cxIdeal: Bitmap's width;
> // int cyIdeal: Bitmap's height.

>        CWnd* pFrmWnd;
> pFrmWnd=GetParent();
> RECT rc;
> pFrmWnd->GetClientRect(&rc);
> pFrmWnd->ClientToScreen(&rc);
> WINDOWPLACEMENT wp;
> pFrmWnd->GetWindowPlacement(&wp);
> cxIdeal+=wp.rcNormalPosition.right-
>                 wp.rcNormalPosition.left-rc.right+rc.left;
> cyIdeal+=wp.rcNormalPosition.bottom-
>                 wp.rcNormalPosition.top-rc.bottom+rc.top;
>        wp.rcNormalPosition.right=wp.rcNormalPosition.left+
>                                  cxIdeal;
>        wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+
>                                   cyIdeal;
> pFrmWnd->SetWindowPlacement(&wp);
> pFrmWnd->CenterWindow();
>        ... ...
>        ... ...
>   }

>   Any comments will be greatly appreciated!

>Best Regards,
>Wayne,
>24 Feb 99

>-----------------** -- Posted from CodeGuru -- **-----------------
>http://www.codeguru.com/    The website for Visual C++ programmers.



Tue, 21 Aug 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to set the default Win size of a SDI?

2. Setting default printer in Win NT, and 2000

3. help: how to set initial SDI window size

4. how to set SDI App window size

5. How to set PropertySheet default size

6. How to modifiy the default Win size of a SDI?

7. Size SDI frame for specific view size?

8. Help: Sizing SDI frame, so the view will have an exact size

9. Setting window size and cursor size

10. Setting Frame Size with Window Size

11. Setting Frame Size with Window Size

12. How to set control size to view size

 

 
Powered by phpBB® Forum Software