From: dgwin32 on
> WM_MOVE:
> GetWindowRect(Parent, &rect);
> MoveWindow(popUp, rect.right-offset, rect.bottom-offset, width, height,
> TRUE);
> return 0;

I don't seem to get any WM_MOVE messages in my popup window callback when
the
mdi frame is moved. I get a WM_WINDOWPOSCHANGING message but thats all,
I dont even get the final WM_WINDOWPOSCHANGED. And for soome reason,
even those I open the popup window with my colour picker as the parent,
the popup windows parent points to the MDI frame.



--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: winapi on
> I don't seem to get any WM_MOVE messages in my popup window callback when
> the
> mdi frame is moved. I get a WM_WINDOWPOSCHANGING message but thats all,
> I dont even get the final WM_WINDOWPOSCHANGED. And for soome reason,
> even those I open the popup window with my colour picker as the parent,
> the popup windows parent points to the MDI frame.

Try "subclassing" the same method I provided.


From: winapi on
> I don't seem to get any WM_MOVE messages in my popup window callback when
> the
> mdi frame is moved. I get a WM_WINDOWPOSCHANGING message but thats all,
> I dont even get the final WM_WINDOWPOSCHANGED. And for soome reason,
> even those I open the popup window with my colour picker as the parent,
> the popup windows parent points to the MDI frame.



Here is a simple example I did, but it's not using MDI.

http://rapidshare.com/files/402783457/Move_PopUp.zip.html


From: dgwin32 on
Thanks for that.

That is what I'm trying to achieve, however, I have seperated my custom
control code into dlls and they are loaded dynamically. The function calls
to
create the controls could be used many times so I couldn't save global
handles
to the controls or assume they are being used at all

I guess my problem is passing the WM_WINDPOSCHANGED/MOVE events
to all the children so they could update themselves but it seems a bit
excessive

I have modifed the code you sent to a similar fashion that I am using in
my main program. I could use the SetCapture() when I open the popup so i
could close it before anything else, but I'm trying to replicate the
behaviour of another application so I want it to be the same.

Also, when I GetParent the palette window handle I dont get the picker
window handle, seems to get the top most window. Maybe if it pointed to the
picker handle
it would move with the rest of the window automatically, similar to how the
hPicker
is doing since its a child of the main window.


===MODIFIED main.cpp===

#include <windows.h>
#include <stdio.h>

HWND hPicker = NULL;
HWND hPalette = NULL;

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK WndProcPicker(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM
lParam);
LRESULT CALLBACK WndProcPalette(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM
lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR
cmdLine, int iCmdShow)
{
HWND hwnd;
HWND hwndPicker;
MSG msg;
WNDCLASSEX wndclass;

wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbWndExtra = 0;
wndclass.cbClsExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_WINLOGO);
wndclass.hIconSm = LoadIcon(NULL,IDI_WINLOGO);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "wClass";

if(!RegisterClassEx(&wndclass))
return 0;

// Colour picker.

wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProcPicker;
wndclass.cbWndExtra = 0;
wndclass.cbClsExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hIconSm = NULL;
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "wClassPicker";

if(!RegisterClassEx(&wndclass))
return 0;


// Colour palette.

wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProcPalette;
wndclass.cbWndExtra = 0;
wndclass.cbClsExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hIconSm = NULL;
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "wClassPalette";

if(!RegisterClassEx(&wndclass))
return 0;


hwnd = CreateWindow
(
"wClass",
"Pop Up Window",
WS_OVERLAPPEDWINDOW,
0, 0, 640, 480,
NULL,
NULL,
hInstance,
NULL
);

printf ("winmain() - hwnd = 0x%x (0x%x)\n", hwnd, GetParent (hwnd));

hPicker = CreateWindowEx
(
0,
"wClassPicker",
"ColourPicker",
WS_VISIBLE | WS_CHILD ,
100,100, 24, 24,
hwnd,
NULL,
GetModuleHandle(NULL),
NULL
);

