小编Mas*_*man的帖子

Win32 程序以恒定速度卡住

我正在使用 win32 API,并且编写了一个简单的程序,每秒绘制 100 个随机像素十次。但是,当我编译并运行代码时,屏幕大约每秒刷新一次。我会对其进行调试,但我正在锁定的设备上工作,并且我的 IDE 没有调试功能。我已经更改了我能找到的所有引用计时器函数的变量,但没有任何效果。我正在使用 gcc 进行编译。这是代码:

#include <windows.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
const int ID_TIMER = 1;

void DrawRandom(HDC hdc);


//Double buffering implementation 
static void Paint(HDC hdc, RECT* prc){
    //Declares our varibles
    HDC hdcMem;
    HBITMAP hbmMem, hbmOld;
    HBRUSH hbrBkGnd;
    POINT Border;
    //Creates creates compatible device context
    hdcMem = CreateCompatibleDC(hdc);

    //Create bitmap big enough for our display
    hbmMem = CreateCompatibleBitmap(hdc, prc->right, prc->bottom);

    //Select the bitmap into the …
Run Code Online (Sandbox Code Playgroud)

c++ winapi

0
推荐指数
1
解决办法
92
查看次数

标签 统计

c++ ×1

winapi ×1