#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); char szName[255]="API"; COLORREF wbgCol=RGB(180,250,180); HINSTANCE g_hInst; //옵션 변수 int x,y,x1,y1; RECT rect[4]; char change[30]; // 옵션 변수 끝 int WINAPI WinMain(HINSTANCE hInstance, //윈도우 고유 id HINSTANCE hPrevInstance, //전에 뜬 창값---안쓴다.. LPSTR lpCmdLine, //포인터 문자를 가져온다. lpCmdLine=명령줄인수 int mShowCmd) // 창보이는방법 sw_show,minmize,maxmize,sw_hide { g_hInst=hInstance; MSG msg; //베시지 객체 생성 WNDCLASS wnd; //윈도우 클래스 객체의 생성 wnd.cbClsExtra=0; wnd.cbWndExtra=0; wnd.hbrBackground=CreateSolidBrush(wbgCol); //창 바탕화면 wnd.hCursor=LoadCursor(NULL,IDC_ARROW); //마우스 커서 wnd.hIcon=LoadIcon(NULL,IDI_APPLICATION); //제목줄 프로그램 대표 그림.. wnd.lpszClassName=szName; //윈도우이름 wnd.lpszMenuName=NULL; //메유없음 wnd.lpfnWndProc=WndProc; //선언한..콜백함수명 wnd.hInstance=hInstance; //선언한..윈도우 고유 ID wnd.style=CS_HREDRAW|CS_VREDRAW; //윈도우 가로세로 크기변경시 새로고침 RegisterClass(&wnd); //레지스트에 등록 HWND hwnd=CreateWindow(szName, // 윈도우 이름 szName, // 윈도우 제목 WS_POPUP , // 창크기 메뉴 100,50,900,650, //시작지점과 크기 NULL, NULL, // hInstance, NULL); ShowWindow(hwnd, SW_SHOW); while(GetMessage(&msg,0,0,0)){ //메세지 감시 if(GetAsyncKeyState(VK_ESCAPE)) break; //ESC눌리면 창닫기 // GetAsyncKeyState 키 눌린상태 확인 함수
TranslateMessage(&msg); // 키보드 사용을 허용한다. DispatchMessage(&msg); // 윈도우에 제어 요소를 반환
} return 0; } LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; //그래픽 툴 구조체 PAINTSTRUCT ps; // 글씨 출력 도움 구조체 //옵션 int i=0; //옵션끝 switch(uMsg) { case WM_DESTROY: //창 닫기 PostQuitMessage(0); break; case WM_SIZE: for(i=0;i<4;i++) { SetRect(&rect[i],50+100*i+10*i,50,150+100*i+10*i,100); // rect 설정 } break; case WM_PAINT: hdc=BeginPaint(hwnd,&ps); for(i=0;i<4;i++) { Rectangle(hdc,rect[i].left,rect[i].top,rect[i].right,rect[i].bottom);//렉 그리기 // DrawText(hdc,&rText[i],6,&rect[i],DT_CENTER|DT_VCENTER|DT_SINGLELINE); } DrawText(hdc,"계산기",6,&rect[0],DT_CENTER|DT_VCENTER|DT_SINGLELINE); DrawText(hdc,"메모장",6,&rect[1],DT_CENTER|DT_VCENTER|DT_SINGLELINE); DrawText(hdc,"그림판",6,&rect[2],DT_CENTER|DT_VCENTER|DT_SINGLELINE); DrawText(hdc,"카드놀이",8,&rect[3],DT_CENTER|DT_VCENTER|DT_SINGLELINE); EndPaint(hwnd,&ps); break; case WM_LBUTTONDOWN: { POINT point; point.x=LOWORD(lParam); point.y=HIWORD(lParam); for(i=0;i<4;i++) { if(PtInRect(&rect[i],point)) { if(i==0)WinExec("c:\\winnt\\system32\\calc.exe",SW_SHOW); if(i==1)WinExec("c:\\winnt\\system32\\notepad.exe",SW_SHOW); if(i==2)WinExec("c:\\winnt\\system32\\mspaint.exe",SW_SHOW); if(i==3)WinExec("c:\\winnt\\system32\\sol.exe",SW_SHOW); } } } break; } return DefWindowProc(hwnd,uMsg,wParam,lParam); //return 0; }
|