Click here to Skip to main content
15,923,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWTL Question - Pointers to different dialogs Pin
David Stidolph25-Feb-02 11:07
David Stidolph25-Feb-02 11:07 
GeneralRe: WTL Question - Pointers to different dialogs Pin
Joaquín M López Muñoz25-Feb-02 11:26
Joaquín M López Muñoz25-Feb-02 11:26 
GeneralWorks ok in app but not in dll :( Pin
Muralia Dhar25-Feb-02 10:44
Muralia Dhar25-Feb-02 10:44 
GeneralRe: Works ok in app but not in dll :( Pin
Joaquín M López Muñoz25-Feb-02 11:08
Joaquín M López Muñoz25-Feb-02 11:08 
GeneralRe: Works ok in app but not in dll :( Pin
Muralia Dhar25-Feb-02 19:46
Muralia Dhar25-Feb-02 19:46 
GeneralRe: Works ok in app but not in dll :( Pin
Joaquín M López Muñoz25-Feb-02 20:16
Joaquín M López Muñoz25-Feb-02 20:16 
GeneralDamn Tray Notification Icon! Pin
25-Feb-02 9:22
suss25-Feb-02 9:22 
GeneralRe: Damn Tray Notification Icon! Pin
Roger Stewart25-Feb-02 11:25
professionalRoger Stewart25-Feb-02 11:25 
Here is the code I use in one of my applications that has a tray icon:

In my header fo MyDlg class I have declared

private:
NOTIFYICONDATA m_notifyIconData;

I have also added the declaration for OnTrayNotification after the MFC stuff

// Generated message map functions
//{{AFX_MSG(CAVCDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnDestroy();
afx_msg void OnPaint();
// ... other MFC wizard junk
//}}AFX_MSG
// Our handler for the tray WM_ message
afx_msg LRESULT OnTrayNotification(WPARAM nID, LPARAM lParam);
DECLARE_MESSAGE_MAP()


At the top of my Dlg cpp file I declare a WM_ message
static UINT WM_MY_TRAY_NOTIFICATION = RegisterWindowMessage("MyTrayNotification");
// In my message map I use ON_REGISTERED_MESSAGE to handle
// the WM_MY_TRAY_NOTIFICATION instead of ON_MESSAGE
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CAVCDlg)
ON_WM_SYSCOMMAND()
ON_WM_DESTROY()
ON_WM_PAINT()
// ... other wizard junk
//}}AFX_MSG_MAP

// This should be delcared outside the wizard section
ON_REGISTERED_MESSAGE(WM_MY_TRAY_NOTIFICATION,OnTrayNotification)
END_MESSAGE_MAP()

// Link up the tray to the MyDlg in OnInitDlg()
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();

//...

SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

m_notifyIconData.cbSize = sizeof(m_notifyIconData);
m_notifyIconData.hWnd = this->m_hWnd;
m_notifyIconData.uID = WM_MY_TRAY_NOTIFICATION;
m_notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_notifyIconData.uCallbackMessage = WM_MY_TRAY_NOTIFICATION;
m_notifyIconData.hIcon = m_hIcon;
lstrcpy( m_notifyIconData.szTip, _T("Hello") );
Shell_NotifyIcon( NIM_ADD, &m_notifyIconData );

return TRUE;
}

// We need to destroy what we created...
void CMyDlg::OnDestroy()
{
m_notifyIconData.uFlags = NIF_ICON;
Shell_NotifyIcon( NIM_DELETE, &m_notifyIconData );

CDialog::OnDestroy();
}

LRESULT CMyDlg::OnTrayNotification( WPARAM uID, LPARAM lEvent )
{
if ( lEvent == WM_LBUTTONDBLCLK )
{
AfxMessageBox("Left Button Double-Click");
}
else if ( lEvent == WM_RBUTTONUP )
{
AfxMessageBox("Right Button Up");
}

return 0;
}

Hope all this rambling on help you some Smile | :)
If you still have questions email me and I will send you this test app zipped up.



Roger Stewart
rstewart27104@yahoo.com
GeneralRe: Damn Tray Notification Icon! Pin
Nish Nishant25-Feb-02 14:47
sitebuilderNish Nishant25-Feb-02 14:47 
GeneralDatabase: mfc-odbc api getting column information Pin
25-Feb-02 8:29
suss25-Feb-02 8:29 
Questionhow do i use the "reinterpret_cast" operator? Pin
Pyropat25-Feb-02 8:13
Pyropat25-Feb-02 8:13 
AnswerRe: how do i use the "reinterpret_cast" operator? Pin
Tim Deveaux25-Feb-02 8:34
Tim Deveaux25-Feb-02 8:34 
AnswerRe: how do i use the "reinterpret_cast" operator? Pin
Paul M Watt25-Feb-02 9:30
mentorPaul M Watt25-Feb-02 9:30 
AnswerRe: how do i use the "reinterpret_cast" operator? Pin
Nish Nishant25-Feb-02 16:19
sitebuilderNish Nishant25-Feb-02 16:19 
AnswerRe: how do i use the "reinterpret_cast" operator? Pin
Sef Tarbell27-Feb-02 4:59
Sef Tarbell27-Feb-02 4:59 
GeneralRe: (corrected)how do i use the "reinterpret_cast" operator? Pin
Sef Tarbell27-Feb-02 5:01
Sef Tarbell27-Feb-02 5:01 
GeneralDirectX or OpenGL Pin
Nnamdi Onyeyiri25-Feb-02 7:54
Nnamdi Onyeyiri25-Feb-02 7:54 
GeneralRe: DirectX or OpenGL Pin
Christian Graus25-Feb-02 8:34
protectorChristian Graus25-Feb-02 8:34 
GeneralRe: DirectX or OpenGL Pin
Jeremy Falcon25-Feb-02 8:41
professionalJeremy Falcon25-Feb-02 8:41 
GeneralSubclassing a CComBSTR Pin
Mauricio Ritter25-Feb-02 6:48
Mauricio Ritter25-Feb-02 6:48 
GeneralRe: Subclassing a CComBSTR Pin
Michael Dunn25-Feb-02 7:25
sitebuilderMichael Dunn25-Feb-02 7:25 
Generalmodeless dialog & sockets Pin
25-Feb-02 6:47
suss25-Feb-02 6:47 
GeneralRe: modeless dialog & sockets Pin
Joaquín M López Muñoz25-Feb-02 6:59
Joaquín M López Muñoz25-Feb-02 6:59 
GeneralRe: modeless dialog & sockets Pin
25-Feb-02 7:30
suss25-Feb-02 7:30 
GeneralRe: modeless dialog & sockets Pin
Joaquín M López Muñoz25-Feb-02 7:42
Joaquín M López Muñoz25-Feb-02 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.