473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need to call Form.Invalidate()

I have a menu option 'Open...' that opens an OpenFileDialog to select an
image file to open. Than I need to call Form.Invalidate() to clear the Form
and display the image. This happens in a seperate file-handling class.

The problem is that I cannot get access to the Form.

The delegate passes in an 'object' that I can cast to
System.Windows.Form.ToolStripMenuItem. I can call GetParent() on that to get
the ToolStrip. I can query Container, TopLevelContainer but none gives me
the Form that the menu is located on.

How?
Apr 4 '06 #1
4 3487
VJ
I would implement the OpenFileDialog as a Class or in a Class.. then
initiate this in the Main form.., I would have event communicate back to the
main the file availability in which I would clear the form.. Since order of
execution is guaranteed.. this will return back to line after event
raising... where you can add the image again...

HTH
VJ

"Martijn Mulder" <i@m> wrote in message
news:44***********************@news.wanadoo.nl...
I have a menu option 'Open...' that opens an OpenFileDialog to select an
image file to open. Than I need to call Form.Invalidate() to clear the Form
and display the image. This happens in a seperate file-handling class.

The problem is that I cannot get access to the Form.

The delegate passes in an 'object' that I can cast to
System.Windows.Form.ToolStripMenuItem. I can call GetParent() on that to
get the ToolStrip. I can query Container, TopLevelContainer but none gives
me the Form that the menu is located on.

How?

Apr 4 '06 #2
What does TopLevelControl give you back?

Apr 4 '06 #3
> What does TopLevelControl give you back?

TopLevelControl gives me access to the
System.Windows.Forms.ToolStripDropDownMenu where the ToolStripMenuItem
'Open...' is located on (&File), together with the usual Save, Save as...
etc items..
Apr 4 '06 #4
Odd. What about the TopLevelControl of the ToolStripDropDownMenu?

I would think that this thing must lead back to the owning Form at some
point.

Your only other option, if you can't find the enclosing Form, is to
inherit from ToolStripDropDownMenu and have your version implement a
new event that is raised whenever the image file changes, and have the
enclosing Form listen for that event.

Apr 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexander Jhin | last post by:
I have this very basic Custom Control: public class TestPanel : Panel { public TestPanel() : base() { this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque |...
2
by: Serge Klokov | last post by:
Hi! 1. Please, help with example "paint on form by mouse" 2. Below is my example, but it clear the line after each Refresh()... how to fix? 3. How to draw the line in Mouse_Move event? ...
3
by: jerry chapman | last post by:
Based on a mouse click I change something on the screen. I then want to repaint the screen to show the change. When I tried to use .Invalidate in my mouse routine, I got a compilation error. ...
6
by: Phillip N Rounds | last post by:
I have an application which is heavily graphics intensive, all the graphics being custom. Scattered throughout by app, I have MyView->OnDraw( this->GetDC() ); Apparently, each call to ...
5
by: Michel | last post by:
How to force the redrawing of a Form?
0
by: David W. Fenton | last post by:
I was just working on an A97 app in which has lots of filtering and dynamic changing of the recordsets, but also uses bookmark navigation of subsets of records. I was trying to implement some...
6
by: Marc | last post by:
Hi, I am using the below code which simply allows a single button control to be dragged and dropped anywhere around a form. My problem is that want to move about 100 buttons on the form. Is...
6
by: Nayan | last post by:
I have been working on a card game (called Uno) for past few days. Language used : C# 2.0 When I start a new game, a dialog window pops up asking the name of the player. I enter the name, and...
2
by: active | last post by:
Refresh says: -Forces the control to invalidate its client area and immediately redraw itself and any child controls. Not the Menu for example? While Invalidate() says: -Invalidates the entire...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.