void xxxCalcClientRect( PWND pwnd, LPRECT lprc, BOOL fHungRedraw) { int cxFrame, yTopOld; RECT rcTemp; PMENU pMenu; TL tlpmenu; int cBorders; BOOL fEmptyClient; CheckLock(pwnd); /* * Clear all the frame bits. NOTE: The HIBYTE of all these #defines * must stay the same for this line to work. */ ClrWF(pwnd, (WFHPRESENT | WFVPRESENT | WFCPRESENT | WFMPRESENT)); // // We need to clear the client border bits also. Otherwise, when the // window gets really small, the client border will draw over the menu // and caption. // ClrWF(pwnd, WFCEPRESENT); /* * If the window is iconic, the client area is empty. */ if (TestWF(pwnd, WFMINIMIZED)) { // SetRectEmpty(lprc); // We must make it an empty rectangle. // But, that empty rectangle should be at the top left corner of the // window rect. Else, ScreenToClient() will return bad values. lprc->right = lprc->left; lprc->bottom = lprc->top; return; } // Save rect into rcTemp for easy local calculations. CopyRect(&rcTemp, lprc); // Save the top so we'll know how tall the caption was yTopOld = rcTemp.top; // Adjustment for the caption if (TestWF(pwnd, WFBORDERMASK) == LOBYTE(WFCAPTION)) { SetWF(pwnd, WFCPRESENT); rcTemp.top += TestWF(pwnd, WEFTOOLWINDOW) ? SYSMET(CYSMCAPTION) : SYSMET(CYCAPTION); } // Subtract out window borders cBorders = GetWindowBorders(pwnd->style, pwnd->ExStyle, TRUE, FALSE); cxFrame = cBorders * SYSMET(CXBORDER); InflateRect(&rcTemp, -cxFrame, -cBorders*SYSMET(CYBORDER)); if (!TestwndChild(pwnd) && (pMenu = pwnd->spmenu)) { SetWF(pwnd, WFMPRESENT); if (!fHungRedraw) { ThreadLockAlways(pMenu, &tlpmenu); rcTemp.top += xxxMenuBarCompute(pMenu, pwnd, rcTemp.top - yTopOld, cxFrame, rcTemp.right - rcTemp.left); ThreadUnlock(&tlpmenu); } } // // Fix for B#1425 -- Sizing window really small used to move children's // rects because the client calculations were wrong. So we make the // bottom of the client match up with the top (the bottom of the menu // bar). // fEmptyClient = FALSE; if (rcTemp.top >= rcTemp.bottom) { rcTemp.bottom = rcTemp.top; fEmptyClient = TRUE; } // // BOGUS BOGUS BOGUS // Hack for Central Point PC Tools. // Possibly for M5 only. // B#8445 // // They check for div-by-zero all over, but they jump to the wrong place // if a zero divisor is encountered, and end up faulting anyway. So this // code path was never tested basically. There's a period when starting // up where the window rect of their drives ribbon is empty. In Win3.x, // the client would be shrunk to account for the border it had, and it // would look like it wasn't empty because the width would be negative, // signed! So we version-switch this code, since other apps have // reported the non-emptiness as an annoying bug. // if (TestWF(pwnd, WFWIN40COMPAT) && (rcTemp.left >= rcTemp.right)) { rcTemp.right = rcTemp.left; fEmptyClient = TRUE; } if (fEmptyClient) goto ClientCalcEnd; // // Subtract client edge if we have space // if (TestWF(pwnd, WEFCLIENTEDGE) && (rcTemp.right - rcTemp.left >= (2 * SYSMET(CXEDGE))) && (rcTemp.bottom - rcTemp.top >= (2 * SYSMET(CYEDGE))) ) { SetWF(pwnd, WFCEPRESENT); InflateRect(&rcTemp, -SYSMET(CXEDGE), -SYSMET(CYEDGE)); } // // Subtract scrollbars // Note compatibility with 3.1: // * You don't get a horizontal scrollbar unless you have MORE // space (> ) in your client than you need for one. // * You get a vertical scrollbar if you have AT LEAST ENOUGH // space (>=) in your client for one. // if (TestWF(pwnd, WFHSCROLL) && (rcTemp.bottom - rcTemp.top > SYSMET(CYHSCROLL))) { SetWF(pwnd, WFHPRESENT); if (!fHungRedraw) rcTemp.bottom -= SYSMET(CYHSCROLL); } if (TestWF(pwnd, WFVSCROLL) && (rcTemp.right - rcTemp.left >= SYSMET(CXVSCROLL))) { SetWF(pwnd, WFVPRESENT); if (!fHungRedraw) rcTemp.right -= SYSMET(CXVSCROLL); } ClientCalcEnd: CopyRect(lprc, &rcTemp); }
static void MSWDrawXPBackground(wxButton *button, WXDRAWITEMSTRUCT *wxdis) { LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis; HDC hdc = lpDIS->hDC; UINT state = lpDIS->itemState; RECT rectBtn; CopyRect(&rectBtn, &lpDIS->rcItem); wxUxThemeHandle theme(button, L"BUTTON"); int iState; if ( state & ODS_SELECTED ) { iState = PBS_PRESSED; } else if ( button->HasCapture() || button->IsMouseInWindow() ) { iState = PBS_HOT; } else if ( state & ODS_FOCUS ) { iState = PBS_DEFAULTED; } else if ( state & ODS_DISABLED ) { iState = PBS_DISABLED; } else { iState = PBS_NORMAL; } // draw parent background if needed if ( wxUxThemeEngine::Get()->IsThemeBackgroundPartiallyTransparent(theme, BP_PUSHBUTTON, iState) ) { wxUxThemeEngine::Get()->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn); } // draw background wxUxThemeEngine::Get()->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState, &rectBtn, NULL); // calculate content area margins MARGINS margins; wxUxThemeEngine::Get()->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState, TMT_CONTENTMARGINS, &rectBtn, &margins); RECT rectClient; ::CopyRect(&rectClient, &rectBtn); ::InflateRect(&rectClient, -margins.cxLeftWidth, -margins.cyTopHeight); // if focused and !nofocus rect if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) ) { DrawFocusRect(hdc, &rectClient); } if ( button->UseBgCol() ) { COLORREF colBg = wxColourToRGB(button->GetBackgroundColour()); HBRUSH hbrushBackground = ::CreateSolidBrush(colBg); // don't overwrite the focus rect ::InflateRect(&rectClient, -1, -1); FillRect(hdc, &rectClient, hbrushBackground); ::DeleteObject(hbrushBackground); } }
//----CheckBox绘制函数---------------------------------------------------------- //功能:这是CheckBox控件的MSG_PAINT消息响应函数 //参数:pMsg,消息指针 //返回:固定true //----------------------------------------------------------------------------- static bool_t CheckBox_Paint(struct WindowMsg *pMsg) { HWND hwnd; HDC hdc; RECT rc; RECT rc0; hwnd=pMsg->hwnd; hdc =BeginPaint(hwnd); if(NULL!=hdc) { GetClientRect(hwnd,&rc0); SetTextColor(hdc,RGB(1,1,1)); SetDrawColor(hdc,RGB(40,40,40)); SetFillColor(hdc,RGB(200,200,200)); FillRect(hdc,&rc0); if(hwnd->Style&CBS_SELECTED) { CopyRect(&rc,&rc0); rc.right =rc.left+RectH(&rc0); InflateRect(&rc,-2,-2); SetDrawColor(hdc,RGB(70,70,70)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetDrawColor(hdc,RGB(110,110,110)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetFillColor(hdc,RGB(240,240,240)); FillRect(hdc,&rc); InflateRect(&rc,-4,-4); SetDrawColor(hdc,RGB(150,150,240)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetDrawColor(hdc,RGB(100,100,220)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetFillColor(hdc,RGB(50,50,200)); FillRect(hdc,&rc); } else { CopyRect(&rc,&rc0); rc.right =rc.left+RectH(&rc0); InflateRect(&rc,-2,-2); SetDrawColor(hdc,RGB(100,100,100)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetDrawColor(hdc,RGB(160,160,160)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetFillColor(hdc,RGB(220,220,220)); FillRect(hdc,&rc); } CopyRect(&rc,&rc0); InflateRectEx(&rc,-RectH(&rc),0,0,0); DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER); EndPaint(hwnd,hdc); } return true; }
static void winInitDialog (HWND hwndDlg) { HWND hwndDesk; RECT rc, rcDlg, rcDesk; HICON hIcon, hIconSmall; hwndDesk = GetParent (hwndDlg); if (!hwndDesk || IsIconic (hwndDesk)) hwndDesk = GetDesktopWindow (); /* Remove minimize and maximize buttons */ SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX)); /* Set Window not to show in the task bar */ SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW ); /* Center dialog window in the screen. Not done for multi-monitor systems, where * it is likely to end up split across the screens. In that case, it appears * near the Tray icon. */ if (GetSystemMetrics(SM_CMONITORS)>1) { /* Still need to refresh the frame change. */ SetWindowPos (hwndDlg, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); } else { GetWindowRect (hwndDesk, &rcDesk); GetWindowRect (hwndDlg, &rcDlg); CopyRect (&rc, &rcDesk); OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top); OffsetRect (&rc, -rc.left, -rc.top); OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom); SetWindowPos (hwndDlg, HWND_TOPMOST, rcDesk.left + (rc.right / 2), rcDesk.top + (rc.bottom / 2), 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED); } #ifdef XWIN_MULTIWINDOW if (g_hIconX) hIcon=g_hIconX; else #endif hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)); #ifdef XWIN_MULTIWINDOW if (g_hSmallIconX) hIconSmall=g_hSmallIconX; else #endif hIconSmall = LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); PostMessage (hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); PostMessage (hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall); }
void CMemoryCardView::CRender::DrawScene() { RECT ClientRect; glClear(GL_COLOR_BUFFER_BIT); if(m_memoryCard == NULL) return; unsigned int nItemCount = static_cast<unsigned int>(m_memoryCard->GetSaveCount()); CopyRect(&ClientRect, &m_viewState->m_ClientRect); int nY = 0; int nUpperClip = (int)(m_viewState->m_nScrollPosition - m_viewState->m_nItemHeight); int nLowerClip = nUpperClip + ClientRect.bottom + m_viewState->m_nItemHeight; for(unsigned int i = 0; i < nItemCount; i++) { if(nY >= nLowerClip) break; if(nY > nUpperClip) { glClear(GL_DEPTH_BUFFER_BIT); glViewport(0, (ClientRect.bottom - nY - m_viewState->m_nItemHeight + m_viewState->m_nScrollPosition), m_viewState->m_nItemWidth, m_viewState->m_nItemHeight); if(nY == (m_viewState->m_nSelection * m_viewState->m_nItemHeight)) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 1, 1, 0, 0, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glBegin(GL_QUADS); { glVertex2f(0.0, 0.0); glVertex2f(1.0, 0.0); glVertex2f(1.0, 1.0); glVertex2f(0.0, 1.0); } glEnd(); } glEnable(GL_DEPTH_TEST); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, -2.0f, -7.0f); glScalef(1.0f, -1.0f, -1.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (float)m_viewState->m_nItemWidth / (float)m_viewState->m_nItemHeight, 0.1f, 100.0f); IconMeshPtr iconMesh; IconList::iterator itIcon = m_icons.find(i); if(itIcon == m_icons.end()) { const CSave* pSave = m_memoryCard->GetSaveByIndex(i); try { auto iconStream(Framework::CreateInputStdStream(pSave->GetNormalIconPath().native())); IconPtr iconData(new CIcon(iconStream)); iconMesh = IconMeshPtr(new CIconMesh(iconData)); } catch(...) { } m_icons[i] = iconMesh; } else { iconMesh = itIcon->second; } if(iconMesh) { iconMesh->Render(); } } nY += m_viewState->m_nItemHeight; } SwapBuffers(m_deviceContext); }
/*************************************************** PrintPage Performs the actual printing of the grid cells. PrintInit must be called first to setup the printing criteria. Params pDC - device context of the printer (or print preview) pageNum - page number to print Return UG_SUCCESS - success UG_ERROR - failure ****************************************************/ int CUGPrint::PrintPage(CDC * pDC, int pageNum) { //TEST if(m_bIsPreview == FALSE) { SIZE size; pDC->SetMapMode(MM_ANISOTROPIC); SetWindowExtEx(pDC->m_hDC,1,1,&size); SetViewportExtEx(pDC->m_hDC,m_virPixWidth,m_virPixWidth,&size); } int x,h,w,col,xx; long y,row,yy; int startCol,endCol; long startRow,endRow; RECT cellrect={0,0,0,0}; RECT origCellRect; int leftMargin = m_printLeftMarginPX; int topMargin = m_printTopMarginPX; //get the co-ords to print if(GetPageFromList(pageNum,&startCol,&endCol,&startRow,&endRow) != UG_SUCCESS) return UG_ERROR; //*********************************************************** // Caculate the column width that will be used in drawing cells. //*********************************************************** CRect ColRect; int nColWidth, nFirstCol; m_ColRects.RemoveAll(); ColRect.left = leftMargin; ColRect.right = ColRect.left; nFirstCol = startCol; if( m_printSideHeading ) nFirstCol = 0 - m_GI->m_numberSideHdgCols; for( int i = nFirstCol; i <= endCol; i++ ) { if( i < 0 ) { //get the side heading co-ords ColRect.left = ColRect.right; ColRect.right += (int) (m_ctrl->m_CUGSideHdg->GetSHColWidth(i) * m_printHScale); } else { //get the left,right co-ords ColRect.left = ColRect.right; m_ctrl->GetColWidth( i, &nColWidth ); ColRect.right += (int) (nColWidth * m_printHScale); } m_ColRects.Add(ColRect); } //********************* // draw the page //********************* //draw the grid cellrect.top = topMargin; cellrect.bottom = topMargin; //main grid row drawing loop yy = startRow; if(m_printTopHeading) yy = 0 - m_GI->m_numberTopHdgRows; for(y = yy; y <= endRow ; y++) { //set up the rectangle for the row if(y < 0 ) { //set up the rect for the top heading cellrect.top = cellrect.bottom; cellrect.bottom+= (int)(m_ctrl->m_CUGTopHdg->GetTHRowHeight(y) * m_printVScale); cellrect.left = leftMargin; cellrect.right = cellrect.left; } else { if(yy < 0) { yy=0; y = startRow; } //set up the rect for the row to be drawn cellrect.top = cellrect.bottom; m_ctrl->GetRowHeight(y,&h); cellrect.bottom += (int)(h * m_printVScale); cellrect.left = leftMargin ; cellrect.right = cellrect.left; } //dont draw the row if it is 0 pixels high if(cellrect.top == cellrect.bottom) continue; //main column drawing loop xx =startCol; if(m_printSideHeading) xx = 0 - m_GI->m_numberSideHdgCols; for(x = xx; x <= endCol; x++) { if( x < 0 ) { //get the side heading co-ords cellrect.left = cellrect.right; cellrect.right += (int)(m_ctrl->m_CUGSideHdg->GetSHColWidth(x) * m_printHScale); } else { if(xx < 0) { xx=0; x = startCol; } //get the left,right co-ords cellrect.left = cellrect.right; m_ctrl->GetColWidth(x,&w); cellrect.right += (int)(w * m_printHScale); } //dont draw the column if it is 0 pixels wide if(cellrect.left == cellrect.right) continue; //store the original cell rect, incase it is modified below CopyRect(&origCellRect,&cellrect); col = x; row = y; //check to see if the cell is a joined cell if(m_ctrl->GetJoinStartCell(&col,&row)==UG_SUCCESS) { RECT tempRect; CUGCell sourceCell, targetCell; int col2, tempCol, tempCol2; long row2, tempRow, tempRow2; tempCol = col; tempRow = row; m_ctrl->GetJoinRange(&col,&row,&col2,&row2); tempCol2 = col2; tempRow2 = row2; if ((y == startRow && x == col) || (x == startCol && y == row) || (y == startRow && x == startCol)) { m_ctrl->GetCell (col,row,&sourceCell); m_ctrl->SetCell (x,y,&sourceCell); m_ctrl->JoinCells (x,y,col2,row2); col = x; row = y; m_ctrl->GetJoinRange(&col,&row,&col2,&row2); } if(col == x && row == y) { CopyRect(&tempRect,&cellrect); if (col2 > endCol || row2 > endRow) { if (col2 > endCol) col2 = endCol; if (row2 > endRow) row2 = endRow; m_ctrl->JoinCells (col,row,col2,row2); } while(col2 > col) { if (col2 <= endCol) { m_ctrl->GetColWidth(col2,&w); tempRect.right+=(int)(w* m_printHScale); } col2--; } while(row2 > row) { if (row2 <= endRow) { m_ctrl->GetRowHeight(row2,&h); tempRect.bottom+=(int)(h* m_printVScale); } row2--; } InternPrintCell(pDC,&tempRect,col,row); m_ctrl->JoinCells (tempCol,tempRow,tempCol2,tempRow2); } } else { InternPrintCell(pDC,&cellrect,x,y); } //draw a section of the print frame if selected CopyRect(&cellrect,&origCellRect); } } if ( m_printFrame ) { // draw left border and top border. if ((( m_printTopHeading ) && ( m_GI->m_numberTopHdgRows > 0 )) || ( startRow <= endRow)) { pDC->MoveTo(leftMargin,topMargin); pDC->LineTo(leftMargin,cellrect.bottom-1); pDC->MoveTo(leftMargin,topMargin); pDC->LineTo(cellrect.right-1, topMargin); } } return UG_SUCCESS; }
void ShowNotifyWnd(HWND hWnd, LPCTSTR title, LPCTSTR content, int timeoutMS, int nIcon, int nImg) { //EnterCriticalSection(&g_NotifyInfo.cs); //g_NotifyInfo.mode = mode; LPNOTIFYWND_DATA pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return; _tcscpy_s(pInfo->szTitle, _ARRAYSIZE(pInfo->szTitle), title); _tcscpy_s(pInfo->szContent, _ARRAYSIZE(pInfo->szContent), content); if(nIcon >= 0) pInfo->rcTitle.left = pInfo->rcIcon.right + g_NotifyInfo.gap; else pInfo->rcTitle.left = 3 + g_NotifyInfo.gap; if(nImg >= 0) pInfo->rcContent.left = pInfo->rcImg.right + g_NotifyInfo.gap; else pInfo->rcContent.left = pInfo->rcContentOutter.left + g_NotifyInfo.gap; pInfo->rcContent.top = pInfo->rcContentOutter.top + g_NotifyInfo.gap; pInfo->rcContent.right = pInfo->rcContent.left + pInfo->contentWidth; pInfo->rcContentOutter.right = pInfo->rcContent.right + g_NotifyInfo.gap; pInfo->wndWidth = pInfo->rcContentOutter.right + 3; pInfo->rcTitle.right = pInfo->wndWidth - g_NotifyInfo.gap; pInfo->rcContent.bottom = pInfo->rcContent.top + 48; pInfo->rcContentOutter.bottom = pInfo->rcContent.bottom + g_NotifyInfo.gap; //rcCloseBtn pInfo->rcCloseBtn.right = pInfo->wndWidth - 3 - g_NotifyInfo.gap/2; pInfo->rcCloseBtn.left = pInfo->rcCloseBtn.right - g_NotifyInfo.closeBtnSize; pInfo->rcCloseBtn.top = (pInfo->rcTitle.top + pInfo->rcTitle.bottom - g_NotifyInfo.closeBtnSize)/2; pInfo->rcCloseBtn.bottom = pInfo->rcCloseBtn.top + g_NotifyInfo.closeBtnSize; SetBkMode(pInfo->hMemDC, TRANSPARENT); //DT_TOP = 0; (default) 在这里测量矩形 HGDIOBJ hOldFont = SelectObject(pInfo->hMemDC, g_NotifyInfo.hFontContent); DrawText(pInfo->hMemDC, pInfo->szContent, -1, &pInfo->rcContent, DT_LEFT | DT_WORDBREAK | DT_CALCRECT); //复原宽度 pInfo->rcContent.right = pInfo->rcContent.left + pInfo->contentWidth; if(pInfo->mode == MODE_PROGRESS) { pInfo->bDownloading = TRUE; pInfo->rcProgressText.left = pInfo->rcContent.left; pInfo->rcProgressText.top = pInfo->rcContent.bottom + g_NotifyInfo.gap; pInfo->rcProgressText.right = pInfo->rcContent.right; pInfo->rcProgressText.bottom = pInfo->rcProgressText.top + pInfo->titleHeight; pInfo->rcProgressBarOutter.left = pInfo->rcContent.left; pInfo->rcProgressBarOutter.top = pInfo->rcProgressText.bottom + g_NotifyInfo.gap; pInfo->rcProgressBarOutter.right = pInfo->rcContent.right; pInfo->rcProgressBarOutter.bottom = pInfo->rcProgressBarOutter.top + g_NotifyInfo.gap * 2 + 4; CopyRect(&pInfo->rcProgressBar, &pInfo->rcProgressBarOutter); InflateRect(&pInfo->rcProgressBar, -2, - 2); pInfo->rcContent.bottom = pInfo->rcProgressBar.bottom + g_NotifyInfo.gap; } //更新高度等 if(nImg >= 0 && pInfo->rcImg.bottom > pInfo->rcContent.bottom) pInfo->rcContentOutter.bottom = pInfo->rcImg.bottom + g_NotifyInfo.gap; else pInfo->rcContentOutter.bottom = pInfo->rcContent.bottom + g_NotifyInfo.gap; pInfo->wndHeight = pInfo->rcContentOutter.bottom + 3; //FillRgn(hdc, pInfo->hRgnBkGnd, pInfo->hBrush); RECT rc = { 0, 0, pInfo->wndWidth, pInfo->wndHeight }; FillRect(pInfo->hMemDC, &rc, GetSysColorBrush(COLOR_INACTIVECAPTION)); //pInfo->hBrush); FrameRect(pInfo->hMemDC, &rc, g_NotifyInfo.hBrushBorder); FillRect(pInfo->hMemDC, &pInfo->rcContentOutter, (HBRUSH)GetStockObject(WHITE_BRUSH)); //绘制标题icon if(nIcon >= 0 && !g_NotifyInfo.pIcons->IsNull()) { g_NotifyInfo.pIcons->AlphaBlend(pInfo->hMemDC, pInfo->rcIcon.left, pInfo->rcIcon.top, g_NotifyInfo.iconSize, g_NotifyInfo.iconSize, g_NotifyInfo.iconSize * nIcon, 0, g_NotifyInfo.iconSize, g_NotifyInfo.iconSize); } //绘制左上角Image if(nImg >= 0 && !g_NotifyInfo.pImgs->IsNull()) { g_NotifyInfo.pImgs->AlphaBlend(pInfo->hMemDC, pInfo->rcImg.left, pInfo->rcImg.top, g_NotifyInfo.imgSize, g_NotifyInfo.imgSize, g_NotifyInfo.imgSize * nImg, 0, g_NotifyInfo.imgSize, g_NotifyInfo.imgSize); } //绘制标题 SelectObject(pInfo->hMemDC, g_NotifyInfo.hFontTitle); SetTextColor(pInfo->hMemDC, g_NotifyInfo.clrTitle); DrawText(pInfo->hMemDC, pInfo->szTitle, -1, &pInfo->rcTitle, DT_LEFT | DT_VCENTER | DT_SINGLELINE); //绘制文本 SelectObject(pInfo->hMemDC, g_NotifyInfo.hFontContent); SetTextColor(pInfo->hMemDC, g_NotifyInfo.clrContent); DrawText(pInfo->hMemDC, pInfo->szContent, -1, &pInfo->rcContent, DT_LEFT | DT_WORDBREAK); //复原字体 SelectObject(pInfo->hMemDC, hOldFont); int scrollbar_width = GetSystemMetrics(SM_CXVSCROLL); //Width of the screen of the primary display monitor int screen_width = GetSystemMetrics(SM_CXSCREEN); if(pInfo->mode == MODE_TEXT) { SetWindowPos(hWnd, NULL, screen_width - pInfo->wndWidth - scrollbar_width, g_NotifyInfo.rcWorkArea.bottom, pInfo->wndWidth, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS | SWP_SHOWWINDOW); SetTimer(hWnd, TIMERID_NOTIFY_SHOWING, INTERVAL_NOTIFYWND, NULL); } else if(pInfo->mode == MODE_PROGRESS) { //绘制进度条的外边框 FrameRect(pInfo->hMemDC, &pInfo->rcProgressBarOutter, g_NotifyInfo.hBrushBorder); pInfo->szProgressText[0] = 0; pInfo->progress = 0; //SWP_NOCOPYBITS : 抛弃客户区内容(如果不设置,则系统把窗口的有效区域拷贝到移动后的窗口) //因为窗口的内容可能已经发生变更,所以指定这个属性,相当于强制窗口重绘(InvalidateRect)。 SetWindowPos(hWnd, NULL, screen_width - pInfo->wndWidth - scrollbar_width, g_NotifyInfo.rcWorkArea.bottom - pInfo->wndHeight, pInfo->wndWidth, pInfo->wndHeight, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS | SWP_SHOWWINDOW); KillTimer(hWnd, TIMERID_NOTIFY_SHOWING); } //防止定时器冲突,kill 现有的所有显示定时器 KillTimer(hWnd, TIMERID_NOTIFY_HIDING); KillTimer(hWnd, TIMERID_NOTIFY_HIDE); //安装超时定时器, 如果这个参数小于等于0,则表示永远显示! if(timeoutMS > 0) SetTimer(hWnd, TIMERID_NOTIFY_TIMEOUT, timeoutMS, NULL); else KillTimer(hWnd, TIMERID_NOTIFY_TIMEOUT); //LeaveCriticalSection(&g_NotifyInfo.cs); }
static HRESULT WINAPI VideoRenderer_SetTargetRect(BaseControlVideo* iface, RECT *pTargetRect) { VideoRendererImpl *This = impl_from_BaseControlVideo(iface); CopyRect(&This->DestRect,pTargetRect); return S_OK; }
LRESULT khm_toolbar_notify(LPNMHDR notice) { switch(notice->code) { case TBN_GETINFOTIP: { LPNMTBGETINFOTIP git = (LPNMTBGETINFOTIP) notice; int cmd; khui_action * a; cmd = git->iItem; a = khui_find_action(cmd); if (a) { if (a->caption) { StringCchCopy(git->pszText, git->cchTextMax, a->caption); } else if (a->tooltip) { StringCchCopy(git->pszText, git->cchTextMax, a->tooltip); } else if (a->is_caption) { wchar_t buf[INFOTIPSIZE]; buf[0] = L'\0'; LoadString(khm_hInstance, a->is_caption, buf, ARRAYLENGTH(buf)); StringCchCopy(git->pszText, git->cchTextMax, buf); } else { StringCchCopy(git->pszText, git->cchTextMax, L""); } } else { StringCchCopy(git->pszText, git->cchTextMax, L""); } } break; case TBN_HOTITEMCHANGE: { LPNMTBHOTITEM hi = (LPNMTBHOTITEM) notice; if (hi->dwFlags & HICF_LEAVING) { khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, L""); } else { khui_action * a; int cmd; wchar_t buf[256]; cmd = hi->idNew; a = khui_find_action(cmd); buf[0] = L'\0'; if (a) { if (a->tooltip) StringCbCopy(buf, sizeof(buf), a->tooltip); else if (a->is_tooltip) { LoadString(khm_hInstance, a->is_tooltip, buf, ARRAYLENGTH(buf)); } } khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf); } } break; case TBN_DROPDOWN: { LPNMTOOLBAR nmtb = (LPNMTOOLBAR) notice; RECT r; GetWindowRect(khui_hwnd_standard_toolbar, &r); if (nmtb->iItem == KHUI_ACTION_DESTROY_CRED) { khm_menu_show_panel(KHUI_MENU_DESTROY_CRED, r.left + nmtb->rcButton.left, r.top + nmtb->rcButton.bottom); } else if (nmtb->iItem == KHUI_ACTION_RENEW_CRED) { khm_menu_show_panel(KHUI_MENU_RENEW_CRED, r.left + nmtb->rcButton.left, r.top + nmtb->rcButton.bottom); } else { return TBDDRET_NODEFAULT; } return TBDDRET_DEFAULT; } break; case NM_CUSTOMDRAW: { LPNMTBCUSTOMDRAW nmcd = (LPNMTBCUSTOMDRAW) notice; if(nmcd->nmcd.dwDrawStage == CDDS_PREPAINT) { return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE; } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { return CDRF_NOTIFYPOSTPAINT; } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) { /* draw the actual icon */ int iidx; int ibmp; HBITMAP hbmp; RECT r; khui_action * act = khui_find_action((int) nmcd->nmcd.dwItemSpec); if(!act || !act->ib_normal) return CDRF_DODEFAULT; if((act->state & KHUI_ACTIONSTATE_DISABLED) && act->ib_disabled) { ibmp = act->ib_disabled; } else if(act->ib_hot && ((nmcd->nmcd.uItemState & CDIS_HOT) || (nmcd->nmcd.uItemState & CDIS_SELECTED))){ ibmp = act->ib_hot; } else { ibmp = act->ib_normal; } iidx = khui_ilist_lookup_id(ilist_toolbar, ibmp); if(iidx < 0) { hbmp = LoadImage(khm_hInstance, MAKEINTRESOURCE(ibmp), IMAGE_BITMAP, KHUI_TOOLBAR_IMAGE_WIDTH, KHUI_TOOLBAR_IMAGE_HEIGHT, 0); iidx = khui_ilist_add_masked_id(ilist_toolbar, hbmp, KHUI_TOOLBAR_BGCOLOR, ibmp); DeleteObject(hbmp); } if(iidx < 0) return CDRF_DODEFAULT; CopyRect(&r, &(nmcd->nmcd.rc)); r.left += ((r.bottom - r.top) - KHUI_TOOLBAR_IMAGE_HEIGHT) / 2; r.top += ((r.bottom - r.top) - KHUI_TOOLBAR_IMAGE_HEIGHT) / 2; #if 0 r.left += ((r.right - r.left) - KHUI_TOOLBAR_IMAGE_WIDTH) / 2; #endif khui_ilist_draw(ilist_toolbar, iidx, nmcd->nmcd.hdc, r.left, r.top, 0); return CDRF_DODEFAULT; } } break; } return 0; }
bool GetScreenSelection(HINSTANCE hInstance, RECT *rcSelection, HWND target) { char* szClassName = "SelectionClass"; DWORD style = WS_POPUP | WS_EX_TOPMOST;// | WS_VISIBLE; DWORD styleEx = WS_EX_TOOLWINDOW; WNDCLASSEX wcex = { 0 }; wcex.cbSize = sizeof(WNDCLASSEX); wcex.hInstance = hInstance; wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.hCursor = LoadCursor(NULL, IDC_CROSS); wcex.lpfnWndProc = SelectionProc; wcex.lpszClassName = szClassName; SelectionState state = { 0 }; state.Result = FALSE; HDC hDeviceContext = GetDC(target); if (!GetClientRect(target, &state.Window.Rect)) { goto cleanup; } state.Window.hBitmap = CreateCompatibleBitmap(hDeviceContext, state.Window.Rect.right, state.Window.Rect.bottom); if (!state.Window.hBitmap) goto cleanup; state.Window.hDeviceContext = CreateCompatibleDC(hDeviceContext); if (!state.Window.hDeviceContext) goto cleanup; state.Selection.hBitmap = CreateCompatibleBitmap(hDeviceContext, state.Window.Rect.right, state.Window.Rect.bottom); if (!state.Selection.hBitmap) goto cleanup; state.Selection.hDeviceContext = CreateCompatibleDC(hDeviceContext); if (!state.Selection.hDeviceContext) goto cleanup; SelectObject(state.Window.hDeviceContext, state.Window.hBitmap); SelectObject(state.Selection.hDeviceContext, state.Selection.hBitmap); BitBlt(state.Window.hDeviceContext, 0, 0, state.Window.Rect.right, state.Window.Rect.bottom, hDeviceContext, state.Window.Rect.left, state.Window.Rect.top, SRCCOPY); ReleaseDC(NULL, hDeviceContext); hDeviceContext = NULL; HWND hWndSelect = Win32CreateWindow(hInstance, wcex, styleEx, style, "Selection Window", state.Window.Rect.right, state.Window.Rect.bottom, state.Window.Rect.left, state.Window.Rect.top, HWND_DESKTOP, &state); if (!hWndSelect) { goto cleanup; } SetForegroundWindow(target); SetForegroundWindow(hWndSelect); ShowWindow(hWndSelect, SW_SHOW); UpdateWindow(hWndSelect); MSG msg; state.Wait = TRUE; while (state.Wait) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { PostQuitMessage(msg.wParam); } } if (state.Result) { CopyRect(rcSelection, &state.Selection.Rect); } cleanup: if (hDeviceContext) ReleaseDC(NULL, hDeviceContext); CleanUp(state.Window); CleanUp(state.Selection); return state.Result; };
static HRESULT WINAPI VideoRenderer_GetSourceRect(BaseControlVideo* iface, RECT *pSourceRect) { VideoRendererImpl *This = impl_from_BaseControlVideo(iface); CopyRect(pSourceRect,&This->SourceRect); return S_OK; }
CSDWindow::CSDWindow(POINT point, SIZE size) { CRect rectTemp(point, size); CopyRect(rectTemp); }
// // Dialogbox procedure for Configuration window // BOOL CALLBACK ConfigDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static char buf[256]; HWND hwndCombo, hwndCtrl; int index, items, val; RECT rect; static int prevwidth, prevheight; switch(uMsg) { case WM_INITDIALOG: prevwidth = GetSystemMetrics(SM_CXSCREEN) / GLYPH_WIDTH; prevheight = GetSystemMetrics(SM_CYSCREEN) / GLYPH_HEIGHT + 1; //Add any saved messages to the combo box for(index = 0; index < g_nNumMessages; index++) { if(lstrlen(g_szMessages[index]) > 0) SendDlgItemMessage(hwnd, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)g_szMessages[index]); } //select the first message, and preview it SendDlgItemMessage(hwnd, IDC_COMBO1, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETRANGE, 0, MAKELONG(SPEED_MIN, SPEED_MAX)); SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_SETRANGE, 0, MAKELONG(DENSITY_MIN, DENSITY_MAX)); SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_SETRANGE, 0, MAKELONG(MSGSPEED_MIN, MSGSPEED_MAX)); SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_SETRANGE, 0, MAKELONG(FONT_MIN, FONT_MAX)); //SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETTICFREQ, 5, 0); SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_SETTICFREQ, 5, 0); SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_SETTICFREQ, 50, 0); SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_SETTICFREQ, 2, 0); SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETPOS, TRUE, g_nMatrixSpeed); SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_SETPOS, TRUE, g_nDensity); SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_SETPOS, TRUE, g_nMessageSpeed); SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_SETPOS, TRUE, g_nFontSize); CheckDlgButton(hwnd, IDC_RANDOM, g_fRandomizeMessages); CheckDlgButton(hwnd, IDC_BOLD, g_fFontBold); AddFonts(GetDlgItem(hwnd, IDC_COMBO2)); index = SendDlgItemMessage(hwnd, IDC_COMBO2, CB_FINDSTRING, 0, (LPARAM)g_szFontName); SendDlgItemMessage(hwnd, IDC_COMBO2, CB_SETCURSEL, index, 0); UpdatePreview(hwnd); return 0; case WM_DESTROY: //DeInitMessage(); return 0; case WM_CTLCOLORSTATIC: if(GetDlgCtrlID((HWND)lParam) == IDC_ABOUT) { SetTextColor((HDC)wParam, RGB(0,80,0)); SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE)); return (BOOL)GetSysColorBrush(COLOR_3DFACE); } else if(GetDlgCtrlID((HWND)lParam) == IDC_PREVIEW) { HDC hdc = (HDC)wParam; RECT clip; GetDlgItemText(hwnd, IDC_COMBO1, buf, 256); GetClientRect((HWND)lParam, &rect); if(prevwidth < rect.right) { rect.left = (rect.right-prevwidth) / 2; rect.right = rect.left + prevwidth; } else { rect.left = 0; rect.right = prevwidth; } if(prevheight < rect.bottom) { rect.top = (rect.bottom-prevheight) / 2; rect.bottom = rect.top + prevheight; } else { rect.top = 0; rect.bottom = prevheight; } SetTextColor(hdc, RGB(128,255,128)); SetBkColor(hdc, 0); //SetRect(&rect, 0, 0, PrevMessage->width, MAXMSG_HEIGHT); CopyRect(&clip, &rect); FillRect(hdc, &rect, GetStockObject(BLACK_BRUSH)); SelectObject(hdc, g_hFont); InflateRect(&clip, 2, 2); FrameRect(hdc, &clip, GetSysColorBrush(COLOR_3DSHADOW)); IntersectClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom); // figure out where the bounding rectangle should be DrawText(hdc, buf, -1, &rect, DT_CENTER|DT_VCENTER|DT_WORDBREAK|DT_CALCRECT); OffsetRect(&rect, (prevwidth-(rect.right-rect.left))/2, (prevheight-(rect.bottom-rect.top))/2); // now draw it! DrawText(hdc, buf, -1, &rect, DT_CENTER|DT_VCENTER|DT_WORDBREAK); return (BOOL)GetStockObject(NULL_BRUSH); } else { break; } case WM_HSCROLL: if((HWND)lParam == GetDlgItem(hwnd, IDC_SLIDER4)) { // one of the sliders changed..update UpdatePreview(hwnd); } return 0; case WM_COMMAND: switch(HIWORD(wParam)) { case CBN_EDITCHANGE: case CBN_SELCHANGE: //fall through to Preview: index = SendDlgItemMessage(hwnd, IDC_COMBO2, CB_GETCURSEL, 0, 0); SendDlgItemMessage(hwnd, IDC_COMBO2, CB_GETLBTEXT, index, (LPARAM)g_szFontName); //SetMessageFont(hwnd, g_szFontName, g_nFontSize, TRUE); UpdatePreview(hwnd); return 0; } switch(LOWORD(wParam)) { case IDC_RANDOM: g_fRandomizeMessages = IsDlgButtonChecked(hwnd, IDC_RANDOM); break; case IDC_BOLD: g_fFontBold = IsDlgButtonChecked(hwnd, IDC_BOLD); UpdatePreview(hwnd); break; case IDOK: hwndCtrl = GetDlgItem(hwnd, IDC_COMBO1); items = min(MAX_MESSAGES, SendMessage(hwndCtrl, CB_GETCOUNT, 0, 0)); for(index = 0; index < items; index++) { SendMessage(hwndCtrl, CB_GETLBTEXT, index, (LPARAM)g_szMessages[index]); } g_nNumMessages = items; //matrix speed val = SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_GETPOS, 0, 0); if(val >= SPEED_MIN && val <= SPEED_MAX) g_nMatrixSpeed = val; //density val = SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_GETPOS, 0, 0); if(val >= DENSITY_MIN && val <= DENSITY_MAX) g_nDensity = val; //message speed val = SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_GETPOS, 0, 0); if(val >= MSGSPEED_MIN && val <= MSGSPEED_MAX) g_nMessageSpeed = val; //font size val = SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_GETPOS, 0, 0); if(val >= FONT_MIN && val <= FONT_MAX) g_nFontSize = val; SaveSettings(); EndDialog(hwnd, 0); return 0; case IDCANCEL: EndDialog(hwnd, 0); return TRUE; case IDC_ADD: hwndCombo = GetDlgItem(hwnd, IDC_COMBO1); if(GetWindowText(hwndCombo, buf, 256)) { SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)buf); } UpdatePreview(hwnd); return 0; case IDC_REMOVE: hwndCombo = GetDlgItem(hwnd, IDC_COMBO1); GetWindowText(hwndCombo, buf, 256); index = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0); SendMessage(hwndCombo, CB_DELETESTRING, index, 0); SendMessage(hwndCombo, CB_SETCURSEL, 0, 0); UpdatePreview(hwnd); return 0; } return 0; case WM_CLOSE: EndDialog(hwnd, 0); return 0; } return 0; }
/*************************************************** DrawCellsIntern function is the key to the fast redraw functionality in the Ultimate Grid. This function is responsible for drawing cells within the grid area, it makes sure that only the cells that are marked as invalid (by calling CUGDrawHint::IsInvalid function) are redrawn. Params: dc - screen DC db_dc - off-screen DC, used when double buffering is enabled. Returns: <none> *****************************************************/ void CUGGrid::DrawCellsIntern(CDC *dc,CDC *db_dc) { RECT rect = {0,0,0,0}; RECT cellRect; RECT tempRect; CUGCell cell,tempCell; CString string; CSize size; RECT focusRect = {-1,-1,-1,-1}; CUGCellType * cellType; int rightBlank = -1; int bottomBlank = -1; int col,x; long row,y; int selectBlock; int dcID; CDC* origDC = dc; //double buffering if(m_doubleBufferMode) { origDC = dc; dc = db_dc; //get the default font to use if(m_GI->m_defFont != NULL){ origDC->SelectObject(m_GI->m_defFont); dc->SelectObject(m_GI->m_defFont); } } else{ //get the default font to use if(m_GI->m_defFont != NULL){ dc->SelectObject(m_GI->m_defFont); } } m_ctrl->OnScreenDCSetup(origDC,db_dc,UG_GRID); //set the right and bottom vars to point to //the extremes, if the right or bottom is //sooner then they will be updated in the //main drawing loop m_GI->m_rightCol = m_GI->m_numberCols; m_GI->m_bottomRow = m_GI->m_numberRows; //main draw loop, this loop goes through all visible //cells and checks to see if they need redrawing //if they do then the cell is retrieved and drawn for(y = 0; y < m_GI->m_numberRows;y++) { //skip rows hidden under locked rows if(y == m_GI->m_numLockRows) y = m_GI->m_topRow; row = y; //calc the top bottom and right side of the rect //for the current cell to be drawn rect.top = rect.bottom; if(m_GI->m_uniformRowHeightFlag) rect.bottom += m_GI->m_defRowHeight; else rect.bottom += m_GI->m_rowHeights[row]; if(rect.top == rect.bottom) continue; rect.right = 0; //check all visible cells in the current row to //see if they need drawing for(x = 0;x < m_GI->m_numberCols;x++){ //skip cols hidden under locked cols if(x == m_GI->m_numLockCols) x = m_GI->m_leftCol; row = y; col = x; //calc the left and right side of the rect rect.left = rect.right; rect.right += m_GI->m_colInfo[col].width; if(rect.left == rect.right) continue; //check to see if the cell need to be redrawn if(m_drawHint.IsInvalid(col,row) != FALSE){ //copy the rect, then use the cellRect from here //this is done since the cellRect may be modified CopyRect(&cellRect,&rect); //get the cell to draw m_ctrl->GetCellIndirect(col,row,&cell); //check to see if the cell is joined if(cell.IsPropertySet(UGCELL_JOIN_SET)){ m_ctrl->GetCellRect(col,row,&cellRect); m_ctrl->GetJoinStartCell(&col,&row,&cell); if(m_drawHint.IsValid(col,row)) continue; m_drawHint.SetAsValid(col,row); } //get the cell type to draw the cell if(cell.IsPropertySet(UGCELL_CELLTYPE_SET)){ cellType = m_ctrl->GetCellType(cell.GetCellType()); } else { cellType = m_ctrl->GetCellType(-1); } dcID = dc->SaveDC(); //draw the cell, check to see if it is 'current' and/or selected CopyRect(&tempRect,&cellRect); if(row == m_GI->m_currentRow && ( col == m_GI->m_currentCol || m_GI->m_highlightRowFlag)) cellType->OnDraw(dc,&cellRect,col,row,&cell,0,1); else{ if(m_GI->m_multiSelect->IsSelected(col,row,&selectBlock)) cellType->OnDraw(dc,&cellRect,col,row,&cell,selectBlock+1,0); else cellType->OnDraw(dc,&cellRect,col,row,&cell,0,0); } CopyRect(&cellRect,&tempRect); //draw a black line at the right edge of the locked columns if(m_GI->m_numLockCols >0){ if(col == m_GI->m_leftCol){ dc->SelectObject(GetStockObject(BLACK_PEN)); dc->MoveTo(cellRect.left-1,cellRect.top); dc->LineTo(cellRect.left-1,cellRect.bottom+1); } else if(col == m_GI->m_numLockCols-1){ dc->SelectObject(GetStockObject(BLACK_PEN)); dc->MoveTo(cellRect.right-1,cellRect.top); dc->LineTo(cellRect.right-1,cellRect.bottom+1); } } //draw a black line at the bottom of the locked rows if(m_GI->m_numLockRows >0){ if(row == m_GI->m_topRow ){ dc->SelectObject(GetStockObject(BLACK_PEN)); dc->MoveTo(cellRect.left,cellRect.top-1); dc->LineTo(cellRect.right+1,cellRect.top-1); } else if(row == m_GI->m_numLockRows-1){ dc->SelectObject(GetStockObject(BLACK_PEN)); dc->MoveTo(cellRect.left,cellRect.bottom-1); dc->LineTo(cellRect.right+1,cellRect.bottom-1); } } dc->RestoreDC(dcID); } //check to see if the focus rect should be drawn //this function should be called all the time //even if it is off screen if(row == m_GI->m_currentRow && (col == m_GI->m_currentCol || m_GI->m_highlightRowFlag)){ CopyRect(&focusRect,&cellRect); } //check to see if the right side of the rect is past the edge //of the grid drawing area, if so then break if(rect.right > m_GI->m_gridWidth){ m_GI->m_rightCol = col; break; } } //check to see if there is blank space on the right side of the grid //drawing area if(rect.right < m_GI->m_gridWidth && m_GI->m_rightCol == m_GI->m_numberCols){ rightBlank = rect.right; } //check to see if the bottom of the rect is past the bottom of the //grid drawing area, if so then break if(rect.bottom > m_GI->m_gridHeight){ m_GI->m_bottomRow = row; break; } //check for extra rows if(y >= (m_GI->m_numberRows-1)){ long origNumRows = m_GI->m_numberRows; long newRow = y+1; m_ctrl->VerifyCurrentRow(&newRow); if(m_GI->m_numberRows > origNumRows){ m_drawHint.AddHint(0,y+1,m_GI->m_numberCols-1,y+1); } } } //clear the draw hints m_drawHint.ClearHints(); //check to see if there is blank space on the bottom of the grid //drawing area if(rect.bottom < m_GI->m_gridHeight && m_GI->m_bottomRow == m_GI->m_numberRows) bottomBlank = rect.bottom; //fill in the blank grid drawing areas if(rightBlank >=0 || bottomBlank >=0){ CBrush brush(m_ctrl->OnGetDefBackColor(UG_GRID)); GetClientRect(&rect); if(rightBlank >=0){ rect.left = rightBlank; dc->FillRect(&rect,&brush); } if(bottomBlank >=0){ rect.left = 0; rect.top = bottomBlank; dc->FillRect(&rect,&brush); } } //double buffering if(m_doubleBufferMode){ dc = origDC; dc->BitBlt(0,0,m_GI->m_gridWidth,m_GI->m_gridHeight,db_dc,0,0,SRCCOPY); } //draw the focus rect, if the flag was set above if(!m_tempDisableFocusRect){ if((m_hasFocus || m_ctrl->m_findDialogRunning) && !m_ctrl->m_editInProgress) { if(m_GI->m_highlightRowFlag) { focusRect.left = 0; if(rect.right < m_GI->m_gridWidth) focusRect.right = rect.right; else { if( m_GI->m_bExtend ) focusRect.right = m_GI->m_gridWidth; else { int iStartCol = m_ctrl->GetLeftCol(), iEndCol = m_ctrl->GetNumberCols() - 1; int iWidth = 0; for( int iLoop = iStartCol ; iLoop <= iEndCol ; iLoop++ ) iWidth += m_ctrl->GetColWidth( iLoop ); focusRect.right = iWidth; } } } m_ctrl->OnDrawFocusRect(dc,&focusRect); } } //reset temporary flags m_tempDisableFocusRect = FALSE; }
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { TRichUtil *ru; EnterCriticalSection(&csRich); ru = rlist_find(slist, hwnd); LeaveCriticalSection(&csRich); switch(msg) { case WM_THEMECHANGED: case WM_STYLECHANGED: RichUtil_ClearUglyBorder(ru); break; case WM_NCPAINT: { LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); if (ru->hasUglyBorder && IsThemeActive()) { HANDLE hTheme = OpenThemeData(ru->hwnd, L"EDIT"); if (hTheme) { RECT rcBorder; RECT rcClient; int nState; HDC hdc = GetWindowDC(ru->hwnd); GetWindowRect(hwnd, &rcBorder); rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top; rcBorder.left = rcBorder.top = 0; CopyRect(&rcClient, &rcBorder); rcClient.left += ru->rect.left; rcClient.top += ru->rect.top; rcClient.right -= ru->rect.right; rcClient.bottom -= ru->rect.bottom; ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); if(IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL)) DrawThemeParentBackground(hwnd, hdc, &rcBorder); if (!IsWindowEnabled(hwnd)) nState = ETS_DISABLED; else if(SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY) nState = ETS_READONLY; else nState = ETS_NORMAL; DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL); CloseThemeData(hTheme); ReleaseDC(hwnd, hdc); return 0; } } return ret; } case WM_NCCALCSIZE: { LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam; if (ru->hasUglyBorder && IsThemeActive()) { HANDLE hTheme = OpenThemeData(hwnd, L"EDIT"); if (hTheme) { RECT rcClient; HDC hdc = GetDC(GetParent(hwnd)); ZeroMemory(&rcClient, sizeof(RECT)); if(GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) { ru->rect.left = rcClient.left-ncsParam->rgrc[0].left; ru->rect.top = rcClient.top-ncsParam->rgrc[0].top; ru->rect.right = ncsParam->rgrc[0].right-rcClient.right; ru->rect.bottom = ncsParam->rgrc[0].bottom-rcClient.bottom; CopyRect(&ncsParam->rgrc[0], &rcClient); CloseThemeData(hTheme); ReleaseDC(GetParent(hwnd), hdc); return WVR_REDRAW; } ReleaseDC(GetParent(hwnd), hdc); CloseThemeData(hTheme); } } return ret; } case WM_ENABLE: RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME); break; case WM_DESTROY: { LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); EnterCriticalSection(&csRich); slist = rlist_remove(slist, ru); LeaveCriticalSection(&csRich); if (ru) free(ru); return ret; } } return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); }
////////// // // The Oppie-1 memory block is one of two banks, either showing the first // 1KB of its 2KB RAM, or the second. // ////// void iiDebo1_renderMemory(void) { s32 lnI, lnJ, lnOffset; RECT lrc, lrcAddress, lrcDelta; s8 buffer[256]; ////////// // Fill the background ////// SetRect(&lrc, 35, 23, bmpMemory->bi.biWidth - 1, bmpMemory->bi.biHeight - 1); iBmp_fillRect(bmpMemory, &bmpMemory->rc, memoryBorderColor, memoryBorderColor, memoryBorderColor, memoryBorderColor, false, &lrc, true); iBmp_fillRect(bmpMemory, &lrc, memoryFillColor, memoryFillColor, memoryFillColor, memoryFillColor, false, NULL, false); SetRect(&lrc, 0, 23, 35, bmpMemory->bi.biHeight - 1); iBmp_fillRect(bmpMemory, &lrc, memoryOptionColor, memoryOptionColor, memoryOptionColor, memoryOptionColor, false, NULL, false); ////////// // Options ////// if (gnMemoryPage == 0) { // 1 KB page BitBlt(bmpMemory->hdc, 36, 0, bmp1KbOver->bi.biWidth - 1, bmp1KbOver->bi.biHeight - 1, bmp1KbOver->hdc, 0, 0, SRCCOPY); BitBlt(bmpMemory->hdc, 111, 0, bmp2Kb->bi.biWidth - 1, bmp2Kb->bi.biHeight - 1, bmp2Kb->hdc, 0, 0, SRCCOPY); } else { // 2 KB page BitBlt(bmpMemory->hdc, 36, 0, bmp1Kb->bi.biWidth - 1, bmp1Kb->bi.biHeight - 1, bmp1Kb->hdc, 0, 0, SRCCOPY); BitBlt(bmpMemory->hdc, 111, 0, bmp2KbOver->bi.biWidth - 1, bmp2KbOver->bi.biHeight - 1, bmp2KbOver->hdc, 0, 0, SRCCOPY); } BitBlt(bmpMemory->hdc, 357, 0, bmp8BitsOver->bi.biWidth - 1, bmp8BitsOver->bi.biHeight - 1, bmp8BitsOver->hdc, 0, 0, SRCCOPY); BitBlt(bmpMemory->hdc, 422, 0, bmp16Bits->bi.biWidth - 1, bmp16Bits->bi.biHeight - 1, bmp16Bits->hdc, 0, 0, SRCCOPY); BitBlt(bmpMemory->hdc, 488, 0, bmp32Bits->bi.biWidth - 1, bmp32Bits->bi.biHeight - 1, bmp32Bits->hdc, 0, 0, SRCCOPY); BitBlt(bmpMemory->hdc, 552, 0, bmp64Bits->bi.biWidth - 1, bmp64Bits->bi.biHeight - 1, bmp64Bits->hdc, 0, 0, SRCCOPY); ////////// // Memory page ////// sprintf(buffer, "000:\0"); CopyRect(&lrcAddress, &lrc); SetRect(&lrc, 40, 25, bmpMemory->bi.biWidth - 1, bmpMemory->bi.biHeight - 1); SetBkMode(bmpMemory->hdc, TRANSPARENT); SelectObject(bmpMemory->hdc, fontUbuntuMono8->hfont); DrawText(bmpMemory->hdc, buffer, strlen(buffer), &lrcDelta, DT_CALCRECT); lrcDelta.bottom -= 2; for (lnI = gnMemoryPage * 1024; lnI < (gnMemoryPage + 1) * 1024; lnI += 32) { ////////// // Display the address ////// sprintf(buffer, " %03x:\0", lnI); SetTextColor(bmpMemory->hdc, RGB(whiteColor.red, whiteColor.grn, whiteColor.blu)); DrawText(bmpMemory->hdc, buffer, strlen(buffer), &lrcAddress, DT_LEFT); ////////// // Contents ////// // Build the line memset(buffer, 32, 32 * 3); for (lnOffset = 0, lnJ = lnI, buffer[0] = 0; lnOffset < 32; lnOffset++) sprintf(buffer + (lnOffset * 3), "%02x \0", ram[lnJ + lnOffset]); // Draw the line SetTextColor(bmpMemory->hdc, RGB(blackColor.red, blackColor.grn, blackColor.blu)); DrawText(bmpMemory->hdc, buffer, 32 * 3, &lrc, DT_LEFT | DT_SINGLELINE); ////////// // If any of the addresses are in this range, highlight them ////// if (state.pipeStage >= _STAGE1) iiDebo1_renderMemory_highlightMemory(lnI, lnI + 32, pipe1.ip, bmpMemory, &lrc, stage1LowColor, 3); if (state.pipeStage >= _STAGE2) iiDebo1_renderMemory_highlightMemory(lnI, lnI + 32, pipe2.ip, bmpMemory, &lrc, stage2LowColor, ((pipe2.p2_increment2) ? 2 : 1)); if (state.pipeStage >= _STAGE3) iiDebo1_renderMemory_highlightMemory(lnI, lnI + 32, pipe3.ip, bmpMemory, &lrc, stage3LowColor, ((pipe3.p2_increment2) ? 2 : 1)); if (state.pipeStage >= _STAGE4) iiDebo1_renderMemory_highlightMemory(lnI, lnI + 32, pipe4.ip, bmpMemory, &lrc, stage4LowColor, ((pipe4.p2_increment2) ? 2 : 1)); if (state.pipeStage >= _STAGE5) iiDebo1_renderMemory_highlightMemory(lnI, lnI + 32, pipe5.ip, bmpMemory, &lrc, stage5LowColor, ((pipe5.p2_increment2) ? 2 : 1)); ////////// // Move down ////// lrcAddress.top += (lrcDelta.bottom - lrcDelta.top); lrc.top += (lrcDelta.bottom - lrcDelta.top); } }
//缺省消息响应函数,可被相应的流程继承 LRESULT CGameProcedure::MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { //-------------------------------------------------------------- // 处理一些缺省的消息 switch (message) { // 窗口大小发生改变 case WM_SIZE: { // 最小化 if( SIZE_MINIMIZED == wParam ) { m_bRenderingPaused = true; // 最小化时渲染暂停 m_bMinimized = true; m_bMaximized = FALSE; } // 最大化 else if( SIZE_MAXIMIZED == wParam ) { m_bRenderingPaused = FALSE; //恢复渲染工作(可能上一个状态时最小化) m_bMinimized = FALSE; m_bMaximized = true; HandlePossibleSizeChange( message, wParam, lParam); } // 恢复窗口 else if( SIZE_RESTORED == wParam ) { if( m_bMaximized ) // 刚才是最大化 { m_bMaximized = FALSE; HandlePossibleSizeChange(message, wParam, lParam); } else if( m_bMinimized ) // 刚才是最小化 { m_bRenderingPaused = FALSE; m_bMinimized = FALSE; HandlePossibleSizeChange(message, wParam, lParam); } else { //如果上一个状态既不是最大化也不是最小化,显然这次的WM_SIZE //消息是因为用户拖动窗口边缘引起的,这种情况我们并不马上恢复 //设备,我们等待用户停止拖动后在处理,也就是对WM_EXITSIZEMOVE //的处理... } } } break; // 用户拖动窗口开始 case WM_ENTERSIZEMOVE: { m_bRenderingPaused = true; } break; // 用户拖动中 case WM_SIZING: { RECT* pRect = (RECT*)lParam; switch(wParam) { case WMSZ_RIGHT: case WMSZ_BOTTOMRIGHT: { KeepWindowFOV(pRect, WMSZ_RIGHT, WMSZ_TOPLEFT); } break; case WMSZ_LEFT: case WMSZ_BOTTOMLEFT: { KeepWindowFOV(pRect, WMSZ_LEFT, WMSZ_TOPRIGHT); } break; case WMSZ_TOP: case WMSZ_TOPRIGHT: { KeepWindowFOV(pRect, WMSZ_TOP, WMSZ_BOTTOMLEFT); } break; case WMSZ_BOTTOM: { KeepWindowFOV(pRect, WMSZ_BOTTOM, WMSZ_TOPLEFT); } break; case WMSZ_TOPLEFT: { KeepWindowFOV(pRect, WMSZ_TOP, WMSZ_BOTTOMRIGHT); } break; } return TRUE; } break; // 窗口尺寸发生了改变后 case WM_WINDOWPOSCHANGING: { WINDOWPOS* pPos = (WINDOWPOS*)lParam; // 非大小改变 if(pPos->flags & SWP_NOSIZE || pPos->flags & SWP_DRAWFRAME) break; // 是“全屏”状态 if(s_pVariableSystem && s_pVariableSystem->GetAs_Int("View_FullScreen")) break; // 计算新的Client RECT rectFrame; SetRect(&rectFrame, 0, 0, pPos->cx, pPos->cy); OffsetRect(&rectFrame, pPos->x, pPos->y); RECT rectNewFrame; CopyRect(&rectNewFrame, &rectFrame); KeepWindowFOV(&rectNewFrame, -1, WMSZ_TOPLEFT); // 如果相同不处理 if(EqualRect(&rectFrame, &rectNewFrame)) break; pPos->x = rectNewFrame.left; pPos->y = rectNewFrame.top; pPos->cx = rectNewFrame.right-rectNewFrame.left; pPos->cy = rectNewFrame.bottom-rectNewFrame.top; return 0; } break; // 桌面分辨率改变 case WM_DISPLAYCHANGE: { if( s_pEventSystem && s_pVariableSystem->GetAs_Int("View_FullScreen")) { s_pEventSystem->PushEvent(GE_VARIABLE_CHANGED, "View_FullScreen", "1"); } // 重置分辨率 if(m_bMaximized) { ShowWindow(g_hMainWnd, SW_RESTORE); ShowWindow(g_hMainWnd, SW_MAXIMIZE); } else { s_pEventSystem->PushEvent(GE_VARIABLE_CHANGED, "View_Resoution", s_pVariableSystem->GetAs_String("View_Resoution").c_str()); } break; } // 用户拖动窗口边缘结束 case WM_EXITSIZEMOVE: { m_bRenderingPaused = FALSE; HandlePossibleSizeChange(message, wParam, lParam); // 设置分辨率变量 if(s_pVariableSystem) { RECT rect; GetClientRect(hWnd, &rect); char szTemp[MAX_PATH]; _snprintf(szTemp, MAX_PATH, "%d,%d", rect.right-rect.left, rect.bottom-rect.top); s_pVariableSystem->SetVariable("View_Resoution", szTemp, FALSE, FALSE); } } break; // 决定窗口最大最小尺寸 case WM_GETMINMAXINFO: { MINMAXINFO* pMinMaxInfo = (MINMAXINFO*)lParam; pMinMaxInfo->ptMinTrackSize.x = MINWINDOW_WIDTH; pMinMaxInfo->ptMinTrackSize.y = MINWINDOW_HEIGHT; // 最大尺寸为“窗口最大化”时的大小 RECT rect; SetRect(&rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); AdjustWindowRect(&rect, GetWindowStyle(g_hMainWnd), FALSE); pMinMaxInfo->ptMaxSize.x = rect.right-rect.left; pMinMaxInfo->ptMaxSize.y = rect.bottom-rect.top; pMinMaxInfo->ptMaxTrackSize.x = rect.right-rect.left; pMinMaxInfo->ptMaxTrackSize.y = rect.bottom-rect.top; } break; // 设置光标 case WM_SETCURSOR: { switch(LOWORD(lParam)) { case HTCLIENT: { if(s_pCursorMng) { s_pCursorMng->OnSetCursor(); return TRUE; } } break; default: break; } } break; // 窗口激活切换 case WM_ACTIVATEAPP: if( wParam == TRUE ) { m_bActive = TRUE; } else { m_bActive = FALSE; } // 通知输入器 if(s_pInputSystem) ((CInputSystem*)s_pInputSystem)->OnActiveApp(m_bActive); break; // 消息主循环移到菜单中 case WM_ENTERMENULOOP: { m_bRenderingPaused = true; } break; // 消息主循环移出菜单 case WM_EXITMENULOOP: { m_bRenderingPaused = FALSE; } break; // 系统按键 case WM_SYSCOMMAND: { switch(wParam) { // 屏蔽F10 case SC_KEYMENU: return 1; default: break; } } break; // 窗口重绘消息 case WM_PAINT: { PAINTSTRUCT psStruct; ::BeginPaint(hWnd, &psStruct); ::EndPaint(hWnd, &psStruct); s_pGfxSystem->OnPaint(); } break; // 窗口背景刷 case WM_ERASEBKGND: { return 1; } break; // 处理玩家的退出请求 case WM_CLOSE: { //AxProfile::AxProfile_Report(); // 主流程中,弹出设置菜单 if(GetActiveProcedure() == s_pProcMain && s_pUISystem) { if(wParam==0xC0DE && lParam==0XC0DE) { ProcessCloseRequest(); break; } else { s_pEventSystem->PushEvent( GE_TOGLE_SYSTEMFRAME ); return TRUE; } } } break; // 窗口销毁 case WM_DESTROY: { PostQuitMessage(0); } break; // 输入法改变 case WM_INPUTLANGCHANGE: { if(s_pEventSystem) { s_pEventSystem->PushEvent(GE_CHAT_INPUTLANGUAGE_CHANGE); } } break; case WM_IME_NOTIFY: { if(wParam == IMN_SETOPENSTATUS || wParam == IMN_SETCONVERSIONMODE) { if(s_pEventSystem) { s_pEventSystem->PushEvent(GE_CHAT_INPUTLANGUAGE_CHANGE); } } } break; default: break; } return DefWindowProc( hWnd, message, wParam, lParam ); }
////////// // // Called to render the Debo1 window. // Note: Renders into the bmpDebo1->hdc bitmap for later copying with BitBlt(). // Note: The file debo-1.png was used as a template for this construction. // ////// void iiDebo1_render(void) { RECT lrc; ////////// // Render the sub-components ////// iiDebo1_renderStage1(); iiDebo1_renderStage2(); iiDebo1_renderStage3(); iiDebo1_renderStage4(); iiDebo1_renderStage5(); iiDebo1_renderRegisters(); iiDebo1_renderDisassembly(); iiDebo1_renderMemory(); ////////// // The main window has a white background, and then each component is rendered atop ////// FillRect(bmpDebo1->hdc, &bmpDebo1->rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); ////////// // Title ////// CopyRect(&lrc, &bmpDebo1->rc); --lrc.top; lrc.left += 8; SelectObject(bmpDebo1->hdc, fontUbuntu14->hfont); SetBkMode(bmpDebo1->hdc, TRANSPARENT); SetTextColor(bmpDebo1->hdc, RGB(titleColor.red, titleColor.grn, titleColor.blu)); DrawText(bmpDebo1->hdc, cgcAppTitle, strlen(cgcAppTitle), &lrc, DT_LEFT); ////////// // Pipeline stages ////// BitBlt(bmpDebo1->hdc, 5, 28, bmpStage1->bi.biWidth, bmpStage1->bi.biHeight, bmpStage1->hdc, 0, 0, SRCCOPY); BitBlt(bmpDebo1->hdc, 78, 28, bmpStage2->bi.biWidth, bmpStage2->bi.biHeight, bmpStage2->hdc, 0, 0, SRCCOPY); BitBlt(bmpDebo1->hdc, 178, 28, bmpStage3->bi.biWidth, bmpStage3->bi.biHeight, bmpStage3->hdc, 0, 0, SRCCOPY); BitBlt(bmpDebo1->hdc, 278, 9, bmpStage4->bi.biWidth, bmpStage4->bi.biHeight, bmpStage4->hdc, 0, 0, SRCCOPY); BitBlt(bmpDebo1->hdc, 528, 28, bmpStage5->bi.biWidth, bmpStage5->bi.biHeight, bmpStage5->hdc, 0, 0, SRCCOPY); ////////// // Registers ////// BitBlt(bmpDebo1->hdc, 618, 2, bmpRegisters->bi.biWidth, bmpRegisters->bi.biHeight, bmpRegisters->hdc, 0, 0, SRCCOPY); ////////// // Disassembly ////// BitBlt(bmpDebo1->hdc, 618, 173, bmpDisassembly->bi.biWidth, bmpDisassembly->bi.biHeight, bmpDisassembly->hdc, 0, 0, SRCCOPY); ////////// // Memory ////// BitBlt(bmpDebo1->hdc, 0, 154, bmpMemory->bi.biWidth, bmpMemory->bi.biHeight, bmpMemory->hdc, 0, 0, SRCCOPY); }
//纯文本式的右下角浮出窗口过程 LRESULT CALLBACK NotifyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LPNOTIFYWND_DATA pInfo = NULL; RECT rc; POINT pt; //这是一个广播消息 if(message == g_NotifyInfo.nMsg_ExitNow) { pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); //通知主窗口退出(即客户端主程序退出) if(pInfo != NULL && pInfo->mode == MODE_TEXT) PostMessage(g_NotifyInfo.hWndMainFrm, WM_EXITNOW, 0, 0); return TRUE; } switch (message) { case WM_NCCREATE: { SIZE _size = { 0 }; LPCREATESTRUCT pCreateStruct = (LPCREATESTRUCT)lParam; LPCTSTR pStr = _T("啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"); pInfo = (LPNOTIFYWND_DATA)malloc(sizeof(NOTIFYWND_DATA)); memset(pInfo, 0, sizeof(NOTIFYWND_DATA)); pInfo->mode = (int)(pCreateStruct->lpCreateParams); //创建内存位图和DC HDC hdc = GetDC(hWnd); pInfo->hMemDC = CreateCompatibleDC(hdc); HGDIOBJ hOldFont = SelectObject(pInfo->hMemDC, g_NotifyInfo.hFontContent); GetTextExtentPoint32(pInfo->hMemDC, pStr, _tcslen(pStr), &_size); pInfo->hMemBm = CreateCompatibleBitmap(hdc, _size.cx + g_NotifyInfo.imgSize + 48, 600); ReleaseDC(hWnd, hdc); SelectObject(pInfo->hMemDC, hOldFont); SelectObject(pInfo->hMemDC, pInfo->hMemBm); pInfo->contentWidth = _size.cx + g_NotifyInfo.gap; pInfo->titleHeight = _size.cy; pInfo->rcIcon.left = 3 + g_NotifyInfo.gap; pInfo->rcTitle.left = pInfo->rcIcon.left + g_NotifyInfo.iconSize + g_NotifyInfo.gap; pInfo->rcTitle.top = 3 + g_NotifyInfo.gap; pInfo->rcTitle.bottom = pInfo->rcTitle.top + pInfo->titleHeight; pInfo->rcIcon.top = (pInfo->rcTitle.top + pInfo->rcTitle.bottom - g_NotifyInfo.iconSize)/2; pInfo->rcIcon.right = pInfo->rcIcon.left + g_NotifyInfo.iconSize; pInfo->rcIcon.bottom = pInfo->rcIcon.top + g_NotifyInfo.iconSize; pInfo->rcContentOutter.left = 3; pInfo->rcContentOutter.top = pInfo->rcTitle.bottom + g_NotifyInfo.gap; pInfo->rcImg.left = pInfo->rcContentOutter.left + g_NotifyInfo.gap; pInfo->rcImg.top = pInfo->rcContentOutter.top + g_NotifyInfo.gap; pInfo->rcImg.right = pInfo->rcImg.left + g_NotifyInfo.imgSize; pInfo->rcImg.bottom = pInfo->rcImg.top + g_NotifyInfo.imgSize; SetWindowPos(hWnd, HWND_TOPMOST, -10000, -10000, pInfo->wndWidth, pInfo->wndHeight, SWP_HIDEWINDOW); pInfo->tme.cbSize = sizeof(TRACKMOUSEEVENT); pInfo->tme.dwFlags = TME_LEAVE; //我们需要 WM_MOUSELEAVE 消息; pInfo->tme.hwndTrack = hWnd; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pInfo); } return TRUE; case WM_PAINT: { pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); BitBlt(hdc, 0, 0, pInfo->wndWidth, pInfo->wndHeight, pInfo->hMemDC, 0, 0, SRCCOPY); //绘制closebtn(有进度条时,不能关闭) int imgIndex = IMG_NORMAL; if(pInfo->bMouseOnClose) { imgIndex = (pInfo->bMouseDown && pInfo->bCloseBtnPushed)? IMG_PUSHED : IMG_HOVER; } g_NotifyInfo.pImgCloseBtns->TransparentBlt(hdc, pInfo->rcCloseBtn.left, pInfo->rcCloseBtn.top, g_NotifyInfo.closeBtnSize, g_NotifyInfo.closeBtnSize, imgIndex * g_NotifyInfo.closeBtnSize, 0, g_NotifyInfo.closeBtnSize, g_NotifyInfo.closeBtnSize, RGB(255, 0, 255)); EndPaint(hWnd, &ps); } return TRUE; case WM_ERASEBKGND: return TRUE; case WM_UPDATEPROGRESS: pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; if(pInfo->mode == MODE_PROGRESS) { LPCTSTR pStr = (LPCTSTR)lParam; if(pStr != NULL) _tcscpy_s(pInfo->szProgressText, _ARRAYSIZE(pInfo->szProgressText), pStr); pInfo->progress = (int)wParam; //绘制进度条 HGDIOBJ hOldFont = SelectObject(pInfo->hMemDC, g_NotifyInfo.hFontContent); SetTextColor(pInfo->hMemDC, g_NotifyInfo.clrContent); FillRect(pInfo->hMemDC, &pInfo->rcProgressText, (HBRUSH)GetStockObject(WHITE_BRUSH)); DrawText(pInfo->hMemDC, pInfo->szProgressText, -1, &pInfo->rcProgressText, DT_LEFT | DT_TOP | DT_SINGLELINE); SelectObject(pInfo->hMemDC, hOldFont); FillRect(pInfo->hMemDC, &pInfo->rcProgressBar, (HBRUSH)GetStockObject(WHITE_BRUSH)); CopyRect(&rc, &pInfo->rcProgressBar); rc.right = pInfo->rcProgressBar.left + (pInfo->rcProgressBar.right - pInfo->rcProgressBar.left) * pInfo->progress / 100; FillRect(pInfo->hMemDC, &rc, GetSysColorBrush(COLOR_ACTIVECAPTION)); //pInfo->hBrush); if(pInfo->progress >= 100) { //5 秒后自动隐藏 pInfo->bDownloading = FALSE; SetTimer(hWnd, TIMERID_NOTIFY_HIDE, 2000, NULL); } UnionRect(&rc, &pInfo->rcProgressText, &pInfo->rcProgressBar); InvalidateRect(hWnd, &rc, FALSE); } return TRUE; case WM_MOUSEMOVE: { pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); BOOL bTmp = PtInRect(&pInfo->rcCloseBtn, pt); if(bTmp != pInfo->bMouseOnClose) { pInfo->bMouseOnClose = bTmp; InvalidateRect(hWnd, &pInfo->rcCloseBtn, FALSE); } TrackMouseEvent(&pInfo->tme); } break; case WM_MOUSELEAVE: pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; if(pInfo->bMouseOnClose) { pInfo->bMouseOnClose = FALSE; InvalidateRect(hWnd, &pInfo->rcCloseBtn, FALSE); } break; case WM_LBUTTONDOWN: pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); pInfo->bMouseDown = TRUE; if(PtInRect(&pInfo->rcCloseBtn, pt)) { pInfo->bCloseBtnPushed = TRUE; InvalidateRect(hWnd, &pInfo->rcCloseBtn, FALSE); SetCapture(hWnd); } break; case WM_LBUTTONUP: pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); pInfo->bMouseDown = FALSE; if(pInfo->bCloseBtnPushed) { pInfo->bCloseBtnPushed = FALSE; ReleaseCapture(); if(PtInRect(&pInfo->rcCloseBtn, pt)) { KillTimer(hWnd, TIMERID_NOTIFY_SHOWING); KillTimer(hWnd, TIMERID_NOTIFY_HIDING); KillTimer(hWnd, TIMERID_NOTIFY_TIMEOUT); KillTimer(hWnd, TIMERID_NOTIFY_HIDE); InvalidateRect(hWnd, &pInfo->rcCloseBtn, FALSE); //ShowWindow(hDlg, SW_HIDE); //用渐隐( AW_BLEND )的方式隐藏窗口,动画时间:200ms AnimateWindow(hWnd, 200, AW_HIDE | AW_BLEND); } } break; case WM_TIMER: pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; GetWindowRect(hWnd, &rc); switch(wParam) { case TIMERID_NOTIFY_SHOWING: if((rc.bottom - rc.top) >= (pInfo->wndHeight - g_NotifyInfo.dy)) { KillTimer(hWnd, wParam); SetWindowPos(hWnd, NULL, rc.left, rc.bottom - pInfo->wndHeight, pInfo->wndWidth, pInfo->wndHeight, SWP_NOZORDER | SWP_NOACTIVATE); } else { SetWindowPos(hWnd, NULL, rc.left, rc.top - g_NotifyInfo.dy, pInfo->wndWidth, (rc.bottom - rc.top) + g_NotifyInfo.dy, SWP_NOZORDER | SWP_NOACTIVATE); } break; case TIMERID_NOTIFY_HIDING: { UINT flags = SWP_NOZORDER | SWP_NOACTIVATE; if((rc.bottom - rc.top) <= 0) { KillTimer(hWnd, wParam); flags = flags | SWP_HIDEWINDOW; } SetWindowPos(hWnd, NULL, rc.left, rc.top + g_NotifyInfo.dy, pInfo->wndWidth, rc.bottom - rc.top - g_NotifyInfo.dy, flags); } break; case TIMERID_NOTIFY_TIMEOUT: { KillTimer(hWnd, TIMERID_NOTIFY_SHOWING); KillTimer(hWnd, TIMERID_NOTIFY_TIMEOUT); KillTimer(hWnd, TIMERID_NOTIFY_HIDE); SetTimer(hWnd, TIMERID_NOTIFY_HIDING, INTERVAL_NOTIFYWND, NULL); } break; case TIMERID_NOTIFY_HIDE: //立即隐藏 { KillTimer(hWnd, TIMERID_NOTIFY_SHOWING); KillTimer(hWnd, TIMERID_NOTIFY_HIDING); KillTimer(hWnd, TIMERID_NOTIFY_TIMEOUT); KillTimer(hWnd, TIMERID_NOTIFY_HIDE); AnimateWindow(hWnd, 200, AW_HIDE | AW_BLEND); } break; } break; case WM_POWERBROADCAST: { //TCHAR szText[256]; //PBT_APMQUERYSUSPEND //_stprintf_s(szText, _ARRAYSIZE(szText), _T("NotifyWnd_PowerEvent: event = %x"), wParam); //WriteLogLine(szText); pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo != NULL && pInfo->mode == MODE_TEXT) return SendMessage(g_NotifyInfo.hWndMainFrm, WM_POWERBROADCAST, wParam, lParam); } break; case WM_NCDESTROY: { pInfo = (LPNOTIFYWND_DATA)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pInfo == NULL) return TRUE; //DeleteCriticalSection(&g_NotifyInfo.cs); DeleteObject(pInfo->hMemBm); DeleteDC(pInfo->hMemDC); free(pInfo); SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL); } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// ---------------------------------------------------------------------------- // // AddNextContiguousRectangle() // This is called from RemoveGaps to find the next contiguous rectangle // in the array. If there are no more contiguous rectangles it picks the // closest rectangle and moves it so it is contiguous. // // ---------------------------------------------------------------------------- LPRECT FAR * NEAR PASCAL AddNextContiguousRectangle(LPRECT FAR *aprc, LPRECT FAR *pprcSplit, UINT count) { LPRECT FAR *pprcL; LPRECT FAR *pprcTest; LPRECT FAR *pprcAxis; LPRECT FAR *pprcDiag; UINT dAxis = (UINT)-1; UINT dDiag = (UINT)-1; POINT dpAxis; POINT dpDiag; POINT dpMove; pprcL = aprc + count; for (pprcTest = aprc; pprcTest < pprcSplit; pprcTest++) { LPRECT lprcTest = *pprcTest; LPRECT FAR *pprcScan; for (pprcScan = pprcSplit; pprcScan < pprcL; pprcScan++) { RECT rcCheckOverlap; LPRECT lprcScan = *pprcScan; LPRECT FAR *pprcCheckOverlap; LPRECT FAR *FAR *pppBest; LPPOINT pdpBest; UINT FAR *pdBest; UINT dX, dY; UINT dTotal; // // Figure out how far the rectangle may be along both axes. // Note some of these numbers could be garbage at this point but // the code below will take care of it. // if (lprcScan->right <= lprcTest->left) dpMove.x = dX = lprcTest->left - lprcScan->right; else dpMove.x = -(int)(dX = (lprcScan->left - lprcTest->right)); if (lprcScan->bottom <= lprcTest->top) dpMove.y = dY = lprcTest->top - lprcScan->bottom; else dpMove.y = -(int)(dY = (lprcScan->top - lprcTest->bottom)); // // Figure out whether the rectangles are vertical, horizontal or // diagonal to each other and pick the measurements we will test. // if ((lprcScan->top < lprcTest->bottom) && (lprcScan->bottom > lprcTest->top)) { // The rectangles are somewhat horizontally aligned. dpMove.y = dY = 0; pppBest = &pprcAxis; pdpBest = &dpAxis; pdBest = &dAxis; } else if ((lprcScan->left < lprcTest->right) && (lprcScan->right > lprcTest->left)) { // The rectangles are somewhat vertically aligned. dpMove.x = dX = 0; pppBest = &pprcAxis; pdpBest = &dpAxis; pdBest = &dAxis; } else { // The rectangles are somewhat diagonally aligned. pppBest = &pprcDiag; pdpBest = &dpDiag; pdBest = &dDiag; } // // Make sure there aren't other rectangles in the way. We only // need to check the upper array since that is the pool of // semi-placed rectangles. Any rectangles in the lower array that // are "in the way" will be found in a different iteration of the // enclosing loop. // CopyRect(&rcCheckOverlap, lprcScan); OffsetRect(&rcCheckOverlap, dpMove.x, dpMove.y); for (pprcCheckOverlap = pprcScan + 1; pprcCheckOverlap < pprcL; pprcCheckOverlap++) { RECT rc; if (IntersectRect(&rc, *pprcCheckOverlap, &rcCheckOverlap)) break; } if (pprcCheckOverlap < pprcL) { // There was another rectangle in the way; don't use this one. continue; } // // If it is closer than the one we already had, use it instead. // dTotal = dX + dY; if (dTotal < *pdBest) { *pdBest = dTotal; *pdpBest = dpMove; *pppBest = pprcScan; } } } // // If we found anything along an axis use that otherwise use a diagonal. // if (dAxis != (UINT)-1) { pprcSplit = pprcAxis; dpMove = dpAxis; } else if (dDiag != (UINT)-1) { // BUGBUG: consider moving the rectangle to a side in this case. // (that, of course would add a lot of code to avoid collisions) pprcSplit = pprcDiag; dpMove = dpDiag; } else dpMove.x = dpMove.y = 0; // // Move the monitor into place and return it as the one we chose. // if (dpMove.x || dpMove.y) OffsetRect(*pprcSplit, dpMove.x, dpMove.y); return pprcSplit; }
// Message handler for about box. INT_PTR CALLBACK DecryptProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: // Get the owner window and dialog box rectangles. HWND hwndOwner; RECT rc, rcDlg, rcOwner; if ((hwndOwner = GetParent(hDlg)) == NULL) { hwndOwner = GetDesktopWindow(); } GetWindowRect(hwndOwner, &rcOwner); GetWindowRect(hDlg, &rcDlg); CopyRect(&rc, &rcOwner); // Offset the owner and dialog box rectangles so that right and bottom // values represent the width and height, and then offset the owner again // to discard space taken up by the dialog box. OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); OffsetRect(&rc, -rc.left, -rc.top); OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); // The new position is the sum of half the remaining space and the owner's // original position. SetWindowPos(hDlg, HWND_TOP, rcOwner.left + (rc.right / 2), rcOwner.top + (rc.bottom / 2), 0, 0, // Ignores size arguments. SWP_NOSIZE); SetWindowText(hDlg, szFile); return (INT_PTR)TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { TCHAR pwd[MAX_PASSWORD]; GetDlgItemText(hDlg, IDC_PWD, pwd, MAX_PASSWORD); if (!wcslen(pwd)) { MessageBox(hDlg, L"Password cannot be empty", L"Password error", MB_ICONERROR); break; } if (!SodiumDecryptFile(pwd)) { sodium_memzero(pwd, MAX_PASSWORD); break; } sodium_memzero(pwd, MAX_PASSWORD); EndDialog(hDlg, LOWORD(wParam)); PostQuitMessage(0); return (INT_PTR)TRUE; } else if (LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); PostQuitMessage(0); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; }
BOOL AlignRects(LPRECT arc, DWORD cCount, DWORD iPrimary, DWORD dwFlags) { LPRECT lprc, lprcL; // // Limit for loops. // lprcL = arc + cCount; // // We don't need to get all worked up if there is only one rectangle. // if (cCount > MONITORS_MAX) { return FALSE; } if (cCount > 1) { if (!(dwFlags & CUDR_NOSNAPTOGRID)) { // // Align monitors on 8 pixel boundaries so GDI can use the same // brush realization on compatible devices (BIG performance win). // Note that we assume the size of a monitor will be in multiples // of 8 pixels on X and Y. We cannot do this for the work areas so // we convert them to be relative to the origins of their monitors // for the time being. // // The way we do this alignment is to just do the overlap/gap // resoluton in 8 pixel space (ie divide everything by 8 beforehand // and multiply it by 8 afterward). // // Note: WE CAN'T USE MULTDIV HERE because it introduces one-off // errors when monitors span the origin. These become eight-off // errors when we scale things back up and we end up trying to // create DCs with sizes like 632x472 etc (not too good). It also // handles rounding the wierdly in both positive and negative space // and we just want to snap things to a grid so we compensate for // truncation differently here. // for (lprc = arc; lprc < lprcL; lprc++) { RECT rc; int d; CopyRect(&rc, lprc); d = rc.right - rc.left; if (rc.left < 0) rc.left -= 4; else rc.left += 3; rc.left /= 8; rc.right = rc.left + (d / 8); d = rc.bottom - rc.top; if (rc.top < 0) rc.top -= 4; else rc.top += 3; rc.top /= 8; rc.bottom = rc.top + (d / 8); CopyRect(lprc, &rc); } } // // RemoveGaps is designed assuming that none of the rectangles that it // is passed will overlap. Thus we cannot safely call it if we have // skipped the call to RemoveOverlaps or it might loop forever. // if (!(dwFlags & CUDR_NORESOLVEPOSITIONS)) { RemoveOverlaps(arc, cCount); if (!(dwFlags & CUDR_NOCLOSEGAPS)) { RemoveGaps(arc, cCount); } } if (!(dwFlags & CUDR_NOSNAPTOGRID)) { // // Now return the monitor rectangles to pixel units this is a // simple multiply and MultDiv doesn't offer us any code size // advantage so (I guess that assumes a bit about the compiler, // but...) just do it right here. // for (lprc = arc; lprc < lprcL; lprc++) { lprc->left *= 8; lprc->top *= 8; lprc->right *= 8; lprc->bottom *= 8; } } } if (!(dwFlags & CUDR_NOPRIMARY)) { // // Reset all the coordinates based on the primaries position, // so that it is always located at 0,0 // LONG dx = -((arc + iPrimary)->left); LONG dy = -((arc + iPrimary)->top); for (lprc = arc; lprc < lprcL; lprc++) { OffsetRect(lprc, dx, dy); } } return TRUE; }
//用以保持窗口比例不发生改变 //最大化除外 VOID CGameProcedure::KeepWindowFOV(RECT* pRect, UINT dwChanging, UINT dwAnchor) { RECT rectTemp; CopyRect(&rectTemp, pRect); rectTemp.left -= m_rectFCOffset.left; rectTemp.top -= m_rectFCOffset.top; rectTemp.right -= m_rectFCOffset.right; rectTemp.bottom -= m_rectFCOffset.bottom; if(WMSZ_LEFT == dwChanging || WMSZ_RIGHT == dwChanging) { //宽不变 rectTemp.bottom = rectTemp.top + (INT)((rectTemp.right-rectTemp.left)*m_fWindowFOV); } else if(WMSZ_TOP == dwChanging || WMSZ_BOTTOM == dwChanging) { //高不变 rectTemp.right = rectTemp.left + (INT)((rectTemp.bottom-rectTemp.top)/m_fWindowFOV); } else { //根据比例自动调节 FLOAT fFov = (FLOAT)(rectTemp.bottom-rectTemp.top)/(FLOAT)(rectTemp.right-rectTemp.left); if(fFov > m_fWindowFOV) { rectTemp.bottom = rectTemp.top + (INT)((rectTemp.right-rectTemp.left)*m_fWindowFOV); } else { rectTemp.right = rectTemp.left + (INT)((rectTemp.bottom-rectTemp.top)/m_fWindowFOV); } } AdjustWindowRect(&rectTemp, DEFWINDOW_STYLE, FALSE); switch(dwAnchor) { case WMSZ_TOPLEFT: { pRect->right = pRect->left + (rectTemp.right-rectTemp.left); pRect->bottom = pRect->top + (rectTemp.bottom-rectTemp.top); } break; case WMSZ_TOPRIGHT: { pRect->left = pRect->right - (rectTemp.right-rectTemp.left); pRect->bottom = pRect->top + (rectTemp.bottom-rectTemp.top); } break; case WMSZ_BOTTOMLEFT: { pRect->right = pRect->left + (rectTemp.right-rectTemp.left); pRect->top = pRect->bottom - (rectTemp.bottom-rectTemp.top); } break; case WMSZ_BOTTOMRIGHT: { pRect->left = pRect->right - (rectTemp.right-rectTemp.left); pRect->top = pRect->bottom - (rectTemp.bottom-rectTemp.top); } break; } }
void DrawStuff(LPDRAWITEMSTRUCT lpDrawItem) { PUSERKEYINFO pui; DRAWSTRUCT *ds; LISTSTRUCT *ls; int index; RECT rc; //HICON hIcon; HWND hDlg,hwndList; int max; BOOL focused; focused=TRUE; if(lpDrawItem->hwndItem!=0) { if(GetFocus()!=lpDrawItem->hwndItem) focused=FALSE; } hwndList=lpDrawItem->hwndItem; hDlg=GetParent(hwndList); ls=GetListStruct(hwndList); ds=GetDrawStruct(hDlg); pui=(PUSERKEYINFO)(lpDrawItem->itemData); CopyRect(&rc,&(lpDrawItem->rcItem)); #ifdef _WIN32 ImageList_Draw(ds->hIml,pui->icon, lpDrawItem->hDC, rc.left+((CX_SMICON-16)/2), rc.top+((CY_SMICON-16)/2), ILD_TRANSPARENT); #else hIcon=LoadIcon(gPGPsdkUILibInst,MAKEINTRESOURCE(pui->icon)); DrawIcon(lpDrawItem->hDC, rc.left+((CX_SMICON-32)/2), rc.top+((CY_SMICON-32)/2), hIcon); DeleteObject(hIcon); #endif rc.right=rc.left; rc.left=rc.left+16; max=0; for(index=0;index<NUMCOLUMNS;index++) { #if LISTBOX max=max+ls->colwidth[index]; #else max=max+ ListView_GetColumnWidth(lpDrawItem->hwndItem,index); #endif } for(index=0;index<NUMCOLUMNS;index++) { #if LISTBOX rc.right=rc.right+ls->colwidth[index]; #else rc.right=rc.right+ ListView_GetColumnWidth(lpDrawItem->hwndItem,index); #endif switch(index) { case 0: { HFONT oldFont; RECT origrc; // Save original rect CopyRect(&origrc,&rc); oldFont=SelectObject(lpDrawItem->hDC, ds->hFont); if(pui->pru->kind==kPGPRecipientUserKind_MissingRecipient) SelectObject(lpDrawItem->hDC, ds->hStrikeOut); // See if we need the lock icon if(pui->pru->lockRefCount!=0) { RECT temprc; CopyRect(&temprc,&rc); temprc.left=temprc.right-16; if(temprc.left>rc.left) { // Enough space. Draw Lock if((BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused) { FillRect (lpDrawItem->hDC, &temprc, ds->HighBrush); } else { FillRect (lpDrawItem->hDC, &temprc, ds->BackBrush); } ImageList_Draw(ds->hIml,IDX_CLOSEDLOCK, lpDrawItem->hDC, temprc.left+((CX_SMICON-16)/2), temprc.top+((CY_SMICON-16)/2), ILD_TRANSPARENT); // Make space for lock from text rc.right=rc.right-16; } } DrawItemColumn(lpDrawItem->hDC,pui->UserId, &rc); // Set rectangle back to original CopyRect(&rc,&origrc); SelectObject(lpDrawItem->hDC,oldFont); break; } case 1: { if(ds->DisplayMarginal) DrawBar(ds,lpDrawItem->hDC,&rc,pui->Validity, 2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused); else DrawNoviceButton(ds,lpDrawItem->hDC,&rc,pui->Validity, 2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused); break; } /* case 2: // we no longer display trust in rec dlg { DrawBar(ds,lpDrawItem->hDC,&rc,pui->Trust, 2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused); break; } */ case 2: { HFONT oldFont; oldFont=SelectObject(lpDrawItem->hDC, ds->hFont); DrawItemColumn(lpDrawItem->hDC,pui->szSize, &rc); SelectObject(lpDrawItem->hDC,oldFont); break; } } rc.left=rc.right; } lpDrawItem->rcItem.right=max; }
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { TRichUtil *ru = NULL, tru; int idx; LRESULT ret; tru.hwnd = hwnd; { mir_cslock lck(csRich); if (List_GetIndex(&sListInt, &tru, &idx)) ru = (TRichUtil *)sListInt.items[idx]; } switch (msg) { case WM_THEMECHANGED: case WM_STYLECHANGED: RichUtil_ClearUglyBorder(ru); break; case WM_NCPAINT: ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); if (ru->hasUglyBorder && IsThemeActive()) { HANDLE hTheme = OpenThemeData(ru->hwnd, L"EDIT"); if (hTheme) { RECT rcBorder; RECT rcClient; int nState; HDC hdc = GetWindowDC(ru->hwnd); GetWindowRect(hwnd, &rcBorder); rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top; rcBorder.left = rcBorder.top = 0; CopyRect(&rcClient, &rcBorder); rcClient.left += ru->rect.left; rcClient.top += ru->rect.top; rcClient.right -= ru->rect.right; rcClient.bottom -= ru->rect.bottom; ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); if (IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL)) DrawThemeParentBackground(hwnd, hdc, &rcBorder); if (!IsWindowEnabled(hwnd)) nState = ETS_DISABLED; else if (SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY) nState = ETS_READONLY; else nState = ETS_NORMAL; DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL); CloseThemeData(hTheme); ReleaseDC(hwnd, hdc); return 0; } } return ret; case WM_NCCALCSIZE: { ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS *)lParam; if (ru->hasUglyBorder && IsThemeActive()) { HANDLE hTheme = OpenThemeData(hwnd, L"EDIT"); if (hTheme) { RECT rcClient = {0}; HDC hdc = GetDC(GetParent(hwnd)); if (GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) { ru->rect.left = rcClient.left - ncsParam->rgrc[0].left; ru->rect.top = rcClient.top - ncsParam->rgrc[0].top; ru->rect.right = ncsParam->rgrc[0].right - rcClient.right; ru->rect.bottom = ncsParam->rgrc[0].bottom - rcClient.bottom; ncsParam->rgrc[0] = rcClient; CloseThemeData(hTheme); ReleaseDC(GetParent(hwnd), hdc); return WVR_REDRAW; } ReleaseDC(GetParent(hwnd), hdc); CloseThemeData(hTheme); } } } return ret; case WM_ENABLE: RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME); break; case WM_GETDLGCODE: return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam) & ~DLGC_HASSETSEL; case WM_NCDESTROY: ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); { mir_cslock lck(csRich); List_Remove(&sListInt, idx); } mir_free(ru); return ret; } return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam); }
void DrawBar(DRAWSTRUCT *ds,HDC hdc,RECT *ptrBarRect, int DataValue,int MaxValue,BOOL Selected) { RECT rc; HBRUSH oldbrush,barbrush; HPEN oldpen; COLORREF oldbkcolor; int cx; CopyRect(&rc,ptrBarRect); if(Selected) { FillRect (hdc, &rc, ds->HighBrush); oldpen = SelectObject (hdc, ds->g_unseltextpen); } else { FillRect (hdc, &rc, ds->BackBrush); oldpen = SelectObject (hdc, ds->g_seltextpen); } rc.top+=5; rc.left+=5; rc.bottom-=5; rc.right-=5; if(rc.right<=rc.left) return; cx=rc.right-rc.left; oldbrush = SelectObject (hdc, ds->barbgbrush); SelectObject (hdc, ds->buttonpen); Rectangle (hdc, rc.left - 1, rc.top - 1, rc.right + 2, rc.bottom + 2); SelectObject (hdc, ds->shadowpen); MoveToEx (hdc, rc.left, rc.bottom, NULL); LineTo (hdc, rc.left, rc.top); LineTo (hdc, rc.right, rc.top); SelectObject (hdc, ds->hilightpen); LineTo (hdc, rc.right, rc.bottom); LineTo (hdc, rc.left, rc.bottom); if (MaxValue != 0) { if (DataValue > MaxValue) { barbrush = ds->spcbarbrush; rc.right = rc.left + cx; } else { barbrush = ds->stdbarbrush; rc.right = rc.left + (int)(((float)DataValue / (float)MaxValue) * (float)cx); } } else rc.right = rc.left; rc.top++; rc.left++; if (rc.right > rc.left) { oldbkcolor=SetBkColor (hdc, ds->barcolor); FillRect (hdc, &rc, barbrush); rc.top--; rc.left--; // hilight pen already selected MoveToEx (hdc, rc.right, rc.top, NULL); LineTo (hdc, rc.left, rc.top); LineTo (hdc, rc.left,rc.bottom); SelectObject (hdc, ds->shadowpen); LineTo (hdc, rc.right, rc.bottom); LineTo (hdc, rc.right, rc.top); SetBkColor(hdc,oldbkcolor); } SelectObject (hdc, oldbrush); SelectObject (hdc, oldpen); }
static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) { if(hdcPaint) { HDC hdcMem; RECT rcClient, rcBp; HFONT hOldFont = 0; int xOffset = 0; HANDLE hbp = 0; GetClientRect(ctl->hwnd, &rcClient); #ifndef _USE_D2D rcBp = rcClient; INIT_PAINT(hdcPaint, rcBp, hdcMem); #else hdcMem = cfg::dat.hdcBg; MapWindowPoints(ctl->hwnd, pcli->hwndContactList, reinterpret_cast<POINT *>(&rcClient), 2); #endif hOldFont = reinterpret_cast<HFONT>(SelectObject(hdcMem, ctl->hFont)); // If its a push button, check to see if it should stay pressed if(ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED; // Draw the flat button if(ctl->flatBtn) { if(ctl->hThemeToolbar && ctl->bThemed) { RECT rc = rcClient; int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; Gfx::drawBGFromSurface(ctl->hwnd, rc, hdcMem); if(Api::pfnIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { Api::pfnDrawThemeParentBackground(ctl->hwnd, hdcMem, &rc); } Api::pfnDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc); } else { HBRUSH hbr; RECT rc = rcClient; if(ctl->buttonItem) { RECT rcParent; POINT pt; TImageItem *imgItem = ctl->stateId == PBS_HOT ? ctl->buttonItem->imgHover : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->imgPressed : ctl->buttonItem->imgNormal); LONG *glyphMetrics = ctl->stateId == PBS_HOT ? ctl->buttonItem->hoverGlyphMetrics : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->pressedGlyphMetrics : ctl->buttonItem->normalGlyphMetrics); #ifndef _USE_D2D GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); Gfx::drawBGFromSurface(ctl->hwnd, rc, hdcMem); #endif if(imgItem) Gfx::renderSkinItem(hdcMem, &rc, imgItem); if(Skin::glyphItem) { Api::pfnAlphaBlend(hdcMem, (rc.right - glyphMetrics[2]) / 2, (rc.bottom - glyphMetrics[3]) / 2, glyphMetrics[2], glyphMetrics[3], Skin::glyphItem->hdc, glyphMetrics[0], glyphMetrics[1], glyphMetrics[2], glyphMetrics[3], Skin::glyphItem->bf); } } else if(ctl->bSkinned) { // skinned RECT rcParent; TStatusItem *item; int item_id; GetWindowRect(ctl->hwnd, &rcParent); Gfx::drawBGFromSurface(ctl->hwnd, rc, hdcMem); item_id = ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED); item = &Skin::statusItems[item_id]; Gfx::setTextColor(item->TEXTCOLOR); if(item->IGNORED) FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE)); else { rc.top += item->MARGIN_TOP; rc.bottom -= item->MARGIN_BOTTOM; rc.left += item->MARGIN_LEFT; rc.right -= item->MARGIN_RIGHT; Gfx::renderSkinItem(hdcMem, &rc, item->imageItem); } } else { if(ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT) hbr = GetSysColorBrush(COLOR_3DFACE); else { HDC dc; HWND hwndParent; hwndParent = GetParent(ctl->hwnd); dc = GetDC(hwndParent); hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent); ReleaseDC(hwndParent, dc); } if(hbr) { FillRect(hdcMem, &rc, hbr); DeleteObject(hbr); } } if(!ctl->bSkinned && ctl->buttonItem == 0) { if(ctl->stateId == PBS_HOT || ctl->focus) { if(ctl->pbState) DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT); else DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT); } else if(ctl->stateId == PBS_PRESSED) DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT); } } } else { // Draw background/border if(ctl->hThemeButton && ctl->bThemed) { int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; POINT pt; RECT rcParent; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); BitBlt(hdcMem, 0, 0, rcClient.right, rcClient.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY); if(Api::pfnIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { Api::pfnDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); } Api::pfnDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient); } else { UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0); if(ctl->defbutton && ctl->stateId == PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState); } // Draw focus rectangle if button has focus if(ctl->focus) { RECT focusRect = rcClient; InflateRect(&focusRect, -3, -3); DrawFocusRect(hdcMem, &focusRect); } } // If we have an icon or a bitmap, ignore text and only draw the image on the button if(ctl->hIcon || ctl->hIconPrivate || ctl->iIcon) { int ix = (rcClient.right - rcClient.left) / 2 - (CXSMICON / 2); int iy = (rcClient.bottom - rcClient.top) / 2 - (CXSMICON / 2); HICON hIconNew = ctl->hIconPrivate != 0 ? ctl->hIconPrivate : ctl->hIcon; if(lstrlen(ctl->szText) == 0) { if(ctl->iIcon) ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, CXSMICON, CYSMICON, CLR_NONE, CLR_NONE, ILD_NORMAL); else DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, CXSMICON, CYSMICON, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); ctl->sLabel.cx = ctl->sLabel.cy = 0; } else { GetTextExtentPoint32(hdcMem, ctl->szText, lstrlen(ctl->szText), &ctl->sLabel); if(CXSMICON + ctl->sLabel.cx + 8 > rcClient.right - rcClient.left) ctl->sLabel.cx = (rcClient.right - rcClient.left) - CXSMICON - 8; else ctl->sLabel.cx += 4; ix = (rcClient.right - rcClient.left) / 2 - ((CXSMICON + ctl->sLabel.cx) / 2); if(ctl->iIcon) ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, CXSMICON, CYSMICON, CLR_NONE, CLR_NONE, ILD_NORMAL); else DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, CXSMICON, CYSMICON, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); xOffset = ix + CXSMICON + 4; } } else if(ctl->hBitmap) { BITMAP bminfo; int ix, iy; GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo); ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2); iy = (rcClient.bottom - rcClient.top) / 2 - (bminfo.bmHeight / 2); if(ctl->stateId == PBS_PRESSED) { ix++; iy++; } DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->hBitmap, 0, ix, iy, bminfo.bmWidth, bminfo.bmHeight, IsWindowEnabled(ctl->hwnd) ? DST_BITMAP : DST_BITMAP | DSS_DISABLED); } if(GetWindowTextLength(ctl->hwnd)) { // Draw the text and optinally the arrow RECT rcText; CopyRect(&rcText, &rcClient); SetBkMode(hdcMem, TRANSPARENT); if(!ctl->bSkinned) Gfx::setTextColor(IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT)); if(ctl->arrow) { DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - CXSMICON + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - CYSMICON / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), CXSMICON, CYSMICON, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED); rcText.left += (4 + CXSMICON); } if(xOffset) rcText.left += (4 + CXSMICON); Gfx::renderText(hdcMem, ctl->hThemeButton, ctl->szText, &rcText, DT_VCENTER | DT_CENTER | DT_SINGLELINE, 0); } if(hOldFont) SelectObject(hdcMem, hOldFont); #ifndef _USE_D2D FINALIZE_PAINT(hbp, &rcBp, 0); #endif } }
void Canvas::CopyRect(const Rect &r, const Rect &r2) { CopyRect(r, r2.left, r2.top); }
/* ================ rvGENavigator::WndProc Window Procedure ================ */ LRESULT CALLBACK rvGENavigator::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { rvGENavigator *nav = ( rvGENavigator * ) GetWindowLong( hWnd, GWL_USERDATA ); switch( msg ) { case WM_INITMENUPOPUP: return SendMessage( gApp.GetMDIFrame( ), msg, wParam, lParam ); case WM_ACTIVATE: common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE ); break; case WM_ERASEBKGND: return TRUE; case WM_DESTROY: gApp.GetOptions().SetWindowPlacement( "navigator", hWnd ); break; case WM_CLOSE: gApp.GetOptions().SetNavigatorVisible( false ); nav->Show( false ); return 0; case WM_DRAWITEM: { DRAWITEMSTRUCT *dis = ( DRAWITEMSTRUCT * ) lParam; idWindow *window = ( idWindow * )dis->itemData; if( window ) { rvGEWindowWrapper *wrapper = rvGEWindowWrapper::GetWrapper( window ); idStr name = window->GetName(); RECT rDraw; float offset; bool disabled; idWindow *parent = window; offset = 1; disabled = false; while( parent = parent->GetParent( ) ) { if( rvGEWindowWrapper::GetWrapper( parent )->IsHidden( ) ) { disabled = true; } offset += 10; } CopyRect( &rDraw, &dis->rcItem ); rDraw.right = rDraw.left + GENAV_ITEMHEIGHT; rDraw.top ++; rDraw.right ++; FrameRect( dis->hDC, &rDraw, ( HBRUSH )GetStockObject( BLACK_BRUSH ) ); rDraw.right --; FillRect( dis->hDC, &rDraw, GetSysColorBrush( COLOR_3DFACE ) ); Draw3dRect( dis->hDC, &rDraw, GetSysColorBrush( COLOR_3DHILIGHT ), GetSysColorBrush( COLOR_3DSHADOW ) ); InflateRect( &rDraw, -3, -3 ); Draw3dRect( dis->hDC, &rDraw, GetSysColorBrush( COLOR_3DSHADOW ), GetSysColorBrush( COLOR_3DHILIGHT ) ); if( !wrapper->IsHidden( ) ) { DrawIconEx( dis->hDC, rDraw.left, rDraw.top, disabled ? nav->mVisibleIconDisabled : nav->mVisibleIcon, 16, 16, 0, NULL, DI_NORMAL ); } CopyRect( &rDraw, &dis->rcItem ); rDraw.left += GENAV_ITEMHEIGHT; rDraw.left += 1; if( dis->itemState & ODS_SELECTED ) { FillRect( dis->hDC, &rDraw, GetSysColorBrush( COLOR_HIGHLIGHT ) ); } else { FillRect( dis->hDC, &rDraw, GetSysColorBrush( COLOR_WINDOW ) ); } if( wrapper->CanHaveChildren( ) && window->GetChildCount( ) ) { if( wrapper->IsExpanded( ) ) { DrawIconEx( dis->hDC, rDraw.left + offset, rDraw.top + 3, nav->mCollapseIcon, 16, 16, 0, NULL, DI_NORMAL ); } else { DrawIconEx( dis->hDC, rDraw.left + offset, rDraw.top + 3, nav->mExpandIcon, 16, 16, 0, NULL, DI_NORMAL ); } } HPEN pen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DSHADOW ) ); HPEN oldpen = ( HPEN )SelectObject( dis->hDC, pen ); MoveToEx( dis->hDC, rDraw.left, dis->rcItem.top, NULL ); LineTo( dis->hDC, dis->rcItem.right, dis->rcItem.top ); MoveToEx( dis->hDC, rDraw.left, dis->rcItem.bottom, NULL ); LineTo( dis->hDC, dis->rcItem.right, dis->rcItem.bottom ); SelectObject( dis->hDC, oldpen ); DeleteObject( pen ); rDraw.left += offset; rDraw.left += 20; int colorIndex = ( ( dis->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT ); SetTextColor( dis->hDC, GetSysColor( colorIndex ) ); DrawText( dis->hDC, name, name.Length(), &rDraw, DT_LEFT | DT_VCENTER | DT_SINGLELINE ); if( wrapper->GetVariableDict().GetNumKeyVals( ) || wrapper->GetScriptDict().GetNumKeyVals( ) ) { DrawIconEx( dis->hDC, dis->rcItem.right - 16, ( dis->rcItem.bottom + dis->rcItem.top ) / 2 - 6, ( dis->itemState & ODS_SELECTED ) ? nav->mScriptsLightIcon : nav->mScriptsIcon, 13, 13, 0, NULL, DI_NORMAL ); } } break; } case WM_MEASUREITEM: { MEASUREITEMSTRUCT *mis = ( MEASUREITEMSTRUCT * ) lParam; mis->itemHeight = 22; break; } case WM_CREATE: { LPCREATESTRUCT cs; LVCOLUMN col; // Attach the class to the window first cs = ( LPCREATESTRUCT ) lParam; nav = ( rvGENavigator * ) cs->lpCreateParams; SetWindowLong( hWnd, GWL_USERDATA, ( LONG )nav ); // Create the List view nav->mTree = CreateWindowEx( 0, "SysListView32", "", WS_VSCROLL | WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_OWNERDRAWFIXED | LVS_NOCOLUMNHEADER | LVS_SHOWSELALWAYS, 0, 0, 0, 0, hWnd, ( HMENU )IDC_GUIED_WINDOWTREE, win32.hInstance, 0 ); ListView_SetExtendedListViewStyle( nav->mTree, LVS_EX_FULLROWSELECT ); ListView_SetBkColor( nav->mTree, GetSysColor( COLOR_3DFACE ) ); ListView_SetTextBkColor( nav->mTree, GetSysColor( COLOR_3DFACE ) ); nav->mListWndProc = ( WNDPROC )GetWindowLong( nav->mTree, GWL_WNDPROC ); SetWindowLong( nav->mTree, GWL_USERDATA, ( LONG )nav ); SetWindowLong( nav->mTree, GWL_WNDPROC, ( LONG )ListWndProc ); // Insert the only column col.mask = 0; ListView_InsertColumn( nav->mTree, 0, &col ); break; } case WM_SIZE: { RECT rClient; MoveWindow( nav->mTree, 0, 0, LOWORD( lParam ), HIWORD( lParam ), TRUE ); GetClientRect( nav->mTree, &rClient ); ListView_SetColumnWidth( nav->mTree, 0, rClient.right - rClient.left - 1 ); break; } case WM_NCACTIVATE: return gApp.ToolWindowActivate( gApp.GetMDIFrame(), msg, wParam, lParam ); case WM_NOTIFY: { LPNMHDR nh; nh = ( LPNMHDR ) lParam; switch( nh->code ) { case NM_CLICK: case NM_DBLCLK: { DWORD dwpos = GetMessagePos(); LVHITTESTINFO info; info.pt.x = LOWORD( dwpos ); info.pt.y = HIWORD( dwpos ); MapWindowPoints( HWND_DESKTOP, nh->hwndFrom, &info.pt, 1 ); int index = ListView_HitTest( nav->mTree, &info ); if( index != -1 ) { RECT rItem; int offset; ListView_GetItemRect( nav->mTree, index, &rItem, LVIR_BOUNDS ); LVITEM item; item.mask = LVIF_PARAM; item.iItem = index; ListView_GetItem( nav->mTree, &item ); idWindow *window = ( idWindow * )item.lParam; rvGEWindowWrapper *wrapper = rvGEWindowWrapper::GetWrapper( window ); offset = wrapper->GetDepth( ) * 10 + 1; if( info.pt.x < GENAV_ITEMHEIGHT ) { if( !rvGEWindowWrapper::GetWrapper( window )->IsHidden( ) ) { nav->mWorkspace->HideWindow( window ); } else { nav->mWorkspace->UnhideWindow( window ); } } else if( info.pt.x > GENAV_ITEMHEIGHT + offset && info.pt.x < GENAV_ITEMHEIGHT + offset + 16 ) { if( wrapper->CanHaveChildren( ) && window->GetChildCount( ) ) { if( wrapper->IsExpanded( ) ) { wrapper->Collapse( ); nav->Update( ); } else { wrapper->Expand( ); nav->Update( ); } } } else if( nh->code == NM_DBLCLK ) { SendMessage( gApp.GetMDIFrame( ), WM_COMMAND, MAKELONG( ID_GUIED_ITEM_PROPERTIES, 0 ), 0 ); } } break; } case NM_RCLICK: { DWORD dwpos = GetMessagePos(); LVHITTESTINFO info; info.pt.x = LOWORD( dwpos ); info.pt.y = HIWORD( dwpos ); MapWindowPoints( HWND_DESKTOP, nh->hwndFrom, &info.pt, 1 ); int index = ListView_HitTest( nav->mTree, &info ); if( index != -1 ) { ClientToScreen( hWnd, &info.pt ); HMENU menu = GetSubMenu( LoadMenu( gApp.GetInstance(), MAKEINTRESOURCE( IDR_GUIED_ITEM_POPUP ) ), 0 ); TrackPopupMenu( menu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, info.pt.x, info.pt.y, 0, gApp.GetMDIFrame( ), NULL ); DestroyMenu( menu ); } break; } case LVN_ITEMCHANGED: { NMLISTVIEW *nml = ( NMLISTVIEW * ) nh; if( ( nml->uNewState & LVIS_SELECTED ) != ( nml->uOldState & LVIS_SELECTED ) ) { LVITEM item; item.iItem = nml->iItem; item.mask = LVIF_PARAM; ListView_GetItem( nav->mTree, &item ); if( nml->uNewState & LVIS_SELECTED ) { nav->mWorkspace->GetSelectionMgr().Add( ( idWindow * )item.lParam, false ); } else { nav->mWorkspace->GetSelectionMgr().Remove( ( idWindow * )item.lParam ); } } break; } } break; } } return DefWindowProc( hWnd, msg, wParam, lParam ); }
void cListCtrl::SetMargin(const RECT * textRelRect) { CopyRect(&m_textRelRect, textRelRect); }