Re: Add button to Title bar -
12-16-2006
, 12:35 AM
FYI, here's what I ended up doing to solve my problem.
I created a small non-modal dialog control form, that just had 3 buttons
- Pin Here, Reset, and a checkbox for 'Dialog?', but no title bar, dialog
frame, or mouse activation. When this control form is opened and/or moved,
the SetWindowPos code below is called. This will keep the control form on
top, but not give it focus. More importantly, it doesn't steal focus from
the main form.
Before the main form is opened, it is checked to see if the user has flagged
it as a dialog and if so, openAsDialog() is used. It is also checked to
see if they've previously pinned the form, & if so the desired x,y is set
from that.
If the main form is opened as a dialog, the control form is opened & positioned
on the main form's title bar. There could be several control forms open
at once (for different main forms), so the control form's title is set to
the main form's plus a constant string.
Everytime the main form is moved (menuControlMove), the control form is also
moved by the same x,y changes. Since all my move code is in a library, the
menuAction must doDefault before calling the library methods.
On the main form's menuCanClose, I check to see if there is a control form
and close it also.
Problems with this approach:
1. The control form doesn't move seamlessly with the main form. It only
moves when the main form is done moving.
2. The control form isn't transparent, so it obscures some of the main form's
title bar.
Any suggestions on these 2 problems? Otherwise, it works great. Thanks
for all the input.
Jim Moseley
uses USER32
SetWindowPos(WinHandle CLONG,
WinHandleInsertAfter CLONG,
X CLONG, Y CLONG, CX CLONG, CY CLONG,
wFlags CLONG)
endUses
var HWND_TOP, windowParm longint endvar
HWND_TOP = 0
SWP_NOSIZE = 1 ; &H1
SWP_NOMOVE = 2 ; &H2
SWP_NOACTIVATE = 16 ; &H10
SWP_SHOWWINDOW = 64 ; &H40
windowParm = SWP_NOACTIVATE + SWP_NOSIZE + SWP_NOMOVE
SetWindowPos(siWinHandle, HWIND_TOP, 0,0,0,0, windowParm) |