如何用vs2008编写一个简单的窗口程序
1个回答
展开全部
ShowWindow(myWnd,SW_SHOWNORMAL);
UpdateWindow(myWnd);
MSG msg;
BOOL f;
while(f=GetMessage(&msg,myWnd,0,0)!=0)
{
if(f==-1)
{
MessageBox(myWnd,"消息循环出错 GetMessage返回-1","asd",MB_OK);
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
int x=0,y=0;
LRESULT CALLBACK MyWinProc( HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
{HDC dc=GetDC(hwnd);
char s[2];
sprintf(s,"%c",wParam); //格式转换函数!! 记住了 徐家stdio。h
TextOut(dc,x,y,s,1);
x+=10;
if(400==x) {x=0;y+=20;}
ReleaseDC(hwnd,dc);
break;}
UpdateWindow(myWnd);
MSG msg;
BOOL f;
while(f=GetMessage(&msg,myWnd,0,0)!=0)
{
if(f==-1)
{
MessageBox(myWnd,"消息循环出错 GetMessage返回-1","asd",MB_OK);
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
int x=0,y=0;
LRESULT CALLBACK MyWinProc( HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
{HDC dc=GetDC(hwnd);
char s[2];
sprintf(s,"%c",wParam); //格式转换函数!! 记住了 徐家stdio。h
TextOut(dc,x,y,s,1);
x+=10;
if(400==x) {x=0;y+=20;}
ReleaseDC(hwnd,dc);
break;}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询