求SDK ToolBar的示例代码,带注释,要求从窗体创建到显示一个简单的ToolBar,用sdk,不用MFC(50全给),要待资源脚本,用上tooltip,添加图片等,50分全给最好的示例

解决方案 »

  1.   

    the MSDN is work ,but not very in detail,I need the instance,Please help me!
      

  2.   

    I need you help,just a example,I think it's not very hard,I have not enough time to get every details of the toolbar control in only one day!help me please,hurry up please!
      

  3.   

    try wtl
    it's convenient
      

  4.   

    wtl ?
    another control?
    I have no time,I need tutorial,example!not just a word "wtl",its do no business!
      

  5.   

    //Demonstrate a toolbar
    //Add tooltips to the toolbar
    #pragma comment(lib,"comctl32.lib")
    #include<windows.h>
    #include<commctrl.h>
    #include"graph.h"#define NUMBUTTONS 6void InitToolbar();  //initialize the toolbar LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
    char szWinName[]="MyWin";TBBUTTON tbButton[NUMBUTTONS];
    HWND tbwnd;   //toolbar handle
    int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPreInst,LPSTR lpszArgs,int nWinMode)
    {
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wcl;
    HACCEL hAccel;
    INITCOMMONCONTROLSEX cc;//Define a window class
    wcl.cbSize =sizeof(WNDCLASSEX);
    wcl.hInstance =hThisInst;
    wcl.lpszClassName =szWinName;
    wcl.lpfnWndProc =WindowFunc;
    wcl.style =0;
    wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wcl.hIconSm =LoadIcon(NULL,IDI_WINLOGO);
    wcl.hCursor =LoadCursor(NULL,IDC_ARROW);    wcl.lpszMenuName ="MyMenu";
    wcl.cbClsExtra =0;
    wcl.cbWndExtra =0; wcl.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);//Register the window class
    if(!RegisterClassEx(&wcl)) return 0; hwnd=CreateWindow(
    szWinName,
    "Changing Mapping Modes",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    HWND_DESKTOP,
    NULL,
    hThisInst,
    NULL,
      );  hAccel=LoadAccelerators(hThisInst,"MyMenu");  //Initialize the common controls
      cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
      cc.dwICC=ICC_BAR_CLASSES;
      InitCommonControlsEx(&cc);  InitToolbar();   //initialize the toobar structures  tbwnd=CreateToolbarEx(hwnd,
                        WS_VISIBLE|WS_CHILD|WS_BORDER|TBSTYLE_TOOLTIPS,
    IDM_TOOLBAR,
    NUMBUTTONS,
    hThisInst,
    IDTB_BMP,
                            tbButton,
    NUMBUTTONS,
    16,16,16,16,
    sizeof(TBBUTTON));
      ShowWindow(hwnd,nWinMode);
      UpdateWindow(hwnd);  //Create the message loop
      while(GetMessage(&msg,NULL,0,0))
      {
      if(!TranslateAccelerator(hwnd,hAccel,&msg)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
      }
      }
      return msg.wParam;
    }
    LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
    {
    switch(message){
    case WM_CREATE:

    break; case WM_COMMAND:

    break;
    case WM_PAINT:

    break;

    case WM_DESTROY:
       PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hwnd,message,wParam,lParam);
    }
    return 0;
    }
    //Initialize the toolbar structures
    void InitToolbar()
    {

    tbButton[0].idCommand=IDM_LINES;
        tbButton[0].fsState=TBSTATE_ENABLED;
    tbButton[0].fsStyle=TBSTYLE_BUTTON;
    tbButton[0].dwData=0l;
    tbButton[0].iBitmap=0;
    tbButton[0].iString=0; tbButton[1].idCommand=IDM_RECTANGLES;
        tbButton[1].fsState=TBSTATE_ENABLED;
    tbButton[1].fsStyle=TBSTYLE_BUTTON;
    tbButton[1].dwData=0l;
    tbButton[1].iBitmap=1;
    tbButton[1].iString=0; tbButton[2].idCommand=IDM_ELLIPSES;
        tbButton[2].fsState=TBSTATE_ENABLED;
    tbButton[2].fsStyle=TBSTYLE_BUTTON;
    tbButton[2].dwData=0l;
    tbButton[2].iBitmap=2;
    tbButton[2].iString=0; tbButton[3].idCommand=IDM_RESET;
        tbButton[3].fsState=TBSTATE_ENABLED;
    tbButton[3].fsStyle=TBSTYLE_BUTTON;
    tbButton[3].dwData=0l;
    tbButton[3].iBitmap=3;
    tbButton[3].iString=0; //button separator
    tbButton[4].idCommand=0;
        tbButton[4].fsState=TBSTATE_ENABLED;
    tbButton[4].fsStyle=TBSTYLE_SEP;
    tbButton[4].dwData=0l;
    tbButton[4].iBitmap=0;
    tbButton[4].iString=0; tbButton[5].idCommand=IDM_HELP;
        tbButton[5].fsState=TBSTATE_ENABLED;
    tbButton[5].fsStyle=TBSTYLE_BUTTON;
    tbButton[5].dwData=0l;
    tbButton[5].iBitmap=5;
    tbButton[5].iString=0;}
      

  6.   

    因为本来是有画图功能了,太长了,贴不上去,只好把WindowFunc部分删除了下面是资源文件#include <windows.h>
    #include"graph.h"IDTB_BMP BITMAP "toolbar.bmp"MyMenu MENU
    {
    POPUP "&Draw"{
    MENUITEM "&Lines\tF2",IDM_LINES
    MENUITEM "&Rectangles\tF3",IDM_RECTANGLES
    MENUITEM "&Ellipses\tF4",IDM_ELLIPSES

    MENUITEM "E&xit\tCtrl+X",IDM_EXIT
    }
    POPUP "&Options"
    {
    MENUITEM "&Reset\tF5",IDM_RESET
    MENUITEM "&Show Toolbar\tF6",IDM_SHOW
    MENUITEM "&Hide Toolbar\tF7",IDM_HIDE
    } MENUITEM "&Help",IDM_HELP
    }MyMenu ACCELERATORS
    {
    VK_F2,IDM_LINES,VIRTKEY
    VK_F3,IDM_RECTANGLES,VIRTKEY
    VK_F4,IDM_ELLIPSES,VIRTKEY
    VK_F5,IDM_RESET,VIRTKEY
    VK_F6,IDM_SHOW,VIRTKEY
    VK_F7,IDM_HIDE,VIRTKEY
    "^X",IDM_EXIT
    VK_F1,IDM_HELP,VIRTKEY
    }
      

  7.   

    下面是资源头文件  graph.h#define IDM_LINES       100
    #define IDM_RECTANGLES  101
    #define IDM_ELLIPSES    102
    #define IDM_SHOW        103
    #define IDM_HIDE        104
    #define IDM_RESET       105
    #define IDM_EXIT        106
    #define IDM_HELP        107#define IDM_TOOLBAR     200#define IDTB_BMP        300
      

  8.   

    ok ,it work right,thank you! rabi_(`!懒虫!`)