home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cpptba.zip
/
README.TXT
< prev
next >
Wrap
Text File
|
1993-11-30
|
3KB
|
77 lines
README for CPPTBAR.ZIP
This source code shows how to create simple bitmap toolbars using the
technique shown in IBM distributed FRMSUB.ZIP but using the
IBM User Interface Class Libraries supplied with C/Set++ 2.0 and 2.1
The technique is fairly simple.
1. Create a BITMAP Menu in your RC for the items that you want on the
Toolbar. The following is a simple demostration of Toolbar RC files
BITMAP 201 tb1.bmp /* MID_TB_1 */
BITMAP 202 tb2.bmp /* MID_TB_2 */
MENU WND_BAR
BEGIN
MENUITEM "#201", MID_TB_1, MIS_BITMAP
MENUITEM "#202", MID_TB_2, MIS_BITMAP
END
2. Create a derived class of IFrameWindow and ICommandHandler
class ToolBar : public IFrameWindow, // Define ToolBar Class from
public ICommandHandler // IFrameWindow & ICommandHandler
{
public:
ToolBar(unsigned long windowId);
Boolean command(ICommandEvent& cEvent);
}; // End of Toolbar class definition
3. Make sure that derive class above doesn't use defaultStyle, only thing
that is necessary is menuBar style, if you defind it as defaultStyle
you would get another TitleBar and the appearence is not desirable.
ToolBar::ToolBar(unsigned long windowId)
: IFrameWindow (
IFrameWindow::menuBar,
windowId)
{
handleEventsFor(this); //Set self as command event handler
setFocus(); //Set focus to main window
show(); //Set to show main window
} /* end ToolBar :: ToolBar(...) */
4. Finally you need to add code to the FrameWindow that you are adding
the Toolbar to. Thanks to IFrameWindows addExtension function this
is really simple.
myToolBar = new ToolBar(WND_BAR);
addExtension(myToolBar,IFrameWindow::aboveClient, 40);
Note: I use size of 40 here for this demostration, I attempted to find
a method of providing an automatic size determination of the bitmap..
With more research, a more desirable technique for automatically
determining the size could be found.
I have included a simple example program that demostrates this technique.. It
requires IBM CSet++ compiler.. Basically I added a Toolbar similar to the one
provide in Frmsub.zip but I also extended it to include a Toolbar on the
right side of the Window. I also allow you to remove and add the Toolbars
back and forth on the window.
Alot of credit to this sample has to be giving to FRMSUB.ZIP, but it
worth while that its easy to make Toolbars using IBM Class Libraries
Stewart Hyde
CIS: 71034,3712
GEnie: S.HYDE Asst Sysop OS/2 RT