Click here to Skip to main content
16,013,747 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi thank for read this quetion.i have used createwindowex api to create a toolbar.and the TBSTYLE_TOOLTIPS style was specified to toolbar.then i send TB_ADDBUTTONS message to create a button in toolbar.These all are no problem.But the tooltip function is invalid.The source code is as follows.

C++
//create toolbar
HWND CreateBar(HWND pare_wnd)
{
    INITCOMMONCONTROLSEX P;
    P.dwSize = sizeof(P);
    P.dwICC = ICC_BAR_CLASSES;
    if (InitCommonControlsEx(&P))
    {
        //MessageBoxA(NULL,"加载控件库成功!",NULL,MB_OK);
    }
    else
        MessageBoxA(NULL,"加载控件库失败!",NULL,MB_OK);
    HWND toolbar;
    RECT rt;
    GetClientRect(pare_wnd,&rt);
    toolbar  = CreateWindowEx(WS_EX_CLIENTEDGE,
                              TOOLBARCLASSNAME,
                              NULL,
                              WS_CHILD |WS_VISIBLE|TBSTYLE_TOOLTIPS|TBSTYLE_TRANSPARENT ,  //specify tooltips style
                              rt.left,
                              rt.top,
                              0,
                              0,
                              pare_wnd,
                              (HMENU)NULL,
                              hInst,
                              NULL);
    if (toolbar == NULL)
    {
        MessageBoxA(NULL,"","",MB_OK);
    }
    
    return toolbar;
}


//add button  to toolbar

            TBBUTTON arr[1];
             arr[0].iBitmap = I_IMAGENONE;
             arr[0].idCommand = IDM_ABOUT;
             arr[0].fsState = TBSTATE_ENABLED  ;
             arr[0].fsStyle = BTNS_CHECK  ;
             arr[0].dwData = 0;
             arr[0].iString = IS_INTRESOURCE(IDS_STRING129);

             SendMessage(toolbar,TB_BUTTONSTRUCTSIZE ,(WPARAM)(int)size,0);
             
             SendMessage(toolbar,TB_ADDBUTTONS,1,(LPARAM) (LPTBBUTTON)arr);
Posted
Updated 20-Oct-13 22:29pm
v3
Comments
Sergey Alexandrovich Kryukov 21-Oct-13 0:11am    
Which "SDK"?! Okay, nearly everyone can guess that it's Windows API, but why should anyone take any guesses? Some won't event look at your page, so you are the one who is interested in proper tags the most. You really need to tag platform(s), language(s), and them perhaps some other detail, like a library/framework you are using. Do you have a compilation error? Exception? In what line?

—SA

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900