Article View: comp.windows.ms.programmer
Article #3175Re: Activating Dialog Windows
From: Paul Bonneau
Date: Mon, 10 Jun 1991 21:22
Date: Mon, 10 Jun 1991 21:22
42 lines
1692 bytes
1692 bytes
In article <1125@stewart.UUCP> jerry@stewart.UUCP (Jerry Shekhel) writes:
>Hello. Can someone provide a listing of code that, given a window handle,
>will (1) restore the window to normal size if it's minimized, (2) raise the
>window to the top of the stacking order, (3 [MOST IMPORTANT]) give keyboard
>input focus either to the window or to the topmost dialog owned by that window
>if there are any.
>
The following code snippet should work providing every time
you create a dialogs, the parent window is the topmost
dialog.
If you create a popup window that is not a dialog, disable the
topmose dialog or popup, first, else this will not work (it
relies on at most one enable popup at any one time).
Let:
hwnd be the window handle,
hins be the instance handle of your application
BOOL FAR PASCAL
FEnumWnd(HWND hwnd, DWORD lParam)
{
if ((GetWindowLong(hwnd, GWL_STYLE) & WS_POPUP) &&
IsWindowEnabled(hwnd))
{
*(HWND FAR *)lParam = hwnd;
return fFalse;
}
return fTrue;
}
FARPROC lpfn;
HWND hwndPopup;
DefWindowProc(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0L);
BringWindowToTop(hwnd);
lpfn = MakeProcInstance(hins, FEnumWnd);
SetFocus(EnumTaskWindows(hwnd, hwndPopup) ? hwnd : hwndPopup);
FreeProcInstance(lpfn);
cheers - Paul Bonneau.
Technical Details
Message-ID:
<1991Jun10.212241.999@hyper.hyper.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneauReferences:
<1125@stewart.UUCP>Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.ms.programmer Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneau From: bonneau@hyper.hyper.com (Paul Bonneau) Subject: Re: Activating Dialog Windows Message-ID: <1991Jun10.212241.999@hyper.hyper.com> Reply-To: bonneau@hyper.UUCP (Paul Bonneau,,) Organization: HyperCube Inc. References: <1125@stewart.UUCP> Date: Mon, 10 Jun 1991 21:22:41 GMT