printf ("winmain() - hPicker = 0x%x (0x%x)\n", hPicker, GetParent
(hPicker));


ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return int(msg.wParam);
}

LRESULT CALLBACK WndProcPicker(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM
lParam)
{
printf ("winprockpicker - hwnd = 0x%x (0x%x)\n", hwnd, GetParent (hwnd));

switch (iMsg)
{
case WM_NCCREATE:
break;

case WM_NCDESTROY:
break;

case WM_LBUTTONDOWN:
{
POINT pt;
RECT r;

printf ("winprocpicker - WM_LBUTTONDOWN\n");

GetClientRect (hwnd, &r);
pt.x = r.left;
pt.y = r.bottom;
ClientToScreen (hwnd, &pt);

hPicker = CreateWindowEx
(
0,
"wClassPalette",
"ColourPalette",
WS_POPUP | WS_VISIBLE ,
pt.x, pt.y, 200, 200,
hwnd,
NULL,
GetModuleHandle(NULL),
NULL
);


// Redraw the button.

InvalidateRect (hPicker, &r, FALSE);
RedrawWindow (hPicker, &r, NULL, RDW_INTERNALPAINT);
}
break;

case WM_LBUTTONUP:
break;

case WM_MOVE:
printf ("winprocpicker - WM_MOVE\n");
break;

case WM_WINDOWPOSCHANGED:
printf ("winprocpicker - WM_WINDOWPOSCHANGED\n");
break;

case WM_WINDOWPOSCHANGING:
printf ("winprocpicker - WM_WINDOWPOSCHANGING\n");
break;

case WM_PAINT:
{
PAINTSTRUCT ps;
RECT r;
HWND hwndCP = NULL;
HDC hDC = NULL;
HBRUSH hBrush = NULL;


hDC = BeginPaint (hwnd, &ps);

GetClientRect (hwnd, &r);

FillRect (hDC, &r, (HBRUSH) GetSysColorBrush(COLOR_BTNFACE));

DrawEdge (hDC, &r, EDGE_RAISED, BF_RECT | BF_ADJUST);

EndPaint (hwnd, &ps);

}
return 0;

default:
return (DefWindowProc (hwnd, iMsg ,wParam, lParam));
}
}


LRESULT CALLBACK WndProcPalette (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM
lParam)
{
static HWND popUp;
static RECT rect;
static INT offSet = 100;
static INT winX = 200;
static INT winY = 200;

printf ("winprocpalette - hwnd = 0x%x (0x%x)\n", hwnd, GetParent (hwnd));

switch(iMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
RECT r;
HDC hDC = NULL;

hDC = BeginPaint (hwnd, &ps);

GetClientRect (hwnd, &r);

FillRect (hDC, &r, (HBRUSH) GetSysColorBrush(COLOR_BTNFACE));

DrawEdge (hDC, &r, EDGE_RAISED, BF_RECT | BF_ADJUST);

EndPaint (hwnd, &ps);
}
break;

case WM_WINDOWPOSCHANGED:
printf ("palette - WM_WINDOWPOSCHANGED\n");
return 0;
}

return DefWindowProc(hwnd,iMsg,wParam,lParam);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
static HWND popUp;
static RECT rect;
static INT offSet = 100;
static INT winX = 200;
static INT winY = 200;

switch(iMsg)
{
case WM_CREATE:
printf ("main - WM_CREATE\n");
return 0;

case WM_WINDOWPOSCHANGED:
printf ("main - WM_WINDOWPOSCHANGED\n");
return 0;

case WM_DESTROY:
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hwnd,iMsg,wParam,lParam);
}







From: winapi on
> That is what I'm trying to achieve, however, I have seperated my custom
> control code into dlls and they are loaded dynamically. The function calls
> to create the controls could be used many times so I couldn't save global
> handles to the controls or assume they are being used at all

I assume your custom controls allow this type of construct. . . .

HWND control;
control = CreateMyCustomControl(arg. . . .);