[ create a new paste ] login | about

Link: http://codepad.org/cRYq6Kfm    [ raw code | output | fork ]

C++, pasted on Jan 28:
// 
// win32コンソール空プロジェクトからの場合、
// 1.[構成プロパティ] → [C/C++] → [プリプロセッサ] → [プリプロセッサの定義] を _CONSOLE から _WINDOWS に変えて
// 2.[構成プロパティ] → [リンカ] → [システム] → [サブシステムの定義] も /SUBSYSTEM:WINDOWS に変えておく
// 
#include "windows.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LPCTSTR APP_CLASS_STR = TEXT("TEST_APP");

HINSTANCE hInst;

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR args, int cmd)
{
	hInst = hInstance;

	WNDCLASSEX wcex;
	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.hInstance = hInstance;			// ※重要1・登録するウィンドクラスの実体のハンドル
	wcex.lpfnWndProc = WndProc;			// ※重要2・OSから回されるメッセージの処理関数のポインタ
	wcex.lpszClassName = APP_CLASS_STR;	// ※重要3・登録するウィンドクラスの内部名
	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpszMenuName = NULL;
	wcex.hIcon = wcex.hIconSm = NULL;
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.cbClsExtra = wcex.cbWndExtra = 0;
	RegisterClassEx(&wcex);

	MSG msg;
	HWND hWnd = CreateWindow(
		APP_CLASS_STR, TEXT("VIP_DUNGEON")
		, WS_OVERLAPPEDWINDOW
		, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT
		, NULL, NULL, hInst, NULL
	);
	if(!hWnd) return FALSE;

	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);

	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, NULL, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	return (int)msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;

	switch (message)
	{
	case WM_CREATE:
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);

		switch (wmId)
		{
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		// 描画処理
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}


Output:
1
2
3
Line 20: error: windows.h: No such file or directory
Line 9: error: 'LRESULT' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: