Two Handy Properties for Creating Toolbars (Functions/Subroutines/Programs)
Created at 26 JUL 1996 11:09AM
Terminology:
Always-on-top - A window that is never overlapped (covered up) regardless of which window is currently activated.
Button Bar - A set of buttons arranged horizontally or vertically on a window that are typically used as short-cuts to functionality present in the window's menu.
Caption Bar - The area of a window between its system menu button and its minimize/maximize button that allows the window to be dragged using a mouse.
Dockable - A toolbar which, when dragged close to the edge of the frame (area or window) that it works within, attaches to that frame and loses any floating toolbar attributes. This frame can be the desktop.
Floating - A toolbar which can be moved independently of other windows.
Toolbar - A window that typically contains only a button bar. Toolbars are sometimes owned by a particular window; for example, the OpenInsight Form Designer has a toolbar which contains the available Windows controls for designing a form.
Developers frequently ask two questions when designing toolbars in OpenInsight:
Q: How can I get my toolbar to be always-on-top?
Always-on-top is implemented in Windows by setting the extended style of a window. The Windows API include file windows.h defines the extended window styles; the styles are all prefixed by WS_EX_ (Window Style EXtension). The extended style for always-on-top is called WS_EX_TOPMOST, and its value is 8.
The extended style for a window is represented by the OpenInsight property STYLE_EX. The following code fragment is taken from the Basic+ Programmer's Reference help for the STYLE property and modified for STYLE_EX:
subroutine SetStyleEx(CtrlEntID, AddStyle)
declare function Get_Property
declare subroutine Set_Property
* get the current style
Style = Get_Property(CtrlEntID, "STYLE_EX")
/* the style property can be in hex format
but bitor only works with decimal integers */
if Style [1,2] _eqc "0x" then
convert @lower.case to @upper.case in Style
Style = iconv(Style [3,99], "MX")
end
* add the new style
Style = bitor(Style, AddStyle)
Set_Property(CtrlEntID, "STYLE_EX", Style)
return
The following code snippet sets the always-on-top extended style for the window called TOOLBAR using the above function:
call SetStyleEx("TOOLBAR", 8)
Q: How can I make caption bar smaller like the Microsoft Office toolbar uses?
The smaller caption bars popular on toolbars are not actually caption bars at all. They are referred to as "dummy" captions, and are usually just static text controls without any text. By setting the background color of the static text control and placing it along the very top edge (or the left edge for some left-to-right toolbars) of a window, the dummy caption looks like a caption bar. The difference between a static text and a real caption bar is that a window can be dragged using its caption bar. To make a static text control act like a caption bar in this manner, set its DUMMYCAPTION property to true. The following code snipped does just that for the static text named CAPTION on the window called TOOLBAR:
declare subroutine Set_Property
$insert Logical
Set_Property("TOOLBAR.CAPTION", "DUMMYCAPTION", TRUE$)
________
See Also: STYLE and STYLE_EX property, DUMMYCAPTION property
Source code:
http://www.revelation.com/o4wtrs/KB_Articles/KB0017_files/Example.txt