Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating rebar control and introduction a band with toolbar into the rebar
    primarykey
    data
    text
    <p>I use this code to create a rebar control, and introduction a band with toolbar into the rebar.<br> But when window is shown up, I can not see the toolbar. and when I check the height of the rebar, in this line of code: <code>int height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;</code> I find rebar's height is only 4 pixels. </p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdlib.h&gt; #include &lt;CommCtrl.h&gt; #pragma comment(lib, "comctl32.lib") LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); HINSTANCE instance; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { instance = hInstance; WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = L"Example"; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); RegisterClassEx(&amp;wcex); HWND hWnd = CreateWindow(L"Example", L"", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, hInstance, NULL); // Initialize common controls. INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; InitCommonControlsEx(&amp;icex); HWND hwndRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 0, 0, 100, 50, hWnd, NULL, instance, NULL); // create toolbar HWND hWndToolbar = CreateWindowEx(0 , TOOLBARCLASSNAME, NULL, WS_CHILD | TBSTYLE_TOOLTIPS, 0, 0, 0, 0, hwndRebar, (HMENU)0, instance, NULL); HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, 3, 0); SendMessage(hWndToolbar, TB_SETIMAGELIST, (WPARAM)0, (LPARAM)hImageList); SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); TBBUTTON tbb[4] = { {0,0,TBSTATE_ENABLED,TBSTYLE_BUTTON}, {1,1,TBSTATE_ENABLED,TBSTYLE_BUTTON}, {2,2,TBSTATE_ENABLED,TBSTYLE_BUTTON}, }; SendMessage(hWndToolbar, (UINT) TB_ADDBUTTONS, 3, (LPARAM)&amp;tbb); SendMessage(hWndToolbar, TB_AUTOSIZE, 0, 0); ShowWindow(hWndToolbar , SW_SHOW); // Initialize band info. REBARBANDINFO rbBand = { sizeof(REBARBANDINFO) }; rbBand.fMask = RBBIM_STYLE | RBBIM_TEXT | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_COLORS; rbBand.fStyle = RBBS_GRIPPERALWAYS; // Get the height of the toolbar. DWORD dwBtnSize = (DWORD)SendMessage(hWndToolbar, TB_GETBUTTONSIZE, 0,0); // Set values unique to the band with the toolbar. rbBand.clrFore = RGB(233, 233, 233); rbBand.clrBack = RGB(200, 200, 200); rbBand.lpText = TEXT(""); rbBand.hwndChild = hWndToolbar; rbBand.cyChild = LOWORD(dwBtnSize); rbBand.cyMinChild = LOWORD(dwBtnSize); rbBand.cxMinChild = 3 * HIWORD(dwBtnSize); // The default width is the width of the buttons. rbBand.cx = 0; // Add the band SendMessage(hwndRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&amp;rbBand); // show the main window ShowWindow(hWnd, nCmdShow); // check the rebar size WINDOWPLACEMENT wp; GetWindowPlacement(hwndRebar, &amp;wp); int height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; MSG msg; while (GetMessage(&amp;msg, NULL, 0, 0)) { TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload