2011-07-30 1 views
0

さて、できるだけ少数のライブラリを追加して、win32を使っています。私のアプリケーションはsplitterbarsを使って複数の子ウィンドウに分かれており、メインウィンドウにツールバーとステータスバーを追加しました。今、子ウィンドウの1つにツールバーを追加しようとしていますが、WM_SIZEが発生するとすぐにボタンが消えます。これは、すべてメインウィンドウのWndProcで行われます。ここでは、子ウィンドウのツールバーを作成するコードは次のとおりです。子ウィンドウのツールバーは変わっています

case WM_SIZE : 
    { 
    GetClientRect(hwnd, &rect); 

    // Resize toolbar 
    SendMessage(toolMain, TB_AUTOSIZE, 0, 0); 
    SendMessage(toolRender, TB_AUTOSIZE, 0, 0); 
    SendMessage(statusMain, WM_SIZE, 0, 0); 

    GetWindowRect(toolMain, &toolrect); 
    GetWindowRect(statusMain, &statusrect); 

    toolHeight = toolrect.bottom - toolrect.top; 
    statusHeight = statusrect.bottom - statusrect.top; 
    windowHeight = rect.bottom - rect.top; 

    GetWindowRect(toolRender, &toolrect); 

    toolRendHeight = toolrect.bottom - toolrect.top; 

    //Make sure window isn't too small 
    if (rect.right < MINSIZE * 4) 
    { 
     rect.right = MINSIZE * 4; 
     forceresize = true; 
    } 
    if (windowHeight < toolHeight + statusHeight + toolRendHeight + (MINSIZE * 2)) 
    { 
     rect.bottom = toolHeight + statusHeight + toolRendHeight + (MINSIZE * 2); 
     forceresize = true; 
    } 

    //resize splitters 
    xDiv1 = rect.right * xDiv1p; 
    xDiv2 = rect.right * xDiv2p; 
    xDiv3 = rect.right * xDiv3p; 
    yDiv = rect.bottom * yDivp; 

    // Make sure splitters aren't beyond bounds 
    if (xDiv3 > rect.right - MINSIZE) 
     xDiv3 = rect.right - MINSIZE; 
    else if(xDiv3 < xDiv2 + MINSIZE) 
     xDiv3 = xDiv2 + MINSIZE; 

    if (xDiv2 > xDiv3 - MINSIZE) 
     xDiv2 = xDiv3 - MINSIZE; 
    else if (xDiv3 < xDiv1 + MINSIZE) 
     xDiv2 = xDiv1 + MINSIZE; 

    if (xDiv1 > xDiv2 - MINSIZE) 
     xDiv1 = xDiv2 - MINSIZE; 
    else if (xDiv1 < MINSIZE) 
     xDiv1 = MINSIZE; 

    if (yDiv > rect.bottom - MINSIZE) 
     yDiv = rect.bottom - MINSIZE; 
    else if(yDiv < MINSIZE + toolrect.bottom) 
     yDiv = MINSIZE + toolrect.bottom; 

    // Resize windows 
    MoveWindow(wndObjBrowser, 0, toolHeight, xDiv1 - SBS, windowHeight - toolHeight - statusHeight, FALSE); 

    MoveWindow(wndObjList, xDiv1 + SBS, toolHeight, xDiv2 - xDiv1 - (SBS * 2), windowHeight - toolHeight - statusHeight, FALSE); 

    if (!bDualMonitor) 
    { 
    MoveWindow(wndRender, xDiv2 + SBS, toolHeight, rect.right - xDiv2 - SBS, yDiv - toolHeight - SBS, FALSE); 
    //SendMessage(toolRender, TB_AUTOSIZE, 0, 0); 

    MoveWindow(wndAreaList, xDiv2 + SBS, yDiv + SBS, xDiv3 - xDiv2 - (SBS * 2), windowHeight - statusHeight - yDiv - SBS, FALSE); 

    MoveWindow(wndAreaInfo, xDiv3 + SBS, yDiv + SBS, rect.right - xDiv3 - SBS, windowHeight - statusHeight - yDiv - SBS, FALSE); 
    } 
    else if (bDualMonitor) 
    { 
     MoveWindow(wndAreaList, xDiv2 + SBS, toolHeight, rect.right - xDiv2 - SBS, yDiv - toolHeight, FALSE); 

     MoveWindow(wndAreaInfo, xDiv2 + SBS, yDiv + SBS, rect.right - xDiv2 - SBS, windowHeight - statusHeight - yDiv - SBS, FALSE); 
    } 

    if (forceresize) 
     MoveWindow(hwnd, rect.left, rect.top, rect.right, rect.bottom, FALSE); 

    InvalidateRect(hwnd, &rect, TRUE); 
    } 
    break; //WM_SIZE 

任意のアイデア:

toolRender = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS, 
        0, 0, 0, 0, wndRender, NULL, gHinst, 0); 

    SendMessage(toolRender, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); 
    SendMessage(toolRender, CCM_SETVERSION, (WPARAM)5, 0); 

    himl = ImageList_LoadImage(NULL, L"buttons.bmp", 16, 2, RGB(0, 255, 255), IMAGE_BITMAP, LR_LOADFROMFILE | LR_CREATEDIBSECTION); 
    SendMessage(toolRender, TB_SETIMAGELIST, 0, (LPARAM)himl); 

    TBBUTTON tbb2[2]; 

    memset(tbb2, 0, sizeof(tbb2)); 
    tbb2[0].iBitmap = 0; 
    tbb2[0].fsState = TBSTATE_ENABLED; 
    tbb2[0].fsStyle = TBSTYLE_BUTTON; 
    tbb2[0].idCommand = TOOL_SAVEALL; 
    tbb2[0].iString = (INT_PTR)L"Save All"; 

    tbb2[1].iBitmap = 1; 
    tbb2[1].fsState = TBSTATE_ENABLED; 
    tbb2[1].fsStyle = TBSTYLE_BUTTON; 
    tbb2[1].idCommand = TOOL_HELP; 
    tbb2[1].iString = (INT_PTR)L"Help"; 

    SendMessage(toolRender, TB_SETMAXTEXTROWS, 0, 0); 
    SendMessage(toolRender, TB_ADDBUTTONS, sizeof(tbb2)/sizeof(TBBUTTON), (LPARAM)&tbb2); 

そしてここでは、私の全体のWM_SIZEメッセージですか?

答えて

0

多くのMoveWindow呼び出しで、なぜbRepaintパラメータにFALSEを渡していますか?最後のInvalidateRectは子ウィンドウではなく、現在のウィンドウのみを無効にします。

関連する問題