Newsgroup: it.comp.programmare.win32
Titolo: inserire toolbar

Scusate la banalità della domanda, ma qual' è il sistema più semplice per
inserire una barra degli strumenti in un programma? Ho provato con
CreateWindow, ma non succede niente.
Ciao e grazie a chi avrà la pazienza di aiutarmi.

CreateWindow, ma non succede niente.
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#pragma hdrstop
#include <condefs.h>
USERC("resource.rc");
//---------------------------------------------------------------------------
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
//---------------------------------------------------------------------------
#pragma argsused
 HINSTANCE Hinst ;
 TBBUTTON tbb[] = { 0, 1, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0
,
                  1, 2, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0, 0  }
;
 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
 static char szAppName[] = "SysMets3" ;
 MSG         msg ;
 WNDCLASSEX  wndclass ;
 HWND hwnd ;
 Hinst = hInstance ;
 wndclass.cbSize        = sizeof (wndclass) ;
 wndclass.style         = CS_HREDRAW | CS_VREDRAW|CS_SAVEBITS ;
 wndclass.lpfnWndProc   = WndProc ;
 wndclass.cbClsExtra    = 0 ;
 wndclass.cbWndExtra    = 0 ;
 wndclass.hInstance     = hInstance ;
 wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
 wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
 wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH) ;
 wndclass.lpszMenuName  = NULL ;
 wndclass.lpszClassName = szAppName ;
 wndclass.hIconSm       = LoadIcon (NULL, IDI_APPLICATION) ;
 RegisterClassEx (&wndclass) ;
 hwnd = CreateWindow (szAppName, "Get System Metrics No. 3",
                          WS_OVERLAPPEDWINDOW ,//| WS_VSCROLL |
WS_HSCROLL,
                          0,0,400,300,
                          NULL, NULL, hInstance, NULL) ;
 ShowWindow (hwnd, SW_SHOWNORMAL) ;
 UpdateWindow (hwnd) ;
 InitCommonControls () ;
 while (GetMessage (&msg, NULL, 0, 0))
       {
       TranslateMessage (&msg) ;
       DispatchMessage (&msg) ;
       }
  return msg.wParam ;
 }
  HWND hWndToolbar ;
 LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM
lParam)
{
 static HBITMAP hbitmap ;
 char str[76] ;
 switch (iMsg)
        {
        case WM_CREATE :
        hbitmap = LoadBitmap(Hinst,"MYBITMAP");//IDB_TOOLBAR, //
resource ID for bitmap
        hWndToolbar = CreateToolbarEx (
                      hwnd,
                      WS_CHILD | WS_BORDER | WS_VISIBLE | CCS_TOP |
TBSTYLE_TOOLTIPS, // style
                      100,//IDB_TOOLBAR, // toolbar ID
                      2, // number of bitmaps
                      /*HINST_COMMCTRL,//*/NULL, // mod instance
/*IDB_STD_SMALL_COLOR,//*/(UINT)hbitmap,//IDB_TOOLBAR, // resource ID
for bitmap
                      (LPCTBBUTTON)&tbb, // address of buttons
                      2, // number of buttons
                      0,0, // width & height of buttons
                      21,21, // width & height of bitmaps
                      sizeof (TBBUTTON)); // structure
        break ;
        case WM_SIZE :
        SendMessage(hWndToolbar,TB_AUTOSIZE,0,0) ;
        break ;
        case WM_COMMAND :
        if ( (HWND) lParam == hWndToolbar ) {
           if ( LOWORD(wParam) == 1  ||  LOWORD(wParam) == 2 ) {
              /* disabilita il pulsante */
SendMessage(hWndToolbar,TB_ENABLEBUTTON,1,MAKELONG(false,0)) ;
              sprintf(str,"Toolbar button = %d",LOWORD(wParam)) ;
              MessageBox(hwnd,str,"Toolbar",MB_OK) ;
              }
            }
        return 0 ;
        case WM_DESTROY :
        DeleteObject(hbitmap) ;
        PostQuitMessage (0) ;
        return 0 ;
       }
 return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}