Re: MoveWindow not sending WM_SIZE on deeply nested windows
- From: jetan@xxxxxxxxxxxxxxxxxxxx ("Jeffrey Tan[MSFT]")
- Date: Fri, 21 Jul 2006 12:50:42 GMT
Hi Christian,
Please forgive my ignorance, but I am not sure what "second bug" you are
referring. What do you mean "all "default_parent" stuff must be removed"?
However, I have removed all the "default_parent" and change for (i = 0; i
<= MAX_COUNT; i++) to for (i = 0; i < MAX_COUNT; i++) , but I still get
the error at 48,
Below is the modified code sinppet, please feel free to point out whatever
I overlooked:
#include "stdafx.h"
#include<stdio.h>
HINSTANCE hInst;
HWND top_window; // Top window handle.
HWND lastHwnd; // Last created window handle
#define szWindowClass "WINDOW"
#define szTopWindowClass "TOP_WINDOW"
#define MAX_COUNT 100
HWND Hwnds[MAX_COUNT];
int windowCount;
extern LRESULT CALLBACK window_procedure (HWND, UINT, WPARAM, LPARAM);
void display_error () {
LPVOID lpMsgBuf;
CHAR szBuf[5120]; DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
sprintf(szBuf, "%s\nGetLastError returned %u\n", lpMsgBuf, dw);
MessageBox( NULL, szBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}
ATOM register_class (LPTSTR a_class)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)window_procedure ;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInst;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = a_class;
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
void add_widget ()
{
HWND hwnd, last_parent;
hwnd = CreateWindowEx(WS_EX_CONTROLPARENT, szWindowClass, "Child window",
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
0, 0, 1200, 1200, top_window, 0, hInst, NULL);
if (!hwnd) {
display_error ();
}
Hwnds[windowCount++]= hwnd;
if (!lastHwnd) {
last_parent = SetParent (hwnd, top_window);
} else {
last_parent = SetParent (hwnd, lastHwnd);
}
if (!last_parent) {
display_error ();
}
ShowWindow (hwnd, SW_SHOWDEFAULT);
UpdateWindow (hwnd);
lastHwnd = hwnd;
}
BOOL init ()
{
HWND hwnd;
top_window = CreateWindow(szTopWindowClass, "Test", WS_OVERLAPPEDWINDOW,
0, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
if (!top_window) {
display_error ();
return FALSE;
}
ShowWindow(top_window, SW_SHOW);
UpdateWindow(top_window);
return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR
lpCmdLine, int nCmdShow)
{
MSG msg;
int i;
hInst = hInstance;
if (!register_class (szWindowClass)) {
display_error ();
return FALSE;
}
if (!register_class (szTopWindowClass)) {
display_error ();
return FALSE;
}
if (!init ()) {
display_error ();
return FALSE;
}
for (i = 0; i < MAX_COUNT; i++) {
add_widget ();
}
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK window_procedure (HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
int i;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
Thanks!
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: MoveWindow not sending WM_SIZE on deeply nested windows
- From: Christian ASTOR
- Re: MoveWindow not sending WM_SIZE on deeply nested windows
- References:
- MoveWindow not sending WM_SIZE on deeply nested windows
- From: Emmanuel Stapf [ES]
- Re: MoveWindow not sending WM_SIZE on deeply nested windows
- From: Christian ASTOR
- MoveWindow not sending WM_SIZE on deeply nested windows
- Prev by Date: Re: MoveWindow not sending WM_SIZE on deeply nested windows
- Next by Date: Chevron support in a IDeskband toolbar
- Previous by thread: Re: MoveWindow not sending WM_SIZE on deeply nested windows
- Next by thread: Re: MoveWindow not sending WM_SIZE on deeply nested windows
- Index(es):
Relevant Pages
|