Thread: Toolbar Questions

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    363

    Toolbar Questions

    I've added a toolbar to my programme using code I pretty much copied keyword for keyword from theForger's tutorial. I now have two problems with the tool bar.
    1) The tool bar appears inside the client area of the window(as in right beside the verticle scrollbar), is there any EASY way I can move it up out of the client area?
    2) Once I've added some standard butons for things like new and open, how do I add another bitmap for some other buttons?

    For anyone who's interested, here's my version of the code
    Code:
                              HWND hwToolBar;
                              TBADDBITMAP tbabToolBar;
                              TBBUTTON tbbToolBar[3];
    
                              hwToolBar = CreateWindowEx(0,
                                                         TOOLBARCLASSNAME,
                                                         NULL,
                                                         WS_CHILD | WS_VISIBLE |
                                                         TBSTYLE_TOOLTIPS | CCS_ADJUSTABLE,
                                                         0,
                                                         0,
                                                         0,
                                                         0,
                                                         hwnd,
                                                         (HMENU)IDT_MAIN_TOOLBAR,
                                                         GetModuleHandle(NULL),
                                                         NULL);
                              crMain.ToolW = hwToolBar;
                              SendMessage(hwToolBar,
                                          TB_BUTTONSTRUCTSIZE,
                                          (WPARAM)sizeof(TBBUTTON),
                                          0);
                                                          
                              tbabToolBar.hInst = HINST_COMMCTRL;
                              tbabToolBar.nID   = IDB_STD_SMALL_COLOR;
                              SendMessage(hwToolBar, TB_ADDBITMAP, 0, (LPARAM)&tbabToolBar);
                           
                              ZeroMemory(tbbToolBar, sizeof(tbbToolBar));
    
                              tbbToolBar[0].iBitmap   = STD_FILENEW;
                              tbbToolBar[0].fsState   = TBSTATE_ENABLED;
                              tbbToolBar[0].fsStyle   = TBSTYLE_BUTTON;
                              tbbToolBar[0].idCommand = IDM_F_NEW;
    
                              tbbToolBar[1].iBitmap   = STD_FILEOPEN;
                              tbbToolBar[1].fsState   = TBSTATE_ENABLED;
                              tbbToolBar[1].fsStyle   = TBSTYLE_BUTTON;
                              tbbToolBar[1].idCommand = IDM_F_OPEN;
    
                              tbbToolBar[2].iBitmap   = STD_FILESAVE;
                              tbbToolBar[2].fsState   = TBSTATE_ENABLED;
                              tbbToolBar[2].fsStyle   = TBSTYLE_BUTTON;
                              tbbToolBar[2].idCommand = IDM_F_SAVEAS;
                         
                              SendMessage(hwToolBar,
                                          TB_ADDBUTTONS,
                                          sizeof(tbbToolBar)/sizeof(TBBUTTON),
                                          (LPARAM)&tbbToolBar);
    If you own a piece of land and there is an volcano on it and it ruins a
    nearby town, do you have to pay for the property damage?

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    >Once I've added some standard butons for things like new and
    >open, how do I add another bitmap for some other buttons?
    In the windows API documentation or on MSDN there is a descirption of the standard buttons like STD_FILENEW. If you want to create your own, I beleive STD_FILENEW is just like a resource. Just create a bitmap resource and try using that.

    You can move the toolbar by changing where it is created. Change the location in the CreateWindowEx function. Again, see the documentation for the exact arguments that relate to location.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    The toolbar is created as a child window. Its position must be in the client area. You can't change it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. toolbar button question
    By supernater in forum Windows Programming
    Replies: 1
    Last Post: 05-25-2009, 08:24 PM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Dockable Toolbar (Like taskbar or office toolbar)
    By om3ga in forum Windows Programming
    Replies: 2
    Last Post: 11-20-2005, 03:09 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. Toolbar Buttons
    By G'n'R in forum Windows Programming
    Replies: 2
    Last Post: 10-02-2003, 04:35 AM