Well, I don't really know how to make a windows hook DLL...
And it flashes even worse, when I use it in a normal window in a wm_paint:
Code:
#include <windows.h>
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
HDC hdc;
RECT rc;
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
ShowWindow (hwnd, nFunsterStil);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
hdc = GetDC(hwnd);
rc.left = 51;
rc.top = 53;
rc.right = 137;
rc.bottom = 76;
Rectangle(hdc,48,48,140,77);
DrawText(hdc,"Garfield rules",14,&rc,DT_CENTER|DT_NOCLIP);
ReleaseDC(hwnd, hdc);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
My actual code was:
Code:
#include <windows.h>
HDC hdc;
RECT rc;
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
hdc = GetDC(HWND_DESKTOP);
rc.left = 51;
rc.top = 53;
rc.right = 137;
rc.bottom = 76;
while(1==1){
Rectangle(hdc,48,48,140,77);
DrawText(hdc,"Garfield rules",14,&rc,DT_CENTER|DT_NOCLIP);
Sleep(1);
}
ReleaseDC(HWND_DESKTOP, hdc);
return 0;
}