Setting Taskbar properties programmatically 
Author Message
 Setting Taskbar properties programmatically

Hello,

I am looking for a way to set the Auto Hide and Always On Top
properties of the taskbar.  In MSVC++ there are messages for getting
the state but none seemed to set the state.  Couldn't find any
registry setting either.

Any tricks I'm missing?

All help much appreciated.

Thanks,

Drew



Sat, 25 Nov 2000 03:00:00 GMT  
 Setting Taskbar properties programmatically

I would like to add on to this question how to add an icon to the
taskbar.  I would like to add an informative icon on the right
side where the clock appears.  I know of several apps that do
this.                                                          

I imagine you might have to get the window handle for the taskbar
in order to add the icon.  I don't see any "set" methods except
for a few states.  Anyone have a code example?                  

Craig Smith

--



Sun, 03 Dec 2000 03:00:00 GMT  
 Setting Taskbar properties programmatically

Quote:

>I imagine you might have to get the window handle for the taskbar
>in order to add the icon.  I don't see any "set" methods except
>for a few states.  Anyone have a code example?              

No you just need to use Shell_NotifyIcon. Here's some sample code:

// This loads the systray icon, giving it an ID
// because I have more than one tray icon.
// The private message is also specified.

void  CMainFrame::AddQuickIcon (void)
{  
      NOTIFYICONDATA tnid;
      CString csTip ;

      tnid.cbSize = sizeof(NOTIFYICONDATA);
      tnid.hWnd   = GetSafeHwnd();
      tnid.uID    = SYSTRAY_QUICK_ID; // personal ID
      tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
      tnid.uCallbackMessage = PRIV_SYSTRAY_ICON;
      tnid.hIcon  = m_hIconPhone ;

      if (csTip.LoadString (IDS_QUICKMENU))
         strncpy (tnid.szTip, csTip, sizeof(tnid.szTip));
      else
         tnid.szTip[0] = '\0';

      Shell_NotifyIcon(NIM_ADD, &tnid);

Quote:
}

// -------------------------------------------------------------------
// This appears in the mainframe message map,
// and specifies a message sent when the user
// interacts with the icon. Note that the message
// ID matches that specified in the uCallbackMessage
// structure member.

   ON_MESSAGE (PRIV_SYSTRAY_ICON, OnSysTrayIconClick)

// ------------------------------------------------------------------

afx_msg LONG CMainFrame::OnSysTrayIconClick (WPARAM wParam, LPARAM
lParam)
{
   switch (wParam)
   {
      // bunch of other code omitted here. Note that the
      // ID here matches that specified when the icon
      // was inserted, in the uID structure member.

      case SYSTRAY_QUICK_ID:

           switch (lParam)
           {
              case WM_LBUTTONDOWN:
              case WM_RBUTTONDOWN:
                   ShowQuickMenu ();
                   break ;
           }
           break ;

      default:
           DebugMessage ("......");
           break ;
   }

   return TRUE ;

Quote:
}

// -------------------------------------------------------------------
// This shows the menu the systray icon. The
// popup menu is loaded elsewhere. You can
// create a single bar menu with several popups,
// and use GetSubMenu to choose the one you
// want for any particular circumstance.

void  CMainFrame::ShowQuickMenu ()
{
   POINT   CurPos ;

   GetCursorPos (&CurPos);
   SetForegroundWindow ();// Bodge for bug in Explorer

   // Display the menu. This menu is a popup loaded elsewhere.

   TrackPopupMenu (m_hQuickMenu,
                   TPM_LEFTBUTTON,
                   CurPos.x,
                   CurPos.y,
                   0,
                   GetSafeHwnd(),
                   NULL);

   PostMessage (WM_NULL, 0, 0);// Bodge for bug in Explorer

Quote:
}

Bob Moore [MVP]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Sun, 03 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Setting taskbar properties

2. Hide Taskbar Programmatically Pt. II

3. Show AutoHide Taskbar Programmatically Pt. I

4. Tough: Hide TaskBar Programmatically

5. Setting a property of a property

6. Q: Set Tab Window Text in Property Page/Property Sheet

7. Setting / getting list separator (Regional Setting Properties)???

8. Any Way To Programmatically Detect ReadOnly Properties?

9. Changing MS-DOS window properties programmatically

10. How to access Custom Database Properties of a Access 97 database programmatically

11. How to programmatically close Property Sheet?

12. Programmatically Setting Version Numbers

 

 
Powered by phpBB® Forum Software