void DockingCont::updateCaption(void) { TCITEM tcItem = {0}; INT iItem = getActiveTb(); if (iItem < 0) return; /* get data of new active dialog */ tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); /* update caption text */ strcpy(_pszCaption, ((tTbData*)tcItem.lParam)->pszName); /* test if additional information are available */ if ((((tTbData*)tcItem.lParam)->uMask & DWS_ADDINFO) && (strlen(((tTbData*)tcItem.lParam)->pszAddInfo) != 0)) { strcat(_pszCaption, " - "); strcat(_pszCaption, ((tTbData*)tcItem.lParam)->pszAddInfo); } if (_isFloating == true) { ::SetWindowText(_hSelf, _pszCaption); } else { ::SetWindowText(_hCaption, _pszCaption); } }
void DockingCont::focusClient(void) { TCITEM tcItem = {0}; INT iItem = getActiveTb(); if (iItem != -1) { /* get data of new active dialog */ tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); /* set focus */ ::SetFocus(((tTbData*)tcItem.lParam)->hClient); } }
tTbData* DockingCont::getDataOfActiveTb() { tTbData* pTbData = NULL; int iItem = getActiveTb(); if (iItem != -1) { TCITEM tcItem = {0}; tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); pTbData = (tTbData*)tcItem.lParam; } return pTbData; }
void DockingCont::viewToolbar(tTbData *pTbData) { TCITEM tcItem = {0}; int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); if (iItemCnt > 0) { UINT iItem = getActiveTb(); tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); if (!tcItem.lParam) return; // hide active dialog ::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_HIDE); } // create new tab if it not exists int iTabPos = SearchPosInTab(pTbData); tcItem.mask = TCIF_PARAM; tcItem.lParam = (LPARAM)pTbData; if (iTabPos == -1) { // set only params and text even if icon available ::SendMessage(_hContTab, TCM_INSERTITEM, iItemCnt, (LPARAM)&tcItem); SelectTab(iItemCnt); } // if exists select it and update data else { ::SendMessage(_hContTab, TCM_SETITEM, iTabPos, (LPARAM)&tcItem); SelectTab(iTabPos); } // show dialog and notify parent to update dialog view if (isVisible() == false) { this->doDialog(); ::SendMessage(_hParent, WM_SIZE, 0, 0); } // set position of client onSize(); }
void DockingCont::focusClient() { TCITEM tcItem = {0}; int iItem = getActiveTb(); if (iItem != -1) { // get data of new active dialog tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); // set focus if (!tcItem.lParam) return; ::SetFocus(((tTbData*)tcItem.lParam)->hClient); } }
void DockingCont::focusClient() { TCITEM tcItem = {0}; int iItem = getActiveTb(); if (iItem != -1) { // get data of new active dialog tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); // set focus if (!tcItem.lParam) return; tTbData *tbData = (tTbData *)tcItem.lParam; if (tbData->pszAddInfo && lstrcmp(tbData->pszAddInfo, DM_NOFOCUSWHILECLICKINGCAPTION) == 0) return; ::SetFocus(tbData->hClient); } }
bool DockingCont::updateCaption() { if (!_hContTab) return false; TCITEM tcItem = {0}; int iItem = getActiveTb(); if (iItem < 0) return false; // get data of new active dialog tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); if (!tcItem.lParam) return false; // update caption text _pszCaption = ((tTbData*)tcItem.lParam)->pszName; // test if additional information are available if ((((tTbData*)tcItem.lParam)->uMask & DWS_ADDINFO) && (lstrlen(((tTbData*)tcItem.lParam)->pszAddInfo) != 0)) { _pszCaption += TEXT(" - "); _pszCaption += ((tTbData*)tcItem.lParam)->pszAddInfo; } if (_isFloating == true) { ::SetWindowText(_hSelf, _pszCaption.c_str()); } else { ::SetWindowText(_hCaption, _pszCaption.c_str()); } return true; }
void DockingCont::drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct) { TCITEM tcItem = {0}; RECT rc = pDrawItemStruct->rcItem; int nTab = pDrawItemStruct->itemID; bool isSelected = (nTab == getActiveTb()); // get current selected item tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, nTab, (LPARAM)&tcItem); if (!tcItem.lParam) return; const TCHAR *text = ((tTbData*)tcItem.lParam)->pszName; int length = lstrlen(((tTbData*)tcItem.lParam)->pszName); // get drawing context HDC hDc = pDrawItemStruct->hDC; int nSavedDC = ::SaveDC(hDc); // For some bizarre reason the rcItem you get extends above the actual // drawing area. We have to workaround this "feature". rc.top += ::GetSystemMetrics(SM_CYEDGE); ::SetBkMode(hDc, TRANSPARENT); HBRUSH hBrush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE)); ::FillRect(hDc, &rc, hBrush); ::DeleteObject((HGDIOBJ)hBrush); // draw orange bar if ((_bDrawOgLine == TRUE) && (isSelected)) { RECT barRect = rc; barRect.top += rc.bottom - 4; hBrush = ::CreateSolidBrush(RGB(250, 170, 60)); ::FillRect(hDc, &barRect, hBrush); ::DeleteObject((HGDIOBJ)hBrush); } // draw icon if enabled if (((tTbData*)tcItem.lParam)->uMask & DWS_ICONTAB) { HIMAGELIST hImageList = (HIMAGELIST)::SendMessage(_hParent, DMM_GETIMAGELIST, 0, 0); int iPosImage = ::SendMessage(_hParent, DMM_GETICONPOS, 0, (LPARAM)((tTbData*)tcItem.lParam)->hClient); if ((hImageList != NULL) && (iPosImage >= 0)) { // Get height of image so we IMAGEINFO info = {0}; RECT & imageRect = info.rcImage; ImageList_GetImageInfo(hImageList, iPosImage, &info); ImageList_Draw(hImageList, iPosImage, hDc, rc.left + 3, 2, ILD_NORMAL); if (isSelected == true) { rc.left += imageRect.right - imageRect.left + 5; } } } if (isSelected == true) { COLORREF _unselectedColor = RGB(0, 0, 0); ::SetTextColor(hDc, _unselectedColor); // draw text rc.top -= ::GetSystemMetrics(SM_CYEDGE); ::SelectObject(hDc, _hFont); ::DrawText(hDc, text, length, &rc, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX); } ::RestoreDC(hDc, nSavedDC); }