///////////////////////////////////////////////// // CTile::gdiDrawFG // // Action: draw the tile // // Params: hdc: hdc to draw to // x: x pixel to draw to // y: y pixel to draw to // // Returns: VOID //////////////////////////////////////////////// VOID FAST_CALL CTile::gdiDrawFG(CONST INT hdc, CONST INT x, CONST INT y) { if (m_bIsometric) { m_pCnvForegroundIso->Blt( HDC(hdc), x, y, m_nFgIdxIso, SRCPAINT ); } else { m_pCnvForeground->Blt( HDC(hdc), x, y, m_nFgIdx, SRCPAINT ); } }
HDC Surface1::getDC(BOOL Discard) { HDC phdc = HDC(); HRESULT hr = getRawInterface()->GetDC(Discard, &phdc); if(FAILED(hr)) throw COMException(hr, "IDXGISurface1::GetDC"); return phdc; }
LRESULT ViewCaption::OnPrintClient(WPARAM wdc, LPARAM flags) { if (CDC* dc= CDC::FromHandle(HDC(wdc))) OnEraseBkgnd(dc); return 0; }
void CMDITabs::OnPaint() { CPaintDC dc(this); if (GetItemCount() == 0) return; // do nothing int dcState = dc.SaveDC(); // windows should draw the control as usual _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); pThreadState->m_lastSentMsg.wParam = WPARAM(HDC(dc)); Default(); dc.RestoreDC(dcState); DWORD face = ::GetSysColor(COLOR_3DFACE); if (m_bTop) { CRect rect(0, m_height - 7, m_width, m_height); dc.FillSolidRect(&rect, face); } else { CRect rect(0, 0, m_width, 3); dc.FillSolidRect(&rect, face); } }
WIN32WindowBase::WIN32WindowBase(void) : Inherited(), _sfHwnd (HWND(0)), _sfHdc (HDC(0)), _sfHglrc (HGLRC(0)), _sfDummy0 (Int32(0)) { }
INT_PTR TquantPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_Q_I_MIN: case IDC_ED_Q_I_MAX: case IDC_ED_Q_P_MIN: case IDC_ED_Q_P_MAX: case IDC_ED_Q_B_MIN: case IDC_ED_Q_B_MAX: case IDC_ED_Q_MB_MIN: case IDC_ED_Q_MB_MAX: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_Q_I_MIN : eval(hed, parent->qmin, parent->qmax, IDFF_enc_q_i_min); break; case IDC_ED_Q_I_MAX : eval(hed, parent->qmin, parent->qmax, IDFF_enc_q_i_max); break; } return TRUE; } break; } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_Q_I_MIN: case IDC_ED_Q_I_MAX: ok = eval(hwnd, parent->qmin, parent->qmax); break; default: goto colorEnd; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } colorEnd: ; } } return TconfPageEnc::msgProc(uMsg, wParam, lParam); }
INT_PTR TquantTablesPageBase::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) { HWND hed=GetDlgItem(m_hwnd,LOWORD(wParam)); if (hed!=GetFocus()) { return FALSE; } repaint(hed); TwidgetMatrix *item=(TwidgetMatrix*)Twidget::getDlgItem(hed); if (item->id) { int valI; if (eval(hed,1,255,&valI)) { uint8_t *intra8,*inter8,*intra4Y,*inter4Y,*intra4C,*inter4C; getCustomQuantMatrixes(&intra8,&inter8,&intra4Y,&inter4Y,&intra4C,&inter4C); uint8_t *intra,*inter; switch (cbxGetCurSel(IDC_CBX_QUANT_TABLE)) { case 1: intra=intra4Y; inter=inter4Y; break; case 2: intra=intra4C; inter=inter4C; break; default: intra=intra8; inter=inter8; break; } (item->intra?intra:inter)[item->id-1]=(uint8_t)valI; setChange(); } } return TRUE; } break; case WM_CTLCOLOREDIT: { HWND hwnd=HWND(lParam); if (hwnd==GetDlgItem(m_hwnd,IDC_CBX_QUANT_TABLE)) { break; } bool ok=eval(hwnd,1,255); if (!ok) { HDC dc=HDC(wParam); SetBkColor(dc,RGB(255,0,0)); return INT_PTR(getRed()); } else { return FALSE; } } } return Twindow::msgProc(uMsg,wParam,lParam); }
//-------------------------------------------------------------------------- // Close a canvas' HDC //-------------------------------------------------------------------------- BOOL APIENTRY CNVCloseHDC( CONST CNV_HANDLE cnv, CONST INT hdc ) { // Close the canvas' HDC reinterpret_cast<CCanvas *>(cnv)->CloseDC(HDC(hdc)); // All's good return TRUE; }
template<class TbindEdit> bool Twindow::onCtlColorEdit(TbindEdit *bindsEdit,LPARAM lParam,WPARAM wParam) { HWND hwnd=HWND(lParam); int id=getId(hwnd); for (int i=0; bindsEdit[i].idc; i++) if (bindsEdit[i].idc==id) if (!eval(hwnd,bindsEdit[i].min,bindsEdit[i].max)) { HDC dc=HDC(wParam); SetBkColor(dc,RGB(255,0,0)); return true; } return false; }
//-------------------------------------------------------------------------- // Resize a canvas //-------------------------------------------------------------------------- BOOL APIENTRY CNVResize( CONST CNV_HANDLE cnv, CONST INT hdcCompatible, CONST INT nWidth, CONST INT nHeight ) { // Resize the canvas reinterpret_cast<CCanvas *>(cnv)->Resize(HDC(hdcCompatible), nWidth, nHeight); // All's good return TRUE; }
//-------------------------------------------------------------------------- // Kill the canvas host //-------------------------------------------------------------------------- VOID APIENTRY CNVKillCanvasHost( CONST INT hInstance, CONST INT hCanvasHostDC ) { // Release the window's DC ReleaseDC(m_hHostWnd, HDC(hCanvasHostDC)); // Destroy the window DestroyWindow(m_hHostWnd); // Unregister the windows class UnregisterClass("canvasHost", HINSTANCE(hInstance)); }
//-------------------------------------------------------------------------- // Create a canvas //-------------------------------------------------------------------------- CNV_HANDLE APIENTRY CNVCreate( CONST INT hdcCompatable, CONST INT nWidth, CONST INT nHeight, CONST INT nUseDX ) { // Allocate a new canvas CCanvas *cnv = new CCanvas(); // Create the canvas cnv->CreateBlank(HDC(hdcCompatable), nWidth, nHeight, nUseDX); // Push the canvas onto the list m_canvases.push_back(cnv); // Return the canvas' address return reinterpret_cast<CNV_HANDLE>(cnv); }
INT_PTR TresizeAspectPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_HSCROLL: switch (GetWindowLong(HWND(lParam), GWL_ID)) { case IDC_TBR_ASPECT_USER: { int a = tbrGet(IDC_TBR_ASPECT_USER); cfgSet(IDFF_aspectRatio, a * 256); userAspect2dlg(); return TRUE; } case IDC_TBR_HWOVERLAY_ASPECT: { int a = tbrGet(IDC_TBR_HWOVERLAY_ASPECT); cfgSet(IDFF_hwOverlayAspect, a * 256); aspect2dlg(); return TRUE; } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_RESIZEDX: case IDC_ED_RESIZEDY: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); applyResizeXY(); return TRUE; } break; case IDC_BT_RESIZE_XCOND: if (HIWORD(wParam) == BN_CLICKED) { cfgSet(IDFF_resizeIfXcond, -1 * cfgGet(IDFF_resizeIfXcond)); resizeIf2dlg(); return TRUE; } break; case IDC_BT_RESIZE_YCOND: if (HIWORD(wParam) == BN_CLICKED) { cfgSet(IDFF_resizeIfYcond, -1 * cfgGet(IDFF_resizeIfYcond)); resizeIf2dlg(); return TRUE; } break; case IDC_BT_RESIZE_XYCOND: if (HIWORD(wParam) == BN_CLICKED) { cfgSet(IDFF_resizeIfXYcond, 1 - cfgGet(IDFF_resizeIfXYcond)); resizeIf2dlg(); return TRUE; } break; case IDC_BT_RESIZE_PIXCOND: if (HIWORD(wParam) == BN_CLICKED) { cfgSet(IDFF_resizeIfPixCond, -1 * cfgGet(IDFF_resizeIfPixCond)); resizeIf2dlg(); return TRUE; } break; } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_RESIZEDX: ok = sizeXok(hwnd); break; case IDC_ED_RESIZEDY: ok = sizeYok(hwnd); break; default: goto colorEnd; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } colorEnd: ; break; } case WM_DRAWITEM: switch (wParam) { case IDC_BT_RESIZE_PIXCOND: case IDC_BT_RESIZE_XCOND: case IDC_BT_RESIZE_YCOND: case IDC_BT_RESIZE_XYCOND: { DRAWITEMSTRUCT *dis = (LPDRAWITEMSTRUCT)lParam; ((TflatButton*)Twidget::getDlgItem(dis->hwndItem))->paint(dis); return TRUE; } } break; } return TconfPageDecVideo::msgProc(uMsg, wParam, lParam); }
INT_PTR TffdshowPageEnc::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_HSCROLL: if (HWND(lParam) == GetDlgItem(m_hwnd, IDC_TBR_QUICK)) { if (valIdff) { cfgSet(valIdff, tbrGet(IDC_TBR_QUICK)); quick2dlg(false); } return TRUE; } break; case WM_FFONCHANGE: if (wParam == IDFF_lang && ve) { ve->commonOptionChanged(IID_IffdshowEnc, IDFF_lang); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CBX_ENCODER: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_codecId, ((Tencoder*)cbxGetCurItemData(IDC_CBX_ENCODER))->id); codec2dlg(); HTREEITEM hti = TreeView_GetSelection(htv); if (hti) { selectPage(hti2page(hti)); } return TRUE; } break; case IDC_CBX_FOURCC: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_fourcc, (int)cbxGetCurItemData(IDC_CBX_FOURCC)); fourcc2dlg(); return TRUE; } break; case IDC_CBX_MODES: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_mode, (int)cbxGetCurItemData(IDC_CBX_MODES)); quick2dlg(true); return TRUE; } break; case IDC_ED_QUICK: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_QUICK: eval(hed, valMin, valMax, valIdff); tbrSet(IDC_TBR_QUICK, cfgGet(valIdff)); break; } return TRUE; } break; case IDC_BT_PRESET: if (HIWORD(wParam) == BN_CLICKED) { showPresets(); return TRUE; } break; case IDC_CHB_NOT_REGISTRY: cfgSet(IDFF_notreg, getCheck(IDC_CHB_NOT_REGISTRY)); return TRUE; } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_QUICK: ok = eval(hwnd, valMin, valMax); break; default: return FALSE; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } } case WM_DRAWITEM: if (wParam == IDC_CBX_ENCODER) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam; COLORREF crOldTextColor = GetTextColor(dis->hDC); COLORREF crOldBkColor = GetBkColor(dis->hDC); HBRUSH br; if ((dis->itemAction | ODA_SELECT) && (dis->itemState & ODS_SELECTED)) { SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHT)); br = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); } else { br = CreateSolidBrush(crOldBkColor); } FillRect(dis->hDC, &dis->rcItem, br); if (int(dis->itemData) != CB_ERR) { RECT r = dis->rcItem; r.left += 2; Tencoder *enc = (Tencoder*)dis->itemData; DrawText(dis->hDC, enc->name, (int)strlen(enc->name), &r, DT_LEFT | DT_SINGLELINE | DT_VCENTER); setDlgResult(TRUE); r.left += 180; FillRect(dis->hDC, &r, br); MoveToEx(dis->hDC, r.left, r.top, NULL); LineTo(dis->hDC, r.left, r.bottom); SetTextColor(dis->hDC, GetSysColor(COLOR_GRAYTEXT)); r.left += 4; char_t text[70]; SendMessage(hcbxE, CB_GETLBTEXT, dis->itemID, LPARAM(text)); DrawText(dis->hDC, text, (int)strlen(text), &r, DT_LEFT | DT_SINGLELINE | DT_VCENTER); } SetTextColor(dis->hDC, crOldTextColor); SetBkColor(dis->hDC, crOldBkColor); DeleteObject(br); return TRUE; } break; } return TffdshowPageBase::msgProc(uMsg, wParam, lParam); }
LRESULT MainWindow::wndProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_NCHITTEST: return HTCAPTION; case WM_CTLCOLORSTATIC: SetTextColor(reinterpret_cast<HDC>(wParam), theme::color(theme::WINDOW_TITLE)); SetBkColor(reinterpret_cast<HDC>(wParam), theme::color(theme::BACKGROUND)); return (LRESULT)GetStockObject(NULL_BRUSH); case WM_CTLCOLORBTN: return (LRESULT)theme::brush(theme::BACKGROUND); case WM_ERASEBKGND: { HDC dc = HDC(wParam); RECT r; GetClientRect(m_wnd, &r); SelectObject(dc, theme::brush(theme::BACKGROUND)); SelectObject(dc, theme::pen(theme::LINE)); Rectangle(dc, r.left, r.top, r.right, r.bottom); return 1; } case WM_MENUCOMMAND: { HMENU menu = (HMENU)lParam; int idx = wParam; switch (GetMenuItemID(menu, idx)) { case ID_USER_MENU: { MENUITEMINFO info; info.cbSize = sizeof(info); info.fMask = MIIM_DATA; GetMenuItemInfo(menu, idx, TRUE, &info); auto& item = m_menuItems[info.dwItemData]; Table* table = nullptr; for (auto t : m_tables) { if (t->isVisible()) { table = t; break; } } table->launch(item.verb.c_str(), item.path.c_str(), item.args.c_str(), false); break; } case ID_MENU_REFRESH: refresh(); break; case IDM_ABOUT: m_inDialog = true; DialogBox(m_instance, MAKEINTRESOURCE(IDD_ABOUTBOX), m_wnd, about); m_inDialog = false; break; case IDM_EXIT: PostQuitMessage(0); break; case IDM_SETTINGS: { m_inDialog = true; auto ok = ShowSettingsDialog(m_wnd); if (ok) { applySettings(); } m_inDialog = false; break; } } break; } case WM_COMMAND: { int wmId = LOWORD(wParam); switch (wmId) { case IDC_MENU: { HMENU menu = createMenu(); RECT rect; GetWindowRect(GetDlgItem(m_wnd, IDC_MENU), &rect); TrackPopupMenu(menu, TPM_RIGHTALIGN | TPM_TOPALIGN, rect.right, rect.bottom, 0, m_wnd, NULL); break; } case IDC_TAB: switchTab(); return 0; case IDC_EMPTY_LINK: { m_inDialog = true; auto ok = ShowSettingsDialog(m_wnd, SETTINGS_CONTENT); if (ok) { applySettings(); } m_inDialog = false; break; } default: return DefWindowProc(m_wnd, message, wParam, lParam); } } break; case WM_DRAWITEM: { auto draw = reinterpret_cast<LPDRAWITEMSTRUCT>(lParam); FillRect(draw->hDC, &draw->rcItem, theme::brush(theme::BACKGROUND)); SelectPen(draw->hDC, theme::pen(theme::TEXT)); SelectBrush(draw->hDC, theme::brush(theme::TEXT)); const int radius = 4; Ellipse(draw->hDC, 0, 12, radius, 12 + radius); Ellipse(draw->hDC, 8, 12, radius + 8, 12 + radius); Ellipse(draw->hDC, 16, 12, radius + 16, 12 + radius); break; } case WM_ACTIVATEAPP: if (!m_inDialog && wParam == FALSE && settings::settings()[L"general"][L"bottomWindow"].asNumber() == 0) { PostQuitMessage(0); } break; case WM_MOVE: { RECT r; GetWindowRect(m_wnd, &r); settings::cache()[L"left"] = simplejson::Value::number(r.left); settings::cache()[L"top"] = simplejson::Value::number(r.top); settings::saveCache(); break; } default: return DefWindowProc(m_wnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK notifier_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) { switch( msg ) { case WM_ERASEBKGND: { HDC dc = HDC(wp); RECT rc; GetClientRect( hwnd, &rc ); SetBkColor( dc, GetSysColor(COLOR_INFOBK) ); ExtTextOut( dc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL ); FrameRect( dc, &rc, GetSysColorBrush(COLOR_WINDOWFRAME )); return TRUE; } case WM_CTLCOLORSTATIC: { HDC dc = HDC(wp); HWND item = (HWND)lp; LONG id = GetWindowLong( item, GWL_ID ); if ( id == IDC_TITLE ) { SetBkColor( dc, GetSysColor(COLOR_ACTIVECAPTION) ); SetTextColor( dc, GetSysColor(COLOR_CAPTIONTEXT) ); return (LRESULT)GetSysColorBrush(COLOR_ACTIVECAPTION); } else if ( id == IDC_CHANGELOG ) { SetBkColor( dc, GetSysColor(COLOR_WINDOW) ); return (LRESULT)GetSysColorBrush(COLOR_WINDOW); } else { SetBkColor( dc, GetSysColor(COLOR_INFOBK) ); return (LRESULT)GetSysColorBrush(COLOR_INFOBK); } } case WM_COMMAND: switch( LOWORD(wp) ) { case IDOK: _tcscpy( url_file_name, _T("win32-chewing-") ); _tcscat( url_file_name, version ); _tcscat( url_file_name, _T(".exe") ); ShellExecute( NULL, "open", url, NULL, NULL, SW_SHOWNORMAL ); DestroyWindow( hwnd ); return TRUE; case IDCANCEL: DestroyWindow( hwnd ); return TRUE; case IDC_WEBPAGE: if( news_url && *news_url ) { ShellExecute( NULL, "open", news_url, NULL, NULL, SW_SHOWNORMAL ); } } break; case WM_INITDIALOG: SetDlgItemText( hwnd, IDC_VERSION, version ); SetDlgItemText( hwnd, IDC_RELEASEDTIME, released_time ); SetDlgItemText( hwnd, IDC_CHANGELOG, change_log ); SendMessage( GetDlgItem(hwnd, IDC_INFOICON), STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_INFORMATION), 0 ); if( ! has_new_version ) { SetDlgItemText( hwnd, IDC_TITLE, "您的新酷音已經是最新版本" ); EnableWindow( GetDlgItem( hwnd, IDOK), FALSE ); } return TRUE; case WM_DESTROY: PostQuitMessage(0); break; } return FALSE; }
HRESULT TcropNzoomPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: if (red) DeleteObject(red); return TRUE; case WM_HSCROLL: if (HWND(lParam)==GetDlgItem(m_hwnd,IDC_TBR_ZOOMX) || HWND(lParam)==GetDlgItem(m_hwnd,IDC_TBR_ZOOMY)) { cfgSet(IDFF_magnificationX,SendDlgItemMessage(m_hwnd,IDC_TBR_ZOOMX,TBM_GETPOS,0,0)); cfgSet(IDFF_magnificationY,SendDlgItemMessage(m_hwnd,IDC_TBR_ZOOMY,TBM_GETPOS,0,0)); crop2dlg(); return TRUE; } else break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CHB_CROPNZOOM: setInter(getCheck(IDC_CHB_CROPNZOOM)); parent->drawInter(); return TRUE; case IDC_RBT_ZOOM: case IDC_RBT_CROP: cfgSet(IDFF_isZoom,getCheck(IDC_RBT_ZOOM)); return TRUE; case IDC_CHB_MAGNIFICATION_LOCKED: cfgSet(IDFF_magnificationLocked,getCheck(IDC_CHB_MAGNIFICATION_LOCKED)); crop2dlg(); return TRUE; case IDC_ED_CROP_LEFT: case IDC_ED_CROP_RIGHT: case IDC_ED_CROP_TOP: case IDC_ED_CROP_BOTTOM: if (HIWORD(wParam)==EN_CHANGE) { HWND hed=GetDlgItem(m_hwnd,LOWORD(wParam)); if (hed!=GetFocus()) return FALSE; InvalidateRect(hed,NULL,TRUE); BOOL ok; if (cropOK(GetDlgItem(m_hwnd,IDC_ED_CROP_LEFT ))) cfgSet(IDFF_cropLeft ,GetDlgItemInt(m_hwnd,IDC_ED_CROP_LEFT ,&ok,FALSE)); if (cropOK(GetDlgItem(m_hwnd,IDC_ED_CROP_RIGHT ))) cfgSet(IDFF_cropRight ,GetDlgItemInt(m_hwnd,IDC_ED_CROP_RIGHT ,&ok,FALSE)); if (cropOK(GetDlgItem(m_hwnd,IDC_ED_CROP_TOP ))) cfgSet(IDFF_cropTop ,GetDlgItemInt(m_hwnd,IDC_ED_CROP_TOP ,&ok,FALSE)); if (cropOK(GetDlgItem(m_hwnd,IDC_ED_CROP_BOTTOM))) cfgSet(IDFF_cropBottom,GetDlgItemInt(m_hwnd,IDC_ED_CROP_BOTTOM,&ok,FALSE)); return TRUE; } break; } break; case WM_CTLCOLOREDIT: { HWND hwnd=HWND(lParam); if (hwnd!=GetDlgItem(m_hwnd,IDC_ED_CROP_LEFT) && hwnd!=GetDlgItem(m_hwnd,IDC_ED_CROP_RIGHT) && hwnd!=GetDlgItem(m_hwnd,IDC_ED_CROP_TOP) && hwnd!=GetDlgItem(m_hwnd,IDC_ED_CROP_BOTTOM)) return FALSE; if (!red) red=CreateSolidBrush(RGB(255,0,0)); if (!cropOK(hwnd)) { HDC dc=HDC(wParam); SetBkColor(dc,RGB(255,0,0)); return HRESULT(red); } else return FALSE; } } return FALSE; }
INT_PTR CALLBACK DialogProc( HWND hWnd, // handle to dialog box UINT msg, // message WPARAM wParam, // first message parameter LPARAM lParam) // second message parameter { switch (msg) { case WM_INITDIALOG: { DWORD common_control_lib_version= GetDllVersion(_T("comctl32.dll")); g_update_common_ctrls = common_control_lib_version < PACKVERSION(5,80); // anything below 5.80 is worth upgrading //{ // ::MessageBox(hWnd, _T("ExifPro requires Common Controls library (ComCtl32.dll) version 4.71 or higher.\n\n") // _T("This library can be found on the Microsoft download site either as a stand-alone \n") // _T("component or part of the Internet Explorer 4.0 or later install package."), // g_INSTALLER, MB_OK | MB_ICONERROR); // ::EndDialog(hWnd, IDCANCEL); // return false; //} } if (g_update_common_ctrls) { // hide it--comctl updater needs to restart ::ShowWindow(::GetDlgItem(hWnd, IDC_RUN), SW_HIDE); } { HICON icon= ::LoadIcon(g_instance_handle, MAKEINTRESOURCE(IDR_MAINFRAME)); ::SendMessage(hWnd, WM_SETICON, ICON_SMALL, LPARAM(icon)); ::SendMessage(hWnd, WM_SETICON, ICON_BIG, LPARAM(icon)); } { HDC dc= ::GetWindowDC(hWnd); int log_pixels_y= ::GetDeviceCaps(dc, LOGPIXELSY); ::ReleaseDC(hWnd, dc); // create title font { HFONT font= static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT)); LOGFONT lf; ::GetObject(font, sizeof lf, &lf); lf.lfWeight = FW_BOLD; lf.lfHeight = -MulDiv(18, log_pixels_y, 96); lf.lfWidth = 0; lf.lfQuality = ANTIALIASED_QUALITY; _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Tahoma")); g_fntTitle = ::CreateFontIndirect(&lf); } // create license info font { HFONT font= static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT)); LOGFONT lf; ::GetObject(font, sizeof lf, &lf); lf.lfWeight = FW_NORMAL; lf.lfHeight = -MulDiv(9, log_pixels_y, 96); lf.lfWidth = 0; //lf.lfQuality = ANTIALIASED_QUALITY; _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Small Fonts")); g_fntLicense = ::CreateFontIndirect(&lf); } } g_camera_image = ::ImageList_LoadImage(g_instance_handle, MAKEINTRESOURCE(IDB_CAMERA), 48, 0, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION); { TCHAR path[2 * MAX_PATH]= _T("c:\\Program Files"); ITEMIDLIST* idl= 0; if (g_IsWindows64) { if (HINSTANCE dll= ::LoadLibrary(_T("shell32.dll"))) { typedef HRESULT (STDAPICALLTYPE *FN_SHGetKnownFolderIDList)(REFKNOWNFOLDERID, DWORD, HANDLE, PIDLIST_ABSOLUTE*); FN_SHGetKnownFolderIDList SHGetKnownFolderIDListFn= reinterpret_cast<FN_SHGetKnownFolderIDList>(::GetProcAddress(dll, "SHGetKnownFolderIDList")); if (SHGetKnownFolderIDListFn) { if (SHGetKnownFolderIDListFn(FOLDERID_ProgramFilesX64, 0, HANDLE(0), &idl) == S_OK) { ::SHGetPathFromIDList(idl, path); IMallocPtr malloc; if (::SHGetMalloc(&malloc) == 0) malloc->Free(idl); } } ::FreeLibrary(dll); } if (idl == 0) { TCHAR buffer[MAX_PATH]; DWORD d= ::GetEnvironmentVariable(_T("ProgramW6432"), buffer, MAX_PATH); if (d > 0) _tcscpy_s(path, MAX_PATH, buffer); } } else if (::SHGetSpecialFolderLocation(hWnd, CSIDL_PROGRAM_FILES, &idl) == 0) { ::SHGetPathFromIDList(idl, path); IMallocPtr malloc; if (::SHGetMalloc(&malloc) == 0) malloc->Free(idl); } _tcscat_s(path, MAX_PATH * 2, _T("\\ExifPro ") EP_VER); ::SetDlgItemText(hWnd, IDC_FOLDER, path); if (pfnAutoCompleteFn) (*pfnAutoCompleteFn)(::GetDlgItem(hWnd, IDC_FOLDER), SHACF_FILESYSTEM); } ::CheckDlgButton(hWnd, IDC_RUN, 1); ::CheckDlgButton(hWnd, IDC_ADD_ICON, 1); ::CheckDlgButton(hWnd, IDC_PROGRAMS, 1); if (HWND edit= ::GetDlgItem(hWnd, IDC_FOLDER)) ::SendMessage(edit, EM_LIMITTEXT, MAX_PATH - 16, 0); ::SendMessage(hWnd, WM_NEXTDLGCTL, WPARAM(::GetDlgItem(hWnd, IDOK)), 1L); return false; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { TCHAR path[MAX_PATH]= { 0 }; if (::GetDlgItemText(hWnd, IDC_FOLDER, path, MAX_PATH) > 0) { HCURSOR cursor= ::SetCursor(::LoadCursor(0, IDC_WAIT)); if (InstallExifPro(path, !!::IsDlgButtonChecked(hWnd, IDC_ADD_ICON), !!::IsDlgButtonChecked(hWnd, IDC_PROGRAMS))) { if (!g_update_common_ctrls) // if comctl updated it waits for a restart { // launch ExifPro? if (::IsDlgButtonChecked(hWnd, IDC_RUN)) { TCHAR exif[MAX_PATH * 2]= { 0 }; AppendFileName(path, g_EXIF_APP, exif); ::ShellExecute(0, _T("open"), exif, 0, 0, SW_SHOWNORMAL); } else { ::MessageBox(hWnd, _T("ExifPro was installed successfully."), g_INSTALLER, MB_ICONINFORMATION | MB_OK); } } ::EndDialog(hWnd, wParam); } } } return true; case IDCANCEL: ::EndDialog(hWnd, wParam); return TRUE; case IDC_BROWSE_DIR: BrowseDir(hWnd); break; case ID_LICENSE: ShowLicense(); break; } return TRUE; case WM_ERASEBKGND: if (HDC dc= HDC(wParam)) { RECT rect; ::GetClientRect(hWnd, &rect); RECT rectTop= rect; rectTop.bottom = 50; rect.top = rectTop.bottom; ::SetBkMode(dc, OPAQUE); ::SetBkColor(dc, RGB(255,255,255)); ::ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rectTop, 0, 0, 0); ::ImageList_Draw(g_camera_image, 0, dc, 14, 7, ILD_NORMAL); HGDIOBJ hOld= ::SelectObject(dc, g_fntTitle); ::SetTextColor(dc, RGB(0,0,0)); const TCHAR* title= _T("ExifPro ") EP_VER _T(" Installer"); ::ExtTextOut(dc, 74, 13, 0, 0, title, _tcslen(title), 0); ::SelectObject(dc, hOld); ::SetBkColor(dc, ::GetSysColor(COLOR_3DSHADOW)); RECT rectLine= rectTop; rectLine.top = rectLine.bottom - 1; ::ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rectLine, 0, 0, 0); ::SetBkColor(dc, ::GetSysColor(COLOR_3DFACE)); ::ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); hOld = ::SelectObject(dc, g_fntLicense); ::SetTextColor(dc, RGB(0,0,0)); const TCHAR* info= _T("By installing this product, you are agreeing to be bound by the terms of the license."); ::ExtTextOut(dc, rect.left + 16, rect.bottom - 16, 0, 0, info, _tcslen(info), 0); ::SelectObject(dc, hOld); } return true; } return 0; }
void CPlotDlg::DrawTicksFrom(CDC *pDC, CAxis *pax, char xy, int beginPt, int direction) { HDC hdc = HDC(*pDC); double value, ibt/*intervalBetweenTicks*/; int pt2Draw(beginPt), lastpt2Draw, res(1), cum(0); LOGFONT fnt; CSize sz; CStdString label; switch(xy) { case 'x': ibt = (pax->xtick.a2 - pax->xtick.a1) / (pax->xtick.nDiv+1); if (direction) lastpt2Draw=-32767; else lastpt2Draw=32768; while (res) { if (LRrange(&pax->rcAx, pt2Draw, 'x')==0) { pDC->MoveTo(pt2Draw, pax->rcAx.bottom); pDC->LineTo(pt2Draw, pax->rcAx.bottom - pax->xtick.size); value = pax->xtick.mult*(pax->xtick.a1+cum*ibt)+pax->xtick.offset; if (pax->xtick.format[0]!=0) label.Format(pax->xtick.format, value); else sprintfFloat(value, 3, label); GetTextExtentPoint32(hdc, label.c_str(), label.length(), &sz); if (iabs(pt2Draw-lastpt2Draw)> sz.cx + pax->xtick.gap4next.x) // only if there's enough gap, Textout { pDC->TextOut(pt2Draw, pax->rcAx.bottom + pax->xtick.labelPos, label); lastpt2Draw = pt2Draw; } if (direction) cum++; else cum--; pt2Draw = pax->GetPixelAbs(pax->xtick.a1 + cum*ibt, 'x'); res = (LRrange(&pax->rcAx, pt2Draw, 'x')==0); } else // This must anticipate the within-range... (e.g., when going left, it should be left of the range...) { if (direction) cum++; else cum--; pt2Draw = pax->GetPixelAbs(pax->xtick.a1 + cum*ibt, 'x'); } } break; case 'y': fnt = pax->ytick.font.GetLogFont(); // chech before and after here ibt = (pax->ytick.a2 - pax->ytick.a1) / (pax->ytick.nDiv+1); if (direction) lastpt2Draw=-32767; else lastpt2Draw=32768; while (res) { if (LRrange(&pax->rcAx, pt2Draw, 'y')==0) { pDC->MoveTo(pax->rcAx.left, pt2Draw); pDC->LineTo(pax->rcAx.left + pax->ytick.size, pt2Draw); value = pax->ytick.mult*(pax->ytick.a1+cum*ibt)+pax->ytick.offset; if (pax->ytick.format[0]!=0) label.Format(pax->ytick.format, value); else sprintfFloat(value, 3, label); GetTextExtentPoint32(hdc, label.c_str(), label.length(), &sz); if (iabs(pt2Draw-lastpt2Draw)> sz.cy + pax->xtick.gap4next.y) // only if there's enough gap, Textout { pDC->TextOut(pax->rcAx.left - pax->ytick.labelPos, pt2Draw-fnt.lfHeight/2, label); lastpt2Draw = pt2Draw; } if (direction) cum++; else cum--; pt2Draw = pax->GetPixelAbs(pax->ytick.a1+cum*ibt, 'y'); res = (LRrange(&pax->rcAx, pt2Draw, 'y')==0); } else // This must anticipate the within-range... (e.g., when going left, it should be left of the range...) { if (direction) cum++; else cum--; pt2Draw = pax->GetPixelAbs(pax->ytick.a1+cum*ibt, 'y'); } } break; } }
BOOL CTrayNotifyIcon::GetDynamicDCAndBitmap(CDC* pDC, CBitmap* pBitmap) { //Validate our parameters ATLASSERT(pDC != NULL); ATLASSERT(pBitmap != NULL); //Get the HWND for the desktop #ifdef _AFX CWnd* pWndScreen = CWnd::GetDesktopWindow(); if (pWndScreen == NULL) return FALSE; #else CWindow WndScreen(::GetDesktopWindow()); if (!WndScreen.IsWindow()) return FALSE; #endif //Get the desktop HDC to create a compatible bitmap from #ifdef _AFX CDC* pDCScreen = pWndScreen->GetDC(); if (pDCScreen == NULL) return FALSE; #else CDC DCScreen(WndScreen.GetDC()); if (DCScreen.IsNull()) return FALSE; #endif //Get the width and height of a small icon int w = GetSystemMetrics(SM_CXSMICON); int h = GetSystemMetrics(SM_CYSMICON); //Create an off-screen bitmap that the dynamic tray icon //can be drawn into. (Compatible with the desktop DC). #ifdef _AFX BOOL bSuccess = pBitmap->CreateCompatibleBitmap(pDCScreen, w, h); #else BOOL bSuccess = (pBitmap->CreateCompatibleBitmap(DCScreen.operator HDC(), w, h) != NULL); #endif if (!bSuccess) { #ifdef _AFX pWndScreen->ReleaseDC(pDCScreen); #else WndScreen.ReleaseDC(DCScreen); #endif return FALSE; } //Get a HDC to the newly created off-screen bitmap #ifdef _AFX bSuccess = pDC->CreateCompatibleDC(pDCScreen); #else bSuccess = (pDC->CreateCompatibleDC(DCScreen.operator HDC()) != NULL); #endif if (!bSuccess) { //Release the Screen DC now that we are finished with it #ifdef _AFX pWndScreen->ReleaseDC(pDCScreen); #else WndScreen.ReleaseDC(DCScreen); #endif //Free up the bitmap now that we are finished with it pBitmap->DeleteObject(); return FALSE; } //Select the bitmap into the offscreen DC #ifdef _AFX pDC->SelectObject(pBitmap); #else pDC->SelectBitmap(pBitmap->operator HBITMAP()); #endif //Release the Screen DC now that we are finished with it #ifdef _AFX pWndScreen->ReleaseDC(pDCScreen); #else WndScreen.ReleaseDC(DCScreen); #endif return TRUE; }
INT_PTR TvolumePage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_HSCROLL: switch (getId(HWND(lParam))) { case IDC_TBR_VOLUME_MASTER: volTbr2cfg(IDC_TBR_VOLUME_MASTER, IDFF_volume, 1); master2dlg(); return TRUE; } break; case WM_VSCROLL: switch (getId(HWND(lParam))) { case IDC_TBR_VOLUME_L: volTbr2cfg(IDC_TBR_VOLUME_L, IDFF_volumeL, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_C: volTbr2cfg(IDC_TBR_VOLUME_C, IDFF_volumeC, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_R: volTbr2cfg(IDC_TBR_VOLUME_R, IDFF_volumeR, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_SL: volTbr2cfg(IDC_TBR_VOLUME_SL, IDFF_volumeSL, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_SR: volTbr2cfg(IDC_TBR_VOLUME_SR, IDFF_volumeSR, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_AL: volTbr2cfg(IDC_TBR_VOLUME_AL, IDFF_volumeAL, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_AR: volTbr2cfg(IDC_TBR_VOLUME_AR, IDFF_volumeAR, -1); speakers2dlg(); return TRUE; case IDC_TBR_VOLUME_LFE: volTbr2cfg(IDC_TBR_VOLUME_LFE, IDFF_volumeLFE, -1); speakers2dlg(); return TRUE; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_VOLUME_NORMALIZE_MAX: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); parent->setChange(); break; } break; case IDC_CHB_VOLUME_L_MUTE: case IDC_CHB_VOLUME_C_MUTE: case IDC_CHB_VOLUME_R_MUTE: case IDC_CHB_VOLUME_SL_MUTE: case IDC_CHB_VOLUME_SR_MUTE: case IDC_CHB_VOLUME_AL_MUTE: case IDC_CHB_VOLUME_AR_MUTE: case IDC_CHB_VOLUME_LFE_MUTE: { int idff = ((TwidgetMS*)Twidget::getDlgItem((HWND)lParam))->idff; cfgSet(idff, getCheck(LOWORD(wParam))); mute2dlg(); break; } case IDC_CHB_VOLUME_L_SOLO: case IDC_CHB_VOLUME_C_SOLO: case IDC_CHB_VOLUME_R_SOLO: case IDC_CHB_VOLUME_SL_SOLO: case IDC_CHB_VOLUME_SR_SOLO: case IDC_CHB_VOLUME_AL_SOLO: case IDC_CHB_VOLUME_AR_SOLO: case IDC_CHB_VOLUME_LFE_SOLO: { int idff = ((TwidgetMS*)Twidget::getDlgItem((HWND)lParam))->idff; for (int i = 0; i < countof(idffsMS); i++) if (idffsMS[i] == idff) { cfgSet(idff, getCheck(LOWORD(wParam)) ? 2 : 0); } else { cfgSet(idffsMS[i], 0); } mute2dlg(); break; } } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_VOLUME_NORMALIZE_MAX: ok = eval(hwnd, 0, isdb ? 30 : MAX_AMPLIFICATION); break; default: return FALSE; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } } } return TconfPageDecAudio::msgProc(uMsg, wParam, lParam); }
int __stdcall wWinMain(HINSTANCE module, HINSTANCE, wchar_t* cc, int) { static int count = 0; static HPEN pen_dot = ::CreatePen(PS_DOT, 1, RGB(0, 0, 0)); MessageHandler msg_handlers[] = { { WM_PAINT, [] (HWND window, WPARAM, LPARAM) -> LRESULT { PAINTSTRUCT ps; HDC dc = ::BeginPaint(window, &ps); ::Rectangle(dc, 10, 10, 100, 100); ::EndPaint(window, &ps); ++count; return 0; }}, { WM_ERASEBKGND, [] (HWND window, WPARAM wparam, LPARAM) -> LRESULT { RECT rect; VerifyNot(::GetClientRect(window, &rect), FALSE); HGDIOBJ prev_obj = ::SelectObject(HDC(wparam), pen_dot); ::Rectangle(HDC(wparam), rect.left, rect.top, rect.right, rect.bottom); ::SelectObject(HDC(wparam), prev_obj); return 0; }}, { WM_DISPLAYCHANGE, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::InvalidateRect(window, NULL, TRUE); return 0; }}, { WM_CLOSE, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::PostQuitMessage(0); return 0; }}, { WM_ENDSESSION, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::PostQuitMessage(0); return 0; }}, { WM_TIMER, [] (HWND window, WPARAM wp, LPARAM) -> LRESULT { ::KillTimer(window, wp); CleanFiles(window); return 0; }}, {-1, NULL} }; SIZE size = {300, 200}; HWND main_window = VerifyNot(MakeWindow( L"file cleaner", WS_OVERLAPPEDWINDOW | WS_VISIBLE, NULL, size, msg_handlers), HWND(NULL)); CleanFiles(main_window); MSG msg; while (VerifyNot(::GetMessageW(&msg, NULL, 0, 0), -1)) { ::DispatchMessageW(&msg); } return 0; }
INT_PTR TsubtitlesTextPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ED_SUB_MINDURATION: if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) { HWND hed=GetDlgItem(m_hwnd,LOWORD(wParam)); if (hed!=GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_SUB_MINDURATION: { static const int idffmins[]= {IDFF_subMinDurationSub,IDFF_subMinDurationLine,IDFF_subMinDurationChar}; eval(hed,1,3600000,idffmins[cbxGetCurSel(IDC_CBX_SUB_MINDURATION)]); break; } } return TRUE; } break; case IDC_CHB_SUBFIX_AP: case IDC_CHB_SUBFIX_IL: case IDC_CHB_SUBFIX_PUNCTUATION: case IDC_CHB_SUBFIX_ORTOGRAPHY: case IDC_CHB_SUBFIX_CAPITAL: case IDC_CHB_SUBFIX_NUMBERS: case IDC_CHB_SUBFIX_HEARING: { int fix=0; if (getCheck(IDC_CHB_SUBFIX_AP )) { fix|=TtextFixBase::fixAP; } if (getCheck(IDC_CHB_SUBFIX_IL )) { fix|=TtextFixBase::fixIl; } if (getCheck(IDC_CHB_SUBFIX_PUNCTUATION)) { fix|=TtextFixBase::fixPunctuation; } if (getCheck(IDC_CHB_SUBFIX_ORTOGRAPHY )) { fix|=TtextFixBase::fixOrtography; } if (getCheck(IDC_CHB_SUBFIX_CAPITAL )) { fix|=TtextFixBase::fixCapital; } if (getCheck(IDC_CHB_SUBFIX_NUMBERS )) { fix|=TtextFixBase::fixNumbers; } if (getCheck(IDC_CHB_SUBFIX_HEARING )) { fix|=TtextFixBase::fixHearingImpaired; } cfgSet(IDFF_subFix,fix); fix2dlg(); break; } } break; case WM_CTLCOLOREDIT: { HWND hwnd=HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_SUB_MINDURATION: ok=eval(hwnd,1,3600000); break; default: return FALSE; } if (!ok) { HDC dc=HDC(wParam); SetBkColor(dc,RGB(255,0,0)); return INT_PTR(getRed()); } else { return FALSE; } } } return TconfPageDecVideo::msgProc(uMsg,wParam,lParam); }
void CMDITabs::OnPaint() { CPaintDC dc(this); if (GetItemCount() == 0) return; // do nothing // cache some system colors DWORD shadow = ::GetSysColor(COLOR_3DSHADOW); DWORD dark = ::GetSysColor(COLOR_3DDKSHADOW); DWORD hilight = ::GetSysColor(COLOR_3DHILIGHT); DWORD light = ::GetSysColor(COLOR_3DLIGHT); // Special preparations for spin-buttons (in case there are more tabs than fit into the window) // extend borders and prevent system from overdrawing our new pixels if (m_bTop) { ::SetPixel(dc, m_width - 5, m_height - 8, hilight); ::SetPixel(dc, m_width - 5, m_height - 7, light); ::SetPixel(dc, m_width - 6, m_height - 8, hilight); ::SetPixel(dc, m_width - 6, m_height - 7, light); ::ExcludeClipRect(dc, 0, m_height - 6, m_width, m_height - 2); ::ExcludeClipRect(dc, m_width - 6, m_height - 8, m_width - 2, m_height - 6); } else { ::SetPixel(dc, m_width - 5, 2, shadow); ::SetPixel(dc, m_width - 5, 3, dark); ::SetPixel(dc, m_width - 6, 2, shadow); ::SetPixel(dc, m_width - 6, 3, dark); ::ExcludeClipRect(dc, 0, 0, m_width, 2); ::ExcludeClipRect(dc, m_width - 6, 2, m_width - 2, 4); } // windows should draw the control as usual _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); pThreadState->m_lastSentMsg.wParam = WPARAM(HDC(dc)); Default(); // extend the horizontal border to the left margin if (m_bTop) { ::SetPixel(dc, 0, m_height - 8, hilight); ::SetPixel(dc, 0, m_height - 7, light); } else { ::SetPixel(dc, 0, 2, shadow); } // special drawing if the leftmost tab is selected CRect rect; GetItemRect(GetCurSel(), rect); if (rect.left == 2) // is at the leftmost position a tab selected? { // if yes, remove the leftmost white line and extend the bottom border of the tab int j = m_bImages ? 1 : 0; HPEN pen = ::CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DFACE)); HGDIOBJ old = ::SelectObject(dc, pen); ::MoveToEx(dc, 0, 2, NULL); ::LineTo(dc, 0, 22 + j); ::MoveToEx(dc, 1, 2, NULL); ::LineTo(dc, 1, 22 + j); ::SelectObject(dc, old); ::DeleteObject(pen); if (m_bTop) { ::SetPixel(dc, 0, 0, hilight); ::SetPixel(dc, 1, 0, hilight); ::SetPixel(dc, 0, 1, light); ::SetPixel(dc, 1, 1, light); } else { ::SetPixel(dc, 0, 22 + j, shadow); ::SetPixel(dc, 1, 22 + j, shadow); ::SetPixel(dc, 0, 23 + j, dark); ::SetPixel(dc, 1, 23 + j, dark); } } }
//---------------------------------------------------------------------------- LRESULT CALLBACK WinProc (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { FWinApplication* pkTheApp = FWinApplication::GetApplication(); if ( !pkTheApp ) return DefWindowProc(hWnd,uiMsg,wParam,lParam); switch ( uiMsg ) { case WM_CREATE: { LPCREATESTRUCT lpCS = LPCREATESTRUCT(lParam); if ( pkTheApp->OnCreate(lpCS) ) return 0; else return -1; } case WM_DESTROY: { pkTheApp->OnDestroy(); PostQuitMessage(0); return 0; } case WM_PAINT: { PAINTSTRUCT kPS; HDC hDC = BeginPaint(hWnd,&kPS); if ( pkTheApp->OnPaint(hDC) ) { EndPaint(hWnd,&kPS); return 0; } EndPaint(hWnd,&kPS); break; } case WM_ERASEBKGND: { HDC hDC = HDC(hWnd); if ( pkTheApp->OnEraseBkgnd(hDC) ) return 0; break; } case WM_MOVE: { int xPos = int(LOWORD(lParam)); int yPos = int(HIWORD(lParam)); if ( pkTheApp->OnMove(xPos,yPos) ) return 0; break; } case WM_SIZE: { int iWidth = int(LOWORD(lParam)); int iHeight = int(HIWORD(lParam)); unsigned int uiSizeType = (unsigned int)(wParam); if ( pkTheApp->OnSize(iWidth,iHeight,uiSizeType) ) return 0; break; } case WM_COMMAND: { WORD wNotifyCode = HIWORD(wParam); WORD wID = LOWORD(wParam); HWND hwndCtl = HWND(lParam); if ( pkTheApp->OnCommand(wNotifyCode,wID,hwndCtl) ) return 0; break; } case WM_SYSCHAR: { char cCharCode = char(wParam); long lKeyCode = long(lParam); if ( pkTheApp->OnSysChar(cCharCode,lKeyCode) ) return 0; break; } case WM_SYSKEYDOWN: { int iVirtKey = int(wParam); long lKeyCode = long(lParam); if ( pkTheApp->OnSysKeyDown(iVirtKey,lKeyCode) ) return 0; break; } case WM_SYSKEYUP: { int iVirtKey = int(wParam); long lKeyCode = long(lParam); if ( pkTheApp->OnSysKeyUp(iVirtKey,lKeyCode) ) return 0; break; } case WM_CHAR: { char cCharCode = char(wParam); long lKeyData = long(lParam); if ( pkTheApp->OnChar(cCharCode,lKeyData) ) return 0; break; } case WM_KEYDOWN: { int iVirtKey = int(wParam); long lKeyData = long(lParam); if ( pkTheApp->OnKeyDown(iVirtKey,lKeyData) ) return 0; break; } case WM_KEYUP: { int iVirtKey = int(wParam); long lKeyData = long(lParam); if ( pkTheApp->OnKeyUp(iVirtKey,lKeyData) ) return 0; break; } case WM_LBUTTONDOWN: { int iXPos = int(LOWORD(lParam)); int iYPos = int(HIWORD(lParam)); unsigned int uiKeys = (unsigned int)(wParam); if ( pkTheApp->OnLButtonDown(iXPos,iYPos,uiKeys) ) return 0; break; } case WM_LBUTTONUP: { int iXPos = int(LOWORD(lParam)); int iYPos = int(HIWORD(lParam)); unsigned int uiKeys = (unsigned int)(wParam); if ( pkTheApp->OnLButtonUp(iXPos,iYPos,uiKeys) ) return 0; break; } case WM_RBUTTONDOWN: { int iXPos = int(LOWORD(lParam)); int iYPos = int(HIWORD(lParam)); unsigned int uiKeys = (unsigned int)(wParam); if ( pkTheApp->OnRButtonDown(iXPos,iYPos,uiKeys) ) return 0; break; } case WM_RBUTTONUP: { int iXPos = int(LOWORD(lParam)); int iYPos = int(HIWORD(lParam)); unsigned int uiKeys = (unsigned int)(wParam); if ( pkTheApp->OnRButtonUp(iXPos,iYPos,uiKeys) ) return 0; break; } case WM_MOUSEMOVE: { int iXPos = int(LOWORD(lParam)); int iYPos = int(HIWORD(lParam)); unsigned int uiKeys = (unsigned int)(wParam); if ( pkTheApp->OnMouseMove(iXPos,iYPos,uiKeys) ) return 0; break; } default: { if ( pkTheApp->OnDefault(wParam,lParam) ) return 0; break; } } return DefWindowProc(hWnd,uiMsg,wParam,lParam); }