
createwindow textout显示的字体
在vc++win32application平台下用createwindow创建窗口,后用textout输出文字,可是输出文字的字体却不一样,一会儿粗黑一些而且小一些,一会...
在vc++win32 application平台下用createwindow创建窗口,后用textout输出文字,可是输出文字的字体却不一样,一会儿粗黑一些而且小一些,一会儿又清晰一些。据我的估计应该是有时候使用英文输出格式,有时候使用汉语输出格式。请问原因在哪里啊,如何调节
我用了个vc助手,上面有个spell check的按钮,点击后,再运行,出现在所创建窗口中的字体就是小一些、又黑又粗的那种。有时候退出再运行或者操作其他的,就会变回正常显示的格式。还有个是vc自带的窗口切换按钮,点一下后,再运行,就变成清晰可见的字体了。 展开
我用了个vc助手,上面有个spell check的按钮,点击后,再运行,出现在所创建窗口中的字体就是小一些、又黑又粗的那种。有时候退出再运行或者操作其他的,就会变回正常显示的格式。还有个是vc自带的窗口切换按钮,点一下后,再运行,就变成清晰可见的字体了。 展开
2个回答
2012-05-13
展开全部
试试指定字体。转载一段C代码。这里"Georgia" 可以换成其他字体:
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Sonnet 55" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, TEXT("Sonnet 55"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 390, 350, NULL, NULL, hInstance, NULL);
while( GetMessage(&msg, NULL, 0, 0)) {
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
DWORD color;
HFONT hFont, holdFont;
static TCHAR *verse1 = TEXT("Not marble, nor the gilded monuments");
static TCHAR *verse2 = TEXT("Of princes, shall outlive this powerful rhyme;");
static TCHAR *verse3 = TEXT("But you shall shine more bright in these contents");
static TCHAR *verse4 = TEXT("Than unswept stone, besmear'd with sluttish time.");
static TCHAR *verse5 = TEXT("When wasteful war shall statues overturn,");
static TCHAR *verse6 = TEXT("And broils root out the work of masonry,");
static TCHAR *verse7 = TEXT("Nor Mars his sword, nor war's quick fire shall burn");
static TCHAR *verse8 = TEXT("The living record of your memory.");
static TCHAR *verse9 = TEXT("'Gainst death, and all oblivious enmity");
static TCHAR *verse10 = TEXT("Shall you pace forth; your praise shall still find room ");
static TCHAR *verse11 = TEXT("Even in the eyes of all posterity");
static TCHAR *verse12 = TEXT("That wear this world out to the ending doom.");
static TCHAR *verse13 = TEXT("So, till the judgment that yourself arise,");
static TCHAR *verse14 = TEXT("You live in this, and dwell in lovers' eyes.");
switch(msg)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
color = GetSysColor(COLOR_BTNFACE);
SetBkColor(hdc, color);
hFont = CreateFont(15, 0, 0, 0, FW_MEDIUM, 0, 0, 0, 0,
0, 0, 0, 0, TEXT("Georgia"));
holdFont = SelectObject(hdc, hFont);
TextOut(hdc, 50, 20, verse1, lstrlen(verse1));
TextOut(hdc, 50, 40, verse2, lstrlen(verse2));
TextOut(hdc, 50, 60, verse3, lstrlen(verse3));
TextOut(hdc, 50, 80, verse4, lstrlen(verse4));
TextOut(hdc, 50, 100, verse5, lstrlen(verse5));
TextOut(hdc, 50, 120, verse6, lstrlen(verse6));
TextOut(hdc, 50, 140, verse7, lstrlen(verse7));
TextOut(hdc, 50, 160, verse8, lstrlen(verse8));
TextOut(hdc, 50, 180, verse9, lstrlen(verse9));
TextOut(hdc, 50, 200, verse10, lstrlen(verse10));
TextOut(hdc, 50, 220, verse11, lstrlen(verse11));
TextOut(hdc, 50, 240, verse12, lstrlen(verse12));
TextOut(hdc, 50, 260, verse13, lstrlen(verse13));
TextOut(hdc, 50, 280, verse14, lstrlen(verse14));
SelectObject(hdc, holdFont);
DeleteObject(hFont);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Sonnet 55" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, TEXT("Sonnet 55"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 390, 350, NULL, NULL, hInstance, NULL);
while( GetMessage(&msg, NULL, 0, 0)) {
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
DWORD color;
HFONT hFont, holdFont;
static TCHAR *verse1 = TEXT("Not marble, nor the gilded monuments");
static TCHAR *verse2 = TEXT("Of princes, shall outlive this powerful rhyme;");
static TCHAR *verse3 = TEXT("But you shall shine more bright in these contents");
static TCHAR *verse4 = TEXT("Than unswept stone, besmear'd with sluttish time.");
static TCHAR *verse5 = TEXT("When wasteful war shall statues overturn,");
static TCHAR *verse6 = TEXT("And broils root out the work of masonry,");
static TCHAR *verse7 = TEXT("Nor Mars his sword, nor war's quick fire shall burn");
static TCHAR *verse8 = TEXT("The living record of your memory.");
static TCHAR *verse9 = TEXT("'Gainst death, and all oblivious enmity");
static TCHAR *verse10 = TEXT("Shall you pace forth; your praise shall still find room ");
static TCHAR *verse11 = TEXT("Even in the eyes of all posterity");
static TCHAR *verse12 = TEXT("That wear this world out to the ending doom.");
static TCHAR *verse13 = TEXT("So, till the judgment that yourself arise,");
static TCHAR *verse14 = TEXT("You live in this, and dwell in lovers' eyes.");
switch(msg)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
color = GetSysColor(COLOR_BTNFACE);
SetBkColor(hdc, color);
hFont = CreateFont(15, 0, 0, 0, FW_MEDIUM, 0, 0, 0, 0,
0, 0, 0, 0, TEXT("Georgia"));
holdFont = SelectObject(hdc, hFont);
TextOut(hdc, 50, 20, verse1, lstrlen(verse1));
TextOut(hdc, 50, 40, verse2, lstrlen(verse2));
TextOut(hdc, 50, 60, verse3, lstrlen(verse3));
TextOut(hdc, 50, 80, verse4, lstrlen(verse4));
TextOut(hdc, 50, 100, verse5, lstrlen(verse5));
TextOut(hdc, 50, 120, verse6, lstrlen(verse6));
TextOut(hdc, 50, 140, verse7, lstrlen(verse7));
TextOut(hdc, 50, 160, verse8, lstrlen(verse8));
TextOut(hdc, 50, 180, verse9, lstrlen(verse9));
TextOut(hdc, 50, 200, verse10, lstrlen(verse10));
TextOut(hdc, 50, 220, verse11, lstrlen(verse11));
TextOut(hdc, 50, 240, verse12, lstrlen(verse12));
TextOut(hdc, 50, 260, verse13, lstrlen(verse13));
TextOut(hdc, 50, 280, verse14, lstrlen(verse14));
SelectObject(hdc, holdFont);
DeleteObject(hFont);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询