Ну вопервых окно тутже будет закрыватся... Во вторых вот код:
| Код | #pragma comment(linker,"/MERGE:.rdata=.text") #pragma comment(linker,"/FILEALING:512 /SECTION:.text,EWRX /IGNORE:4028") #pragma comment(linker,"/ENTRY:WinMain") #include <windows.h> ATOM MyRegisterClass(HINSTANCE hInst); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); BOOL InitInstance(HINSTANCE, int); MSG msg; #define IDM_EXIT 105 char __title[64]="Window"; char __class[64]="Window"; WNDCLASSEX wc; int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hPrevInst, LPTSTR lpCmdLine,int iCmdShow) { wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; wc.hIcon = NULL; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = __class; wc.hIconSm = NULL; RegisterClassEx(&wc); CreateWindowEx(0,__class,__title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,wc.hInstance,NULL); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc;
switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
|
Добавлено @ 13:50 Компиль в Win32 -> Empty -> release ! .EXE получается размером 10 кило !!! Могу попытатся уменьшить код.
Добавлено @ 14:01 Ну уж проше некуда!!! Урезал что смог вот результат:
| Код | #pragma comment(linker,"/MERGE:.rdata=.text") #pragma comment(linker,"/FILEALING:512 /SECTION:.text,EWRX /IGNORE:4028") #pragma comment(linker,"/ENTRY:WinMain") #include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); //--------------------------- WNDCLASSEX wc; #define IDM_EXIT 105 //---------------------------- int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hPrevInst, LPTSTR lpCmdLine,int iCmdShow) { MSG msg; TCHAR __class[64]="Window"; wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = (WNDPROC)WndProc; wc.hInstance = hInst; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszClassName = __class;
RegisterClassEx(&wc); CreateWindowEx(0,__class,__class,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,wc.hInstance,NULL); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
|
|