如何制作窗口,或者更像剪辑区域,我可以在其中绘制像素?
它可能使用 WinApi,但是我不希望我的项目看起来像 winapi,所以它将有
int main(){}
代替
int WINAPI WinMain(HINSTANCE ...
我找到了一个例子,我可以在控制台窗口中绘制
int main()
{
COLORREF color = RGB(255,0,0); // COLORREF to hold the color info
SetConsoleTitle("Pixel In Console?"); // Set text of the console so you can find the window
HWND hwnd = FindWindow(NULL, "Pixel In Console?"); // Get the HWND
HDC hdc = GetDC(hwnd); // Get the DC from that HWND
for( int i = 0 ; i < 50 ; i++ )
{
SetPixel(hdc, 5+i, 12, color); // SetPixel(HDC hdc, int x, int y, COLORREF color)
}
ReleaseDC(hwnd, hdc); // Release the DC
DeleteDC(hdc); // Delete the DC
system("pause");
return(0);
}
但我想在选定的区域上绘制而不是控制台,该区域将保持焦点(当用户单击它时等)。
如果能够为这个程序处理简单的键盘/鼠标事件也很棒,但这不是我的主要目标,也许其他一些第三方库会提供帮助。
我希望我已经清楚地解释了我想做什么,但英语不是我的母语,所以对于任何误解我深表歉意。
我将感谢任何帮助。
因为我是第一次使用这个网站,所以很抱歉在错误的地方出现了一些垃圾邮件或消息,因为我不确定在哪里发布下一条消息:-)
所以我想写的是:
”
否则,Allegro/SDL 如何创建窗口?他们使用汇编程序调用还是 shell 调用?当我能够从头开始创建窗口时,无论需要做多少工作,我都会更高兴:)
”