我是c ++的新手,我正在尝试创建一个游戏.我有一个2d数组的矩形RECT_GRID.我有一个无符号短的二维数组GRID.我在WM_CREATE期间填充矩形数组
WM_PAINT事件为数组中的所有元素绘制矩形.矩形的颜色基于GRID [x] [y]的值
当按下向下键时,我这样做了,它通过将GRID [1] [XMOVE] =设置为不同的颜色来改变其中一个矩形的颜色,然后使客户端矩形无效
基本上发生了什么,它有效地工作了一段时间,但最终它只是停止绘制东西.我在调试期间检查了我的XMOVE变量,我检查了网格值和东西,一切都很好.当我从paint事件中移除for循环并专注于1个特定的矩形时,它永远不会失败,但如果我尝试一次重绘所有这些,大约20次后,它就会停止绘制内容.什么可能导致这个?我是c ++的新手,我打赌我没有正确地绘画并导致溢出或其他东西.
如果有人能解释出现了什么问题,或者正确的做法,我真的很感激.我在Google上找不到这样的例子.谢谢
编辑:
我正在使用3个全球刷HBRUSH A; HBRUSH B; HBRUSH C;
当我修改它们时,我总是说A = MakeBrush(NUM);
我正确地使用刷子吗?
可能重复:
如何阻止C++控制台应用程序立即退出?
所以即时学习c ++和我给出了这个例子,我想运行它.但我不能让它熬夜,除非我改变它.在我发布之后,如何让Microsoft Visual 2010在屏幕到达程序结束时保持屏幕状态?
#include<iostream>
using namespace std;
int area(int length, int width); /* function declaration */
/* MAIN PROGRAM: */
int main()
{
int this_length, this_width;
cout << "Enter the length: "; /* <--- line 9 */
cin >> this_length;
cout << "Enter the width: ";
cin >> this_width;
cout << "\n"; /* <--- line 13 */
cout << "The area of a " << this_length << "x" << this_width;
cout << " rectangle is " << …Run Code Online (Sandbox Code Playgroud) 我有以下代码.
#include<iostream>
using namespace std;
int main() {
int result=0;
_asm {
mov eax,2
mov eax,result;
}
cout<<result<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我知道汇编程序很好,但为什么程序输出2到屏幕?
我正在使用microsoft visual c ++ 2010我可以使用boost库还是需要不同的编译器?
我想创建一个,kernel level of process for windows (Ring 0)但我不知道从哪里开始.我想知道哪些SDK是必需的,任何显示其实现的教程都会有所帮助.
我的C++代码如下:
#include <iostream>
using namespace std;
int main() {
int i = 0;
cout << (i=0) << endl;
if(i=0) {
i=1;
}
cout << i;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么(i=0)等于0?
有我的代码:
int main()
{
STARTUPINFO si = { sizeof(si) };
PPROCESS_INFORMATION pi;
TCHAR szCommandLine[] = TEXT("C:\Windows\notepad.exe");
auto is_suc = CreateProcess(NULL, szCommandLine, NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在win10 CreateProcess()API中是否存在一些问题?
任何人都可以帮我解释一下:
int a, b, c, d;
a = 2;
b = 4;
c = a, b;
d = (a, b);
Run Code Online (Sandbox Code Playgroud)
为什么c == 2和d == 4???
所以我尝试使用此代码,但它不起作用:
CButton *btnApply;
btnApply = reinterpret_cast<CButton *>(GetDlgItem(IDOK));
btnApply->ShowWindow(FALSE);
Run Code Online (Sandbox Code Playgroud)
提前致谢.
在GCC中,C ++的行为__PRETTY_FUNCTION__定义在哪里?我想在Visual Studio中复制其功能。
据我了解,我可以替换__PRETTY_FUNCTION__为__FUNCTION__或__FUNCSIG__,¹,但是那样的话,我将失去在macOS上编译代码的能力。
__PRETTY_FUNCTION__我要如何在例如Visual Studio和Xcode中进行编译的代码中如何包含的功能。