I am using Visual C++ 6.0 and eMmbedded Vvisual C++ 4.0 to develop Windows
and PPC applications.

I knew WS_THICKFRAME can be used to resize the window during the runtime.
Did anybody know how to resize all the controls (like the text and pictures
in a dialog) as well the window during runtime? For example, if the user
drag the border of a window and double its size, I hope all the texts and
pictures at that window are doubled as well to fit the window.

Thanks.

John

Re: How to resize all the controls during runtime by Claus

Claus
Fri Sep 10 00:26:04 CDT 2004

JohnL schrieb:

> I am using Visual C++ 6.0 and eMmbedded Vvisual C++ 4.0 to develop Windows
> and PPC applications.
>
> I knew WS_THICKFRAME can be used to resize the window during the runtime.
> Did anybody know how to resize all the controls (like the text and pictures
> in a dialog) as well the window during runtime? For example, if the user
> drag the border of a window and double its size, I hope all the texts and
> pictures at that window are doubled as well to fit the window.

You have to handle the WM_SIZE message. But AFAIK there is no automatism
to say something like "Keep left top of my rect and expand proportional
to parent window". You will have to do this by yourself.

Claus

Re: How to resize all the controls during runtime by Michael

Michael
Fri Sep 10 00:26:46 CDT 2004

Handle WM_SIZE in the DlgProc. There you can move/resize the controls as
necessary. Use MoveWindow. SetWindowPos can be used, too.

--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com



"JohnL" <hiliuzhe@hotmail.com> wrote in message
news:uqZqU5slEHA.3452@TK2MSFTNGP15.phx.gbl...
>I am using Visual C++ 6.0 and eMmbedded Vvisual C++ 4.0 to develop Windows
> and PPC applications.
>
> I knew WS_THICKFRAME can be used to resize the window during the runtime.
> Did anybody know how to resize all the controls (like the text and
> pictures
> in a dialog) as well the window during runtime? For example, if the user
> drag the border of a window and double its size, I hope all the texts and
> pictures at that window are doubled as well to fit the window.
>
> Thanks.
>
> John
>
>



Re: How to resize all the controls during runtime by JohnL

JohnL
Fri Sep 10 12:22:59 CDT 2004

Thanks a lot, now I can handle it.

John



"Claus Henning" <claus#minus#guntram#dot#henning#at#ortim#dot#de> wrote in
message news:uXOBbavlEHA.2504@TK2MSFTNGP14.phx.gbl...
> JohnL schrieb:
>
> > I am using Visual C++ 6.0 and eMmbedded Vvisual C++ 4.0 to develop
Windows
> > and PPC applications.
> >
> > I knew WS_THICKFRAME can be used to resize the window during the
runtime.
> > Did anybody know how to resize all the controls (like the text and
pictures
> > in a dialog) as well the window during runtime? For example, if the user
> > drag the border of a window and double its size, I hope all the texts
and
> > pictures at that window are doubled as well to fit the window.
>
> You have to handle the WM_SIZE message. But AFAIK there is no automatism
> to say something like "Keep left top of my rect and expand proportional
> to parent window". You will have to do this by yourself.
>
> Claus



Re: How to resize all the controls during runtime by JohnL

JohnL
Fri Sep 10 12:23:11 CDT 2004

Thanks a lot, now I can handle it.

John

"Michael J. Salamone [eMVP]" <mikesa#at#entrek#dot#com> wrote in message
news:OXj7RbvlEHA.2504@TK2MSFTNGP14.phx.gbl...
> Handle WM_SIZE in the DlgProc. There you can move/resize the controls as
> necessary. Use MoveWindow. SetWindowPos can be used, too.
>
> --
>
> Michael Salamone [eMVP]
> Entrek Software, Inc.
> www.entrek.com
>
>
>
> "JohnL" <hiliuzhe@hotmail.com> wrote in message
> news:uqZqU5slEHA.3452@TK2MSFTNGP15.phx.gbl...
> >I am using Visual C++ 6.0 and eMmbedded Vvisual C++ 4.0 to develop
Windows
> > and PPC applications.
> >
> > I knew WS_THICKFRAME can be used to resize the window during the
runtime.
> > Did anybody know how to resize all the controls (like the text and
> > pictures
> > in a dialog) as well the window during runtime? For example, if the user
> > drag the border of a window and double its size, I hope all the texts
and
> > pictures at that window are doubled as well to fit the window.
> >
> > Thanks.
> >
> > John
> >
> >
>
>



Re: How to resize all the controls during runtime by JohnL

JohnL
Fri Sep 10 18:19:53 CDT 2004

Hi, Claus,

I solved the problem, but only partly. Since if I call SetWindowPos function
directly inside of ::OnSize(), the software will corrupt every time.
Instead, to solve this problem, I have to set a variable bEnableResize, and
this variable is enabled in OnInitDialog(). Before the variable is enabled,
SetWindowPos function will not be called.

Can you tell me why SetWindowPos function will corrupt at the beginning? Any
better way to solve it?

John


*****************************************
In resource file,
CONTROL 132,IDC_IPAQ,"Static",SS_BITMAP | WS_CLIPSIBLINGS, 0, 0,
283,383



