How do I force my window to get a WM_SIZE message?
Obviously I don't want to send a WM_SIZE message
explicitly, as I then have to supply the width and
height. Is there an API that refreshes the size of a
window?
David
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"David" <proje...@smallpond.com> wrote in message news:071401c38ec3$e2af92f0$a401...@phx.gbl...
"David" <proje...@smallpond.com> wrote in message
news:071401c38ec3$e2af92f0$a401...@phx.gbl...
Thanks for your post!
Based on your post, you want to call the WM_SIZE handle code in the
WndProc function without supply the width and height, If my understanding
is right, to achieve this purpose, you can define a custom resize flag for
the use of SendMessage(WM_SIZE) ignored width and height parameters,then
process this process custom WM_SIZE message in your WM_SIZE handle code,
something like these:
#define Custom_Resize 23 //in a header file
---------------------------------------------------------------------------
SendMessage(hTargetWindow, WM_SIZE, Custom_Resize, 0); //call the
WM_SIZE handle code as needed in some files
---------------------------------------------------------------------------
..
//in the Target Window WndProc function;
case WM_SIZE:
if (wParam == Custom_Resize)
{
//process here
}
... //original handle code
..
Hope this help!
Gary Chang
Microsoft Online Partner Support
Get Secure! – www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "David" <proje...@smallpond.com>
| Sender: "David" <proje...@smallpond.com>
| Subject: Force a WM_SIZE message
| Date: Thu, 9 Oct 2003 17:17:26 -0700
| Lines: 10
| Message-ID: <071401c38ec3$e2af92f0$a401...@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOOw+KvNmj1933RTpK+5N8CvPouhg==
| Newsgroups:
comp.os.ms-windows.programmer.win32,microsoft.public.win32.programmer.ui,mic
rosoft.public.vc.atl
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.vc.atl:53760
microsoft.public.win32.programmer.ui:7924
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.vc.atl
I create a top level window (values are X = 200, y = 150,
width = 500 and height = 300). In doing that, a
WM_CREATE message is sent.
As a direct result of this message, I create a child
window (this window is X = 0, y = 0, width = 0 and height
= 0).
Eventually a WM_SIZE message is received by the windows
procedure and I handle this message as follows:
LRESULT CTest::OnSize(UINT uMsg,
WPARAM wParam,
LPARAM lParam,
BOOL &bHandled)
{
INT iWidthNew = LOWORD(lParam);
INT iHeightNew = HIWORD(lParam);
if (m_hWndChild)
{
::MoveWindow(m_hWndChild,
dwWidthNew - 200,
dwHeightNew - 100,
200,
100,
TRUE);
}
}
This means that the child window is repositioned at the
bottom right hand corner of its parent window.
If I delete this window and create it again (X = 0, Y =
0, Width = 0 and Height = 0), how do I force a WM_SIZE
message?
I know I can send WM_SIZE to the windows procedure myself
with the correct co-ordinates and dimensions, but is
there an API that will send this automatically.
Something like InvalidateRect(...NULL...) which will send
WM_PAINT automatically.
>-----Original Message-----
>Hi David,
>
>Thanks for your post!
>
>Based on your post, you want to call the WM_SIZE handle
code in the
>WndProc function without supply the width and height, If
my understanding
>is right, to achieve this purpose, you can define a
custom resize flag for
>the use of SendMessage(WM_SIZE) ignored width and height
parameters,then
>process this process custom WM_SIZE message in your
WM_SIZE handle code,
>something like these:
>
>#define Custom_Resize 23 //in a header file
>
>---------------------------------------------------------
------------------
>SendMessage(hTargetWindow, WM_SIZE, Custom_Resize,
0); //call the
>WM_SIZE handle code as needed in some files
>
>---------------------------------------------------------
------------------
>...
> //in the Target Window WndProc function;
>case WM_SIZE:
> if (wParam == Custom_Resize)
> {
> //process here
> }
> ... //original handle code
>
>...
>
>Hope this help!
>
>Gary Chang
>Microsoft Online Partner Support
>Get Secure! - www.microsoft.com/security
>.
>
Thanks for your quickly response,
The windows sent WM_SIZE message to a window when the window has been
created each time, no matter how much the size of the created window. So
you probably don't need such an API to force Windows send a WM_SIZE message.
Gary Chang
Microsoft Online Partner Support
Get Secure! – www.microsoft.com/security
This posting is provided "AS IS" with no warranties,and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "David" <proje...@smallpond.com>
| Sender: "David" <proje...@smallpond.com>
| References: <071401c38ec3$e2af92f0$a401...@phx.gbl>
<p2iX6gtj...@cpmsftngxa06.phx.gbl>
| Subject: RE: Force a WM_SIZE message
| Date: Thu, 9 Oct 2003 23:00:46 -0700
| Lines: 136
| Message-ID: <26f7701c38ef3$d9423da0$a601...@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOO89lCamNNJ18VSfarNcwuuD4IXQ==
| Newsgroups: microsoft.public.vc.atl
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.vc.atl:53775
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.vc.atl
Why don't you just write a function, PositionChildWindowTheWayIWant, and
call it both from WM_SIZE handler and from the code where you recreate
your child window?
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
I don't see anything obvious here. I am puzzled that you might know a
dialog box needs to be resized without knowing the new dimensions.
Perhaps your code to handle WM_SIZE messages determines the
appropriate size on its own (i.e., ignores any dimensions passed as
part of the message). If that _is_ the case, then I suggest putting
that code in a function you can call directly, and calling it when
appropriate, including in response to WM_SIZE messages. Or, send a
WM_SIZE message and give the dimensions as 0, 0.
>
>David
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).
Robert E. Zaret
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"David" <proje...@smallpond.com> wrote in message news:26f7701c38ef3$d9423da0$a601...@phx.gbl...
>
> LRESULT CTest::OnSize(UINT uMsg,
> WPARAM wParam,
> LPARAM lParam,
> BOOL &bHandled)
> {
> INT iWidthNew = LOWORD(lParam);
> INT iHeightNew = HIWORD(lParam);
>
> if (m_hWndChild)
> {
> ::MoveWindow(m_hWndChild,
> dwWidthNew - 200,
> dwHeightNew - 100,
> 200,
> 100,
> TRUE);
> }
> }
If I'm getting this straight, you want to explicitly resize the child window
after creating it, without actually passing it the correct size when you
first create it?
Try this...
VOID CTest::ResizeChild( DWORD dwParentWidth, DWORD dwParentHeight )
{
if (m_hWndChild)
{
::MoveWindow (m_hWndChild, dwParentWidth - 200, dwParentHeight - 100,
200, 100, TRUE);
}
}
LRESULT CTest::OnSize( ... )
{
DWORD dwWidthNew = LOWORD (lParam);
DWORD dwHeightNew = HIWORD (lParam);
ResizeChild( dwWidthNew, dwHeightNew ); // m_hWndChild's validity is
tested in the function
return CWnd::OnSize (...);
}
And, from whatever function creates the new child, simply do this...
{
...
CChildWindowClass *ccwc = new CChildWindowClass (...);
if (ccwc != NULL)
{
ccwc->Create (NULL, NULL, WS_VISIBLE | WS_CHILD, CRect (0, 0, 0, 0),
this, -1, NULL);
RECT cr;
GetClientRect (&cr);
ResizeChild (cr.right, cr.bottom); // cr.top and cr.left are always zero,
so cr.right and cr.bottom are width & height respectively
ccwc->UpdateWindow ();
ccwc->ShowWindow (SW_SHOW);
}
...
}
However, since CWnd::Create(...) already allows you to specify the location
and size of the child window, you're rewriting code that's already been
written!
Easiest way to do it is to NOT pass (0, 0)-(0, 0) for the initial position
and size of the child window, but rather calculate it during creation.
Leave the OnSize(...) function there to handle keeping the child window in
the bottom right corner during size changes. Also note that there is no
bounds checking in your OnSize(...) code to prevent the window from
shrinking below (200,100). This way, the user can grab the corner of the
window, shrink it down to say (50,25) and you'll still resize and remove the
child window to something not suitable for display. You'll want to override
OnSizing(...) so that while the user is dragging the corner, it'll prevent
them from being able to get that small in the first place.
And if I've completely missed your point, then you can ignore this post. :)
Craig L.
not a big deal.
you can use movewindow, setwindowpos, sendmessage as you want.
That the people here said is completely enough for your sizing request.
I think:-P
"David" <proje...@smallpond.com> wrote in message
news:26f7701c38ef3$d9423da0$a601...@phx.gbl...