winmain 창 코드
12199 단어 main
#include<Windows.h>
#include<windowsx.h>
#include <string.h>
#include <cstdio>
#include "enginApp.h"
//#include "resource.h"
using namespace std;
#define WCLASSNAME "WindowClassName"
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600
#define COLOR_BPP 32
HDC hdc;
PAINTSTRUCT scPaint;
LRESULT CALLBACK windowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
WNDCLASSEX windowClass;
HWND hwnd;
MSG msg;
ZeroMemory(&msg, sizeof(MSG));
//
windowClass.cbSize=sizeof(WNDCLASSEX);
windowClass.style=CS_HREDRAW|CS_VREDRAW;
windowClass.lpfnWndProc=windowProc;
windowClass.cbClsExtra=0;
windowClass.cbWndExtra=0;
windowClass.hInstance=hInstance;
windowClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
windowClass.hCursor=LoadCursor(NULL,IDC_ARROW);
windowClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
windowClass.lpszClassName=WCLASSNAME;
windowClass.lpszMenuName=0;
windowClass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
//windowClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(ICON_T3DX));
//windowClass.hCursor = LoadCursor(hInstance, MAKEINTRESOURCE(CURSOR_CROSSHAIR));
//
RegisterClassEx(&windowClass);
//
hwnd=CreateWindowEx(NULL,WCLASSNAME,"Window Application",WS_OVERLAPPEDWINDOW|WS_VISIBLE,200,200,WINDOW_WIDTH,WINDOW_HEIGHT,NULL,NULL,hInstance,NULL);
if (!hwnd)
{
return 0;
}
// ,
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
// load the menu resource
//HMENU hmenuhandle = LoadMenu(hInstance, "MainMenu");
// attach the menu to the window
//SetMenu(hwnd, hmenuhandle);
CEnginApp *enginApp=new CEnginApp(WINDOW_WIDTH,WINDOW_HEIGHT,COLOR_BPP,hwnd,true);
enginApp->Init();
while (true)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}else
{
if(!enginApp->OnIdle())
DestroyWindow(hwnd);
//SendMessage(hwnd,WM_CLOSE,0,0);
Sleep(300);
}
}
enginApp->Release();
return msg.message;
}
LRESULT CALLBACK windowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch (msg)
{
case WM_MOVE:
{
//hdc=GetDC(hwnd);
//if (hdc)
//{
// int ix=LOWORD(lparam);
// int iy=HIWORD(lparam);
// char cTemp[128];
// sprintf_s(cTemp," :x=%d,y=%d",ix,iy);
// SetTextColor(hdc,RGB(0,0,255));
// SetBkColor(hdc,RGB(0,255,0));
// SetBkMode(hdc,OPAQUE);
// TextOut(hdc,0,20,cTemp,strlen(cTemp));
// ReleaseDC(hwnd,hdc);
//}
}
break;
case WM_PAINT:
{
//hdc=BeginPaint(hwnd,&scPaint);
//if (hdc)
//{
// SetTextColor(hdc,RGB(255,0,0));
// SetBkColor(hdc,RGB(0,255,0));
// SetBkMode(hdc,TRANSPARENT);
// TextOut(hdc,0,0,"Welcome!",8);
// EndPaint(hwnd,&scPaint);
// ReleaseDC(hwnd,hdc);
//}
}
break;
case WM_CLOSE:
{
if (MessageBox(0," ?"," ",MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON1)==IDYES)
{
DestroyWindow(hwnd);
}
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
case WM_KEYUP:
{
if (wparam==VK_ESCAPE)
{
//PostQuitMessage(0);
DestroyWindow(hwnd);
}
}
break;
case WM_COMMAND:
{
switch (LOWORD(wparam))
{
//case MENU_FILE_ID_EXIT:
// {
// DestroyWindow(hwnd);
// }
// break;
}
}
break;
}
return DefWindowProc(hwnd,msg,wparam,lparam);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C++ 정리 - 10 main 함수모든 C++ 프로그램엔 main함수가 있어야 한다. (Dynamic-link libraries와 static libraries 에는 main함수가 없다) 내 프로그램에서 main함수를 호출할 수 없다. main함수를...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.