I'm trying to send a WM_CONTEXTMENU message to an NotifyIcon control, hoping to pop open the context menu. Am I totally off base with the following code? Needless to say, since I am posting to this forum, it isn't working. // Send message to open context menu Message m = new Message(); m.Msg = WM_CONTEXTMENU; // Get notify icon native window Type t = this.notifyIcon1.GetType(); NativeWindow icon = ((NativeWindow)t.GetField("window", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this.notifyIcon1)); // Create message m.HWnd = icon.Handle; m.WParam = icon.Handle; Int16 high = Convert.ToInt16(this.m_ptLeftClick.X); Int16 low = Convert.ToInt16(this.m_ptLeftClick.Y); m.LParam = (IntPtr)((Int32)(high << 16) + low); // Send message icon.DefWndProc(ref m);
cmaissan
Posts
-
Sending WM_CONTEXTMENU -
Form height increases on Show()I am definately using Size, not ClientSize. I also believe it is the height of the menu bar that is being added to the form, not the height of the title bar.
-
Form height increases on Show()My application saves the Size and Location properties of the main form in a configuration file. When the program runs I first create the form, set the Size and Location properties, then call the form's Show method. I noticed after closing and restarting the application the form would grow slightly larger, which puzzled me. If I output the value of the Size property immeadiately before and after I call the form's Show method I can see that the form grows in height by exactly 19 pixels. No matter what I set as the value of the Size property, the height always seemed to increase by 19 pixels. I had a hunch maybe 19 pixels was the height of the title bar. I increased the size of the title bar font in Windows, but my form still grew by 19. However, when I increased the size of the menu font my form grew by a larger amount. Other than the menu I have two controls in the form. A ListView control with the Dock property set to Fill and a StatusBar control with the Dock property set to Bottom. Any ideas? Thanks, Chris
-
Mysterious error dialog on exit....I too periodically see an error dialog flash when I quit my application. It seems to have started after I overrode WndProc to perform some custom drawing in a List View control, and doesn't seem to occur with any consistency. My gut says the window handle is being disposed while some of the painting routines are using it, but in all honestly I don't know enough and shouldn't even speculate. If you find a way to "capture" what the error dialog says, let me know. Regards, Chris -- modified at 23:42 Monday 24th April, 2006
-
ListView questionIn the properties for the ListView control you will see a property named "FullRowSelect". Set this property to true. -Chris
-
Hiding a winform just as it runs...When Application.Run(myForm) is called, myForm is made visible. By this point the form has already been created and therefore its constructor and the InitializeComponent() method have already been called. Use Application.Run() instead of Application.Run(myForm). This will start the message loop without making any form visible. You will likely then want to add Application.ExitThread() to an event handler for the Closed event of your main form. -Chris
-
PrintingMaybe it is printing outside the margins of the page. Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location); -Chris
-
Splash Screen ArchitectureYou could do all your initializing in the Main() function. Something like as follows: static void Main() { // Create splash fclsSpash splash = new fclsSplash(); splash.Show(); // Create main form fclsMain main = new fclsMain(); // Initialize this splash.SetMessage("Initializing this."); main.InitializeThis(); // Initialize that splash.SetMessage("Initializing that."); main.InitializeThat(); // Close splash splash.Dispose(); // Show main main.Show(); // Start application Application.Run(); } -Chris
-
Launching a form with visible set to falseLeave out "myform" when you call Application.Run. ie: Application.Run(); -Chris