Nanashi-soft○プログラマ専用○Windows gcc SDL○
ghWnd= CreateWindow(szClassNme, "test", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);そうだよね。WinMainから始まらないから、引数が足りないよね
ShowWindow(ghWnd, nCmdShow);nCmdShow変数も未定義エラーになるので調べたところ
//============================================================================
// Name : test2.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
#include <windows.h>
HWND ghWnd;
char szClassNme[] = "test2";
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int main()
{
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbWndExtra = 0;
wc.cbClsExtra = 0;
wc.hInstance = NULL;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wc.lpszMenuName = NULL;
wc.lpszClassName = szClassNme;
RegisterClass(&wc);
ghWnd= CreateWindow(szClassNme, "test", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, NULL, NULL, NULL, NULL);
ShowWindow(ghWnd, SW_SHOWNORMAL);
UpdateWindow(ghWnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg){
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd, msg, wParam, lParam));
}
}