HWND ClockWindow::Create(HWND hwndParent) { static BtnWindowClass wcClock(CLASSNAME_CLOCKWINDOW, CS_DBLCLKS); ClientRect clnt(hwndParent); WindowCanvas canvas(hwndParent); FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT)); RECT rect = {0, 0, 0, 0}; TCHAR buffer[16]; // Arbitrary high time so that the created clock window is big enough SYSTEMTIME st = { 1601, 1, 0, 1, 23, 59, 59, 999 }; if (!GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buffer, sizeof(buffer)/sizeof(TCHAR))) _tcscpy(buffer, TEXT("00:00")); // Calculate the rectangle needed to draw the time (without actually drawing it) DrawText(canvas, buffer, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT); int clockwindowWidth = rect.right-rect.left + 4; return Window::Create(WINDOW_CREATOR(ClockWindow), 0, wcClock, NULL, WS_CHILD|WS_VISIBLE, clnt.right-(clockwindowWidth), 1, clockwindowWidth, clnt.bottom-2, hwndParent); }
/* This function handles the WM_MEASUREITEM message */ void FASTCALL ChangeDir_OnMeasureItem( HWND hwnd, MEASUREITEMSTRUCT FAR * lpMeasureItem ) { static int cyItem = -1; /* Height of a listbox item */ if( !fBitmapsLoaded ) ChangeDir_LoadBitmaps(); if( -1 == cyItem ) { HFONT hFont; HDC hDC; TEXTMETRIC tm; BITMAP bm; /* Attempt to get the font of the dialog. However, * on the first attempt in the life of the dialog, * this could fail; in that case use the system font. */ hFont= GetWindowFont( hwnd ); if( NULL == hFont ) hFont = GetStockFont( SYSTEM_FONT ); hDC = GetDC( hwnd ); hFont = SelectFont( hDC, hFont ); /* Item height is the maximum of the font height and the * bitmap height. We know that all bitmaps are the same * size, so we just get information for one of them. */ GetTextMetrics( hDC, &tm ); GetObject( rghBmpFolders[0], sizeof( bm ), &bm ); cyItem = max( bm.bmHeight, tm.tmHeight ); ReleaseDC( hwnd, hDC ); } lpMeasureItem->itemHeight = cyItem; }
//function to draw the bottom ribbon with table name and db name void TableView::DrawTableInfoRibbon(HDC hdc, RECT drawrect) { HFONT hfontnormal = GetStockFont(DEFAULT_GUI_FONT); HFONT hfontbold = NULL; LOGFONT lf = {0}; RECT recttext; if(m_mydata && m_mydata->m_db.GetLength() && m_mydata->m_table.GetLength()) { GetObject(hfontnormal, sizeof(lf), &lf); lf.lfWeight = FW_SEMIBOLD; hfontbold = CreateFontIndirect(&lf); hfontbold = (HFONT)SelectObject(hdc, hfontbold); memset(&recttext, 0, sizeof(RECT)); DrawText(hdc, _(L"Database:"), -1, &recttext, DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); DrawText(hdc, _(L"Database:"), -1, &drawrect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); hfontbold = (HFONT)SelectObject(hdc, hfontbold); drawrect.left += recttext.right + 5; hfontnormal = (HFONT)SelectObject(hdc, hfontnormal); memset(&recttext, 0, sizeof(RECT)); DrawText(hdc, m_mydata->m_db.GetAsWideChar(), -1, &recttext, DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); DrawText(hdc, m_mydata->m_db.GetAsWideChar(), -1, &drawrect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); hfontnormal = (HFONT)SelectObject(hdc, hfontnormal); drawrect.left += recttext.right + 10; hfontbold = (HFONT)SelectObject(hdc, hfontbold); memset(&recttext, 0, sizeof(RECT)); DrawText(hdc, _(L"Table:"), -1, &recttext, DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); DrawText(hdc, _(L"Table:"), -1, &drawrect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); hfontbold = (HFONT)SelectObject(hdc, hfontbold); drawrect.left += recttext.right + 5; hfontnormal = (HFONT)SelectObject(hdc, hfontnormal); memset(&recttext, 0, sizeof(RECT)); DrawText(hdc, m_mydata->m_table.GetAsWideChar(), -1, &recttext, DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); DrawText(hdc, m_mydata->m_table.GetAsWideChar(), -1, &drawrect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); hfontnormal = (HFONT)SelectObject(hdc, hfontnormal); } if(hfontbold) { DeleteFont(hfontbold); } if(hfontnormal) { DeleteFont(hfontnormal); } }
void ClockWindow::Paint() { PaintCanvas canvas(_hwnd); FillRect(canvas, &canvas.rcPaint, GetSysColorBrush(COLOR_BTNFACE)); BkMode bkmode(canvas, TRANSPARENT); FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT)); DrawText(canvas, _time, -1, ClientRect(_hwnd), DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX); }
GuiCheckButton GuiCheckButton_create (GuiForm parent, int left, int right, int top, int bottom, const wchar_t *buttonText, void (*valueChangedCallback) (void *boss, GuiCheckButtonEvent event), void *valueChangedBoss, unsigned long flags) { GuiCheckButton me = Thing_new (GuiCheckButton); my d_shell = parent -> d_shell; my d_parent = parent; my d_valueChangedCallback = valueChangedCallback; my d_valueChangedBoss = valueChangedBoss; #if gtk my d_widget = gtk_check_button_new_with_label (Melder_peekWcsToUtf8 (buttonText)); _GuiObject_setUserData (my d_widget, me); my v_positionInForm (my d_widget, left, right, top, bottom, parent); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (my d_widget), (flags & GuiCheckButton_SET) != 0); if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } g_signal_connect (G_OBJECT (my d_widget), "destroy", G_CALLBACK (_GuiGtkCheckButton_destroyCallback), me); my d_valueChangedHandlerId = g_signal_connect (GTK_TOGGLE_BUTTON (my d_widget), "toggled", G_CALLBACK (_GuiGtkCheckButton_valueChangedCallback), me); #elif cocoa #elif win my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText); _GuiObject_setUserData (my d_widget, me); my d_widget -> isRadioButton = false; my d_widget -> window = CreateWindow (L"button", _GuiWin_expandAmpersands (buttonText), WS_CHILD | BS_AUTOCHECKBOX | WS_CLIPSIBLINGS, my d_widget -> x, my d_widget -> y, my d_widget -> width, my d_widget -> height, my d_widget -> parent -> window, (HMENU) 1, theGui.instance, NULL); SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget); SetWindowFont (my d_widget -> window, GetStockFont (ANSI_VAR_FONT), FALSE); my v_positionInForm (my d_widget, left, right, top, bottom, parent); if (flags & GuiCheckButton_SET) { Button_SetCheck (my d_widget -> window, BST_CHECKED); } if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } #elif mac my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText); _GuiObject_setUserData (my d_widget, me); my d_widget -> isRadioButton = false; CreateCheckBoxControl (my d_widget -> macWindow, & my d_widget -> rect, NULL, (flags & GuiCheckButton_SET) != 0, true, & my d_widget -> nat.control.handle); Melder_assert (my d_widget -> nat.control.handle != NULL); SetControlReference (my d_widget -> nat.control.handle, (long) my d_widget); my d_widget -> isControl = true; _GuiNativeControl_setFont (my d_widget, 0, 13); _GuiNativeControl_setTitle (my d_widget); my v_positionInForm (my d_widget, left, right, top, bottom, parent); if (flags & GuiCheckButton_INSENSITIVE) { my f_setSensitive (false); } #endif return me; }
/*! AAのサムネ用イメージを作る @param[in] hWnd ウインドウハンドル @param[in,out] pstItem イメージ作りたいAAのデータとか */ UINT DraughtAaImageing( HWND hWnd, LPAAMATRIX pstItem ) { UINT_PTR cchSize; LPTSTR ptTextaa; INT iRslt, iYdot, iXdot, iLine; HDC hdc, hMemDC; HBITMAP hOldBmp; RECT rect; ptTextaa = SjisDecodeAlloc( pstItem->pcItem ); StringCchLength( ptTextaa, STRSAFE_MAX_CCH, &cchSize ); // 元AAのサイズ確定が必要 iXdot = TextViewSizeGet( ptTextaa, &iLine ); iYdot = iLine * LINE_HEIGHT; pstItem->iMaxDot = iXdot; pstItem->iLines = iLine; if( giItemWidth > iXdot ) iXdot = giItemWidth; if( giItemHeight > iYdot ) iYdot = giItemHeight; pstItem->stSize.cx = iXdot; pstItem->stSize.cy = iYdot; SetRect( &rect, 0, 0, iXdot, iYdot ); // あんまり大きいなら、左上限定とか? // 描画用ビットマップ作成 hdc = GetDC( hWnd ); // サムネ用BMP・これはフルサイズ // pstItem->hThumbDC pstItem->hOldBmp hMemDC = CreateCompatibleDC( hdc ); pstItem->hThumbBmp = CreateCompatibleBitmap( hdc, rect.right, rect.bottom ); hOldBmp = SelectBitmap( hMemDC, pstItem->hThumbBmp ); SelectFont( hMemDC, ghAaFont ); ReleaseDC( ghDraughtWnd, hdc ); iRslt = PatBlt( hMemDC, 0, 0, rect.right, rect.bottom, WHITENESS ); iRslt = DrawText( hMemDC, ptTextaa, cchSize, &rect, DT_LEFT | DT_NOPREFIX | DT_NOCLIP | DT_WORDBREAK ); SelectFont( hMemDC, GetStockFont(DEFAULT_GUI_FONT) ); SelectBitmap( hMemDC, hOldBmp ); DeleteDC( hMemDC ); FREE( ptTextaa ); return 0; }
wyBool TabMessage::Create() { wyWChar* items[] = { _(L"All"), _(L"Queries with errors"), _(L"Queries with warnings"), _(L"Queries with errors/warnings"), _(L"Queries with result set"), _(L"Queries without result set") }; wyInt32 count, i, width = 0; HDC hdc; HFONT hfont = GetStockFont(DEFAULT_GUI_FONT); RECT rect = {0}; COMBOBOXINFO cbinfo = {0}; CreateQueryMessageEdit(m_hwndparent, m_pmdi); m_hwndcombo = CreateWindowEx(0, L"combobox", L"", WS_CHILD | CBS_DROPDOWNLIST | WS_VISIBLE, 0, 0, 0, 0, m_hwndparent, (HMENU)IDC_TOOLCOMBO, (HINSTANCE)GetModuleHandle(0), NULL); SendMessage(m_hwndcombo, WM_SETFONT, (WPARAM)hfont, 0); cbinfo.cbSize = sizeof(COMBOBOXINFO); GetComboBoxInfo(m_hwndcombo, &cbinfo); SetWindowLongPtr(cbinfo.hwndList, GWLP_USERDATA, (LONG_PTR)this); //m_origlistproc = (WNDPROC)SetWindowLongPtr(cbinfo.hwndList, GWLP_WNDPROC, (LONG)ComboListProc); count = sizeof(items)/sizeof(items[0]); hdc = GetDC(m_hwndcombo); hfont = SelectFont(hdc, hfont); for(i = 0; i < count; ++i) { SendMessage(m_hwndcombo, CB_ADDSTRING, 0, (LPARAM)items[i]); DrawText(hdc, items[i], -1, &rect, DT_CALCRECT | DT_NOPREFIX); if(rect.right > width) { width = rect.right; } } SelectFont(hdc, hfont); ReleaseDC(m_hwndcombo, hdc); SendMessage(m_hwndcombo, CB_SETCURSEL, 0, 0); GetWindowRect(m_hwndcombo, &rect); SetWindowPos(m_hwndcombo, NULL, 0, 0, width + (cbinfo.rcButton.right - cbinfo.rcButton.left) + 10, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE); //SendMessage(m_hwndcombo, CB_SETDROPPEDWIDTH, width + 10, 0); return wyTrue; }
BOOL CPlugin::initStandAlone() { HWND hWndParent = NULL; // ensure window class WNDCLASS wc; wc.style = 0; wc.lpfnWndProc = DefWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_APP)); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wc.lpszMenuName = NULL; wc.lpszClassName = szStandAlonePluginWindowClassName; // just register the window class, if class already exists GetLastError() // will return ERROR_CLASS_ALREADY_EXISTS, let's not care about it RegisterClass(&wc); hWndParent = CreateWindow(szStandAlonePluginWindowClassName, "The Tester Plugin", WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX, 0, 0, 800, 600, GetDesktopWindow(), NULL, m_hInst, NULL); // m_hWndStandAloneLogWindow = CreateWindow("LISTBOX", "", // WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | LBS_NOINTEGRALHEIGHT, // 200, 3, 590, 562, // hWndParent, NULL, m_hInst, NULL); m_hWndStandAloneLogWindow = CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_READONLY, 200, 3, 590, 562, hWndParent, NULL, m_hInst, NULL); if(!IsWindow(hWndParent)) return FALSE; m_hWndParent = hWndParent; HFONT hFont = GetStockFont(DEFAULT_GUI_FONT); SetWindowFont(m_hWndStandAloneLogWindow, hFont, FALSE); CreateDialogParam(m_hInst, MAKEINTRESOURCE(IDD_DIALOG_TESTER), m_hWndParent, (DLGPROC)TesterDlgProc, (LPARAM)this); m_bPluginReady = (m_hWnd != NULL); return m_bPluginReady; }
BOOL Dlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { chSETDLGICONS(hwnd, IDI_LOCKCOP); // Keep track of the main dialog window handle g_hDlg = hwnd; // Have the results window use a fixed-pitch font SetWindowFont(GetDlgItem(hwnd, IDC_EDIT_DETAILS), GetStockFont(ANSI_FIXED_FONT), FALSE); // Fill up the process combo-box OnRefreshProcesses(); return(TRUE); }
HWND crEdit (char *text,HWND Parent,int x, int y, int w,int h) { HWND hwnd; int Flags=WS_CHILD ; hwnd=CreateWindowEx ( WS_EX_CLIENTEDGE , "Edit" , text , Flags , x,y,w,h, Parent , NULL , NULL/*thisinst*/ , NULL ) ; SendMessage(hwnd,WM_SETFONT,(WPARAM)GetStockFont(V_FONT),(LPARAM)TRUE); ShowWindow(hwnd,SW_SHOW); UpdateWindow(hwnd); return hwnd; }
HFONT Globals::GetSmallCaptionFont() { EnterCriticalSection(&m_csGlobals); if (m_hSmallCaption) { LOGFONT lfSmallCaption; int nResult = GetObject(GetStockFont(SYSTEM_FONT), sizeof(LOGFONT), &lfSmallCaption); if (nResult > 0) { m_nSmallCaptionHeight = lfSmallCaption.lfHeight = GetSystemMetrics(SM_CYSMSIZE); m_hSmallCaption = CreateFontIndirect(&lfSmallCaption); } } LeaveCriticalSection(&m_csGlobals); return m_hSmallCaption; }
HWND crText (char *text,HWND Parent,int x, int y, int w,int h) { HWND hwnd; int Flags=ES_READONLY|WS_CHILD | ES_RIGHT ; hwnd=CreateWindowEx ( 0 , "Edit" , text , Flags , x,y,w,h, Parent , NULL , NULL/*thisinst*/ , NULL ) ; SendMessage(hwnd,WM_SETFONT,(WPARAM)GetStockFont(V_FONT),(LPARAM)TRUE); ShowWindow(hwnd,SW_SHOW); UpdateWindow(hwnd); return hwnd; }
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) { LoggerWin * logger = (LoggerWin *)lParam; SetWindowLong(hWnd, DWL_USER, (long)logger); SetWindowText(hWnd, szAppName); HFONT hFont = GetStockFont(ANSI_FIXED_FONT); SetWindowFont(GetDlgItem(hWnd, IDC_MAIN_OUTPUT), hFont, FALSE); if(logger) { CheckDlgButton(hWnd, IDC_CHECK_MUTE, logger->bMutedAll ? BST_CHECKED : BST_UNCHECKED); if(logger->width && logger->height) SetWindowPos(hWnd, NULL, logger->x, logger->y, logger->width, logger->height, SWP_NOZORDER); SetWindowPos(hWnd, logger->bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); } return TRUE; }
DcxText::DcxText( UINT ID, DcxDialog * p_Dialog, HWND mParentHwnd, RECT * rc, const TString & styles ) : DcxControl( ID, p_Dialog ) { LONG Styles = 0, ExStyles = 0; BOOL bNoTheme = FALSE; this->parseControlStyles( styles, &Styles, &ExStyles, &bNoTheme ); this->m_Hwnd = CreateWindowEx( ExStyles, TEXT("STATIC"), NULL, WS_CHILD | Styles, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, mParentHwnd, (HMENU) ID, GetModuleHandle(NULL), NULL); if (!IsWindow(this->m_Hwnd)) throw TEXT("Unable To Create Window"); // remove all borders this->removeStyle( WS_BORDER|WS_DLGFRAME ); this->removeExStyle( WS_EX_CLIENTEDGE|WS_EX_DLGMODALFRAME|WS_EX_STATICEDGE|WS_EX_WINDOWEDGE ); if ( bNoTheme ) Dcx::UXModule.dcxSetWindowTheme( this->m_Hwnd , L" ", L" " ); //this->m_tsText = TEXT(""); // pointless, alrdy is "". this->m_clrText = GetSysColor(COLOR_WINDOWTEXT); this->setControlFont( GetStockFont( DEFAULT_GUI_FONT ), FALSE ); this->registreDefaultWindowProc( ); SetProp( this->m_Hwnd, TEXT("dcx_cthis"), (HANDLE) this ); if (styles.istok(TEXT("tooltips"))) { if (IsWindow(p_Dialog->getToolTip())) { this->m_ToolTipHWND = p_Dialog->getToolTip(); AddToolTipToolInfo(this->m_ToolTipHWND, this->m_Hwnd); } else this->showError(NULL,TEXT("-c"),TEXT("Unable to Initialize Tooltips")); } }
/*! ポッパップの文字サイズ変更と表示非表示が入った @param[in] ttSize 文字サイズ・12か16しかない @param[in] bView 非0表示 0表示しない @return HRESULT 終了状態コード */ HRESULT AaItemsTipSizeChange( INT ttSize, UINT bView ) { #ifdef MAA_TOOLTIP LOGFONT stFont; #endif gbAAtipView = bView ? TRUE : FALSE; #ifdef MAA_TOOLTIP SetWindowFont( ghToolTipWnd, GetStockFont(DEFAULT_GUI_FONT), FALSE ); DeleteFont( ghTipFont ); // 今使ってるヤツぶっ壊してから、新しいのつくってくっつける ViewingFontGet( &stFont ); // gstBaseFont stFont.lfHeight = (FONTSZ_REDUCE == ttSize) ? FONTSZ_REDUCE : FONTSZ_NORMAL; ghTipFont = CreateFontIndirect( &stFont ); SetWindowFont( ghToolTipWnd, ghTipFont, TRUE ); #endif return S_OK; }
ExplorerAboutDlg(HWND hwnd) : super(hwnd) { SetWindowIcon(hwnd, IDI_REACTOS); new FlatButton(hwnd, IDOK); _hfont = CreateFont(20, 0, 0, 0, FW_BOLD, TRUE, 0, 0, 0, 0, 0, 0, 0, TEXT("Sans Serif")); new ColorStatic(hwnd, IDC_ROS_EXPLORER, RGB(32,32,128), 0, _hfont); new HyperlinkCtrl(hwnd, IDC_WWW); FmtString ver_txt(ResString(IDS_EXPLORER_VERSION_STR), (LPCTSTR)ResString(IDS_VERSION_STR)); SetWindowText(GetDlgItem(hwnd, IDC_VERSION_TXT), ver_txt); HWND hwnd_winver = GetDlgItem(hwnd, IDC_WIN_VERSION); SetWindowText(hwnd_winver, get_windows_version_str()); SetWindowFont(hwnd_winver, GetStockFont(DEFAULT_GUI_FONT), FALSE); CenterWindow(hwnd); }
static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc) { if(szString == NULL) return; HFONT hFont = GetStockFont(DEFAULT_GUI_FONT); if(hFont == NULL) return; HFONT hFontOld = SelectFont(hDC, hFont); SIZE sz; GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz); POINT pt; pt.x = sz.cx; pt.y = sz.cy; LPtoDP(hDC, &pt, 1); int iY = (lprc->bottom / 2) - ((32) / 2) + 36; int iX = 0; if(lprc->right > pt.x) iX = lprc->right/2 - pt.x/2; else iX = 1; RECT rcText; rcText.left = iX; rcText.right = rcText.left + pt.x; rcText.top = iY; rcText.bottom = rcText.top + pt.y; int iModeOld = SetBkMode(hDC, TRANSPARENT); COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0)); DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER); SetTextColor(hDC, crColorOld); SetBkMode(hDC, iModeOld); SelectFont(hDC, hFontOld); }
static BOOL CALLBACK DirPickDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: onInitDialog(hWnd, (LPSTR)lParam); break; case WM_COMMAND: HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand); break; case WM_MEASUREITEM: { static int cyItem = -1; //Height of a listbox item LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; if(cyItem == -1) { HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0L); if(hFont == NULL) hFont = GetStockFont(SYSTEM_FONT); HDC hDC = GetDC(hWnd); HFONT hFontOld = SelectFont(hDC, hFont); TEXTMETRIC tm; GetTextMetrics(hDC, &tm); cyItem = max(ITEM_BITMAPHEIGHT, tm.tmHeight); SelectFont(hDC, hFontOld); ReleaseDC(hWnd, hDC); } lpmis->itemHeight = cyItem; } break; case WM_DRAWITEM: onDrawItem((LPDRAWITEMSTRUCT)lParam, ((UINT)wParam == ID_COMBO_DIR)); return TRUE; // to prevent default action in listbox (drawing focus) default: return FALSE; } return TRUE; }
bool ListView::BeginLabelEdit(const UINT iItem, const UINT iSubItem) { Rect rcItem; wstring szItem; // Lookup sub-item rectangle if (GetSubItemRect(iItem, iSubItem, LVIR_LABEL, rcItem)) { // Get item text szItem = GetItemText(iItem, iSubItem, 256); // Create Edit control m_pEdit = new ListViewEdit; m_pEdit->Create(szItem.c_str(), iItem, iSubItem, this, Instance, rcItem); SetWindowFont(m_pEdit->Handle, GetStockFont(ANSI_VAR_FONT), FALSE); // Display Edit and focus m_pEdit->ShowAndUpdate(); m_pEdit->SetFocus(); return true; } return false; }
void CDC::Font(int iObjectID) { SelectFont(m_hDC, GetStockFont(iObjectID)); }
BOOL Dlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { chSETDLGICONS(hwnd, IDI_PROCESSINFO); /* Is set to TRUE if the Administrator privileges * are available; either because running elevated * or simply because UAC has been disabled. */ BOOL bCanReadSystemProcesses = FALSE; /* Show if we are running with filtered token or not */ if (GetProcessElevation(&s_elevationType, &s_bIsAdmin)) { /* prefix title with elevation */ TCHAR szTitle[64]; switch(s_elevationType) { /* Default user or UAC is disabled */ case TokenElevationTypeDefault: if (IsUserAnAdmin()) { _tcscpy_s( szTitle, _countof(szTitle), TEXT("Default Administrator: ")); bCanReadSystemProcesses = true; } else { _tcscpy_s( szTitle, _countof(szTitle), TEXT("Default: ")); } break; /* Process has been successfully elevated */ case TokenElevationTypeFull: if (IsUserAnAdmin()) { _tcscpy_s( szTitle, _countof(szTitle), TEXT("Elevated Administrator: ")); bCanReadSystemProcesses = true; } else { _tcscpy_s( szTitle, _countof(szTitle), TEXT("Elevated: ")); } break; /* Process is running with limited privileges */ case TokenElevationTypeLimited: if (s_bIsAdmin) { _tcscpy_s( szTitle, _countof(szTitle), TEXT("Filtered Administrator: ")); } else { _tcscpy_s( szTitle, _countof(szTitle), TEXT("Filtered: ")); } break; } /* Update the dialog title based on the elevation level */ GetWindowText( hwnd, _tcschr(szTitle, TEXT('\0')), _countof(szTitle) - _tcslen(szTitle)); SetWindowText(hwnd, szTitle); /* Add the "shield" icon if needed to allow the user * to restart the application with elevated privileges */ if (!bCanReadSystemProcesses) { Button_SetElevationRequiredState( GetDlgItem(hwnd, IDC_BTN_SYSTEM_PROCESSES), !bCanReadSystemProcesses); } else { /* No need to show the button... */ ShowWindow(GetDlgItem(hwnd, IDC_BTN_SYSTEM_PROCESSES), SW_HIDE); /* ... and the combo-box can take the whole width of the dialog box */ MoveWindow(GetDlgItem(hwnd, IDC_BTN_SYSTEM_PROCESSES), 0, 0, 0, 0, FALSE); } } /* Hide the module-helper listbox. */ ShowWindow(GetDlgItem(hwnd, IDC_MODULEHELP), SW_HIDE); /* Have the results window use a fixed-pitch font */ SetWindowFont( GetDlgItem(hwnd, IDC_RESULTS), GetStockFont(ANSI_FIXED_FONT), FALSE); /* By default, show the running processes */ Dlg_PopulateProcessList(hwnd); return(TRUE); }
void CImportDlg::calcItemHeight() { HFONT fnt = GetStockFont(DEFAULT_GUI_FONT); LOGFONT lf; GetObject(fnt, sizeof(LOGFONT), &lf); lf.lfQuality = CLEARTYPE_QUALITY; lstrcpy(lf.lfFaceName, L"Verdana"); m_fntNormal = CreateFontIndirect(&lf); lf.lfUnderline = TRUE; m_fntLinks = CreateFontIndirect(&lf); lf.lfUnderline = FALSE; lf.lfWeight = FW_BOLD; m_fntBold = CreateFontIndirect(&lf); lf.lfHeight = (int) ((double) lf.lfHeight * 3.0 / 2.0); m_fntCaption = CreateFontIndirect(&lf); HDC hdc = GetDC(m_hWnd); SIZE sz; HFONT oldFnt = SelectFont(hdc, m_fntCaption); GetTextExtentPoint32(hdc, L"QIqpti", 6, &sz); m_captionHeight = sz.cy + 4; SelectFont(hdc, m_fntBold); GetTextExtentPoint32(hdc, L"QIqpti", 6, &sz); m_textHeight = sz.cy + 4; SelectFont(hdc, m_fntNormal); struct { LPWSTR strID; LPWSTR attr; LPWSTR defText; } flds[] = { { XUI_FLD_PHONEWORK }, { XUI_FLD_PHONEHOME }, { XUI_FLD_PHONEFAX }, { XUI_FLD_PHONEMOBILE }, { XUI_FLD_PHONEPAGER }, { XUI_FLD_PHONE }, { XUI_FLD_EMAIL }, { XUI_FLD_EMAILADD }, { XUI_FLD_NICKNAME }, { XUI_FLD_URL }, { NULL, NULL, NULL } }; m_labelsWidth = 0; for(int i=0; flds[i].strID; i++) { SIZE sz; GetTextExtentPoint32(hdc, m_engine->getStringDef(flds[i].strID, NULL, flds[i].defText), lstrlen(m_engine->getStringDef(flds[i].strID, NULL, flds[i].defText)), &sz); if(sz.cx > m_labelsWidth) { m_labelsWidth = sz.cx; } } m_labelsWidth += 10; struct { LPWSTR strID; LPWSTR attr; LPWSTR defText; } links[] = { { XUI_IMPORT_SKIP }, { XUI_IMPORT_NEW }, { XUI_IMPORT_UPDATE }, { NULL, NULL, NULL } }; m_linksWidth = 0; m_linksHeight = 0; for(int i=0; links[i].strID; i++) { SIZE sz; GetTextExtentPoint32(hdc, m_engine->getStringDef(links[i].strID, NULL, links[i].defText), lstrlen(m_engine->getStringDef(links[i].strID, NULL, links[i].defText)), &sz); if(sz.cx > m_linksWidth) { m_linksWidth = sz.cx; } if(sz.cy > m_linksHeight) { m_linksHeight = sz.cy; } } m_linksWidth += 10; m_itemHeight = m_textHeight * 3 + m_captionHeight; if(m_itemHeight < 50) { m_itemHeight = 50; } m_itemHeight += 8; SelectFont(hdc, oldFnt); ReleaseDC(m_hWnd, hdc); }
void CInfoPanel::LoaderThread() { m_news.clear(); CHttpSocket sock; cvs::string xml; CXmlTree tree; size_t len; if(!sock.create("http://march-hare.com")) { xml="<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n<messages>\n<message><subject>Need assistance? Click here for our professional support options!</subject><author>"March Hare Support" <[email protected]></author><url>http://store.march-hare.com/s.nl?sc=2&category=2</url></message>\n</messages>"; len=xml.length(); } else if(!sock.request("GET","/cvspro/prods-pre.asp?register=advert")) { xml="<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n<messages>\n<message><subject>Need help NOW? Click here for our professional support options!</subject><author>"March Hare Support" <[email protected]></author><url>http://store.march-hare.com/s.nl?sc=2&category=2</url></message>\n</messages>"; len=xml.length(); } if(sock.responseCode()!=200) { xml="<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n<messages>\n<message><subject>Need help? Need integration? Need training? Click here for our professional support options!</subject><author>"March Hare Support" <[email protected]></author><url>http://store.march-hare.com/s.nl?sc=2&category=2</url></message>\n</messages>"; len=xml.length(); } else { cvs::string xml = sock.responseData(len); } if(!tree.ParseXmlFromMemory(xml.c_str())) return; CXmlNodePtr node = tree.GetRoot(); if(strcmp(node->GetName(),"messages")) return; if(!node->GetChild("message")) return; do { news_t n; n.subject = node->GetNodeValue("subject"); n.author = node->GetNodeValue("author"); n.url = node->GetNodeValue("url"); m_news.push_back(n); } while(node->GetSibling("message")); if(!m_hItemFont) { HFONT hFont = (HFONT)SendMessage(m_hListWnd,WM_GETFONT,0,0); if(!hFont) hFont=GetStockFont(DEFAULT_GUI_FONT); LOGFONT lf = {0}; GetObject(hFont,sizeof(lf),&lf); lf.lfUnderline=true; m_hItemFont = CreateFontIndirect(&lf); } ListView_DeleteAllItems(m_hListWnd); ListView_DeleteColumn(m_hListWnd,1); LVCOLUMN lvc={0}; lvc.mask=LVCF_WIDTH|LVCF_TEXT; lvc.cx=500; lvc.pszText=_T("Title"); ListView_InsertColumn(m_hListWnd,0,&lvc); lvc.mask=LVCF_WIDTH|LVCF_TEXT; lvc.cx=300; lvc.pszText=_T("Author"); ListView_InsertColumn(m_hListWnd,1,&lvc); for(size_t n=0; n<m_news.size(); n++) { LVITEM lvi = {0}; cvs::wide wnews(m_news[n].subject.c_str()); cvs::wide wauth(m_news[n].author.c_str()); lvi.mask=LVIF_TEXT|LVIF_PARAM; lvi.iItem=(int)n; lvi.pszText=(LPWSTR)(const wchar_t*)wnews; lvi.lParam=(LPARAM)&m_news[n]; int iItem = ListView_InsertItem(m_hListWnd,&lvi); ListView_SetItemText(m_hListWnd,iItem,1,(LPWSTR)(const wchar_t*)wauth); } m_bLoaded = true; }
DcxComboEx::DcxComboEx( UINT ID, DcxDialog * p_Dialog, HWND mParentHwnd, RECT * rc, TString & styles ) : DcxControl( ID, p_Dialog ) { LONG Styles = 0, ExStyles = 0; BOOL bNoTheme = FALSE; this->parseControlStyles( styles, &Styles, &ExStyles, &bNoTheme ); this->m_Hwnd = CreateWindowEx( ExStyles, DCX_COMBOEXCLASS, NULL, WS_CHILD | CBS_AUTOHSCROLL | Styles, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, mParentHwnd, (HMENU) ID, GetModuleHandle(NULL), NULL); if (!IsWindow(this->m_Hwnd)) throw "Unable To Create Window"; if ( bNoTheme ) { Dcx::UXModule.dcxSetWindowTheme( this->m_Hwnd , L" ", L" " ); //SendMessage( this->m_Hwnd, CBEM_SETWINDOWTHEME, NULL, (LPARAM)(LPCWSTR)L" "); // do this instead? } this->m_EditHwnd = (HWND) this->getEditControl( ); if ( IsWindow( this->m_EditHwnd ) ) { if ( bNoTheme ) Dcx::UXModule.dcxSetWindowTheme( this->m_EditHwnd , L" ", L" " ); try { LPDCXCOMBOEXEDIT lpce = new DCXCOMBOEXEDIT; lpce->cHwnd = this->m_Hwnd; lpce->pHwnd = mParentHwnd; //SetWindowLong( this->m_EditHwnd, GWL_STYLE, GetWindowLong( this->m_EditHwnd, GWL_STYLE ));// | ES_AUTOHSCROLL ); lpce->OldProc = SubclassWindow( this->m_EditHwnd, DcxComboEx::ComboExEditProc ); SetWindowLongPtr( this->m_EditHwnd, GWLP_USERDATA, (LONG) lpce ); } catch ( std::bad_alloc ) { DestroyWindow(this->m_Hwnd); throw "Unable to Allocate Memory"; } } HWND combo = (HWND)SendMessage(this->m_Hwnd,CBEM_GETCOMBOCONTROL,0,0); if (IsWindow(combo)) { if (bNoTheme) Dcx::UXModule.dcxSetWindowTheme( combo , L" ", L" " ); COMBOBOXINFO cbi = { 0 }; cbi.cbSize = sizeof(cbi); GetComboBoxInfo(combo, &cbi); if (styles.istok("sort")) { // doesnt work atm. if (IsWindow(cbi.hwndList)) { AddStyles(cbi.hwndList, GWL_STYLE, LBS_SORT); } } if (styles.istok("hscroll")) { //if (IsWindow(cbi.hwndCombo)) //AddStyles(cbi.hwndCombo, GWL_STYLE, WS_HSCROLL); if (IsWindow(cbi.hwndList)) AddStyles(cbi.hwndList, GWL_STYLE, WS_HSCROLL); } } //if (p_Dialog->getToolTip() != NULL) { // if (styles.istok("tooltips")) { // this->m_ToolTipHWND = p_Dialog->getToolTip(); // AddToolTipToolInfo(this->m_ToolTipHWND, this->m_Hwnd); // AddToolTipToolInfo(this->m_ToolTipHWND, this->m_EditHwnd); // } //} this->setControlFont( GetStockFont( DEFAULT_GUI_FONT ), FALSE ); this->registreDefaultWindowProc( ); SetProp( this->m_Hwnd, "dcx_cthis", (HANDLE) this ); DragAcceptFiles(this->m_Hwnd, TRUE); // fix bug with disabled creation // todo: fix this properly if (Styles & WS_DISABLED) { EnableWindow(this->m_Hwnd, TRUE); EnableWindow(this->m_Hwnd, FALSE); } }
bool UFont::useStockFont( StockFont sf ) { m_hObj = GetStockFont(sf); return (NULL != m_hObj); }
int WIN_Init( ) { char colorstring[BSIZE_SP]; /* Initialization of display descriptor */ dispdev->width = GetSystemMetrics( SM_CXSCREEN); dispdev->height = GetSystemMetrics( SM_CYSCREEN); dispdev->numlinestyles = 5; /* see implications in WinPrint! */ dispdev->numcolors = NumWinColors; /* always, user may have set color0 to white */ /* get background color information from spinit, only "white" is recognized as a suitable option! */ if (cp_getvar("color0", CP_STRING, colorstring)) { if (cieq(colorstring, "white")) isblack = FALSE; else isblack = TRUE; } /* get linewidth information from spinit */ if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) linewidth = 0; if (linewidth < 0) linewidth = 0; /* only for the first time: */ if (!IsRegistered) { isblackold = isblack; /* get linewidth information from spinit if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) linewidth = 0; if (linewidth < 0) linewidth = 0; */ /* Initialize colors */ if (isblack) { ColorTable[0] = RGB( 0, 0, 0); /* black = background */ ColorTable[1] = RGB(255,255,255); /* white = text and grid */ } else { ColorTable[0] = RGB(255,255,255); /* white = background */ ColorTable[1] = RGB( 0, 0, 0); /* black = text and grid */ } ColorTable[2] = RGB( 0,255, 0); /* green = first line */ ColorTable[3] = RGB(255, 0, 0); /* red */ ColorTable[4] = RGB( 0, 0,255); /* blue */ ColorTable[5] = RGB(255,255, 0); /* yellow */ ColorTable[6] = RGB(255, 0,255); /* violett */ ColorTable[7] = RGB( 0,255,255); /* azur */ ColorTable[8] = RGB(255,128, 0); /* orange */ ColorTable[9] = RGB(128, 64, 0); /* brown */ ColorTable[10]= RGB(128, 0,255); /* light violett */ ColorTable[11]= RGB(255,128,128); /* pink */ /* 2. color bank (with different line style */ if (isblack) ColorTable[12]= RGB(255,255,255); /* white */ else ColorTable[12]= RGB( 0, 0, 0); /* black */ ColorTable[13]= RGB( 0,255, 0); /* green */ ColorTable[14]= RGB(255, 0, 0); /* red */ ColorTable[15]= RGB( 0, 0,255); /* blue */ ColorTable[16]= RGB(255,255, 0); /* yellow */ ColorTable[17]= RGB(255, 0,255); /* violett */ ColorTable[18]= RGB( 0,255,255); /* azur */ ColorTable[19]= RGB(255,128, 0); /* orange */ ColorTable[20]= RGB(128, 64, 0); /* brown */ ColorTable[21]= RGB(128, 0,255); /* light violett */ ColorTable[22]= RGB(255,128,128); /* pink */ /* Ansii fixed font */ PlotFont = GetStockFont( ANSI_FIXED_FONT); /* register window class */ TheWndClass.lpszClassName = WindowName; TheWndClass.hInstance = hInst; TheWndClass.lpfnWndProc = PlotWindowProc; TheWndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; TheWndClass.lpszMenuName = NULL; TheWndClass.hCursor = LoadCursor(NULL, IDC_ARROW); if (isblack) TheWndClass.hbrBackground = GetStockObject( BLACK_BRUSH); else TheWndClass.hbrBackground = GetStockObject( WHITE_BRUSH); TheWndClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(2)); TheWndClass.cbClsExtra = 0; TheWndClass.cbWndExtra = sizeof(GRAPH *); if (!RegisterClass(&TheWndClass)) return 1; } /* not first time */ else if (isblackold != isblack) { if (isblack) { ColorTable[0] = RGB( 0, 0, 0); /* black = background */ ColorTable[1] = RGB(255,255,255); /* white = text and grid */ } else { ColorTable[0] = RGB(255,255,255); /* white = background */ ColorTable[1] = RGB( 0, 0, 0); /* black = text and grid */ } if (isblack) ColorTable[12]= RGB(255,255,255); /* white */ else ColorTable[12]= RGB( 0, 0, 0); /* black */ isblackold=isblack; } IsRegistered = 1; /* ready */ return (0); }
LRESULT CALLBACK DownloadProgressProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { static WCHAR szProgressText[MAX_STR_LEN] = {0}; switch (uMsg) { case WM_SETTEXT: { if (lParam) { StringCbCopyW(szProgressText, sizeof(szProgressText), (PCWSTR)lParam); } } case WM_ERASEBKGND: case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps), hdcMem; HBITMAP hbmMem; HANDLE hOld; RECT myRect; UINT win_width, win_height; GetClientRect(hWnd, &myRect); /* grab the progress bar rect size */ win_width = myRect.right - myRect.left; win_height = myRect.bottom - myRect.top; /* create an off-screen DC for double-buffering */ hdcMem = CreateCompatibleDC(hDC); hbmMem = CreateCompatibleBitmap(hDC, win_width, win_height); hOld = SelectObject(hdcMem, hbmMem); /* call the original draw code and redirect it to our memory buffer */ DefSubclassProc(hWnd, uMsg, (WPARAM)hdcMem, lParam); /* draw our nifty progress text over it */ SelectFont(hdcMem, GetStockFont(DEFAULT_GUI_FONT)); DrawShadowText(hdcMem, szProgressText, wcslen(szProgressText), &myRect, DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE, GetSysColor(COLOR_CAPTIONTEXT), GetSysColor(COLOR_3DSHADOW), 1, 1); /* transfer the off-screen DC to the screen */ BitBlt(hDC, 0, 0, win_width, win_height, hdcMem, 0, 0, SRCCOPY); /* free the off-screen DC */ SelectObject(hdcMem, hOld); DeleteObject(hbmMem); DeleteDC(hdcMem); EndPaint(hWnd, &ps); return 0; } /* Raymond Chen says that we should safely unsubclass all the things! (http://blogs.msdn.com/b/oldnewthing/archive/2003/11/11/55653.aspx) */ case WM_NCDESTROY: { ZeroMemory(szProgressText, sizeof(szProgressText)); RemoveWindowSubclass(hWnd, DownloadProgressProc, uIdSubclass); } default: return DefSubclassProc(hWnd, uMsg, wParam, lParam); } }
Globals::Globals() : m_ilSizer(NULL), m_ilSlidingScrollImages(NULL), m_hBitmapExpandVert(NULL), m_hBitmapExpandHorz(NULL), m_hBitmapSubMenu(NULL), m_hBitmapSMCombo(NULL), m_hBitmapMenuScroll(NULL), m_hBitmapEndMarker(NULL), m_hBitmapMenuCheck(NULL), m_hBitmapMenuExpand(NULL), m_hBitmapMDIButtons(NULL), m_hBrushDither(NULL), m_hBrushPattern(NULL), m_hSplitVCursor(NULL), m_hSplitHCursor(NULL), m_pWhatsThisHelpActiveBar(NULL), m_pCustomizeActiveBar(NULL), m_hSmallCaption(NULL), m_pEventLog(NULL), m_hMMLibrary(NULL), m_hHookAccelator(NULL), m_hHandCursor(NULL), m_hUser32Library(NULL) { try { m_nSmallCaptionHeight = 0; m_seFunction = _set_se_translator( trans_func ); g_bDemoDlgDisplayed = FALSE; FWnd::Init(); FDialog::Init(); CDDPropertySheet::Init(); for (int nIndex = 0; nIndex < GrabStyleCount; nIndex++) m_hBrushGrab[nIndex] = NULL; TCHAR* szTemp = LoadStringRes(IDS_ALT); if (szTemp) lstrcpy(m_szAlt, szTemp); szTemp = LoadStringRes(IDS_CONTROL); if (szTemp) lstrcpy(m_szCtrl, szTemp); szTemp = LoadStringRes(IDS_SHIFT); if (szTemp) lstrcpy(m_szShift, szTemp); m_bFullDrag = FALSE; m_bUseDBCSUI = FALSE; m_hHookAccelator = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyBoardHook, NULL, GetCurrentThreadId()); assert(m_hHookAccelator); m_pmapAccelator = new FMap; assert(m_pmapAccelator); m_pmapBar = new FMap; assert(m_pmapBar); m_pDragDropMgr = new CDragDropMgr; assert(m_pDragDropMgr); WM_SETTOOLFOCUS = RegisterWindowMessage(_T("DDSETTOOLFOCUS")); assert(WM_SETTOOLFOCUS); WM_REFRESHMENUBAND = RegisterWindowMessage(_T("DDREFRESHMENU")); assert(WM_REFRESHMENUBAND); WM_TOOLTIPSUPPORT = RegisterWindowMessage(_T("DDPPTP")); assert(WM_TOOLTIPSUPPORT); WM_ACTIVEBARCLICK = RegisterWindowMessage(_T("DDACTIVEBARCLICK")); assert(WM_ACTIVEBARCLICK); WM_ACTIVEBARTEXTCHANGE = RegisterWindowMessage(_T("DDACTIVETEXTCHANGE")); assert(WM_ACTIVEBARTEXTCHANGE); WM_RECALCLAYOUT = RegisterWindowMessage(_T("DDPPRECALC")); assert(WM_RECALCLAYOUT); WM_POPUPKEYDOWN = RegisterWindowMessage(_T("DDPPMSGKEYDOWN")); assert(WM_POPUPKEYDOWN); WM_POPUPWINMSG = RegisterWindowMessage(_T("DDPPMSG")); assert(WM_POPUPWINMSG); WM_SIZEPARENT = RegisterWindowMessage(_T("DDWM_SIZEPARENT")); assert(WM_SIZEPARENT); WM_KILLWINDOW = RegisterWindowMessage(_T("DDWM_KILLPOPUP")); assert(WM_KILLWINDOW); WM_FLOATSTATUS = RegisterWindowMessage(_T("DDWM_FLOATSTATUS")); assert(WM_FLOATSTATUS); WM_POSTACTIVATE = RegisterWindowMessage(_T("DDWM_POSTACTIVATE")); assert(WM_POSTACTIVATE); WM_UPDATETABTOOL = RegisterWindowMessage(_T("DDWM_UPDATETABTOOL")); assert(WM_UPDATETABTOOL); WM_CACHEDOCKAREAS = RegisterWindowMessage(_T("DDWM_CACHEDOCKAREAS")); assert(WM_CACHEDOCKAREAS); WM_ACTIVEBARCOMBOSELCHANGE = RegisterWindowMessage(_T("DDWM_ACTIVEBARCOMBOSELCHANGE")); assert(WM_ACTIVEBARCOMBOSELCHANGE); m_nDragDelay = GetProfileInt(_T("Windows"), _T("DragDelay"), DD_DEFDRAGDELAY); assert(m_nDragDelay); m_nDragDist = GetProfileInt(_T("Windows"), _T("DragMinDist"), DD_DEFDRAGMINDIST); assert(m_nDragDist); m_nIDClipBandFormat = RegisterClipboardFormat(_T("ActiveBar Band")); assert(m_nIDClipBandFormat); m_nIDClipCategoryFormat = RegisterClipboardFormat(_T("ActiveBar Category")); assert(m_nIDClipCategoryFormat); m_nIDClipToolFormat = RegisterClipboardFormat(_T("ActiveBar Tool")); assert(m_nIDClipToolFormat); m_nIDClipToolIdFormat = RegisterClipboardFormat(_T("ActiveBar Tool Id")); assert(m_nIDClipToolIdFormat); m_nIDClipBandToolIdFormat = RegisterClipboardFormat(_T("ActiveBar Band Tool Id")); assert(m_nIDClipBandToolIdFormat); m_nIDClipBandChildBandToolIdFormat = RegisterClipboardFormat(_T("ActiveBar Band ChildBand Tool Id")); assert(m_nIDClipBandChildBandToolIdFormat); m_pControls = new FMap; assert(m_pControls); m_nBrushPatternWidth = m_nBrushPatternHeight = 0; m_bUseDBCSUI = FALSE; HFONT hFontSys = GetStockFont(SYSTEM_FONT); HDC hDCTest = GetDC(NULL); if (hDCTest) { m_nBitDepth = GetDeviceCaps(hDCTest, BITSPIXEL); HFONT hFontOld = SelectFont(hDCTest, hFontSys); TEXTMETRIC tm; GetTextMetrics(hDCTest, &tm); SelectFont(hDCTest, hFontOld); switch(tm.tmCharSet) { case SHIFTJIS_CHARSET: case HANGEUL_CHARSET: case CHINESEBIG5_CHARSET: m_bUseDBCSUI = TRUE; break; default: break; } ReleaseDC(NULL, hDCTest); } #ifdef JAPBUILD _fdDefaultControl.cbSizeofstruct = sizeof(FONTDESC); _fdDefaultControl.cySize.Hi = 0; _fdDefaultControl.cySize.Lo = 90000; _fdDefaultControl.fItalic = FALSE; _fdDefaultControl.fStrikethrough = FALSE; _fdDefaultControl.fUnderline = FALSE; _fdDefaultControl.sCharset = DEFAULT_CHARSET; _fdDefaultControl.lpstrName = (LPOLESTR)"‚l‚r ‚oƒSƒVƒbƒN\0\0"; _fdDefaultControl.sWeight = FW_NORMAL; _fdDefault.cbSizeofstruct = sizeof(FONTDESC); _fdDefault.cySize.Hi = 0; _fdDefault.cySize.Lo = 90000; _fdDefault.fItalic = FALSE; _fdDefault.fStrikethrough = FALSE; _fdDefault.fUnderline = FALSE; _fdDefault.sCharset = DEFAULT_CHARSET; _fdDefault.lpstrName = (LPOLESTR)"‚l‚r ‚oƒSƒVƒbƒN\0\0"; _fdDefault.sWeight = FW_NORMAL; #else _fdDefaultControl.cbSizeofstruct = sizeof(FONTDESC); _fdDefaultControl.cySize.Hi = 0; _fdDefaultControl.cySize.Lo = 80000; _fdDefaultControl.fItalic = FALSE; _fdDefaultControl.fStrikethrough = FALSE; _fdDefaultControl.fUnderline = FALSE; _fdDefaultControl.sCharset = DEFAULT_CHARSET; _fdDefaultControl.lpstrName = OLESTR("MS Sans Serif"); _fdDefaultControl.sWeight = FW_NORMAL; _fdDefault.cbSizeofstruct = sizeof(FONTDESC); _fdDefault.cySize.Hi = 0; _fdDefault.cySize.Lo = 80000; _fdDefault.fItalic = FALSE; _fdDefault.fStrikethrough = FALSE; _fdDefault.fUnderline = FALSE; _fdDefault.sCharset = DEFAULT_CHARSET; _fdDefault.lpstrName = OLESTR("Arial"); _fdDefault.sWeight = FW_NORMAL; #endif InitializeCriticalSection(&m_csGlobals); InitializeCriticalSection(&m_csPaintIcon); } CATCH { assert(FALSE); m_pEventLog = NULL; REPORTEXCEPTION(__FILE__, __LINE__) } }
/*! 表示用ウインドウを作る @param[in] hInstance アプリのインスタンス @param[in] hPtWnd 呼び出した方のウインドウハンドル @param[in] bThumb 非0MAAのサムネ表示として呼ばれた @return 作ったウインドウのハンドル */ HWND DraughtWindowCreate( HINSTANCE hInstance, HWND hPtWnd, UINT bThumb ) { INT_PTR iItems; INT iRslt, iScWid = 0, iScHei; HDC hdc; INT iBrdrWid = 0; TCHAR atCaption[SUB_STRING]; RECT wdRect, rect; #ifdef MAA_TOOLTIP TTTOOLINFO stToolInfo; #endif INT iCapHei, iXfrm, iYfrm; INT iLines, iStep = 0; LONG rigOffs = 0; SCROLLINFO stScrollInfo; if( !(hPtWnd ) ) // 破壊する・いらない? { return NULL; } // 已に出来ていたらそのまま返す if( ghDraughtWnd ){ UpdateWindow( ghDraughtWnd ); return ghDraughtWnd; } gbThumb = bThumb; iItems = gvcDrtItems.size( ); // 現在個数・ここでは使わない iCapHei = GetSystemMetrics( SM_CYSMCAPTION ); iXfrm = GetSystemMetrics( SM_CXFIXEDFRAME ); iYfrm = GetSystemMetrics( SM_CYFIXEDFRAME ); if( 0 > gstViewLsPt.x ) // 未設定なら { GetWindowRect( hPtWnd, &wdRect ); rect.left = wdRect.left + 32; // オフセット値に特に意味はない rect.top = wdRect.top + 32; gstViewLsPt.x = rect.left; gstViewLsPt.y = rect.top; } else { rect.left = gstViewLsPt.x; rect.top = gstViewLsPt.y; } rect.right = (giItemWidth * TPNL_HORIZ) + (iXfrm * 2); rect.bottom = (giItemHeight * TPNL_VERTI); iScHei = rect.bottom; rect.bottom += ((iYfrm * 2) + iCapHei); // if( ghPtWnd == hPtWnd ) 呼びだした方によって、ラスト位置リロード・底までしなくて良いか if( gbThumb ) // サムネモード { gdVwTop = 0; iItems = AacItemCount( 0 ); // 現在個数・スクロールバーの刻み設定につかう if( 0 >= iItems ) return NULL; // アイテム開いてないなら何もしない iLines = (iItems + (TPNL_HORIZ-1)) / TPNL_HORIZ; // 行数・切り上げ処理 iStep = iLines - TPNL_VERTI; // すくろるば〜の刻み数 if( 0 > iStep ){ iStep = 0; } rigOffs = rect.right; iScWid = GetSystemMetrics( SM_CXVSCROLL ); // 垂直スクロールバーの幅確保 rect.right += iScWid; iBrdrWid = GetSystemMetrics( SM_CXFIXEDFRAME ); // 枠の幅確保 rect.right += (iBrdrWid*2); StringCchCopy( atCaption, SUB_STRING, TEXT("MAA THUMBNAIL") ); } else { StringCchCopy( atCaption, SUB_STRING, TEXT("DRAUGHT BOARD") ); } // ウインドウ作成 TOPMOSTいるか? 要る ghDraughtWnd = CreateWindowEx( WS_EX_TOOLWINDOW | WS_EX_TOPMOST, DRAUGHT_BOARD_CLASS, atCaption, WS_POPUP | WS_VISIBLE | WS_CAPTION, rect.left, rect.top, rect.right, rect.bottom, NULL, NULL, hInstance, NULL ); #ifdef MAA_TOOLTIP FREE( gptTipBuffer ); // ツールチップ ghDrghtTipWnd = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, ghDraughtWnd, NULL, hInstance, NULL ); SetWindowFont( ghDrghtTipWnd, ghTipFont, TRUE ); // ツールチップをコールバックで割り付け ZeroMemory( &stToolInfo, sizeof(TTTOOLINFO) ); GetClientRect( ghDraughtWnd, &stToolInfo.rect ); stToolInfo.cbSize = sizeof(TTTOOLINFO); stToolInfo.uFlags = TTF_SUBCLASS; stToolInfo.hinst = NULL; // stToolInfo.hwnd = ghDraughtWnd; stToolInfo.uId = IDTT_DRT_TOOLTIP; stToolInfo.lpszText = LPSTR_TEXTCALLBACK; // コレを指定するとコールバックになる SendMessage( ghDrghtTipWnd, TTM_ADDTOOL, 0, (LPARAM)&stToolInfo ); SendMessage( ghDrghtTipWnd, TTM_SETMAXTIPWIDTH, 0 , 0 ); // チップの幅。0設定でいい。これしとかないと改行されない #endif if( gbThumb ) // サムネモード { // 一覧のスクロールバー ghScrBarWnd = CreateWindowEx( 0, WC_SCROLLBAR, TEXT("scroll"), WS_VISIBLE | WS_CHILD | SBS_VERT, rigOffs, 0, iScWid, iScHei, ghDraughtWnd, (HMENU)IDSB_DRT_THUM_SCROLL, hInstance, NULL ); ZeroMemory( &stScrollInfo, sizeof(SCROLLINFO) ); stScrollInfo.cbSize = sizeof(SCROLLINFO); stScrollInfo.fMask = SIF_ALL | SIF_DISABLENOSCROLL; stScrollInfo.nMax = iStep; stScrollInfo.nPos = 0; stScrollInfo.nPage = 1; stScrollInfo.nTrackPos = 0; SetScrollInfo( ghScrBarWnd, SB_CTL, &stScrollInfo, TRUE ); } if( !(ghNonItemDC) ) // 穴埋め描画用ビットマップ作成 { hdc = GetDC( ghDraughtWnd ); ghNonItemDC = CreateCompatibleDC( hdc ); ghNonItemBMP = CreateCompatibleBitmap( hdc, giItemWidth, giItemHeight ); ghOldBmp = SelectBitmap( ghNonItemDC, ghNonItemBMP ); SelectFont( ghNonItemDC, ghAaFont ); iRslt = PatBlt( ghNonItemDC, 0, 0, giItemWidth, giItemHeight, WHITENESS ); ReleaseDC( ghDraughtWnd, hdc ); SetRect( &rect, 0, 0, giItemWidth, giItemHeight ); iRslt = DrawText( ghNonItemDC, TEXT("NO ITEM"), 7, &rect, DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_NOCLIP | DT_SINGLELINE ); SelectFont( ghNonItemDC, GetStockFont(DEFAULT_GUI_FONT) ); ghLinePen = CreatePen( PS_SOLID, 1, 0 ); SelectPen( ghNonItemDC, ghLinePen ); } UpdateWindow( ghDraughtWnd ); return ghDraughtWnd; }
void QuickLaunchBar::AddShortcuts() { CONTEXT("QuickLaunchBar::AddShortcuts()"); WaitCursor wait; try { TCHAR path[MAX_PATH]; SpecialFolderFSPath app_data(CSIDL_APPDATA, _hwnd); ///@todo perhaps also look into CSIDL_COMMON_APPDATA ? _stprintf(path, TEXT("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data); RecursiveCreateDirectory(path); _dir = new ShellDirectory(GetDesktopFolder(), path, _hwnd); _dir->smart_scan(SORT_NAME); // immediatelly extract the shortcut icons for(Entry*entry=_dir->_down; entry; entry=entry->_next) entry->_icon_id = entry->safe_extract_icon(ICF_NORMAL); } catch(COMException&) { return; } ShellFolder desktop_folder; WindowCanvas canvas(_hwnd); COLORREF bk_color = GetSysColor(COLOR_BTNFACE); HBRUSH bk_brush = GetSysColorBrush(COLOR_BTNFACE); AddButton(ID_MINIMIZE_ALL, g_Globals._icon_cache.get_icon(ICID_MINIMIZE).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_MINIMIZE_ALL), NULL); AddButton(ID_EXPLORE, g_Globals._icon_cache.get_icon(ICID_EXPLORER).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_TITLE), NULL); TBBUTTON sep = {0, -1, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0}; SendMessage(_hwnd, TB_INSERTBUTTON, INT_MAX, (LPARAM)&sep); int cur_desktop = g_Globals._desktops._current_desktop; ResString desktop_fmt(IDS_DESKTOP_NUM); HDC hdc = CreateCompatibleDC(canvas); DWORD size = SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0); int cx = LOWORD(size); int cy = HIWORD(size); RECT rect = {0, 0, cx, cy}; RECT textRect = {0, 0, cx-7, cy-7}; for(int i=0; i<DESKTOP_COUNT; ++i) { HBITMAP hbmp = CreateCompatibleBitmap(canvas, cx, cy); HBITMAP hbmp_old = SelectBitmap(hdc, hbmp); FontSelection font(hdc, GetStockFont(ANSI_VAR_FONT)); FmtString num_txt(TEXT("%d"), i+1); TextColor color(hdc, RGB(64,64,64)); BkMode mode(hdc, TRANSPARENT); FillRect(hdc, &rect, GetSysColorBrush(COLOR_BTNFACE)); DrawText(hdc, num_txt, num_txt.length(), &textRect, DT_CENTER|DT_VCENTER|DT_SINGLELINE); SelectBitmap(hdc, hbmp_old); AddButton(ID_SWITCH_DESKTOP_1+i, hbmp, FmtString(desktop_fmt, i+1), NULL, cur_desktop==i?TBSTATE_ENABLED|TBSTATE_PRESSED:TBSTATE_ENABLED); } DeleteDC(hdc); for(Entry*entry=_dir->_down; entry; entry=entry->_next) { // hide files like "desktop.ini" if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) continue; // hide subfolders if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { HBITMAP hbmp = g_Globals._icon_cache.get_icon(entry->_icon_id).create_bitmap(bk_color, bk_brush, canvas); AddButton(_next_id++, hbmp, entry->_display_name, entry); //entry->_etype==ET_SHELL? desktop_folder.get_name(static_cast<ShellEntry*>(entry)->_pidl): entry->_display_name); } } _btn_dist = LOWORD(SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0)); _size = _entries.size() * _btn_dist; SendMessage(GetParent(_hwnd), PM_RESIZE_CHILDREN, 0, 0); }