Using: VS 2003 NET C# for Framework and Framework Compact
Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on
OnMouseMove
Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle))
flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in a
Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local Graphics.
When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API.
- Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in realising a
game programm
and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de 8 12245
I'd have to see your code, but I've done quite a bit of flicker-free drawing
with the CF.
--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems www.applieddata.net
"Mark Johnson" <mj*****@mj10777.de> wrote in message
news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or
Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local
Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in realising
a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
If it is for the full framework (not CF) you can set panel control style to
do double buffering which will remove the flickering. CF doesn't support
control styles, though.
B\rgds
100
"Mark Johnson" <mj*****@mj10777.de> wrote in message
news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or
Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local
Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in realising
a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
public virtual void OnPaint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
p_Graphics = e.Graphics;
OnPanel(0); // This calls OnCreateWorkScreenBitmap()
p_Graphics.DrawImage(bmp_Work[i_Work_Screen],0,0);
}
public void OnCreateWorkScreenBitmap()
{ // First create our Bitmap and the Graphic to Draw
bmp_Work[i_Work_Empty] = new
Bitmap(bmp_Work[i_Work_Back].Size.Width,bmp_Work[i_Work_Back].Size.Height);
Graphics gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Empty]);
gs_Graphics.Clear(cl_Work);
gs_Graphics.Dispose();
if (bmp_Work[i_Work_Screen]!=null)
bmp_Work[i_Work_Screen].Dispose();
bmp_Work[i_Work_Screen] = new
Bitmap((i_Screen_Width_Diff+i_Screen_Width_Real),
(i_Screen_Height_Diff+i_Screen_Height_Real));
gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Screen]);
gs_Graphics.Clear(cl_Work);
// a lot of code chosing which Bitmap at what position should be painted
into the Image with the local Graphics, then
// This Paints Work Bitmap at the desired Position
#if !COMPACT
gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work);
#else
// For Compact the Bitmap cannot be resised
Rectangle srcRect = new
Rectangle(0,0,rt_Work.Width,rt_Work.Height+10);
gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work,srcRect,GraphicsUnit.Pi
xel);
#endif
gs_Graphics.Dispose();
} // public void OnCreateWorkScreenBitmap()
I can send you the full code if you give a e-mail adress.
Mark Johnson, Berlin Germnay mj*****@mj10777.de
"Chris Tacke, eMVP" <ct****@spamfree-opennetcf.org> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP09.phx.gbl... I'd have to see your code, but I've done quite a bit of flicker-free
drawing with the CF.
-- Chris Tacke, eMVP Co-Founder and Advisory Board Member www.OpenNETCF.org --- Windows CE Product Manager Applied Data Systems www.applieddata.net
"Mark Johnson" <mj*****@mj10777.de> wrote in message news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in
a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in
realising a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
Hi Mark,
I'm might be able to help you. You can send me the code at sg******@nospam.dromeydesign.com.
remove nospam stuff from the address.
B\rgds
100
"100" <10*@100.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl... If it is for the full framework (not CF) you can set panel control style
to do double buffering which will remove the flickering. CF doesn't support control styles, though.
B\rgds 100
"Mark Johnson" <mj*****@mj10777.de> wrote in message news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in
a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in
realising a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
Offhand I don't see anything glaring, though you are createing a graphics
object a lot, and I tend to create and use one and only one for all my work.
I have a pretty complex control (a dial-indicator gauge) that essentailly
uses triple-buffering by generating a static image for the areas that don't
change, then drawing it and the changing stuff to another image, which I
then blit to the screen. I've run several instances on a 640x480 display
without any flicker at all.
--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems www.applieddata.net
"Mark Johnson" <mj*****@mj10777.de> wrote in message
news:3f***********************@newsread4.arcor-online.net... public virtual void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) { p_Graphics = e.Graphics; OnPanel(0); // This calls OnCreateWorkScreenBitmap()
p_Graphics.DrawImage(bmp_Work[i_Work_Screen],0,0); } public void OnCreateWorkScreenBitmap() { // First create our Bitmap and the Graphic to Draw bmp_Work[i_Work_Empty] = new
Bitmap(bmp_Work[i_Work_Back].Size.Width,bmp_Work[i_Work_Back].Size.Height); Graphics gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Empty]); gs_Graphics.Clear(cl_Work); gs_Graphics.Dispose(); if (bmp_Work[i_Work_Screen]!=null) bmp_Work[i_Work_Screen].Dispose(); bmp_Work[i_Work_Screen] = new Bitmap((i_Screen_Width_Diff+i_Screen_Width_Real),
(i_Screen_Height_Diff+i_Screen_Height_Real)); gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Screen]); gs_Graphics.Clear(cl_Work);
// a lot of code chosing which Bitmap at what position should be painted into the Image with the local Graphics, then
// This Paints Work Bitmap at the desired Position #if !COMPACT gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work); #else // For Compact the Bitmap cannot be resised Rectangle srcRect = new Rectangle(0,0,rt_Work.Width,rt_Work.Height+10);
gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work,srcRect,GraphicsUnit.Pi xel); #endif gs_Graphics.Dispose(); } // public void OnCreateWorkScreenBitmap()
I can send you the full code if you give a e-mail adress.
Mark Johnson, Berlin Germnay mj*****@mj10777.de "Chris Tacke, eMVP" <ct****@spamfree-opennetcf.org> schrieb im Newsbeitrag news:%2****************@TK2MSFTNGP09.phx.gbl... I'd have to see your code, but I've done quite a bit of flicker-free drawing with the CF.
-- Chris Tacke, eMVP Co-Founder and Advisory Board Member www.OpenNETCF.org --- Windows CE Product Manager Applied Data Systems www.applieddata.net
"Mark Johnson" <mj*****@mj10777.de> wrote in message news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as
in a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in realising a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
I tried the following:
a counter was added so that the Bitmap Methode is only call once:
public override void OnPanel(int i_Event)
{
i_Test++;
base.OnPanel(i_Event);
if (i_New_Game == 1)
Setup_Basic_Logic();
if (i_Test == 1)
OnCreateWorkScreenBitmap();
if (sbStatusBarMainFrame != null)
sbStatusBarMainFrame.Text = "TryGame_Cards.OnPanel("+i_Test+")";
}
This means the Bitmap is only being repainted without being build again.
It still flickers.
I then turned off the OnMouseMove/Up/Down Events and took out the counter.
(i.e. OnPaint runs when resizing)
no flicker !
Only the when the events are turned on where the Invalidate() is done does
it flicker (for the Card only a flicker on the Card being moved).
Mark Johnson, Berlin Germany mj*****@mj10777.de
"Chris Tacke, eMVP" <ct****@spamfree-opennetcf.org> schrieb im Newsbeitrag
news:ue****************@TK2MSFTNGP09.phx.gbl... Offhand I don't see anything glaring, though you are createing a graphics object a lot, and I tend to create and use one and only one for all my
work. I have a pretty complex control (a dial-indicator gauge) that essentailly uses triple-buffering by generating a static image for the areas that
don't change, then drawing it and the changing stuff to another image, which I then blit to the screen. I've run several instances on a 640x480 display without any flicker at all.
-- Chris Tacke, eMVP Co-Founder and Advisory Board Member www.OpenNETCF.org --- Windows CE Product Manager Applied Data Systems www.applieddata.net
"Mark Johnson" <mj*****@mj10777.de> wrote in message news:3f***********************@newsread4.arcor-online.net... public virtual void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) { p_Graphics = e.Graphics; OnPanel(0); // This calls OnCreateWorkScreenBitmap()
p_Graphics.DrawImage(bmp_Work[i_Work_Screen],0,0); } public void OnCreateWorkScreenBitmap() { // First create our Bitmap and the Graphic to Draw bmp_Work[i_Work_Empty] = new
Bitmap(bmp_Work[i_Work_Back].Size.Width,bmp_Work[i_Work_Back].Size.Height); Graphics gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Empty]); gs_Graphics.Clear(cl_Work); gs_Graphics.Dispose(); if (bmp_Work[i_Work_Screen]!=null) bmp_Work[i_Work_Screen].Dispose(); bmp_Work[i_Work_Screen] = new Bitmap((i_Screen_Width_Diff+i_Screen_Width_Real),
(i_Screen_Height_Diff+i_Screen_Height_Real)); gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Screen]); gs_Graphics.Clear(cl_Work);
// a lot of code chosing which Bitmap at what position should be painted into the Image with the local Graphics, then
// This Paints Work Bitmap at the desired Position #if !COMPACT gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work); #else // For Compact the Bitmap cannot be resised Rectangle srcRect = new Rectangle(0,0,rt_Work.Width,rt_Work.Height+10);
gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work,srcRect,GraphicsUnit.Pi xel); #endif gs_Graphics.Dispose(); } // public void OnCreateWorkScreenBitmap()
I can send you the full code if you give a e-mail adress.
Mark Johnson, Berlin Germnay mj*****@mj10777.de "Chris Tacke, eMVP" <ct****@spamfree-opennetcf.org> schrieb im
Newsbeitrag news:%2****************@TK2MSFTNGP09.phx.gbl... I'd have to see your code, but I've done quite a bit of flicker-free drawing with the CF.
-- Chris Tacke, eMVP Co-Founder and Advisory Board Member www.OpenNETCF.org --- Windows CE Product Manager Applied Data Systems www.applieddata.net
"Mark Johnson" <mj*****@mj10777.de> wrote in message news:3f***********************@newsread2.arcor-online.net... > Using: VS 2003 NET C# for Framework and Framework Compact > Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version
on > OnMouseMove > Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle)) > flickers in a nasty way when repainting. > > This does not happen in the Solitare (PC + WinCe) Versions a well as in a > Card game where I have the C++ Source. > > The use of an empty OnPaintBackground brings no visable results. > > The OnPaint calls a Method, which builds a new Bitmap with a local Graphics. > When finished OnPaint does one DrawImage Command (flicker). > > OnPaint is painting to a Panel. > > Is this a Framework problem ? > > Can a flicker free Painting only be done with some sort of Win-API. > - Goal is for this Class to run with the same code on both Systems. > > If yes, what would it look like inside a Framework program ? > > This seems to the last major problem (as of yet) that I have in realising a > game programm > and it would be very nice if this problem could be solved. > > Thank you for any help > > Mark Johnson, Berlin Germany > mj*****@mj10777.de > > >
Since the Invalidate seems to cause the flicker, I tried to call DrawImage
on the saved Grafics from OnPaint.
This failed (crash).
I have howver taken an IntPtr from this Grafics and used it to withe the
Cards.dll Function which take
the IntPtr to draw directly to the Panel.
How then could I use this IntPrt (Hdc to Grafics) to draw a Bitmap to the
Panel as Cards.dll does ?
Maybe this, maybe, would not flicker.
Mark Johnson, Berlin Germany mj*****@mj10777.de
"Mark Johnson" <mj*****@mj10777.de> schrieb im Newsbeitrag
news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or
Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local
Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in realising
a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
Hi,
2 things you could try:
- call update after calling invalidate (force synchronous repainting)
- draw direct in the mouse move event, you can get a valid graphics object
by calling
CreateGraphics, then draw, and don't forget to Dispose() it when done
drawing
HTH
greetings
"Mark Johnson" <mj*****@mj10777.de> wrote in message
news:3f***********************@newsread2.arcor-online.net... Since the Invalidate seems to cause the flicker, I tried to call DrawImage on the saved Grafics from OnPaint. This failed (crash). I have howver taken an IntPtr from this Grafics and used it to withe the Cards.dll Function which take the IntPtr to draw directly to the Panel.
How then could I use this IntPrt (Hdc to Grafics) to draw a Bitmap to the Panel as Cards.dll does ? Maybe this, maybe, would not flicker.
Mark Johnson, Berlin Germany mj*****@mj10777.de
"Mark Johnson" <mj*****@mj10777.de> schrieb im Newsbeitrag news:3f***********************@newsread2.arcor-online.net... Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or Invalidate(Rectangle)) flickers in a nasty way when repainting.
This does not happen in the Solitare (PC + WinCe) Versions a well as in
a Card game where I have the C++ Source.
The use of an empty OnPaintBackground brings no visable results.
The OnPaint calls a Method, which builds a new Bitmap with a local Graphics. When finished OnPaint does one DrawImage Command (flicker).
OnPaint is painting to a Panel.
Is this a Framework problem ?
Can a flicker free Painting only be done with some sort of Win-API. - Goal is for this Class to run with the same code on both Systems.
If yes, what would it look like inside a Framework program ?
This seems to the last major problem (as of yet) that I have in
realising a game programm and it would be very nice if this problem could be solved.
Thank you for any help
Mark Johnson, Berlin Germany mj*****@mj10777.de
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sagaert Johan |
last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up.
I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the...
|
by: benben |
last post by:
I created a form and overrided OnPaint, OnClick and OnResize methods. My
OnPaint calls base.OnPaint then repaints the whole screen.
The screen flickers a lot! It didn't happen when the app was...
|
by: Colin McGuire |
last post by:
Hi, I am just learning "how-to" by reading some of the existing
article solutions in this newsgroup. I happened to come across this
one. Tom Spink knows what he is talking about and I am wondering...
|
by: Brian Henry |
last post by:
I created a smooth progress bar with this code.. but if you update the
values in a row quickly of it and watch it on screen it flickers... how
would i change this to reduce the flickering?...
|
by: iwdu15 |
last post by:
hi, i created a paint program for my c++ class using a global GraphicsPath
variable. i the, in the onpaint method, draw the line the users draws with
the mouse. simple. the only problem is that...
|
by: grayaii |
last post by:
Hi,
I have a simple form that handles all its paint functionality like so:
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.Opaque, true);
And the entry point to this...
|
by: sean |
last post by:
I'm trying to create "rubber-band" rectangles by overriding the
OnPaint method to place rectangles on top of all graphic controls, but
when I call Me.Invalidate() (when the user moves the mouse),...
|
by: Jon Slaughter |
last post by:
I always get flicking in my test code and all graphics code I'm using. It's
random but happens about once a second. Its quite annoying cause I expected
that with double buffering enabled and the...
|
by: asalaheddin |
last post by:
Well, to start, I would like to say that I read many of things available online to overcome the notorious flickering problem that all programmers face when trying to draw, resize, or even drag...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |