Click here to Skip to main content
15,891,567 members
Home / Discussions / C#
   

C#

 
GeneralRe: Urgent help (Calling a .NET Component from a COM Component) Pin
Heath Stewart3-Feb-04 6:30
protectorHeath Stewart3-Feb-04 6:30 
GeneralRe: Urgent help (Calling a .NET Component from a COM Component) Pin
Shahin774-Feb-04 6:48
Shahin774-Feb-04 6:48 
GeneralRe: Urgent help (Calling a .NET Component from a COM Component) Pin
Heath Stewart4-Feb-04 7:04
protectorHeath Stewart4-Feb-04 7:04 
GeneralRe: Urgent help (Calling a .NET Component from a COM Component) Pin
Shahin774-Feb-04 7:42
Shahin774-Feb-04 7:42 
GeneralRe: Urgent help (Calling a .NET Component from a COM Component) Pin
Heath Stewart4-Feb-04 8:41
protectorHeath Stewart4-Feb-04 8:41 
GeneralRe: Calling a .NET Component from a COM Component Pin
KingTermite2-Feb-04 10:14
KingTermite2-Feb-04 10:14 
GeneralRe: Calling a .NET Component from a COM Component Pin
Heath Stewart3-Feb-04 5:56
protectorHeath Stewart3-Feb-04 5:56 
GeneralIDocHostUIHandler, FilterDataObject Pin
s.keller2-Feb-04 9:05
s.keller2-Feb-04 9:05 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
Nick Parker2-Feb-04 9:15
protectorNick Parker2-Feb-04 9:15 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
s.keller2-Feb-04 9:21
s.keller2-Feb-04 9:21 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
Heath Stewart2-Feb-04 9:49
protectorHeath Stewart2-Feb-04 9:49 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
s.keller2-Feb-04 9:55
s.keller2-Feb-04 9:55 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
Heath Stewart2-Feb-04 9:58
protectorHeath Stewart2-Feb-04 9:58 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
s.keller2-Feb-04 10:45
s.keller2-Feb-04 10:45 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
Heath Stewart2-Feb-04 10:50
protectorHeath Stewart2-Feb-04 10:50 
GeneralRe: IDocHostUIHandler, FilterDataObject Pin
s.keller2-Feb-04 11:02
s.keller2-Feb-04 11:02 
GeneralTextbox: Convert to float and backwards Pin
sps-itsec462-Feb-04 8:09
sps-itsec462-Feb-04 8:09 
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.

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.