每当我尝试创建一个c ++ gui程序/窗口时,命令提示符窗口就会出现如下窗口:
但我所做的只是这个::
#include <iostream>
#include "define.h"
LRESULT CALLBACK WinProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd){
window win;
MSG msg;
win.cbClsExtra = NULL; //Additional parameters
win.cbWndExtra = NULL; //Additional parameters
win.hbrBackground = (HBRUSH)COLOR_WINDOW ; //Sets background color for the window
win.hCursor = LoadCursor(NULL, IDC_ARROW); //The cursor that will appear in the window
win.hIcon = NULL; //Icon for the window
win.hInstance = hInst; //Handle to the application instance
win.lpszClassName = "Window Class"; //The unique name of the window class
win.lpszMenuName = NULL; //Used for menus
win.style = NULL; //The look and feel of the window
win.lpfnWndProc=(WNDPROC)WinProc; //The callback procedure (more on that later)
RegisterClass(&win);
HWND hwnd = CreateWindow("Window Class", "Title", WS_OVERLAPPEDWINDOW, 200, 200, 640, 480, NULL, NULL, hInst, NULL);
ShowWindow(hwnd, SW_SHOWNORMAL);
while(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam){
switch (message){
case WM_CREATE:{
HWND button = CreateWindow("BUTTON", "ok", WS_VISIBLE | WS_CHILD | WS_BORDER, 20, 20, 50, 30, hWnd, NULL, NULL, &lParam);
break;
}
case WM_DESTROY:{
PostQuitMessage(0);
return 0;
break;
}
default:{
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
}
我只是在互联网上关注代码而不认为我做错了什么我想以任何方式删除这个烦人的cmd窗口......
所有回复者的tysm非常赞赏...........
修改
并且btw define.h是我创建的头文件,并将WNDCLASS定义为窗口