Click here to Skip to main content
15,885,366 members
Home / Discussions / C#
   

C#

 
GeneralRe: Textbox: Convert to float and backwards Pin
Charlie Williams2-Feb-04 8:37
Charlie Williams2-Feb-04 8:37 
GeneralRe: Textbox: Convert to float and backwards Pin
OmegaSupreme2-Feb-04 8:43
OmegaSupreme2-Feb-04 8:43 
GeneralRe: Textbox: Convert to float and backwards Pin
Heath Stewart2-Feb-04 9:46
protectorHeath Stewart2-Feb-04 9:46 
GeneralRe: Textbox: Convert to float and backwards Pin
OmegaSupreme2-Feb-04 9:58
OmegaSupreme2-Feb-04 9:58 
GeneralRe: Textbox: Convert to float and backwards Pin
Heath Stewart2-Feb-04 10:04
protectorHeath Stewart2-Feb-04 10:04 
GeneralRe: Textbox: Convert to float and backwards Pin
sps-itsec462-Feb-04 10:20
sps-itsec462-Feb-04 10:20 
GeneralRe: Textbox: Convert to float and backwards Pin
Heath Stewart2-Feb-04 10:26
protectorHeath Stewart2-Feb-04 10:26 
GeneralFlickering Pin
bouli2-Feb-04 7:20
bouli2-Feb-04 7:20 
Hi C# masters,

While I continue my investigation on C#, I'm currently testing some techniques I was used to use in MFC.

I have done the following things:
I derived a UserControl to write my own control. In the OnPaint overridable method, I want to do my drawings. As C# uses GDI+, it's cool, I also use GDI+ in C++.
In MFC I was doing the following thing:
- Instanciate a Bitmap object with the width, height, and color depth
- Link a Graphics object to this bitmap
- Work with this graphic object to generate my bitmap
- When the bitmap was generated, I displayed it on the drawing context.
Therefore, it looks like this
in MFC:

<br />
<br />
...<br />
class CMyWnd : public CWnd<br />
{<br />
  ...<br />
  afx_msg void OnPaint();<br />
  ...<br />
}<br />
<br />
...<br />
<br />
void CMyWnd::OnPaint()<br />
{<br />
  CPaintDC    dc(this);<br />
  Rect        rect;<br />
<br />
  GetClientRect((LPRECT) &rect);<br />
<br />
  Bitmap      bmp(rect.Width, rect.Height, PixelFormat32Bpp);<br />
  Graphics    memGraphics(&bmp);<br />
  Color       clr;<br />
<br />
  clr.SetFromCOLORREF(::GetSysColor(COLOR_3DFACE));<br />
<br />
  SolidBrush  brush(clr);<br />
  Pen         pen(Color::Red);<br />
<br />
  // drawings in memgraphics<br />
  memGraphics.FillRectangle(brush, rect);  // erase background<br />
  memGraphics.DrawLine(&pen, rect.X, rect.Y, rect.Width, rect.Height) // diagonal<br />
<br />
  // Bitmaps is generated<br />
  Graphics    graphics(&dc);<br />
  graphics.DrawImage(&bmp, rect);<br />
}<br />


And there were no flickering while resizing on the fly the derived window Smile | :)

So, I applied this technique to C#
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
  Bitmap    bmp=new Bitmap(ClientRectangle.Width, ClientRectangle.Height);<br />
  Graphics  memGraphics=Graphics.FromImage(bmp);<br />
  Pen       pen=new Pen(Color.Red);<br />
  Brush     brush=new SolidBrush(SystemColors.Control);<br />
<br />
  memGraphics.FillRectangle(brush, ClientRectangle);<br />
  memGraphics.DrawLine(pen, ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);<br />
<br />
  e.graphics.DrawImage(bmp, ClientRectangle);<br />
}<br />


I remind that the Bitmap object is instancied on both languages to work on a bitmap in memory and once finished, I display the result.

But, in C#, when I resize the control on the fly, there is still flickering Confused | :confused:

Can any C# master explain me why???

Thanks.
GeneralRe: Flickering Pin
Heath Stewart2-Feb-04 9:43
protectorHeath Stewart2-Feb-04 9:43 
GeneralGDI+ Pin
bouli2-Feb-04 5:00
bouli2-Feb-04 5:00 
GeneralRe: GDI+ Pin
Mazdak2-Feb-04 5:17
Mazdak2-Feb-04 5:17 
GeneralRe: GDI+ Pin
bouli2-Feb-04 5:18
bouli2-Feb-04 5:18 
GeneralRe: GDI+ Pin
Mazdak2-Feb-04 5:27
Mazdak2-Feb-04 5:27 
GeneralRe: GDI+ Pin
bouli2-Feb-04 5:30
bouli2-Feb-04 5:30 
Generalpassword checking Pin
ASGill2-Feb-04 2:33
ASGill2-Feb-04 2:33 
GeneralRe: password checking Pin
Rhys__6662-Feb-04 3:04
Rhys__6662-Feb-04 3:04 
GeneralRe: password checking Pin
Heath Stewart2-Feb-04 3:15
protectorHeath Stewart2-Feb-04 3:15 
GeneralC# Standard Template Library Pin
TeamWild2-Feb-04 1:11
TeamWild2-Feb-04 1:11 
GeneralRe: C# Standard Template Library Pin
Colin Angus Mackay2-Feb-04 1:36
Colin Angus Mackay2-Feb-04 1:36 
GeneralRe: C# Standard Template Library Pin
TeamWild2-Feb-04 2:00
TeamWild2-Feb-04 2:00 
GeneralRe: C# Standard Template Library Pin
Colin Angus Mackay2-Feb-04 2:35
Colin Angus Mackay2-Feb-04 2:35 
GeneralRe: C# Standard Template Library Pin
Judah Gabriel Himango2-Feb-04 8:25
sponsorJudah Gabriel Himango2-Feb-04 8:25 
GeneralRe: C# Standard Template Library Pin
Nemanja Trifunovic2-Feb-04 12:07
Nemanja Trifunovic2-Feb-04 12:07 
GeneralRe: C# Standard Template Library Pin
Heath Stewart2-Feb-04 3:04
protectorHeath Stewart2-Feb-04 3:04 
GeneralRe: C# Standard Template Library Pin
boogs2-Feb-04 9:01
boogs2-Feb-04 9:01 

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.