void C***Dlg::OnSize(UINT nType, int cx, int cy)
{


// TODO: Add your message handler code here

//bEnableResize is enabled in ::OnInitDialog()
if ( bEnableResize ) //To avoid problem in OnSize
{
RECT * lpRect = new RECT();
GetClientRect (lpRect);

//IDC_IPAQ: A Static Control to hold a picture inside.
GetDlgItem (IDC_IPAQ) ->SetWindowPos ( &wndBottom, lpRect->left,
lpRect->top,
cx,
cy,
SWP_SHOWWINDOW);



Invalidate (TRUE);
}

CDialog::OnSize(nType, cx, cy);


}




"Claus Henning" <claus#minus#guntram#dot#henning#at#ortim#dot#de> wrote in
message news:uXOBbavlEHA.2504@TK2MSFTNGP14.phx.gbl...
> JohnL schrieb:
>
> > I am using Visual C++ 6.0 and eMmbedded Vvisual C++ 4.0 to develop
Windows
> > and PPC applications.
> >
> > I knew WS_THICKFRAME can be used to resize the window during the
runtime.
> > Did anybody know how to resize all the controls (like the text and
pictures
> > in a dialog) as well the window during runtime? For example, if the user
> > drag the border of a window and double its size, I hope all the texts
and
> > pictures at that window are doubled as well to fit the window.
>
> You have to handle the WM_SIZE message. But AFAIK there is no automatism
> to say something like "Keep left top of my rect and expand proportional
> to parent window". You will have to do this by yourself.
>
> Claus



Re: How to resize all the controls during runtime by Mihai

Mihai
Sat Sep 11 01:20:23 CDT 2004

> Thanks a lot, now I can handle it.
>
> John
I hope you will never have to localize your application.
Then all the runtime resizing will hit you hard.

--
Mihai
-------------------------
Replace _year_ with _ to get the real email

Re: How to resize all the controls during runtime by Mihai

Mihai
Sat Sep 11 01:20:17 CDT 2004

> Thanks a lot, now I can handle it.
>
> John
I hope you will never have to localize your application.
Then all the runtime resizing will hit you hard.

--
Mihai
-------------------------
Replace _year_ with _ to get the real email

Re: How to resize all the controls during runtime by Sigurd

Sigurd
Sat Sep 11 02:58:42 CDT 2004

JohnL wrote:
> I solved the problem, but only partly. Since if I call SetWindowPos
> function directly inside of ::OnSize(), the software will corrupt
> every time. Instead, to solve this problem, I have to set a variable
> bEnableResize, and this variable is enabled in OnInitDialog(). Before
> the variable is enabled, SetWindowPos function will not be called.

You don't give enough details - what do you mean, "corrupt" ?

It seems likely that your window (the dialog) receives an OnSize() when it
is created, before the controls are created. So GetDlgItem() will probably
return NULL until you receive the OnInitDialog(). Thus, there is no need
for a state variable - just check the GetDlgItem() return value before you
use it...


Also, the following :

> RECT * lpRect = new RECT();
> GetClientRect (lpRect);
> GetDlgItem (IDC_IPAQ) ->SetWindowPos ( &wndBottom, lpRect->left,
> lpRect->top, cx, cy, SWP_SHOWWINDOW);

...is identical to :

GetDlgItem (IDC_IPAQ) ->SetWindowPos ( &wndBottom, 0,
0, cx, cy, SWP_SHOWWINDOW);


--


Sigurd
http://utvikling.com



Re: How to resize all the controls during runtime by JohnL

JohnL
Mon Sep 13 11:26:26 CDT 2004

Thank you very much, Sigurd,

I tried the codes and you are absolutely right.

John




"Sigurd Stenersen" <sigurds@utvikling.com> wrote in message
news:elM$pU9lEHA.3896@TK2MSFTNGP15.phx.gbl...
> JohnL wrote:
> > I solved the problem, but only partly. Since if I call SetWindowPos
> > function directly inside of ::OnSize(), the software will corrupt
> > every time. Instead, to solve this problem, I have to set a variable
> > bEnableResize, and this variable is enabled in OnInitDialog(). Before
> > the variable is enabled, SetWindowPos function will not be called.
>
> You don't give enough details - what do you mean, "corrupt" ?
>
> It seems likely that your window (the dialog) receives an OnSize() when it
> is created, before the controls are created. So GetDlgItem() will
probably
> return NULL until you receive the OnInitDialog(). Thus, there is no need
> for a state variable - just check the GetDlgItem() return value before you
> use it...
>
>
> Also, the following :
>
> > RECT * lpRect = new RECT();
> > GetClientRect (lpRect);
> > GetDlgItem (IDC_IPAQ) ->SetWindowPos ( &wndBottom, lpRect->left,
> > lpRect->top, cx, cy, SWP_SHOWWINDOW);
>
> ...is identical to :
>
> GetDlgItem (IDC_IPAQ) ->SetWindowPos ( &wndBottom, 0,
> 0, cx, cy, SWP_SHOWWINDOW);
>
>
> --
>
>
> Sigurd
> http://utvikling.com
>
>



Re: How to resize all the controls during runtime by Mihai

Mihai
Tue Sep 14 04:30:36 CDT 2004

>> > GetDlgItem (IDC_IPAQ) ->SetWindowPos ( &wndBottom, lpRect->left,
>> > lpRect->top, cx, cy, SWP_SHOWWINDOW);

I think this type of code is dangerous in production code.

What is going to happen if GetDlgItem (IDC_IPAQ) returns NULL? Auch!

Why return NULL? Because 2 months from now someone will decide to change the
name of IDC_IPAQ because is not clear enough, let's say.


--
Mihai
-------------------------
Replace _year_ with _ to get the real email