Rebar and ToolBars

This is a discussion on Rebar and ToolBars within the Windows Programming forums, part of the Platform Specific Boards category; Hello... I should like of know what's incorrect with my project, it must show 2 ToolBars into of a Rebar ...

  1. #1
    A.I Programmer
    Join Date
    Mar 2007
    Location
    Teresina - Brazil
    Posts
    47

    Rebar and ToolBars

    Hello...

    I should like of know what's incorrect with my project, it must show 2 ToolBars into of a Rebar Control.

    The code complete of the my program:

    Code:
    #include <windows.h>
    #define _WIN32_IE 0x0501
    #include <commctrl.h>
    
    #define idFileNew    1000
    #define idFileOpen   1001
    #define idSaveAs     1002
    
    #define idCopy       1003
    #define idCut        1004
    #define idDelete     1005
    
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
    char szClassName[ ] = "WindowsApp";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
       HWND hwnd;
       MSG messages;
       WNDCLASSEX wincl;
    
       INITCOMMONCONTROLSEX InitCtrls;
       InitCtrls.dwICC = ICC_COOL_CLASSES;
       InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
       BOOL Ret = InitCommonControlsEx(&InitCtrls);
        
       wincl.hInstance = hThisInstance;
       wincl.lpszClassName = szClassName;
       wincl.lpfnWndProc = WindowProcedure;
       wincl.style = CS_DBLCLKS;
       wincl.cbSize = sizeof (WNDCLASSEX);
    
       wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
       wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
       wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
       wincl.lpszMenuName = NULL;
       wincl.cbClsExtra = 0;
       wincl.cbWndExtra = 0;
       wincl.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
    
       if (!RegisterClassEx (&wincl))
         return 0;
    
       hwnd = CreateWindowEx (
              0,
              szClassName,
              "Rebar - Wnd",
              WS_OVERLAPPEDWINDOW,
              CW_USEDEFAULT,
              CW_USEDEFAULT,
              544,
              375,
              HWND_DESKTOP,
              NULL,
              hThisInstance,
              NULL
              );
    
       ShowWindow (hwnd, nFunsterStil);
    
       while (GetMessage (&messages, NULL, 0, 0))
       {
          if(!IsDialogMessage(hwnd,&messages))
          {
             TranslateMessage(&messages);
             DispatchMessage(&messages);
          }
       }
    
       return messages.wParam;
    }
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
       static HWND Rebar, ToolBar1, ToolBar2;
       
       switch (message)
       {
          case WM_CREATE:
          {
             REBARINFO RebarInfo;
             REBARBANDINFO RebarBandInfo;
             
             Rebar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|RBS_BANDBORDERS|RBS_DBLCLKTOGGLE|RBS_DBLCLKTOGGLE|CCS_NODIVIDER,0,0,0,0,hwnd,NULL,GetModuleHandle(NULL),NULL);
             
             if(!Rebar)
             {
                return 0;
             }
             
             RebarInfo.cbSize = sizeof(REBARINFO);
             RebarInfo.fMask = 0;
             RebarInfo.himl = (HIMAGELIST)NULL;
             
             if(!SendMessage(Rebar,RB_SETBARINFO,0,(LPARAM)&RebarInfo))
             {
                return 0;
             }
             
             RebarBandInfo.cbSize = sizeof(REBARBANDINFO);
             RebarBandInfo.fMask  = RBBIM_BACKGROUND|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_COLORS|RBBIM_SIZE|RBBIM_STYLE|RBBIM_TEXT; //RBBIM_HEADERSIZE|RBBIM_IDEALSIZE|RBBIM_ID|RBBIM_IMAGE|RBBIM_LPARAM
             RebarBandInfo.fStyle = RBBS_CHILDEDGE|RBBS_FIXEDBMP;
             RebarBandInfo.hbmBack = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(""));
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
             
             //ToolBar1
             
             TBBUTTON TbButton[3];
             TBADDBITMAP TbAddBitmap;
             
             ToolBar1 = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT|TBSTYLE_TRANSPARENT,0,0,0,0,Rebar,NULL,GetModuleHandle(NULL),NULL);
             
             SendMessage(ToolBar1,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
             
             TbAddBitmap.hInst = HINST_COMMCTRL;
             TbAddBitmap.nID = IDB_STD_SMALL_COLOR;
             SendMessage(ToolBar1,TB_ADDBITMAP,0,(LPARAM)&TbAddBitmap);
             
             ZeroMemory(TbButton, sizeof(TbButton));
             
             TbButton[0].iBitmap = STD_FILENEW;
             TbButton[0].fsState = TBSTATE_ENABLED;
             TbButton[0].fsStyle = TBSTYLE_BUTTON;
             TbButton[0].idCommand = idFileNew;
    
             TbButton[1].iBitmap = STD_FILEOPEN;
             TbButton[1].fsState = TBSTATE_ENABLED;
             TbButton[1].fsStyle = TBSTYLE_BUTTON;
             TbButton[1].idCommand = idFileOpen;
    
             TbButton[2].iBitmap = STD_FILESAVE;
             TbButton[2].fsState = TBSTATE_ENABLED;
             TbButton[2].fsStyle = TBSTYLE_BUTTON;
             TbButton[2].idCommand = idSaveAs;
             
             SendMessage(ToolBar1,TB_ADDBUTTONS,sizeof(TbButton)/sizeof(TBBUTTON),(LPARAM)&TbButton);
             
             long SizeTool1 = SendMessage(ToolBar1,TB_GETBUTTONSIZE,0,0);
             
             RebarBandInfo.lpText     = "ToolBar";
             RebarBandInfo.hwndChild  = ToolBar1;
             RebarBandInfo.cxMinChild = 0;
             RebarBandInfo.cyMinChild = HIWORD(SizeTool1);
             RebarBandInfo.cx         = 250;
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
             
             //ToolBar2
             
             ToolBar2 = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT|TBSTYLE_TRANSPARENT,0,0,0,0,Rebar,NULL,GetModuleHandle(NULL),NULL);
             
             SendMessage(ToolBar2,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
             
             TbAddBitmap.hInst = HINST_COMMCTRL;
             TbAddBitmap.nID = IDB_STD_SMALL_COLOR;
             SendMessage(ToolBar2,TB_ADDBITMAP,0,(LPARAM)&TbAddBitmap);
             
             ZeroMemory(TbButton, sizeof(TbButton));
             
             TbButton[0].iBitmap = STD_COPY;
             TbButton[0].fsState = TBSTATE_ENABLED;
             TbButton[0].fsStyle = TBSTYLE_BUTTON;
             TbButton[0].idCommand = idCopy;
    
             TbButton[1].iBitmap = STD_CUT;
             TbButton[1].fsState = TBSTATE_ENABLED;
             TbButton[1].fsStyle = TBSTYLE_BUTTON;
             TbButton[1].idCommand = idCut;
    
             TbButton[2].iBitmap = STD_DELETE;
             TbButton[2].fsState = TBSTATE_ENABLED;
             TbButton[2].fsStyle = TBSTYLE_BUTTON;
             TbButton[2].idCommand = idDelete;
             
             SendMessage(ToolBar2,TB_ADDBUTTONS,sizeof(TbButton)/sizeof(TBBUTTON),(LPARAM)&TbButton);
             
             long SizeTool2 = SendMessage(ToolBar2,TB_GETBUTTONSIZE,0,0);
             
             RebarBandInfo.lpText     = "ToolBar2";
             RebarBandInfo.hwndChild  = ToolBar2;
             RebarBandInfo.cxMinChild = 300;
             RebarBandInfo.cyMinChild = HIWORD(SizeTool2);
             RebarBandInfo.cx         = 250;
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
          }break;
          
          case WM_COMMAND:
          {
             switch(LOWORD(wParam))
             {
                                   
             }
          }break;
               
          case WM_DESTROY:
            PostQuitMessage (0);
            break;
          
          default:
            return DefWindowProc (hwnd, message, wParam, lParam);
       }
    
       return 0;
    }
    I use Dev-C++ 4.9.9.2 and "libcomctl32.a"

    I appreciate any help...

  2. #2
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    arent you supposed in WinMain to return (something like this) :
    Code:
    return (int)msg.wParam;
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  3. #3
    A.I Programmer
    Join Date
    Mar 2007
    Location
    Teresina - Brazil
    Posts
    47
    This is correct!

    Code:
    MSG messages
    
    ...
    
    return messages.wParam;
    Can somebody help me?

  4. #4
    A.I Programmer
    Join Date
    Mar 2007
    Location
    Teresina - Brazil
    Posts
    47
    I make the same project with ComboBoxes and worked.

    See the code to Rebar and ComboBoxes:

    Code:
    #include <windows.h>
    #define _WIN32_IE 0x0501
    #include <commctrl.h>
    
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
    char szClassName[ ] = "WindowsApp";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
       HWND hwnd;
       MSG messages;
       WNDCLASSEX wincl;
    
       INITCOMMONCONTROLSEX InitCtrls;
       InitCtrls.dwICC = ICC_COOL_CLASSES|ICC_BAR_CLASSES ;
       InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
       BOOL Ret = InitCommonControlsEx(&InitCtrls);
        
       wincl.hInstance = hThisInstance;
       wincl.lpszClassName = szClassName;
       wincl.lpfnWndProc = WindowProcedure;
       wincl.style = CS_DBLCLKS;
       wincl.cbSize = sizeof (WNDCLASSEX);
    
       wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
       wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
       wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
       wincl.lpszMenuName = NULL;
       wincl.cbClsExtra = 0;
       wincl.cbWndExtra = 0;
       wincl.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
    
       if (!RegisterClassEx (&wincl))
         return 0;
    
       hwnd = CreateWindowEx (
              0,
              szClassName,
              "Rebar - Wnd",
              WS_OVERLAPPEDWINDOW,
              CW_USEDEFAULT,
              CW_USEDEFAULT,
              544,
              375,
              HWND_DESKTOP,
              NULL,
              hThisInstance,
              NULL
              );
    
       ShowWindow (hwnd, nFunsterStil);
    
       while (GetMessage (&messages, NULL, 0, 0))
       {
          if(!IsDialogMessage(hwnd,&messages))
          {
             TranslateMessage(&messages);
             DispatchMessage(&messages);
          }
       }
    
       return messages.wParam;
    }
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
       static HWND Rebar, ComboBox1, ComboBox2;
       
       switch (message)
       {
          case WM_CREATE:
          {
             REBARINFO RebarInfo;
             REBARBANDINFO RebarBandInfo;
             
             Rebar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|RBS_BANDBORDERS|RBS_DBLCLKTOGGLE|RBS_DBLCLKTOGGLE|CCS_NODIVIDER,0,0,0,0,hwnd,NULL,GetModuleHandle(NULL),NULL);
             
             if(!Rebar)
             {
                return 0;
             }
             
             RebarInfo.cbSize = sizeof(REBARINFO);
             RebarInfo.fMask = 0;
             RebarInfo.himl = (HIMAGELIST)NULL;
             
             if(!SendMessage(Rebar,RB_SETBARINFO,0,(LPARAM)&RebarInfo))
             {
                return 0;
             }
             
             RebarBandInfo.cbSize = sizeof(REBARBANDINFO);
             RebarBandInfo.fMask  = RBBIM_BACKGROUND|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_COLORS|RBBIM_SIZE|RBBIM_STYLE|RBBIM_TEXT; //RBBIM_HEADERSIZE|RBBIM_IDEALSIZE|RBBIM_ID|RBBIM_IMAGE|RBBIM_LPARAM
             RebarBandInfo.fStyle = RBBS_CHILDEDGE|RBBS_FIXEDBMP;
             RebarBandInfo.hbmBack = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(""));
             
             //ComboBox1
             
             ComboBox1 = CreateWindowEx(WS_EX_CLIENTEDGE,"COMBOBOX","",WS_CHILD|WS_VISIBLE|CBS_DROPDOWN,10,10,160,22,Rebar,NULL,GetModuleHandle(NULL),NULL);
             
             RebarBandInfo.lpText     = "ComboBox1";
             RebarBandInfo.hwndChild  = ComboBox1;
             RebarBandInfo.cxMinChild = 0;
             RebarBandInfo.cyMinChild = 22;
             RebarBandInfo.cx         = 160;
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
             
             //ComboBox2
             
             ComboBox2 = CreateWindowEx(WS_EX_CLIENTEDGE,"COMBOBOX","",WS_CHILD|WS_VISIBLE|CBS_DROPDOWN,10,10,160,22,Rebar,NULL,GetModuleHandle(NULL),NULL);
             
             RebarBandInfo.lpText     = "ComboBox2";
             RebarBandInfo.hwndChild  = ComboBox2;
             RebarBandInfo.cxMinChild = 0;
             RebarBandInfo.cyMinChild = 22;
             RebarBandInfo.cx         = 160;
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
          }break;
          
          case WM_COMMAND:
          {
             switch(LOWORD(wParam))
             {
                                   
             }
          }break;
               
          case WM_DESTROY:
            PostQuitMessage (0);
            break;
          
          default:
            return DefWindowProc (hwnd, message, wParam, lParam);
       }
    
       return 0;
    }
    Why with the TooBars don't work?

  5. #5
    A.I Programmer
    Join Date
    Mar 2007
    Location
    Teresina - Brazil
    Posts
    47

    Thumbs up

    I finish the project with the ToolBar, I've only that insert some Windows Styles to the ToolBars...

    Code of tha my project:

    Code:
    /*main.c*/
    
    #include <windows.h>
    #include "resource.h"
    
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
    char szClassName[ ] = "WindowsApp";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
       HWND hwnd;
       MSG messages;
       WNDCLASSEX wincl;
    
       INITCOMMONCONTROLSEX InitCtrls;
       InitCtrls.dwICC = ICC_COOL_CLASSES|ICC_BAR_CLASSES ;
       InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
       BOOL Ret = InitCommonControlsEx(&InitCtrls);
        
       wincl.hInstance = hThisInstance;
       wincl.lpszClassName = szClassName;
       wincl.lpfnWndProc = WindowProcedure;
       wincl.style = CS_DBLCLKS;
       wincl.cbSize = sizeof (WNDCLASSEX);
    
       wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
       wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
       wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
       wincl.lpszMenuName = NULL;
       wincl.cbClsExtra = 0;
       wincl.cbWndExtra = 0;
       wincl.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
    
       if (!RegisterClassEx (&wincl))
         return 0;
    
       hwnd = CreateWindowEx (
              0,
              szClassName,
              "Rebar - Wnd",
              WS_OVERLAPPEDWINDOW,
              CW_USEDEFAULT,
              CW_USEDEFAULT,
              544,
              375,
              HWND_DESKTOP,
              NULL,
              hThisInstance,
              NULL
              );
    
       ShowWindow (hwnd, nFunsterStil);
    
       while (GetMessage (&messages, NULL, 0, 0))
       {
          if(!IsDialogMessage(hwnd,&messages))
          {
             TranslateMessage(&messages);
             DispatchMessage(&messages);
          }
       }
    
       return messages.wParam;
    }
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
       static HWND Rebar, ToolBar1, ToolBar2;
       
       switch (message)
       {
          case WM_CREATE:
          {
             REBARINFO RebarInfo;
             REBARBANDINFO RebarBandInfo;
             RECT Rc;
             
             Rebar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|RBS_BANDBORDERS|RBS_DBLCLKTOGGLE|RBS_DBLCLKTOGGLE|CCS_NODIVIDER,0,0,0,0,hwnd,NULL,GetModuleHandle(NULL),NULL);
             
             if(!Rebar)
             {
                return 0;
             }
             
             RebarInfo.cbSize = sizeof(REBARINFO);
             RebarInfo.fMask = 0;
             RebarInfo.himl = (HIMAGELIST)NULL;
             
             if(!SendMessage(Rebar,RB_SETBARINFO,0,(LPARAM)&RebarInfo))
             {
                return 0;
             }
             
             RebarBandInfo.cbSize = sizeof(REBARBANDINFO);
             RebarBandInfo.fMask  = RBBIM_BACKGROUND|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_COLORS|RBBIM_SIZE|RBBIM_STYLE|RBBIM_TEXT; //RBBIM_HEADERSIZE|RBBIM_IDEALSIZE|RBBIM_IMAGE|RBBIM_LPARAM
             RebarBandInfo.fStyle = RBBS_CHILDEDGE|RBBS_FIXEDBMP|RBBS_GRIPPERALWAYS;
             RebarBandInfo.hbmBack = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(idBack));
             
             //ToolBar1
             
             TBBUTTON TbButton[3];
             TBADDBITMAP TbAddBitmap;
             long Size;
             
             ToolBar1 = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT|CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NODIVIDER,0,0,0,0,hwnd,NULL,GetModuleHandle(NULL),NULL);
             
             SendMessage(ToolBar1,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
             
             TbAddBitmap.hInst = HINST_COMMCTRL;
             TbAddBitmap.nID = IDB_STD_SMALL_COLOR;
             SendMessage(ToolBar1,TB_ADDBITMAP,0,(LPARAM)&TbAddBitmap);
             
             ZeroMemory(TbButton, sizeof(TbButton));
             
             TbButton[0].iBitmap = STD_FILENEW;
             TbButton[0].fsState = TBSTATE_ENABLED;
             TbButton[0].fsStyle = TBSTYLE_BUTTON;
             TbButton[0].idCommand = idFileNew;
    
             TbButton[1].iBitmap = STD_FILEOPEN;
             TbButton[1].fsState = TBSTATE_ENABLED;
             TbButton[1].fsStyle = TBSTYLE_BUTTON;
             TbButton[1].idCommand = idFileOpen;
    
             TbButton[2].iBitmap = STD_FILESAVE;
             TbButton[2].fsState = TBSTATE_ENABLED;
             TbButton[2].fsStyle = TBSTYLE_BUTTON;
             TbButton[2].idCommand = idSaveAs;
             
             SendMessage(ToolBar1,TB_ADDBUTTONS,sizeof(TbButton)/sizeof(TBBUTTON),(LPARAM)&TbButton);
             
             Size = SendMessage(ToolBar1,TB_GETBUTTONSIZE,0,0);
             
             GetWindowRect(ToolBar1,&Rc);
             
             RebarBandInfo.lpText     = "ToolBar 1";
             RebarBandInfo.hwndChild  = ToolBar1;
             RebarBandInfo.cxMinChild = Rc.right - Rc.left;
             RebarBandInfo.cyMinChild = HIWORD(Size);
             RebarBandInfo.cx         = 250;
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
             
             //ToolBar2
             
             ToolBar2 = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT|CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NODIVIDER,0,0,0,0,hwnd,NULL,GetModuleHandle(NULL),NULL);
             
             SendMessage(ToolBar2,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
             
             TbAddBitmap.hInst = HINST_COMMCTRL;
             TbAddBitmap.nID = IDB_STD_SMALL_COLOR;
             SendMessage(ToolBar2,TB_ADDBITMAP,0,(LPARAM)&TbAddBitmap);
             
             ZeroMemory(TbButton, sizeof(TbButton));
             
             TbButton[0].iBitmap = STD_COPY;
             TbButton[0].fsState = TBSTATE_ENABLED;
             TbButton[0].fsStyle = TBSTYLE_BUTTON;
             TbButton[0].idCommand = idCopy;
    
             TbButton[1].iBitmap = STD_CUT;
             TbButton[1].fsState = TBSTATE_ENABLED;
             TbButton[1].fsStyle = TBSTYLE_BUTTON;
             TbButton[1].idCommand = idCut;
    
             TbButton[2].iBitmap = STD_DELETE;
             TbButton[2].fsState = TBSTATE_ENABLED;
             TbButton[2].fsStyle = TBSTYLE_BUTTON;
             TbButton[2].idCommand = idDelete;
             
             SendMessage(ToolBar2,TB_ADDBUTTONS,sizeof(TbButton)/sizeof(TBBUTTON),(LPARAM)&TbButton);
             
             Size = SendMessage(ToolBar2,TB_GETBUTTONSIZE,0,0);
             
             GetWindowRect(ToolBar2,&Rc);
             
             RebarBandInfo.lpText     = "ToolBar 2";
             RebarBandInfo.hwndChild  = ToolBar2;
             RebarBandInfo.cxMinChild = Rc.right - Rc.left;
             RebarBandInfo.cyMinChild = HIWORD(Size);
             RebarBandInfo.cx         = 250;
             
             SendMessage(Rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&RebarBandInfo);
          }break;
          
          case WM_DESTROY:
            PostQuitMessage (0);
            break;
          
          default:
            return DefWindowProc (hwnd, message, wParam, lParam);
       }
    
       return 0;
    }
    Code:
    /*resource.h*/
    
    #define _WIN32_IE 0x0501
    #include <commctrl.h>
    
    #define idFileNew    1000
    #define idFileOpen   1001
    #define idSaveAs     1002
    
    #define idCopy       1003
    #define idCut        1004
    #define idDelete     1005
    
    #define idBack       1006
    Code:
    /*resource.rc*/
    
    #include "resource.h"
    
    idBack BITMAP "back.bmp"
    Bye...
    Last edited by underline_bruce; 05-25-2007 at 10:50 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overlapping toolbars
    By minesweeper in forum Windows Programming
    Replies: 3
    Last Post: 06-15-2003, 12:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21