createwindow textout显示的字体

在vc++win32application平台下用createwindow创建窗口,后用textout输出文字,可是输出文字的字体却不一样,一会儿粗黑一些而且小一些,一会... 在vc++win32 application平台下用createwindow创建窗口,后用textout输出文字,可是输出文字的字体却不一样,一会儿粗黑一些而且小一些,一会儿又清晰一些。据我的估计应该是有时候使用英文输出格式,有时候使用汉语输出格式。请问原因在哪里啊,如何调节
我用了个vc助手,上面有个spell check的按钮,点击后,再运行,出现在所创建窗口中的字体就是小一些、又黑又粗的那种。有时候退出再运行或者操作其他的,就会变回正常显示的格式。还有个是vc自带的窗口切换按钮,点一下后,再运行,就变成清晰可见的字体了。
展开
 我来答
匿名用户
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);
}
帐号已注销
2012-05-12 · TA获得超过1467个赞
知道小有建树答主
回答量:1137
采纳率:0%
帮助的人:591万
展开全部
vc assist x的机制是它会自动搜集你程序中定义的函数、变量和系统库函数、变量等信息,然后在你编写过程中根据上下文情况自动判断给你什么提示。
所以,当你的程序还不存在main()函数的时候,它是不会提示你main的,在main()存在的情况下,它才会根据它的判断逻辑会提示main()。
当然vc assist x是有bug,经常提示不太准确,你不要对它太依赖,毕竟只是个助手而已。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式