I have been sticking pins into my client area. 
A topmost feature usually finds itself included in the System Menu of most of my apps but I thought it was time to add a 'Toggle pin' - it is convenient and I'll know the topmost status without moving my hands; provided I'm not asleep on my keyboard. Have you noticed that the older you get the mirrored qwerty indents on your forehead take longer to go when you wake up?
Anyway, I toyed with putting a pin in the Title Bar but some software put icons there and there would be a conflict. Putting a pin into the client area should be as unobtrusive as possible. I ended up with a 16x16 black foreground, transparent background icon just underneath the Close button on the Title bar. Added: It will be a bit further away when an app menu is employed.
Now, whatever we use in the client area will be of no use if an app is in untopped mode and sitting fully behind another app in topped mode. The toggle pin then is not a replacement for the System Menu approach since we can get at the System Menu via a right click on the Taskbar entry.
Here are a couple of screenshots of a demo showing the Systen Menu and toggle pin addition.

The attached zipped TopmostDemo folder includes TopmostDemo.bas, TopmostDemo.exe, TopmostDemo.rc, TopmostDemo.pbr, Top.ico and NotTop.ico.
This is TopmostDemo.bas with PB 9.01.
Needless to say the System Menu entry and the toggle pin are in sync and the toggle pin takes its lead from the System Menu entry.
Added: '&' removed from the SysMenu texts - Attach Accel isn't being used here.
Added: It is now - see blue text and next post.

A topmost feature usually finds itself included in the System Menu of most of my apps but I thought it was time to add a 'Toggle pin' - it is convenient and I'll know the topmost status without moving my hands; provided I'm not asleep on my keyboard. Have you noticed that the older you get the mirrored qwerty indents on your forehead take longer to go when you wake up?

Anyway, I toyed with putting a pin in the Title Bar but some software put icons there and there would be a conflict. Putting a pin into the client area should be as unobtrusive as possible. I ended up with a 16x16 black foreground, transparent background icon just underneath the Close button on the Title bar. Added: It will be a bit further away when an app menu is employed.
Now, whatever we use in the client area will be of no use if an app is in untopped mode and sitting fully behind another app in topped mode. The toggle pin then is not a replacement for the System Menu approach since we can get at the System Menu via a right click on the Taskbar entry.
Here are a couple of screenshots of a demo showing the Systen Menu and toggle pin addition.

The attached zipped TopmostDemo folder includes TopmostDemo.bas, TopmostDemo.exe, TopmostDemo.rc, TopmostDemo.pbr, Top.ico and NotTop.ico.
This is TopmostDemo.bas with PB 9.01.
Needless to say the System Menu entry and the toggle pin are in sync and the toggle pin takes its lead from the System Menu entry.
Code:
#Compile Exe #Dim All #Register None #Tools Off %NOMMIDS = 1 %NOGDI = 1 #Include "WIN32API.inc" ' 27 January 2005 #Resource "TopmostDemo.pbr" %IDTopMost = 100 %TopmostIcon = 110 %Lable = 120 '------------------------------------------------------------------ Function PBMain() Local hDlg, SysMenu, Result As Long [COLOR="Blue"]Dim ac(0) As ACCELAPI Local hAccel As Dword[/COLOR] CreateForm( hDlg ) SysMenu = GetSystemMenu( hDlg, %FALSE ) Menu Add String, SysMenu, "-", 0, 0 Menu Add String, SysMenu, "Undo TopMost" [COLOR="Blue"]+ $Tab + "Ctrl+T"[/COLOR], %IDTopmost, %MF_ENABLED [COLOR="Blue"] ac(0).fVirt = %FCONTROL Or %FVIRTKEY ac(0).KEY = %VK_T ac(0).cmd = %IDTopmost Accel Attach hDlg, ac() To hAccel[/COLOR] Dialog Show Modal hDlg, Call CBF_Dialog To Result Function = Result End Function '------------------------------------------------------------------ CallBack Function CBF_Dialog Select Case As Long CB.Msg Case %WM_NCACTIVATE Static hWndSaveFocus As Dword If IsFalse CB.wParam Then ' Save control focus hWndSaveFocus = GetFocus() ElseIf hWndSaveFocus Then ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 End If Case %WM_SYSCOMMAND If CB.Ctl = %IDTopmost Then TopMost( CB.Hndl ) Function = 1 End If End Select End Function '------------------------------------ CallBack Function CBF_TopButton If CB.CtlMsg = %STN_CLICKED Then If CB.Ctl = %TopmostIcon Then TopMost( CB.Hndl ) Function = 1 End If End If End Function '-------------------------------------------------------------------------------- Sub TopMost( hWindow As Long ) Local SysMenu As Dword Local SysMenuTopmostText As String SysMenu = GetSystemMenu( hWindow, %FALSE ) Menu Get Text SysMenu, ByCmd %IDTopmost To SysMenuTopmostText If SysMenuTopmostText = "Do TopMost" [COLOR="Blue"]+ $Tab + "Ctrl+T"[/COLOR] Then SetWindowPos hWindow, %HWND_TOPMOST, 0, 0, 0, 0, %SWP_NOMOVE Or %SWP_NOSIZE Menu Set Text SysMenu, ByCmd %IDTopmost, "Undo TopMost"[COLOR="Blue"] + $Tab + "Ctrl+T"[/COLOR] Control Set Image hWindow, %TopmostIcon, "Top" Else SetWindowPos hWindow, %HWND_NOTOPMOST, 0, 0, 0, 0, %SWP_NOMOVE Or %SWP_NOSIZE Menu Set Text SysMenu, ByCmd %IDTopmost, "Do TopMost" [COLOR="Blue"]+ $Tab + "Ctrl+T"[/COLOR] Control Set Image hWindow, %TopmostIcon, "NotTop" End If End Sub '---------------------------------------------------------------------------------------------------------- Sub CreateForm( hDlg As Long ) Local FormWidth As Long ' Form in Dialog Units FormWidth = 130 Dialog New 0, " Topmost Demo",,, FormWidth, 50, %WS_BORDER Or %WS_DLGFRAME Or %WS_SYSMENU _ Or %WS_MINIMIZEBOX Or %DS_MODALFRAME, %WS_EX_WINDOWEDGE To hDlg ' I never use Set Color but some of you might 'Dialog Set Color hDlg, -1&, %LtGray SetWindowPos hDlg, %HWND_TOPMOST, 0, 0, 0, 0, %SWP_NOMOVE Or %SWP_NOSIZE ' Top on opening ' To tuck at top right of client area use a client area x co-ord of 'FormWidth - 12' and a y co-ord of 0. Control Add Image, hDlg, %TopmostIcon, "Top", FormWidth - 12, 0, 10, 10, %SS_NOTIFY, , Call CBF_TopButton 'Control Set Color hDlg, %TopmostIcon, -1&, %LtGray Control Add Label, hDlg, %Lable, "Right click left end of Title bar to get System Menu.", 5, 20, 100, 16 'Control Set Color hDlg, %Lable, -1&, %LtGray End Sub '----------------------------------------------------------------------------------------------------------
Added: It is now - see blue text and next post.

Comment