Click to See Complete Forum and Search --> : c, bitblt and other problems


haniwa
November 9th, 2003, 10:18 AM
Hi folks,

i try to use double-buffering to output a short
list. Here´s the code:

int DrawList (int tmp) {
int i,j;
int numLines = 0, counter = 0;
int LowLine = 0;
HDC hMemDC;

numLines = (WinSizeY-62)/cyChar;
LowLine = LineCount-numLines;
if (numLines >= maxWindow) {
LowLine = (LineCount-maxWindow);
numLines = maxWindow;
}
if (numLines >= LineCount)LowLine = 0;

InvalidateRect (hwnd, NULL, TRUE);

hdc = BeginPaint(hwnd, &ps);
hMemDC = CreateCompatibleDC(hdc);
if (hMemDC == NULL) MessageBox (hwnd, TEXT ("could not get Backbuffer Device Context\n :-("),
"TestApp", MB_OK | MB_ICONSTOP);
SelectObject (hMemDC, GetStockObject (BLACK_BRUSH));
SelectObject (hMemDC, GetStockObject (NULL_PEN));
SetTextColor(hMemDC, 0x00DF00);
SetBkColor(hMemDC, 0x000000);
Rectangle (hMemDC, 0, 0, WinSizeX, WinSizeY);
counter = 0;
for (j=(LowLine); j<=LineCount-1; j++) {
for (i=0; i<=LBLength[j]; i++) {
Buffer[i]=LineBuffer[j][i];
}
TextOut (hMemDC, 4, cyChar*counter+2, Buffer, LBLength[j]);
counter++;
}
/* Display the memory DC */

BitBlt( hdc, 0, 0, WinSizeX, WinSizeY, hMemDC, 0, 0, SRCCOPY );

DeleteDC(hMemDC);
EndPaint( hwnd, &ps );

return 0;
}

it just doesnt work. :( Sending the output
directly to hdc works, using BLACKNESS on the
bitblt works too. using hMemDC results
in a transparent window. Where´s the problem?

2. i want to hide the application window
from view on request. like the boss key
in older games. what would be the
easiest way to hide the application from
the desktop, taskbar and that 'alt-tab' list (if thats possible...)?

thanx in advance, i really need your
on the first problem.
haniwa

edit:
i am quite new to programming, so dont
hesitate to point me to better ways of
doing things.:)

gstercken
November 10th, 2003, 06:06 AM
Just creating an offscreen device context using CreateCompatibleDC() is not enough: You will also need to create a compatible bitmap of the desired size (using CreateCompatibleBitmap()) and select it into the memory DC.

haniwa
November 10th, 2003, 12:33 PM
Danke Mann!

nachdem ich das ne halbe stunde so probiert hab:
hMemDC = CreateCompatibleBitmap( hMemDC, Winsi...
gehts nu doch.:)

Danke und hab noch ne schöne Woche,
haniwa

english translation:

thank you