Click here to Skip to main content
15,907,687 members
Home / Discussions / C#
   

C#

 
GeneralRe: Copy access table to another access table Pin
dan!sh 14-Dec-07 6:48
professional dan!sh 14-Dec-07 6:48 
Generaldatagridview checkbox Pin
arkiboys14-Dec-07 5:25
arkiboys14-Dec-07 5:25 
GeneralRe: datagridview checkbox Pin
Paul Conrad23-Dec-07 9:47
professionalPaul Conrad23-Dec-07 9:47 
QuestionHow to paint all controls in form's paint,completely removing control's own paint Pin
ctoma200514-Dec-07 4:41
ctoma200514-Dec-07 4:41 
AnswerRe: How to paint all controls in form's paint,completely removing control's own paint Pin
Wes Aday14-Dec-07 5:25
professionalWes Aday14-Dec-07 5:25 
GeneralRe: How to paint all controls in form's paint,completely removing control's own paint Pin
ctoma200514-Dec-07 6:21
ctoma200514-Dec-07 6:21 
AnswerRe: How to paint all controls in form's paint,completely removing control's own paint Pin
Anthony Mushrow14-Dec-07 14:09
professionalAnthony Mushrow14-Dec-07 14:09 
GeneralRe: How to paint all controls in form's paint,completely removing control's own paint Pin
ctoma200514-Dec-07 14:27
ctoma200514-Dec-07 14:27 
Sorry,I didn't give all the details. My controls are all image-based, but I wan't to also use them as sprites(I'm developing 2D games). I can't use the control's painting, because I will never get rid of flickering. Now..the form in it's onpaint already has access to all this control, so it's not hard to call child.GetImage() for example. That is what manual double buffering means..all painting is done in one place(form.onpaint)

I don't now how to stop the controls from using their default-painting.

Here is what I have at this moment for the control:

<br />
public class MyControl : Control<br />
{<br />
 ...<br />
 //override Control.Visible,as this property doesn't take "false" value at design time<br />
 private bool visible = true;<br />
<br />
 //this value is insepcted by the form..so it knows if it should redraw the control<br />
 public bool isValid;<br />
<br />
...<br />
public Image GetImage() //returns control's present image(it can be changed)<br />
...<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
 //don't do nothing,as the form takes care of all the painting<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
 //HERE i don't know what to do<br />
 //I think i need this:<br />
 isVisible = false; //let the form now that the control was invalidated<br />
 Parent.Invalidate() //tell the parent that the control is invalidated..so redraw it<br />
 //use winapi to validate the window..so it doesn't keep sending WM_PAINT<br />
 ValidateRect(this.Handlde) <br />
}<br />


Now..this is what the form should do:

<br />
public partial class TestForm : Form<br />
{<br />
...<br />
 protected override void OnPaint(PaintEventArgs e)<br />
 {     <br />
  for (int i = Controls.Count - 1; i >= 0; i--)<br />
  {<br />
   if (Controls[i] is MyControl)<br />
   {<br />
    if (!((MyControl)Controls[i]).IsValid && ((MyControl)Controls[i]).GetImage() != null)<br />
    {<br />
      grafx.Graphics.DrawImageUnscaledAndClipped<br />
       (((MyControl)Controls[i]).GetImage(),<br />
       ((MyControl)Controls[i]).ImageRect);<br />
     ((MyControl)Controls[i]).IsValid = true; //validate it<br />
    }<br />
   }<br />
  }<br />
  grafx.Render(e.Graphics); // grafs is the BufferedGraphics<br />
}<br />


Using this code..will invalidate the form continuously... blocking the form Frown | :(
What have I left out?

If I don't make MyControl derive from Control will not give me design-time support..but Control
implements IWin32Window so it get's messages fron the system..not the form.

Thanks very much for your patience..sorry I'm not very good at explaining
GeneralRe: How to paint all controls in form's paint,completely removing control's own paint Pin
Anthony Mushrow14-Dec-07 14:52
professionalAnthony Mushrow14-Dec-07 14:52 
GeneralRe: How to paint all controls in form's paint,completely removing control's own paint Pin
ctoma200515-Dec-07 4:04
ctoma200515-Dec-07 4:04 
QuestionHow to use vnchook.dll in c#.net application Pin
dhami_naresh14-Dec-07 4:35
dhami_naresh14-Dec-07 4:35 
QuestionHow to read Data from MS Access Pin
s3rro14-Dec-07 4:24
s3rro14-Dec-07 4:24 
AnswerRe: How to read Data from MS Access Pin
Wes Aday14-Dec-07 5:27
professionalWes Aday14-Dec-07 5:27 
GeneralRe: How to read Data from MS Access Pin
s3rro14-Dec-07 5:29
s3rro14-Dec-07 5:29 
AnswerRe: How to read Data from MS Access Pin
Paul Conrad23-Dec-07 9:47
professionalPaul Conrad23-Dec-07 9:47 
QuestionHow to draw all controls in form's paint event? PLEASE HELP! Pin
ctoma200514-Dec-07 4:02
ctoma200514-Dec-07 4:02 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
KarstenK14-Dec-07 4:05
mveKarstenK14-Dec-07 4:05 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
ctoma200514-Dec-07 6:27
ctoma200514-Dec-07 6:27 
QuestionRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
Skippums14-Dec-07 7:27
Skippums14-Dec-07 7:27 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
ctoma200514-Dec-07 14:30
ctoma200514-Dec-07 14:30 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
Christian Graus14-Dec-07 9:41
protectorChristian Graus14-Dec-07 9:41 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
ctoma200514-Dec-07 14:24
ctoma200514-Dec-07 14:24 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
Christian Graus14-Dec-07 15:26
protectorChristian Graus14-Dec-07 15:26 
GeneralRe: How to draw all controls in form's paint event? PLEASE HELP! Pin
ctoma200515-Dec-07 4:08
ctoma200515-Dec-07 4:08 
Generalinteger problem!! Pin
zeeShan anSari14-Dec-07 3:57
zeeShan anSari14-Dec-07 3:57 

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.