C++based on Beethoven 'Pathique by Arthur Rubinstein

本文介绍了一个基于Windows平台的简单窗口程序实现方法,利用GDI进行基本的绘图操作,并展示了如何创建窗口类、注册窗口类、消息处理过程等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Previously I wrote about c++ which was based on Chopin' Nocturne.

#define WIN32_LEAN_AND_MEAN

#include <windows.h> // Include all the windows headers
#include <windowsx.h> // Include useful macros
#include "resource.h"

#define WINDOW_CLASS_NAME L"WINCLASS1"

void GameLoop()
{
	// One frame of game logic occurs here...
}

LRESULT CALLBACK WindowProc(
	HWND _hwnd,
	UINT _msg,
	WPARAM _wparam,
	LPARAM _lparam)
{
	// This is the main message handler of the system
	PAINTSTRUCT ps; // Used in WM_PAINT
	HDC hdc; // Handle to a device context

	// What is the message
	switch (_msg)
	{
	case WM_CREATE:
	{
		// Do initialization stuff here


		// Return Success
		return (0);
	}
	break;
	case WM_PAINT:
	{
		// Simple validate the window
		hdc = BeginPaint(_hwnd, &ps);

		// You would do all your painting here...

		EndPaint(_hwnd, &ps);

		// Return Success
		return (0);
	}
	break;
	case WM_DESTROY:
	{
		// Kill the application, this sends a WM_QUIT
		PostQuitMessage(0);

		// Return Sucess
		return(0);
	}
	break;
	default:
		break;
	} // End swicth

	// Processo any messages that we did not take care of...
	return (DefWindowProc(_hwnd, _msg, _wparam, _lparam));

}

int WINAPI WinMain(
	HINSTANCE _hInstance,
	HINSTANCE _hPrevInstance,
	LPSTR _lpCmdLine,
	int _nCmdShow)
{
	WNDCLASSEX winclass; // This will hold the class we create.
	HWND hwnd;           // Generic window handle.
	MSG msg;             // Generic message.
	HCURSOR hCrosshair = LoadCursor(_hInstance, MAKEINTRESOURCE(IDC_CURSOR1));// Loading cursor ,MAKEINTRESOURCE enables us 
         to  relate to the resource file  such as icons and other bitmaps. screw thatfucking capital word anyway
         // First fill in the window class structure.
	winclass.cbSize = sizeof(WNDCLASSEX);
	winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
	winclass.lpfnWndProc = WindowProc;
	winclass.cbClsExtra = 0;
	winclass.cbWndExtra = 0;
	winclass.hInstance = _hInstance;
	winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	winclass.hCursor = LoadCursor(_hInstance, MAKEINTRESOURCE(IDC_CURSOR1));
	winclass.hbrBackground = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
	winclass.lpszMenuName = NULL;
	winclass.lpszClassName = WINDOW_CLASS_NAME;
	winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

	// Registr the window class
	if (!RegisterClassEx(&winclass))
	{
		return(0);
	}

	// Create the window
	hwnd = CreateWindowEx(
		NULL, // Extended style
		WINDOW_CLASS_NAME, // Class
		L"My first Window", // Title
		WS_OVERLAPPEDWINDOW | WS_VISIBLE,
		0, 0, // Initial x, y
		400, 400, // Initial width, height
		NULL, // Handle to parent
		NULL, // Handle to menu
		_hInstance, // Instance of this application
		NULL // Extra creation parameters
	);

	if (!(hwnd))
	{
		return (0);
	}

	// Enter main event loop
	while (true)
	{
		// Test if there is a message in queue, if so get it.
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			// Test if this is a quit
			if (msg.message == WM_QUIT)
			{
				break;
			}

			// Translate any accelerator keys
			TranslateMessage(&msg);
		}

		// Main game processing goes here
		GameLoop(); // One frame of game logic occurs here...
	}

	// Return to Windows like this...
	return (static_cast<int>(msg.wParam));
}

The Title of this code is about GDI ,which is Graph Device Interface.

fuck this ,my VPS is shut down anyway .

a really great OpenGL course is waiting for me on the YouTube

I amreally sad now cause i 'm listening to the first movement of Beethovan's Pathique

Jesus Chris! the second movement is coming soon!

Time to check out that scripts.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值