| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Always on top? |
Hello Snebjoern!
Monday April 22 1996 14:10, Snebjoern Andersen wrote to All:
SA> Is there any way to create a PM window that always stays at the top of
SA> the z-order?
Yes, below is the way :-)
Ä OS2PROG (2:5020/214.14) ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ OS2PROG Ä
Msg : 103 of 152 -89 +136
From : Peter Fitzsimmons 1:259/414 Thu 15 Jun 95 04:02
To : Eric Carmody Thu 22 Jun 95 02:49
Subj : TWO PROBLEMS.
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
EC> I saw your note to Paul S. about how to keep a window on top by
EC> setting it up as a subclass, rather than doing the
EC> timer-delay-loop-force-on-top scenario ... that I currently am doing
EC> (via a call to WinSetWindowPos(). I am not familiar with what
EC> subclassing is; would you mind very much to type me a little about
EC> it, and maybe how to implement it in regards to keeping my window
EC> floating ontop. Thansk.
WinSubclassWindow() will allow you to replace the window proceedure of any
window with your own. It will return the address of the old function, so you
can pass along any messages you don't want to process in your replacement proc
(A subclass proceedure would never call WinDefWindowProc, it would call the old
proc returned from
WinSubclassWindow() instead; this way, the window can be subclassed multiple
times).
I have not tried the float-on-top myself, but I would start by trying to
intercept WM_ADJUSTFRAMEPOS.
Hmmm, I just scanned comp.os2.programmer.misc, and found this (it is an
except from the OS/2 Programmer's FAQ.
-----------------------------------------------------------------------
How do you make a window float above all others?
Here's a sample program showing floating windows (derived from
dvipm). The advantages over the WM_TIMER approach [which was presented
in v2.2 -ed] are:
o there's no delay
o repainting is minimized
o avoids timing problems
o the floating windows are not unconditionally moved to the very top
(that is, when moving the base window B (with floating window F) behind
a window W, the order of the windows is this: BFW, not BWF!)
The excessive repainting caused by other solutions was quite annoying
with dvipm as recomputing the dvipm status window is slow.
Credit: Eberhard Mattes
/* floatwin.c */
/* This program shows how to implement floating windows. The source
code works with both 16-bit and 32-bit C compilers.
If the Z-order of the base window is changed, the floating window
will be moved on top of the base window.
Generalizing this approach to many windows floating on many windows
(floating on many windows ...) is left as exercise. */
#define INCL_WIN
#define INCL_GPI
#include
/* Syntactic sugar for supporting both 16-bit and 32-bit compilers. */
#ifdef __32BIT__
#define MSG ULONG
#define FLAGS fl
#else
#define MSG USHORT
#define FLAGS fs
#endif
#ifndef NULLHANDLE
#define NULLHANDLE NULL
#endif
/* The original frame window procedure. */
static PFNWP pfOldBaseFrameProc = NULL;
/* The handle of the floating window. */
static HWND hwndFloat = NULLHANDLE;
/* This frame window procedure is used for subclassing base windows.
When changing the Z-order of the frame window, the floating window
is moved instead of the base window and the hwndInsertBehind field
is modified to move the base window behind the floating window. */
MRESULT EXPENTRY
BaseFrameProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM mp2)
{
PSWP pswp;
switch (msg)
{
case WM_ADJUSTWINDOWPOS pswp = PVOIDFROMMP (mp1);
if ((pswp->FLAGS & SWP_ZORDER) && hwndFloat != NULLHANDLE
&& WinIsWindowVisible (hwndFloat))
{
WinSetWindowPos (hwndFloat, pswp->hwndInsertBehind,
0, 0, 0, 0, SWP_ZORDER);
/* This is the trick! */
pswp->hwndInsertBehind = hwndFloat;
}
break;
}
return pfOldBaseFrameProc (hwnd, msg, mp1, mp2);
}
/* Common client window procedure for base windows and floating
windows. Display TXT and use CLR for filling the background. */
MRESULT CommonClientWndProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM mp2,
PCH txt, COLOR clr)
{
HPS hps;
RECTL rcl;
switch (msg)
{
case WM_PAINT hps = WinBeginPaint (hwnd, 0L, 0L);
WinQueryWindowRect (hwnd, &rcl);
GpiSetColor (hps, CLR_DARKCYAN);
GpiSetBackColor (hps, clr);
WinDrawText (hps, -1, txt, &rcl, 0, 0,
DT_TEXTATTRS | DT_CENTER | DT_VCENTER | DT_ERASERECT);
WinEndPaint (hps);
return 0;
}
return WinDefWindowProc (hwnd, msg, mp1, mp2);
}
/* Client window procedure for floating windows. */
MRESULT EXPENTRY FloatClientWndProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM
mp2)
{
return CommonClientWndProc (hwnd, msg, mp1, mp2, "Floating Window",
CLR_RED);
}
/* Client window procedure for base windows. */
MRESULT EXPENTRY BaseClientWndProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM
mp2)
{
return CommonClientWndProc (hwnd, msg, mp1, mp2, "Base
Window", CLR_YELLOW);
}
/* Start here. */
int main (void)
{
static char szBaseClientClass[] = "floatwin.base";
static char szFloatClientClass[] = "floatwin.float";
ULONG flFrameFlags;
HAB hab;
HMQ hmq;
QMSG qmsg;
HWND hwndBase;
/* Initialize Presentation Manager. */
hab = WinInitialize (0);
hmq = WinCreateMsgQueue (hab, 0);
/* Create client window classes. */
WinRegisterClass (hab, szBaseClientClass, BaseClientWndProc,
CS_SIZEREDRAW, 0);
WinRegisterClass (hab, szFloatClientClass, FloatClientWndProc,
CS_SIZEREDRAW, 0);
/* Create the base window and the floating window. Note windows are
initially invisible. */
flFrameFlags = (FCF_TITLEBAR | FCF_SYSMENU |
FCF_SIZEBORDER | FCF_MINMAX |
FCF_TASKLIST);
/* Create and subclass the base window. */
hwndBase = WinCreateStdWindow (HWND_DESKTOP, 0,
&flFrameFlags, szBaseClientClass,
"floatwin - Base Window",
0L, 0, 1, NULL);
pfOldBaseFrameProc = WinSubclassWindow (hwndBase, BaseFrameProc);
/* Create the floating window. */
hwndFloat = WinCreateStdWindow (HWND_DESKTOP, 0,
&flFrameFlags, szFloatClientClass,
"floatwin - Floating Window",
0L, 0, 1, NULL);
/* Set the position, size and Z-order of the windows and make them
visible. It's important to use SWP_ZORDER for the base
window. */
WinSetWindowPos (hwndFloat, HWND_TOP, 10, 10, 300, 80,
SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER);
WinSetWindowPos (hwndBase, HWND_TOP, 100, 50, 300, 80,
SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER |
SWP_ACTIVATE);
/* The message loop. */
while (WinGetMsg (hab, &qmsg, 0L, 0, 0))
WinDispatchMsg (hab, &qmsg);
/* Clean up. */
WinDestroyWindow (hwndBase);
WinDestroyWindow (hwndFloat);
WinDestroyMsgQueue (hmq);
WinTerminate (hab);
return 0;
}
--- Maximus/2 2.02p1
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 5020/620 509 35 400 464/200 31 72 34 5100/8 396/1 270/101 712/515 @PATH: 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.