Click here to Skip to main content
16,005,389 members
Home / Discussions / C#
   

C#

 
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 
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 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 
GeneralRe: integer problem!! Pin
KarstenK14-Dec-07 4:06
mveKarstenK14-Dec-07 4:06 
GeneralRe: integer problem!! Pin
zeeShan anSari14-Dec-07 4:14
zeeShan anSari14-Dec-07 4:14 
GeneralRe: integer problem!! Pin
Michael Potter14-Dec-07 4:49
Michael Potter14-Dec-07 4:49 
GeneralRe: integer problem!! Pin
Luc Pattyn14-Dec-07 5:18
sitebuilderLuc Pattyn14-Dec-07 5:18 
AnswerRe: integer problem!! Pin
Skippums14-Dec-07 6:38
Skippums14-Dec-07 6:38 
GeneralRe: integer problem!! Pin
Luc Pattyn14-Dec-07 10:08
sitebuilderLuc Pattyn14-Dec-07 10:08 
GeneralRe: integer problem!! Pin
Skippums14-Dec-07 11:49
Skippums14-Dec-07 11:49 
GeneralDisplay limited items in listbox using C# from xml Pin
new2pgrmg14-Dec-07 3:51
new2pgrmg14-Dec-07 3:51 
GeneralRe: Display limited items in listbox using C# from xml Pin
Kristian Sixhøj14-Dec-07 4:22
Kristian Sixhøj14-Dec-07 4:22 
GeneralRegex.....Problem........... Pin
Siddharth Rastogi14-Dec-07 3:50
Siddharth Rastogi14-Dec-07 3:50 
AnswerRe: Regex.....Problem........... Pin
Matthew Butler14-Dec-07 6:04
Matthew Butler14-Dec-07 6:04 
QuestionHow to trigger Paste in terminal server window? Pin
mav.northwind14-Dec-07 2:58
mav.northwind14-Dec-07 2:58 
AnswerRe: How to trigger Paste in terminal server window? Pin
Kristian Sixhøj14-Dec-07 3:52
Kristian Sixhøj14-Dec-07 3:52 
GeneralRe: How to trigger Paste in terminal server window? Pin
mav.northwind14-Dec-07 4:15
mav.northwind14-Dec-07 4:15 

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.