home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cpptba.zip / README.TXT < prev    next >
Text File  |  1993-11-30  |  3KB  |  77 lines

  1.  README for CPPTBAR.ZIP 
  2.  
  3.  This source code shows how to create simple bitmap toolbars using the 
  4.  technique shown in IBM distributed FRMSUB.ZIP but using the
  5.  IBM User Interface Class Libraries supplied with C/Set++ 2.0 and 2.1
  6.  
  7.  The technique is fairly simple.
  8.  
  9.  1. Create a BITMAP Menu in your RC for the items that you want on the
  10.     Toolbar.  The following is a simple demostration of Toolbar RC files
  11.  
  12.  
  13.    BITMAP    201    tb1.bmp        /* MID_TB_1  */
  14.    BITMAP    202    tb2.bmp        /* MID_TB_2  */
  15.  
  16.    MENU WND_BAR
  17.     BEGIN
  18.       MENUITEM  "#201",  MID_TB_1,  MIS_BITMAP
  19.       MENUITEM  "#202",  MID_TB_2,  MIS_BITMAP
  20.     END
  21.  
  22.  
  23.   2. Create a derived class of IFrameWindow and ICommandHandler
  24.  
  25.    class ToolBar : public IFrameWindow,    //   Define ToolBar Class from
  26.                    public ICommandHandler  //   IFrameWindow & ICommandHandler
  27.    {
  28.       public:
  29.          ToolBar(unsigned long windowId);     
  30.          Boolean command(ICommandEvent& cEvent);
  31.    };                                      // End of Toolbar class definition
  32.  
  33.       
  34.   3. Make sure that derive class above doesn't use defaultStyle, only thing
  35.      that is necessary is menuBar style, if you defind it as defaultStyle
  36.      you would get another TitleBar and the appearence is not desirable.
  37.  
  38.  
  39.    ToolBar::ToolBar(unsigned long windowId)        
  40.       :  IFrameWindow (                            
  41.          IFrameWindow::menuBar,                  
  42.          windowId)                                 
  43.    {
  44.       handleEventsFor(this);              //Set self as command event handler
  45.       setFocus();                         //Set focus to main window
  46.       show();                             //Set to show main window
  47.    } /* end ToolBar :: ToolBar(...) */
  48.  
  49.  
  50.    4.  Finally you need to add code to the FrameWindow that you are adding
  51.        the Toolbar to. Thanks to IFrameWindows addExtension function this
  52.        is really simple.
  53.  
  54.  
  55.       myToolBar = new ToolBar(WND_BAR);
  56.       addExtension(myToolBar,IFrameWindow::aboveClient, 40);         
  57.  
  58.       Note: I use size of 40 here for this demostration, I attempted to find
  59.       a method of providing an automatic size determination of the bitmap..
  60.       With more research, a more desirable technique for automatically 
  61.       determining the size could be found.
  62.  
  63. I have included a simple example program that demostrates this technique.. It
  64. requires IBM CSet++ compiler.. Basically I added a Toolbar similar to the one
  65. provide in Frmsub.zip but I also extended it to include a Toolbar on the
  66. right side of the Window.  I also allow you to remove and add the Toolbars 
  67. back and forth on the window.
  68.  
  69. Alot of credit to this sample has to be giving to FRMSUB.ZIP, but it
  70. worth while that its easy to make Toolbars using IBM Class Libraries
  71.  
  72. Stewart Hyde
  73. CIS:     71034,3712
  74. GEnie:   S.HYDE       Asst Sysop OS/2 RT
  75.  
  76.  
  77.