LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE : _splitter.init(_hInst, _hSelf, _splitterSize, _ratio, _dwSplitterStyle); return TRUE; case WM_COMMAND : { switch (LOWORD(wParam)) { case ROTATION_A_GAUCHE: rotateTo(LEFT); return TRUE; case ROTATION_A_DROITE: rotateTo(RIGHT); return TRUE; } return TRUE; } case WM_RESIZE_CONTAINER : { RECT rc0, rc1; getClientRect(rc0); rc1.top = rc0.top += _y; rc1.bottom = rc0.bottom; rc1.left = rc0.left += _x; rc1.right = rc0.right; if (_dwSplitterStyle & SV_VERTICAL) { if (wParam != 0) { rc0.right = int(wParam); rc1.left = int(wParam) + _x + _splitter.getPhisicalSize(); rc1.right = rc1.right - rc1.left + _x; } } else //SV_HORIZONTAL { if (lParam != 0) { rc0.bottom = int(lParam); rc1.top = int(lParam) + _y + _splitter.getPhisicalSize(); rc1.bottom = rc1.bottom - rc1.top + _y; } } _pWin0->reSizeTo(rc0); _pWin1->reSizeTo(rc1); ::InvalidateRect(_splitter.getHSelf(), NULL, TRUE); return TRUE; } case WM_DOPOPUPMENU : { if ((_splitterMode != LEFT_FIX) && (_splitterMode != RIGHT_FIX) ) { POINT p; ::GetCursorPos(&p); if (!_hPopupMenu) { POINT p; ::GetCursorPos(&p); _hPopupMenu = ::CreatePopupMenu(); ::InsertMenu(_hPopupMenu, 1, MF_BYPOSITION, ROTATION_A_GAUCHE, TEXT("Rotate to left")); ::InsertMenu(_hPopupMenu, 0, MF_BYPOSITION, ROTATION_A_DROITE, TEXT("Rotate to right")); } ::TrackPopupMenu(_hPopupMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); } return TRUE; } case WM_GETSPLITTER_X : { if (_splitterMode == LEFT_FIX) return MAKELONG(_pWin0->getWidth(), LEFT_FIX); else if (_splitterMode == RIGHT_FIX) { int x = getWidth()-_pWin1->getWidth(); if (x < 0) x = 0; return MAKELONG(x, RIGHT_FIX); } else return MAKELONG(0, DYNAMIC); } case WM_GETSPLITTER_Y : { if (_splitterMode == LEFT_FIX) return MAKELONG(_pWin0->getHeight(), LEFT_FIX); else if (_splitterMode == RIGHT_FIX) { int y = getHeight()-_pWin1->getHeight(); if (y < 0) y = 0; return MAKELONG(y, RIGHT_FIX); } else return MAKELONG(0, DYNAMIC); } case WM_LBUTTONDBLCLK: { POINT pt; ::GetCursorPos(&pt); ::ScreenToClient(_splitter.getHSelf(), &pt); Window* targetWindow; if(this->isVertical()) targetWindow = pt.x < 0?_pWin0:_pWin1; else targetWindow = pt.y < 0?_pWin0:_pWin1; HWND parent = ::GetParent(getHSelf()); ::SendMessage(parent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)targetWindow->getHSelf()); ::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0); return TRUE; } default : return ::DefWindowProc(_hSelf, message, wParam, lParam); } }
void ToolBar::reset(bool create) { if(create && _hSelf) { //Store current button state information TBBUTTON tempBtn; for(size_t i = 0; i < _nrCurrentButtons; i++) { ::SendMessage(_hSelf, TB_GETBUTTON, (WPARAM)i, (LPARAM)&tempBtn); _pTBB[i].fsState = tempBtn.fsState; } ::DestroyWindow(_hSelf); _hSelf = NULL; } if(!_hSelf) { _hSelf = ::CreateWindowEx( WS_EX_PALETTEWINDOW, TOOLBARCLASSNAME, TEXT(""), WS_TOOLBARSTYLE, 0, 0, 0, 0, _hParent, NULL, _hInst, 0); // Send the TB_BUTTONSTRUCTSIZE message, which is required for // backward compatibility. ::SendMessage(_hSelf, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); ::SendMessage(_hSelf, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_HIDECLIPPEDBUTTONS); } if (!_hSelf) { throw std::runtime_error("ToolBar::reset : CreateWindowEx() function return null"); } if (_state != TB_STANDARD) { //If non standard icons, use custom imagelists setDefaultImageList(); setHotImageList(); setDisableImageList(); } else { //Else set the internal imagelist with standard bitmaps TBADDBITMAP addbmp = {_hInst, 0}; TBADDBITMAP addbmpdyn = {0, 0}; for (size_t i = 0 ; i < _nrButtons ; i++) { addbmp.nID = _toolBarIcons.getStdIconAt(i); ::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmp); } if (_nrDynButtons > 0) { for (size_t j = 0; j < _nrDynButtons; j++) { addbmpdyn.nID = (UINT_PTR)_vDynBtnReg.at(j).hBmp; ::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmpdyn); } } } if (create) { //if the toolbar has been recreated, readd the buttons size_t nrBtnToAdd = (_state == TB_STANDARD?_nrTotalButtons:_nrButtons); _nrCurrentButtons = nrBtnToAdd; WORD btnSize = (_state == TB_LARGE?32:16); ::SendMessage(_hSelf, TB_SETBUTTONSIZE , (WPARAM)0, (LPARAM)MAKELONG (btnSize, btnSize)); ::SendMessage(_hSelf, TB_ADDBUTTONS, (WPARAM)nrBtnToAdd, (LPARAM)_pTBB); } ::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0); if (_pRebar) { _rbBand.hwndChild = getHSelf(); _rbBand.cxMinChild = 0; _rbBand.cyIntegral = 1; _rbBand.cyMinChild = _rbBand.cyMaxChild = getHeight(); _rbBand.cxIdeal = getWidth(); _pRebar->reNew(REBAR_BAR_TOOLBAR, &_rbBand); } }