Win32工具栏和TBSTYLE_WRAPABLE

时间:2014-01-14 20:11:49

标签: c++ winapi dialog

我有一个工具栏,它不会将WM_SIZE消息包装到其父级。这是工具栏的创建代码:

            // create toolbar
            g_hTool = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, 
                WS_CHILD | WS_VISIBLE | TBSTYLE_WRAPABLE, 0, 0, 0, 0,
                hWnd, ( HMENU )IDC_TEX_TOOL, GetModuleHandle( NULL ), NULL );

            // Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility.
            SendMessage( g_hTool, TB_BUTTONSTRUCTSIZE, ( WPARAM )sizeof( TBBUTTON ), 0 );
            SendMessage( g_hTool, TB_SETBUTTONSIZE, 0, MAKELPARAM( 32, 32 ) );
            SendMessage( g_hTool, TB_SETBITMAPSIZE, 0, MAKELPARAM( 32, 32 ) );
            SendMessage( g_hTool, TB_SETEXTENDEDSTYLE, 0, ( LPARAM )TBSTYLE_EX_DRAWDDARROWS );

这是WM_SIZE(由父窗口处理):

switch( uMsg ):
{
...
case WM_SIZE:
        {
            // get auxiliary viewport toolbar window handle and autosize
            SendMessage( g_hTool, TB_AUTOSIZE, 0, 0 );

            RECT cr;
            GetWindowRect( g_hTool, &cr );
            nTexToolHeight = cr.bottom - cr.top;

            // get status bar window handle and autosize
            SendMessage( g_hStatus, WM_SIZE, 0, 0 );

            // get status bar height
            GetWindowRect( g_hStatus, &cr );
            nTexStatusHeight = cr.bottom - cr.top;
break;
}
...
}

知道为什么工具栏不会换行吗?按钮超出父窗口的范围。超出窗口的按钮被剪裁,但工具栏没有调整大小,按钮仍然看不见......

0 个答案:

没有答案