想請教一下各位~~
小弟的CODE如下
hFont = (HFONT)GetStockObject(SYSTEM_FONT); // 設定字型
GetObject(hFont, sizeof(LOGFONT), &logFont);
memset (&logFont, 0, sizeof (LOGFONT));
_tcscpy(logFont.lfFaceName, TEXT("Fixedsys"));
logFont.lfHeight = 45;
logFont.lfWidth = 35;
logFont.lfWeight = 2000;*/
logFont.lfEscapement = 0;
logFont.lfOrientation = 0;
logFont.lfItalic = FALSE;
logFont.lfUnderline = FALSE;
logFont.lfStrikeOut = FALSE;
logFont.lfCharSet = DEFAULT_CHARSET;
logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logFont.lfQuality = DRAFT_QUALITY;
logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
hFont = CreateFontIndirect(&SetLogFontType(45, 35, 2500));
hOldFont = (HFONT)SelectObject(dc,hFont);
小弟在第二行中_tcscpy(logFont.lfFaceName, TEXT("Fixedsys"));
改變Fixedsys的參數~可是輸出後的字型還是沒變
想請假高手幫下忙!!!
感激不盡!!
请确认字型是否存在
然后试试修改字体的大小,看看效果是否正常
这个很像贴图的。。数字键盘的我觉得贴图反倒好做。字体实现要折腾一下。。
數字是用ExtTextOut寫上去的~~
背景跟按鍵的背景則是兩張不貼上去的
所以想請教一下~怎樣才能變成我上一樓的字型
可以的話教我一下~使用LOGFONT時的完整流程!!
多謝來看帖的大大!!!
你可以把设备上支持的字体枚举出来,看看是否支持你需要的字体。
不好意思~~想請問一下~
要如何才能把设备上支持的字体枚举出来呢?
可以給各SAMPL CODE嗎?
萬分謝謝!!
- //======================================================================
- // FontList - Lists the available fonts in the system
- //
- // Written for the book Programming Windows CE
- // Copyright (C) 2003 Douglas Boling
- //======================================================================
- #include // For all that Windows stuff
- #include "FontList.h" // Program-specific stuff
- //----------------------------------------------------------------------
- // Global data
- //
- const TCHAR szAppName[] = TEXT ("FontList");
- HINSTANCE hInst; // Program instance handle
- FONTFAMSTRUCT ffs[FAMILYMAX];
- INT sFamilyCnt = 0;
- // Message dispatch table for MainWindowProc
- const struct decodeUINT MainMessages[] = {
- WM_CREATE, DoCreateMain,
- WM_PAINT, DoPaintMain,
- WM_DESTROY, DoDestroyMain,
- };
- //======================================================================
- // Program entry point
- //
- int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPWSTR lpCmdLine, int nCmdShow) {
- MSG msg;
- int rc = 0;
- HWND hwndMain;
- // Initialize this instance.
- hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow);
- if (hwndMain == 0)
- return 0x10;
- // Application message loop
- while (GetMessage (&msg, NULL, 0, 0)) {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- // Instance cleanup
- return TermInstance (hInstance, msg.wParam);
- }
- //----------------------------------------------------------------------
- // InitInstance - Instance initialization
- //
- HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow) {
- WNDCLASS wc;
- HWND hWnd;
- // Save program instance handle in global variable.
- hInst = hInstance;
- #if defined(WIN32_PLATFORM_PSPC)
- // If Pocket PC, allow only one instance of the application.
- hWnd = FindWindow (szAppName, NULL);
- if (hWnd) {
- SetForegroundWindow ((HWND)(((DWORD)hWnd) | 0x01));
- return 0;
- }
- #endif
- // Register application main window class.
- wc.style = 0; // Window style
- wc.lpfnWndProc = MainWndProc; // Callback function
- wc.cbClsExtra = 0; // Extra class data
- wc.cbWndExtra = 0; // Extra window data
- wc.hInstance = hInstance; // Owner handle
- wc.hIcon = NULL, // Application icon
- wc.hCursor = LoadCursor (NULL, IDC_ARROW);// Default cursor
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
- wc.lpszMenuName = NULL; // Menu name
- wc.lpszClassName = szAppName; // Window class name
- if (RegisterClass (&wc) == 0) return 0;
- // Create main window.
- hWnd = CreateWindowEx (WS_EX_NODRAG, // Ex style flags
- szAppName, // Window class
- TEXT("Font Listing"),// Window title
- // Style flags
- WS_VISIBLE | WS_CAPTION | WS_SYSMENU,
- CW_USEDEFAULT, // x position
- CW_USEDEFAULT, // y position
- CW_USEDEFAULT, // Initial width
- CW_USEDEFAULT, // Initial height
- NULL, // Parent
- NULL, // Menu, must be null
- hInstance, // Application instance
- NULL); // Pointer to create
- // parameters
- // Return fail code if window not created.
- if (!IsWindow (hWnd)) return 0;
- // Standard show and update calls
- ShowWindow (hWnd, nCmdShow);
- UpdateWindow (hWnd);
- return hWnd;
- }
- //----------------------------------------------------------------------
- // TermInstance - Program cleanup
- //
- int TermInstance (HINSTANCE hInstance, int nDefRC) {
- return nDefRC;
- }
- //======================================================================
- // Font callback functions
- //
- //----------------------------------------------------------------------
- // FontFamilyCallback - Callback function that enumerates the font
- // families
- //
- int CALLBACK FontFamilyCallback (CONST LOGFONT *lplf,
- CONST TEXTMETRIC *lpntm,
- DWORD nFontType, LPARAM lParam) {
- int rc = 1;
- // Stop enumeration if array filled.
- if (sFamilyCnt >= FAMILYMAX)
- return 0;
- // Copy face name of font.
- lstrcpy (ffs[sFamilyCnt++].szFontFamily, lplf->lfFaceName);
- return rc;
- }
- //----------------------------------------------------------------------
- // EnumSingleFontFamily - Callback function that enumerates fonts
- //
- int CALLBACK EnumSingleFontFamily (CONST LOGFONT *lplf,
- CONST TEXTMETRIC *lpntm,
- DWORD nFontType, LPARAM lParam) {
- PFONTFAMSTRUCT pffs;
- pffs = (PFONTFAMSTRUCT) lParam;
- pffs->nNumFonts++; // Increment count of fonts in family
- return 1;
- }
这是programing microsoft windowsCE.net 中的示范代码