Sorry for the confusion. What I want is a global value. I think I understand your example (thank you), however, I'm not sure where to put it in my code. The only place I can see to add it would be in the constructor, but I'm not sure if this would cause this code to be run each time the service received a request (I think it would).
If I understand everything correctly, then if I put your example in the constructor, then the first time the service handled a request (or when the file was changed) it would get the data, other wise is would skip the step to load the data. Is that right?
There is no member of the ListView class that specifies an item height, nor is there any Windows message or notification message (for custom drawing) that supports such an operation (for which you'd normally override WndProc in a child class and handle Windows messages the "old fashioned" way).
If you need this type of control, I suggest you take a look at the very robust third-party controls from companies like Developer Express[^] and Infragistics[^].
What I want to do is have a context menu come up whenever the user right-clicks a tab label.
Right now I added a context menu to my TabControl, and the context menu pops up regardless where the user right clicks, be it the tabpage or the tab label.
Is it possible for me to have the menu pop up only when the user right clicks the tab label (where the tab's name is displayed)?
Also, how can I deduce which tabpage was right clicked?
What I want is similar to the tabs in VS .Net. You right click a tab, it becomes the selected tab, and a little menu is displayed. And this only occurs when you click the tab name. This is the type of functionality I am looking for.
You could iterate through your TabControl.TabPages collection property and use the TabControl.GetTabRect to get the bounds of each tab (till you find a match). Use Rectangle.Contains (calling it on the Rectangle returned from GetTabRect to see if the mouse coordinates in the MouseDown event handler are over the specified tab. This will give you the tab that was clicked. You can then use ContextMenu.Show to show a ContextMenu at those coordinates. Show also tracks the ContextMenu so it continues to display until clicked.
Why, when so many solutions already exist? You don't need to assembly the frames in C# to be used in an ASP.NET web application. For example, some software will create MPEGs from frames and provide you with a URL that you can use with an embedded player (like Windows Media Player, QuickTime, RealPlayer , etc.).
If you insist on rewriting what's already been done a thousand times, you can assembly these frames in an AVI - an uncompressed (traditionally) video format. There is an article about this here on CodeProject: http://www.codeproject.com/csharp/steganodotnet4.asp[^].
If you want to encode this as something else, I recommend you look at Managed DirectX 9.0b (http://msdn.microsoft.com/directx[^]), which lets you easily enough pass the AVI through compressors. There are other ways, too, but again this type of software has already been written countless times.
Yes. It is the single instance of an object. Because of this reason, make sure you lock any shared resources in your implementation using the lock statement (compiles to use a Monitor) or a similar locking mechanism (mutexes, etc.), which you can find in the System.Threading namespace.
I've designed a form with a left and right section divided by a splitter component. in the left i've inserted a treeview component and on the right a panel with edits showing the data of the selected node in the tree.
I've seen that if i select a node and then focus on an edit control, in the tree the selection disappears.
Is there a property of a workaround to having always visible the selected item? In MFC when you use splitters, the splitted areas are standalone windows with their own focus handling.
There is a reason why they are called ListView and TreeView!
You could come up with something like this, but you would have to draw the ListView control yourself. You can look at this[^] article by Jon Rista, here on CodeProject, for a start or just use his control...
I have a C# Windows Form that contains the logic to display an icon in the systray. I have that form hidden (visible = false). When the user clicks the systray icon I unhide the form (visible = true) to allow the user to change some settings. When the user finishes changing the settings he can click the close button (the X in the top right corner).
In the frm.closing event I have this:
this.Visible = false;
e.Cancel = true;
That code will hide the form for later use and it keeps the application from exiting.
Life is good UNTIL the user goes to shutdown the computer. During the shutdown process Windows goes to close my application; but my app sends Windows the Cancel signal and so Windows never shuts down. I’m about ready to hack something up with WndProc but I was hoping there might be some way to tell if whether my app is being closed by Windows or by a click of the close button (the X in the top right corner).
Implement the IMessageFilter interface and add an instance of your implementation using Application.AddMessageFilter (this can degrade performance severely if not implemented correctly / efficiently). Watch for the WM_QUERYENDSESSION (0x0011, cancelable) or WM_ENDSESSION (0x0016).
Alternatively, you can override WndProc in your main application window (the form you pass to Application.Run, for example) and do the same thing.
Windows sends this message when shutting down. You can return false to attempt to prevent Windows from shutting down (it most likely will), or just return true and close your application or do whatever you need to.