#include <StdAfx.h>
#include "resource.h"
#include "tchar.h"LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
WNDCLASS wc;
HWND hWnd;
// HMENU hMenu;
MSG msg;
char szAppName[]="helloWin"; 
// hMenu=LoadMenu(hInstance,(LPCTSTR)IDC_MENU);
wc.lpszClassName=szAppName;
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.lpfnWndProc=WndProc;
wc.hInstance=hInstance;
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hIcon=LoadIcon(NULL,LPCTSTR(IDI_APPLICATION));
wc.lpszMenuName=(LPCSTR)IDC_MENU;
if(!RegisterClass(&wc))
{
MessageBeep(1000);
return false;
}
hWnd=CreateWindow(szAppName,"sdk",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,0);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while(::GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(msg.message=WM_DESTROY)
{
::MessageBox(NULL,TEXT("bye"),TEXT("bye"),0);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
HPEN hPen,hOldPen;
char szName[]="hell world";
int szlen=sizeof(szName)-1;
int wmpara;
switch(message)
{
case WM_COMMAND:
wmpara=LOWORD(wParam);
switch(wmpara)
{
case IDM_EXIT:
DestroyWindow(hWnd);
return 0;
case IDM_DISP:
MessageBox(hWnd,"&raquo;&para;&Oacute;&shy;&frac12;&oslash;&Egrave;&euml;sdk&Ecirc;&Agrave;&frac12;&ccedil;","hello",0);
return 0;
} case WM_PAINT:
LOGFONT LogFont;
HFONT hHelv,hTmsRmn,hOldFont;
LogFont.lfHeight=25;
LogFont.lfWidth=15;
LogFont.lfItalic=1;
LogFont.lfUnderline=1;
LogFont.lfEscapement=0;
LogFont.lfOrientation=0;
LogFont.lfCharSet=GB2312_CHARSET;
lstrcpy(LogFont.lfFaceName,"Helv");
hHelv=CreateFontIndirect(&LogFont);

LogFont.lfHeight=25;
LogFont.lfWidth=15;
LogFont.lfItalic=1;
LogFont.lfUnderline=1;
lstrcpy(LogFont.lfFaceName,"TmsRmn");
hTmsRmn=CreateFontIndirect(&LogFont);
hdc=BeginPaint(hWnd,&ps);
// hdc=GetDC(hWnd);
GetClientRect(hWnd,&rect);
hOldFont=(HFONT)SelectObject(hdc,hHelv);
TextOut(hdc,100,100,"hello",5);
SelectObject(hdc,hTmsRmn);
TextOut(hdc,200,200,szName,szlen);
SelectObject(hdc,hOldFont);
DeleteObject(hHelv);
DeleteObject(hTmsRmn);
TextOut(hdc,250,250,"hello world",sizeof("hello world")-1);
DrawText(hdc,"&raquo;&para;&Oacute;&shy;&frac12;&oslash;&Egrave;&euml;sdk&sup3;&Igrave;&ETH;ò",-1,&rect,DT_SINGLELINE|DT_VCENTER|DT_CENTER);
// ReleaseDC(hWnd,hdc);
hPen=CreatePen(PS_SOLID,1,RGB(0,0,255));
hOldPen=(HPEN)SelectObject(hdc,hPen);
MoveToEx(hdc,20,100,0);
LineTo(hdc,200,200);
SelectObject(hdc,hOldPen);
DeleteObject(hPen);
EndPaint(hWnd,&ps);
// MessageBox(hWnd,"hello","hi",0);
return 0;
// case WM_CREATE:
// PlaySound(TEXT("hellowin.wav"),NULL,SND_FILENAME|SND_ASYNC);
// return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,message,wParam,lParam);}