Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bad Loop help please (side note) Pin
B.F.13-Nov-05 4:37
B.F.13-Nov-05 4:37 
GeneralRe: Bad Loop help please Pin
lklf13-Nov-05 16:51
lklf13-Nov-05 16:51 
AnswerRe: Bad Loop help please Pin
chamilkab13-Nov-05 18:00
chamilkab13-Nov-05 18:00 
Questionproblems with ST_SplitterWnd and CFrameWnd Pin
#937013-Nov-05 1:34
#937013-Nov-05 1:34 
AnswerRe: problems with ST_SplitterWnd and CFrameWnd Pin
Gary R. Wheeler13-Nov-05 2:01
Gary R. Wheeler13-Nov-05 2:01 
GeneralRe: problems with ST_SplitterWnd and CFrameWnd Pin
#937013-Nov-05 4:18
#937013-Nov-05 4:18 
QuestionOPC XML DA Client - Managed C++ Implementation Pin
exetera13-Nov-05 0:38
exetera13-Nov-05 0:38 
QuestionDouble Buffering Pin
Akilez12-Nov-05 22:17
Akilez12-Nov-05 22:17 
I am new to using Bitmaps in my programs... As tutorial/practice I want to create a simple game, the graphics of which will be supplied by bitmaps, however loading and blitting the individual bitmaps to the window DC provides much flicker. I realize I need to implement some double buffering strategy, however, I am, as yet unable to do so.

The way I see it:

1. Create two compatible DCs. (intermediate and final)
2. Load and select the individual bitmaps to the intermediate DC.
3. BitBlt() then ecah to their proper position in the "final" DC
4. Load and select the "final" bitmap (the final DC) into the window DC
5. BitBlt() this resultant image to the screen.

I am assuming there is something I do not understand about the process, or step four above, specifically. I am unsure what.

The code:
BITMAP bm;
PAINTSTRUCT ps;

HDC hdc = BeginPaint(hwnd, &ps);
HBITMAP hbmOld;
HDC hdcMem = CreateCompatibleDC(hdc);
HDC hdcFinal = CreateCompatibleDC(hdcMem);
int loopX, loopY;
for (loopX = 0; loopX < 20; loopX++) {
for (loopY =0; loopY < 20; loopY++) {

hbmOld = (HBITMAP)SelectObject(hdcMem, LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(map.getMap(loopX, loopY))));

GetObject(LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(map.getMap(loopX, loopY))), sizeof(bm), &bm);

BitBlt(hdcFinal, loopX * 32, loopY * 32, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
}
}
hbmOld = (HBITMAP)SelectObject(hdcFinal, CreateCompatibleBitmap(hdcMem, 640, 640));
GetObject(CreateCompatibleBitmap(hdcMem, 640, 640), sizeof(bm), &bm);

BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcFinal, 0, 0, SRCCOPY);

SelectObject(hdcFinal, hbmOld);
SelectObject(hdcMem, hbmOld);

ReleaseDC(hwnd, hdcFinal);
ReleaseDC(hwnd, hdcMem);

EndPaint(hwnd, &ps);
AnswerRe: Double Buffering Pin
Jack Puppy13-Nov-05 1:37
Jack Puppy13-Nov-05 1:37 
AnswerRe: Double Buffering Pin
Michael Dunn13-Nov-05 12:31
sitebuilderMichael Dunn13-Nov-05 12:31 
QuestionHow to use _inp and _outp in VC++ Pin
vikas amin12-Nov-05 21:43
vikas amin12-Nov-05 21:43 
AnswerRe: How to use _inp and _outp in VC++ Pin
Gary R. Wheeler13-Nov-05 2:17
Gary R. Wheeler13-Nov-05 2:17 
AnswerRe: How to use _inp and _outp in VC++ Pin
douglasjordan13-Nov-05 15:32
douglasjordan13-Nov-05 15:32 
AnswerRe: How to use _inp and _outp in VC++ Pin
ThatsAlok13-Nov-05 17:32
ThatsAlok13-Nov-05 17:32 
AnswerRe: How to use _inp and _outp in VC++ Pin
normanS13-Nov-05 19:07
normanS13-Nov-05 19:07 
QuestionHow to manage the code in VC++ Pin
vikas amin12-Nov-05 19:12
vikas amin12-Nov-05 19:12 
AnswerRe: How to manage the code in VC++ Pin
Gary R. Wheeler13-Nov-05 2:55
Gary R. Wheeler13-Nov-05 2:55 
AnswerRe: How to manage the code in VC++ Pin
ThatsAlok14-Nov-05 1:21
ThatsAlok14-Nov-05 1:21 
QuestionCGridCellRich scrollbars? Pin
gilbert.ross@gmail.com12-Nov-05 17:45
gilbert.ross@gmail.com12-Nov-05 17:45 
Questionhey guys the directshow..... Pin
abstar12-Nov-05 17:34
abstar12-Nov-05 17:34 
AnswerRe: hey guys the directshow..... Pin
douglasjordan13-Nov-05 11:47
douglasjordan13-Nov-05 11:47 
QuestionWhich Control Would Work Best? Pin
LighthouseJ12-Nov-05 17:33
LighthouseJ12-Nov-05 17:33 
AnswerRe: Which Control Would Work Best? Pin
vikas amin12-Nov-05 19:34
vikas amin12-Nov-05 19:34 
AnswerRe: Which Control Would Work Best? Pin
Michael Dunn13-Nov-05 12:34
sitebuilderMichael Dunn13-Nov-05 12:34 
GeneralRe: Which Control Would Work Best? Pin
LighthouseJ13-Nov-05 16:10
LighthouseJ13-Nov-05 16:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.