Accessing the message loop in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How does one access the Windows Message Loop in a C# window.forms application?

I have a graphics display application in which I would like to "step" through the graphical display (it is a binary tree visualiser and I would like to step through the tree as it is being drawn - node by node!) using a mouse click in the form.

Something like this:

Paint method {
....
DisplayBinaryTree(rootnode);
....
}

DisplaBinaryTree {
DrawNode(current);
Wait until mouse is clicked
DisplayBinaryTree(current.Left)
DisplayBinaryTree(current.Right)
}

Can anyone tell me how to implement the line "Wait until mouse is clicked"? I assume that I have to get the mouse_clicked message off the message loop somehow, but I can't see any provision for that in C#.
 
Override the WndProc method and handle the messages in a switch statement.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, snap-to-grid and Layered Windows are
all discussed in May's edition of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml






Philip Sinfield said:
How does one access the Windows Message Loop in a C# window.forms application?

I have a graphics display application in which I would like to "step"
through the graphical display (it is a binary tree visualiser and I would
like to step through the tree as it is being drawn - node by node!) using a
mouse click in the form.
Something like this:

Paint method {
....
DisplayBinaryTree(rootnode);
....
}

DisplaBinaryTree {
DrawNode(current);
Wait until mouse is clicked
DisplayBinaryTree(current.Left)
DisplayBinaryTree(current.Right)
}

Can anyone tell me how to implement the line "Wait until mouse is
clicked"? I assume that I have to get the mouse_clicked message off the
message loop somehow, but I can't see any provision for that in C#.
 
Back
Top