티스토리 뷰
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("Key");
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor=LoadCursor(NULL,IDC_CROSS);
WndClass.hIcon=LoadIcon(NULL,IDI_ERROR);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd=CreateWindow(lpszClass,lpszClass, WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,(HMENU)NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
while (GetMessage(&Message,NULL,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static TCHAR str[256];
int len;
switch (iMessage) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CHAR:
len=lstrlen(str);
str[len]=(TCHAR)wParam;
str[len+1]=0;
InvalidateRect(hWnd,NULL,FALSE);
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd, &ps);
TextOut(hdc, 100, 100, str, lstrlen(str));
EndPaint(hWnd, &ps);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
============================================
①static TCHAR str[256];
============================================
②case WM_CHAR:
len=lstrlen(str);
str[len]=(TCHAR)wParam;
str[len+1]=0;
③InvalidateRect(hWnd,NULL,FALSE);
return 0;
④case WM_PAINT:
hdc=BeginPaint(hWnd, &ps);
TextOut(hdc, 100, 100, str, lstrlen(str));
EndPaint(hWnd, &ps);
============================================
'Programing > API' 카테고리의 다른 글
API - InfoDlg (0) | 2009.01.19 |
---|---|
API - TimerText2 (0) | 2009.01.19 |
API - First (0) | 2009.01.19 |
- Total
- Today
- Yesterday
- Operation System
- WPF
- KAI
- ffmpeg
- 가상드라이브
- c#
- 데몬
- API 프로그래밍
- Programming - C
- 백신
- GAME
- V3
- 스터디_발표자료
- 소니
- 유마일
- Programming - C / C++
- 인코더
- WL-54G
- 프로그래밍
- 녹화
- 구글
- Programing
- PSP
- TCP/IP
- 하이퍼큐브
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |