Hi Folks:
Developing with XP Media Edition, VC6, WIN32, no MFC.
This is a second request for help from the Win32 group,
and a first request from the UI group.
A year ago I attempted to get tabs working in some modeless
child dialogs, and had to give up. Now I'd like to try again.
This is my first MDI application. I'm a big believer in
using the Resource editor to lay out dialogs.
As I understand it, MDI children don't lend themselves to
being laid out with the resource editor. So the MDI children's
WM_CREATE call CreateDialogParam() to invoke a modeless child
dialog that will be sized to fit into the client area of the MDI
child, and is laid out with the Resource Editor.
So I lay out a simple test dialog, with a line of static text
and two buttons, to serve as a child of the MDI children.
Before attempting to set any hooks, this dialog is displayed
as desired, with the static text and the two buttons on the
typical gray background. The tab button seems to have no effect.
I attempt to implement a hook, and the dialog is now white,
with no controls visible.
Here is what I've done:
In the modeless dialog children dialog proc I've added the
following to the WM_INITDIALOG trap:
switch (message)
{
case WM_INITDIALOG:
global_active_test_modeless_dialog_handle = hdlg;
global_test_modeless_dialog_hook_handle =
SetWindowsHookEx(WH_GETMESSAGE,
test_message_hook_proc,
NULL, GetCurrentThreadId());
This is in the dialog proc's WM_DESTROY trap:
case WM_DESTROY:
global_active_test_modeless_dialog_handle = NULL;
if(global_test_modeless_dialog_hook_handle != NULL)
{
UnhookWindowsHookEx(
global_test_modeless_dialog_hook_handle);
}
The C++ module for the modeless dialog child has this definition of
test_message_hook_proc:
LRESULT CALLBACK test_message_hook_proc(int code, WPARAM wparam,
LPARAM lparam)
{
LRESULT return_val = 0;
if(code!=HC_ACTION)
{
return_val = CallNextHookEx(
global_test_modeless_dialog_hook_handle,
code,
wparam,
lparam);
}
else
{
if(wparam != PM_NOREMOVE)
{
if((global_active_test_modeless_dialog_handle != NULL) &&
(IsDialogMessage(
global_active_test_modeless_dialog_handle,
(MSG *)lparam)))
{
((MSG *)lparam)->message = WM_NULL;
}
}
return_val = CallNextHookEx(
global_test_modeless_dialog_hook_handle, code,
wparam, lparam);
}
return return_val;
}
The message loop in the app's WinMain:
while (GetMessage (&msg, NULL, 0, 0))
{
bool pass_to_translate = true;
if(global_active_list_modeless_dialog_handle != NULL)
{
pass_to_translate = false;
}
if (!TranslateMDISysAccel (hwndClient, &msg) &&
!TranslateAccelerator (hwndFrame, hAccel, &msg))
{
if(pass_to_translate)
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
}
Moving the "if(pass_to_translate)" to embrace the
TranslateMDISysAccel() clause had no effect.
I've added processing for WM_GETDLGCODE, DM_GETDEFID and
DM_SETDEFID message processing to the modeless child.
A breakepoint in the DM_GETDEFID trap shows that message is
being received, and I've tried returning
MAKELPARAM(IDOK, DC_HASDEFID)
with no effect. Returning 0 also has no effect.
The dialog then comes up blank, as before, and the
WM_GETDLGCODE message is never received by the modeless child.
Any suggestins?
Thanks
Larry