⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winskel.cpp

📁 Direct3D游戏编程入门教程源代码.rar
💻 CPP
字号:
//-------------------------------------------------------------------------
// File: winskel.cpp
//
// Desc: Example code showing how to create a minimal Windows skeleton
//
// Last modified: 31. Dezember 2000
//
// Copyright (c) 1999-2001 Wolfgang Engel wolf@direct3d.net
//--------------------------------------------------------------------------
#include <windows.h> 
#include "resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 
VOID Render();

char szWinName[] = "MyWin"; /* name of window class */ 
BOOL bActive = TRUE;

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, 
				   LPSTR lpszArgs, int nWinMode) 
{
	HWND hwnd; 
	MSG msg; 
	
	/* Step 1: Define a window class. */ 
	WNDCLASS wcl; 
	wcl.hInstance = hThisInst; /* handle to this instance */ 
	wcl.lpszClassName = szWinName; /* window class name */ 
	wcl.lpfnWndProc = WndProc; /* window function */ 
	wcl.style = 0; /* default style */ 
	wcl.hIcon = LoadIcon(hThisInst, MAKEINTRESOURCE(IDI_ICON1)); /* icon style */ 
	wcl.hCursor = LoadCursor( hThisInst, MAKEINTRESOURCE(IDC_HULLA)) ; /* cursor style */ 
	wcl.lpszMenuName = NULL; /* no menu */ 
	wcl.cbClsExtra = 0; /* no extra */ 
	wcl.cbWndExtra = 0; /* information needed */ 

	/* Make the window background white. */ 
	wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH) ; 

	/* Step 2: Register the window class. */ 
	if(!RegisterClass (&wcl)) 
		return 0; 
	
	DWORD dwWindowStyle = WS_SYSMENU;
	DWORD dwWidth = 640;
	DWORD dwHeight = 480;
	
	RECT rc;
	SetRect(&rc, 0, 0, dwWidth, dwHeight);
	AdjustWindowRect(&rc, dwWindowStyle, TRUE);

	/* Step 3: Now that a window class has been registered, 
				a window can be created. */ 
	hwnd = CreateWindow(szWinName, /* name of window class */ 
						"FAKE 4", /* title */ 
						dwWindowStyle, /* window style - normal */ 
						CW_USEDEFAULT, /* X coordinate - let Windows decide */ 
						CW_USEDEFAULT, /* y coordinate - let Windows decide */ 
						(rc.right - rc.left), /*  */ 
						(rc.bottom - rc.top), /*  */ 
						HWND_DESKTOP, /* no parent window */ 
						NULL, /* no menu */ 
						hThisInst, /* handle of this instance of the program */ 
						NULL /* no additional arguments */ 
						);

	/* Step 4: Display the window. */ 
	ShowWindow(hwnd, nWinMode); 

	BOOL bGotMsg;

	/* Step 5: Create the message loop. */
	while (WM_QUIT != msg.message)
	{
		if( bActive)
			bGotMsg = PeekMessage (&msg, NULL, 0U, 0U, PM_REMOVE);
		else
			bGotMsg = GetMessage (&msg, NULL, 0U, 0U);

		if(bGotMsg)
		{
			TranslateMessage(&msg); /* allow use of keyboard */ 
			DispatchMessage(&msg); /* return control to Windows */ 
		}
		else
		{
			if(bActive)
				Render();
		}
	}

	return msg.wParam; 
} 

//-----------------------------------------------------------------------------
// Name: WndProc
// Desc: This function is called by Windows and is passed 
//	 	 messages from the message queue
//-----------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, 
							 WPARAM wParam, LPARAM lParam) 
{ 
	switch (message) 
	{ 
		case WM_DESTROY: /* terminate the program */ 
			PostQuitMessage(WM_QUIT); 
		  break; 

		case WM_KEYDOWN:
		{
			switch (wParam)
			{
			case VK_ESCAPE:
				PostQuitMessage(WM_QUIT); 
			 break;

			case VK_F1:
			{
			 bActive = FALSE;
			 MessageBox( hwnd, "Here comes your help text", 
				 "Help for FAKE 4", MB_ICONQUESTION|MB_OK | MB_SYSTEMMODAL );
			 bActive = TRUE;
			}
			break;
			}
		}
	}
  return DefWindowProc(hwnd, message, wParam, lParam); 
}


//-----------------------------------------------------------------------------
// Name: Render
// Desc: dummy function to show the use of the enhanced skeleton
//-----------------------------------------------------------------------------
VOID Render()
{
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -