werty1st

werty1st

Oct 14th, 2009
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. namespace DesktopGadget
  2. {
  3.  
  4.     public partial class Form1 : Form
  5.     {
  6.         [DllImport("user32.dll")]
  7.         private static extern int GetSystemMenu(int hwnd, int bRevert);
  8.  
  9.         [DllImport("user32.dll")]
  10.         private static extern int AppendMenu(int hMenu, int Flagsw, int IDNewItem, string lpNewItem);
  11.  
  12.         public Form1()
  13.         {
  14.             InitializeComponent();
  15.             SetupSystemMenu();
  16.         }
  17.  
  18.         private void SetupSystemMenu()
  19.         {
  20.             // Handle des Menue's
  21.             int menu = GetSystemMenu(this.Handle.ToInt32(), 0);
  22.             // Separator einf�gen
  23.             AppendMenu(menu, 0xA00, 0, null);
  24.             // Eindeutige ID (IDNewItem) als Beispiel 111
  25.             AppendMenu(menu, 0, 111, "Settings");
  26.         }
  27.  
  28.         protected override void WndProc(ref Message m)
  29.         {
  30.             base.WndProc(ref m);
  31.  
  32.             if (m.Msg == 0x112)
  33.             {
  34.                 // Wurde die ID 111 (unsere Testeintrag) angeklickt?
  35.                 if (m.WParam.ToInt32() == 111)
  36.                 {
  37.                     string sInput = Microsoft.VisualBasic.Interaction.InputBox("Enter URL", "Settings", "http:\\google.de", 0, 0);
  38.                     webBrowser1.Navigate(sInput);
  39.                 }
  40.             }
  41.         }
  42.  
  43.         private void Form1_Activated(object sender, EventArgs e)
  44.         {
  45.             this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
  46.         }
  47.  
  48.         private void Form1_Deactivate(object sender, EventArgs e)
  49.         {
  50.             this.FormBorderStyle = FormBorderStyle.None;
  51.         }
  52.     }
  53. }
Add Comment
Please, Sign In to add comment