#Features works when debugged with f5 but doesnt work when built into an executable

6 messages · Page 1 of 1 (latest)

mild hollow
#

dont know if anyone can help me i have a feature in the project in working on where it can take screenshots of the screen but when i build it into an executable the feature doesnt work, it works when i debug normally with f5

stone zephyr
#

What feature?

mild hollow
# stone zephyr What feature?
// Function to take a screenshot and save it as JPEG (Provided Code)
void TakeScreenshot(const string& type = "") {
    int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
    int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
    int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
    int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);

    HDC hScreenDC = GetDC(NULL);
    HDC hMemoryDC = CreateCompatibleDC(hScreenDC);
    HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, width, height);
    HGDIOBJ oldBitmap = SelectObject(hMemoryDC, hBitmap);

    BitBlt(hMemoryDC, 0, 0, width, height, hScreenDC, x, y, SRCCOPY | CAPTUREBLT);

    Gdiplus::Bitmap bitmap(hBitmap, NULL);
    CLSID clsid;
    GetEncoderClsid(L"image/jpeg", &clsid);

    string timestamp = getTimestamp();
    string filename = "requirements\\Screenshots\\screenshot_" + (type.empty() ? "" : type + "_") + timestamp + ".jpg";
    for (char& c : filename) {
        if (c == ':') c = '_';
    }
    wstring wFilename(filename.begin(), filename.end());
    bitmap.Save(wFilename.c_str(), &clsid, NULL);

    SelectObject(hMemoryDC, oldBitmap);
    DeleteDC(hMemoryDC);
    ReleaseDC(NULL, hScreenDC);
    DeleteObject(hBitmap);
}
mild hollow
#

even yesterday it when it worked it was by luck lol