五、枚举所有字体 LOGFONT lf; lf.lfCharSet = DEFAULT_CHARSET; // Initialize the LOGFONT structure strcpy(lf.lfFaceName,""); CClientDC dc (this);
//Enumerate the font families ::EnumFontFamiliesEx((HDC) dc,&lf, (FONTENUMPROC) EnumFontFamProc,(LPARAM) this,0);
//枚举函数 int CALLBACK EnumFontFamProc(LPENUMLOGFONT lpelf,LPNEWTEXTMETRIC lpntm,DWORD nFontType,long lparam) { // Create a pointer to the dialog window CDay7Dlg* pWnd = (CDay7Dlg*) lparam; // add the font name to the list box
两个新的菜单项。 int CMainFrame:: OnCreate (LPCREATESTRUCT lpCreateStruct) { … //Make sure system menu item is in the right range. ASSERT(IDM_MYSYSITEM <0xF000); //Get pointer to system menu. CMenu* pSysMenu=GetSystemMenu(FALSE); ASSERT_VALID(pSysMenu); //Add a separator and our menu item to system menu. CString StrMenuItem(_T ("New menu item")); pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_MYSYSITEM, StrMenuItem); … }
//--------------------------------------------------------- 如何查询和设置系统参数 在Windows 3.1 SDK中介绍过SDK函数SystemParametersInfo,调用该函数可以查询和设置系统参数,诸如按键的重复速率设置、鼠标双击延迟时间、图标字体以及桌面覆盖位图等等。 //Create a font that is used for icon titles. LOGFONT stFont; :: SystemParametersInfo (SPIF_GETICONTITLELOGFONT, sizeof (LOGFONT), &stFont, SPIF_SENDWININICHANGE); m_font.CreateFontIndirect (&stFont); //Change the wallpaper to leaves.bmp. :: SystemParametersInfo (SPI_SETDESKWALLPAPER, 0, _T("forest.bmp"),SPIF_UPDATEINIFILE);
任务栏上的图标闪烁: The FlashWindow function flashes the specified window once, whereas the FlashWindowEx function flashes a specified number of times. BOOL FlashWindow( HWND hWnd, // handle to window to flash BOOL bInvert // flash status );//闪烁一次 FlashWindowEx()//闪烁多次
SM_CYCAPTION Height of a caption area, in pixels. SM_CYSMCAPTION Height of a small caption, in pixels. -------------------------------------------------------- GetWindowRect(&rect); rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) + 3;
怎样查找到正处在鼠标下面的窗口(具体到子窗口和菜单),无论是这个窗口是否具有焦点: POINT pt; CWnd* hWnd; // Find out which window owns the cursor GetCursorPos(&pt); hWnd=CWnd::WindowFromPoint(pt); if(hWnd==this) { //鼠标在窗体中空白处,即不在任何控件或子窗口当中 }