tags:

views:

46

answers:

2

hi

how to make C# program that will be All time in the taskbar ?

i want to Build a Keyboard program.

i need that when i open the device the program will open and be in the taskbar.

another question is, when i have an external program that has a Textbox, how

to make that when i press any key in my C# keyboard it will be in this external Textbox ?

thank's in advance

+3  A: 

To Create a system Tray application in Windows-CE, put some code like:

CSystemTray m_TrayIcon;   // Member variable of some class

... 
// in some member function maybe...

m_TrayIcon.Create(pParentWnd, WM_MY_NOTIFY, "Click here", 
                  hIcon, nTrayIconID);

Eg. For a non-MFC tray icon, do the following:

Collapse
CSystemTray m_TrayIcon;   // Member variable of some class

... 
// in some member function maybe...

m_TrayIcon.Create(hInstance, NULL, WM_MY_NOTIFY, 
                  "Click here", hIcon, nID);

// Send all menu messages to hMyMainWindow

m_TrayIcon.SetTargetWnd(hMyMainWindow);

As found here:

http://www.codeproject.com/KB/shell/systemtray.aspx

To create a system tray application in Windows XP or Windows 7/Vista, put some code like this in your project:

private void Form1_Resize(object sender, System.EventArgs e)
{
   if (FormWindowState.Minimized == WindowState)
      Hide();
}

and this to handle the system tray click

private void notifyIcon1_DoubleClick(object sender,
                                     System.EventArgs e)
{
    Show();
    WindowState = FormWindowState.Normal;
}

This and more information found at :

http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm

Michael Eakins
i work on Windows-CE, is it will work on it ?
Gold
thank's for the help - but not working on Windows-CE
Gold
+4  A: 

It's not implemented in the CF, but the NotifyIcon class is what you're after. The SDF does implement it. It would be used something like this:

m_notifyIcon = new NotifyIcon();
m_notifyIcon.Icon = this.Icon;
m_notifyIcon.Visible = true;
m_notifyIcon.Click += new EventHandler(m_notifyIcon_Click);
m_notifyIcon.DoubleClick += new EventHandler(m_notifyIcon_DoubleClick);

EDIT

If you want to implement this yourself, the place to start is with the Shell_NotifyIcon API. You'll want to pass it the handle to a MessageWindow class and handle the WM_NOTIFY messages.

ctacke
thank's for the help, but is there any free sample ?
Gold
The SDF Community Edition is free to use and distribute. The code above uses it and is free. How much more free are you after?
ctacke