Larry,
First set up a call back function as follows:
LRESULT CALLBACK DlgFn(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{ case IDOK:
case 2:
EndDialog(DlgBoxHandle, LOWORD(wParam));
DlgBoxHandle = NULL;
DlgItemCtrlHandle = NULL;
return TRUE;
break;
}
break;
}
return FALSE;
}
Second: Set up a message function to create and display the dialog box:
void ShowMessage(int type)
{
if (!DlgBoxHandle)
{
DlgBoxHandle = CreateDialog(hInst, MAKEINTRESOURCE
(IDD_DIALOG_BOX),hWnd,(DLGPROC)DlgFn);
DlgItemCtrlHandle = GetDlgItem(DlgBoxHandle, IDC_TEXT_CTRL);
SetDlgItemText(DlgBoxHandle,IDC_TEXT_CTRL,_T(“Some Sample Textâ€));
}
UpdateWindow(DlgItemCtrlHandle);
ShowWindow(DlgItemCtrlHandle,SW_SHOW);
SetFocus(DlgBoxHandle);
if (DlgBoxHandle && type)
{
DestroyWindow(DlgBoxHandle);
DlgBoxHandle = NULL;
DlgItemCtrlHandle=NULL;
}
}
Third:
Call the function with a parameter of 0 - this will keep the dialog box in
display on top of all other windows until you call it again with
ShowMessage(1) which will destroy the dialog box.
ShowMessage(0);
Some advice: Be very weary of what mvps tell you and especially this one De
Paolo.
regards,
John