?? jiance.cpp
字號:
#include<windows.h>
#include"1.h"
const TCHAR szAppName[]=TEXT("chapter6");
HINSTANCE hInst;
const struct decodeUINT MainMessages[]={
WM_PAINT,DoPaintMain,
WM_DESTROY,DoDestroyMain,
};
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,int nCmdShow){
MSG msg;
int rc=0;
HWND hwndMain;
hwndMain=InitInstance(hInstance,lpCmdLine,nCmdShow);
if(hwndMain==0)
return 0x10;
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return TermInstance(hInstance,msg.wParam);
}
HWND InitInstance(HINSTANCE hInstance,LPWSTR lpCmdLine,int nCmdShow){
WNDCLASS wc;
HWND hWnd;
hInst=hInstance;
#if defined(WIN32_PLATFORM_PSPC)
hWnd=FindWindow(szAppName,NULL);
if(hWnd){
SetForegroundWindow((HWND)(((DWORD)hWnd)|0x01));
return 0;
}
#endif
wc.style=0;
wc.lpfnWndProc=MainWndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=NULL,
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName=szAppName;
if(RegisterClass(&wc)==0) return 0;
hWnd=CreateWindowEx (WS_EX_NODRAG,
szAppName,
TEXT("chapter6"),
WS_VISIBLE|WS_CAPTION|WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if((!hWnd)||(!IsWindow(hWnd))) return 0;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return hWnd;
}
int TermInstance(HINSTANCE hInstance,int nDefRC){
return nDefRC;
}
LRESULT CALLBACK MainWndProc(HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
INT i;
for(i=0;i<dim(MainMessages);i++){
if(wMsg==MainMessages[i].Code)
return(*MainMessages[i].Fxn)(hWnd,wMsg,wParam,lParam);
}
return DefWindowProc(hWnd,wMsg,wParam,lParam);
}
LRESULT DoPaintMain(HWND hWnd,UINT wMsg,WPARAM wParam,
LPARAM lParam){
PAINTSTRUCT ps;
RECT rect;
HDC hdc;
INT i,dy;
DWORD dwColorTable[]={RGB(0,0,1),RGB(0,233,1),
RGB(1,1,1),RGB(45,23,1),
RGB(254,3,5),RGB(0,254,1)};
GetClientRect(hWnd,&rect);
hdc=BeginPaint(hWnd,&ps);
dy=20;
rect.bottom=30;
SetBkMode(hdc,TRANSPARENT);
for(i=0;i<6;i++){
SetTextColor(hdc,dwColorTable[i]);
SetBkColor(hdc,dwColorTable[6-i]);
DrawText(hdc,TEXT("Using DrawText"),-1,&rect,
DT_VCENTER);
rect.top+=dy;
rect.bottom+=dy;
}
SetBkMode(hdc,OPAQUE);
for(i=0;i<6;i++)
{
SetTextColor(hdc,dwColorTable[i]);
SetBkColor(hdc,dwColorTable[6-i]);
ExtTextOut(hdc,rect.left,rect.top,ETO_CLIPPED||ETO_OPAQUE,&rect,TEXT("Using DrawTextOut"),
16,0);
rect.top+=dy;
rect.left+=dy;
}
EndPaint(hWnd,&ps);
return 0;
}
LRESULT DoDestroyMain(HWND hWnd,UINT wMsg,WPARAM wParam, LPARAM lParam)
{
PostQuitMessage(0);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -