473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

redraw shaking problem !

Hi all,

i'm trying to make my first windows tetris game but found a severe
problem. that is, everytime i update(redraw) the window it may be
filled with shaking lines. i checked some articles and also i have a
nice book "tricks of windows programming guru", but they both didnt
help.
here're parts of my code:

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Do something...

while (1)
{
if (PeekMessage(&msg, hwndRoot, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

updateGame();
}

return FALSE;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
drawGame();
break;
case WM_KEYDOWN:
keyPressedGame(wParam);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}

return 0;
}

void updateGame()
{
// Do something...

InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}

and also i use UpdateWindow and
is there anything wrong ? btw i use GDI to draw objects in my game,
does it matter anyway ?
btw, how to mail to this group directly ? i have to post my message
via browser.

Mar 21 '07 #1
4 1566
black(flashing vampire) said:
Hi all,

i'm trying to make my first windows tetris game
comp.os.ms-windows.programmer.win32
but found a severe problem. that is, everytime i update(redraw) the
window it may be filled with shaking lines.
Double-buffering - blit from back buffer to main buffer. Works like a
charm.
btw, how to mail to this group directly ?
Use a newsreader, e.g. Thunderbird. Legal, free download from the Web.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 21 '07 #2
On Mar 21, 5:26 pm, Richard Heathfield <r...@see.sig.invalidwrote:
black(flashing vampire) said:
Hi all,
i'm trying to make my first windows tetris game

comp.os.ms-windows.programmer.win32
but found a severe problem. that is, everytime i update(redraw) the
window it may be filled with shaking lines.

Double-buffering - blit from back buffer to main buffer. Works like a
charm.
btw, how to mail to this group directly ?

Use a newsreader, e.g. Thunderbird. Legal, free download from the Web.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.

someone told me that double buffer is used only for applications which
have less memory, but my app is a very simple one, should i use double
buffer anyway ?
and because it is my first time to build a windows app, could you show
me a simple example of double buffer with GDI ? one million thanks !!!

Mar 21 '07 #3
black(flashing vampire) said:
On Mar 21, 5:26 pm, Richard Heathfield <r...@see.sig.invalidwrote:
>>
Double-buffering - blit from back buffer to main buffer. Works like a
charm.
someone told me that double buffer is used only for applications which
have less memory, but my app is a very simple one, should i use double
buffer anyway ?
Since double-buffering requires *more* memory, that sounds like very
strange advice. The idea of double-buffering is that you update the
window in one fell swoop rather than in lots of itty-bitty little
draws, resulting in a vastly smoother transition between frames. It's
an astoundingly effective technique. But, as I suggested in my first
reply, you would be better off seeking advice on the precise details in
comp.os.ms-windows.programmer.win32, where Windows programming is
topical.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 21 '07 #4
...as I suggested in my first
reply, you would be better off seeking advice on the precise details in
comp.os.ms-windows.programmer.win32, where Windows programming is
topical.
oki i'll try my luck there, thanks man !

Mar 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Peter | last post by:
I want to draw some lines on a widget. This works ok, but when I want to redraw, the old lines are still there. How do I clear or refresh the widget, so I can draw a new set of lines? Code...
0
by: PHH | last post by:
Help me, please, When I redraw a ListviewItem in Listview (redraw items with icon and text columms). I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish and run...
0
by: WHITETIGER | last post by:
Help me, please, When I redraw a ListviewItem in Listview (redraw items with icon and text columms). I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish and run...
2
by: ch424 | last post by:
Hi, Does anybody know the fastest way to trigger a DrawingArea redaw in pygtk? At the moment, I'm using a bit of a hack: def redraw(self): self.area.hide() self.area.show() Is there a...
1
by: kiplring | last post by:
I wrote a program which draw a dancer at cornor of desktop. ( I Accessed through hDC) But It has a problem. I remains all trait at the desktop until I invoke any Redraw( Refresh) action - click,...
5
by: CroDude | last post by:
Hi all! I've made a simple control derived from a panel class which draws gradient in a overrided OnPaintBackground event. Well, I know that I need to redraw control when it's resized by...
0
by: Dean Earley | last post by:
Hi all. I have just added translucency to one of my applications using the layered windows API, but I have come across a redraw problem. Unfortunately, I cant reproduce this in a standalone...
2
by: diogoko | last post by:
I have some code like: try { someButton.disabled = true; cpuIntensiveCode(); } finally { someButton.disabled = false; } The problem is that someButton is never disabled, because the browser
8
by: Spockman | last post by:
Hi Guys! I stuck in this problem quiet awhile. I have a MainForm in my application. It contains a second one as a member. If both a visible I have a problem to redraw the second one. eg: MainForm...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.