so I have this code to draw screen to client area every 100ms

                    HDC hDC = GetDC(hWnd);

                    SetStretchBltMode(hDC, HALFTONE);
                    StretchBlt(hDC, 0, 0, screen.right/2, screen.bottom/2, GetDC(NULL), 0, 0, screen.right, screen.bottom, SRCCOPY);

                    DeleteDC(hDC);

however whenever it draws the program freezes for a while (like 10ms), it's not really noticeable unless you move the window around - then you can see how window stutters and just "teleports" to where it is supposed to be, is there something I can do to fix this?

also is it possible to draw, for example, blue rectangle, or text on the screen, no matter what's going on? e.g. my program is minimized and there's a game running on fullscreen (or at least fullscreen-windowed/borderless), as some kind of reminder? how do I do something like that? it doesn't have to be drawn, it can be a dialog that won't make users lose focus on the application they are using, like steam's "friend has connected/started to play <Game>"... I tried to google that, but since I dont even know what exactly I have to google it's kinda hard to find solution...

Recommended Answers

All 2 Replies

I think you should do a transparent overlay. It will only work with the game in fullscreen bordeless since it's "external".
To work in fullscreen you need to inject.
You can create a thread and draw/render with it.

Or, if you just want to show a message, with win32, you can create a window with ex style WS_EX_TOPMOST should be enough and set a timer to close it.

You need to create a Real-Time-Message-Loop as done in Direct-X. See: http://www.directxtutorial.com/Lesson.aspx?lessonid=9-1-4

while(true)
{
    while(PeekMessage(&messages, NULL, 0, 0, PM_REMOVE))
    {
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }

    if (messages.message == WM_QUIT)
        break;

    //Do Drawing Here instead of WM_PAINT..
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.