Click here to Skip to main content
15,922,533 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: 830421 - PostMessage problem Pin
peterchen11-Jul-04 4:34
peterchen11-Jul-04 4:34 
GeneralRe: 830421 - PostMessage problem Pin
Michael Dunn11-Jul-04 6:44
sitebuilderMichael Dunn11-Jul-04 6:44 
GeneralRe: 830421 - PostMessage problem Pin
Gary R. Wheeler11-Jul-04 14:04
Gary R. Wheeler11-Jul-04 14:04 
GeneralRe: 830421 - PostMessage problem Pin
Ryan Binns11-Jul-04 18:16
Ryan Binns11-Jul-04 18:16 
GeneralRe: 830421 - PostMessage problem Pin
Michael Dunn11-Jul-04 19:50
sitebuilderMichael Dunn11-Jul-04 19:50 
GeneralTray Icon Messaging in Dialog based MFC Bot Pin
kJeromek11-Jul-04 2:40
kJeromek11-Jul-04 2:40 
GeneralRe: Tray Icon Messaging in Dialog based MFC Bot Pin
ThatsAlok11-Jul-04 3:12
ThatsAlok11-Jul-04 3:12 
GeneralRe: Tray Icon Messaging in Dialog based MFC Bot Pin
JeromeKJerome11-Jul-04 4:43
JeromeKJerome11-Jul-04 4:43 
It seems to me the code in your articls is about the same as mine. This is the code that doesn't work right.

in BotDlg.h

#define WM_TRAY_NOTIFY WM_USER + 0

...
...

class CBotDlg : public CDialog
{
// Construction
public:
CBotDlg(CWnd* pParent = NULL); // standard constructor
LRESULT OnTrayNotify(WPARAM wParam, LPARAM lParam);
void TakeABreak();
void BackToWork();
void OnMenuExit();
NOTIFYICONDATA m_nTrayData;
bool m_bOnBreak;
bool m_bHidden;

...
...

in BotDlg.cpp

...
...

BEGIN_MESSAGE_MAP(CBotDlg, CDialog)

ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()

ON_MESSAGE (WM_TRAY_NOTIFY, OnTrayNotify)
ON_COMMAND(IDC_BREAK, CBotDlg::TakeABreak)
ON_COMMAND (IDC_WORK, CBotDlg::BackToWork)
ON_COMMAND (IDC_EXIT, CBotDlg::OnMenuExit)

ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()

...
...

m_nTrayData.cbSize = sizeof(NOTIFYICONDATA);
m_nTrayData.hWnd = m_hWnd;
m_nTrayData.uID = 0;
m_nTrayData.hIcon = LoadIcon (AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_BREAK));
m_nTrayData.uCallbackMessage = WM_TRAY_NOTIFY;
strcpy (m_nTrayData.szTip, "Bot");
m_nTrayData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_bOnBreak = false;
m_bHidden = false;

return TRUE; // return TRUE unless you set the focus to a control

...
...


// ******************************
// * *
// * OnTrayNotify *
// * *
// ******************************
//
// Tray Notification Handler
//
LRESULT CBotDlg::OnTrayNotify(WPARAM wParam, LPARAM lParam)
{
// ---- Left-button dclick: Exit Program
if (lParam == WM_LBUTTONDBLCLK)
{
Shell_NotifyIcon(NIM_DELETE, &m_nTrayData);
EndDialog(0);
}//end if
// ---- Right-button down: Pop-up menu
if (lParam == WM_RBUTTONDOWN)
{
CMenu menu;
VERIFY (menu.LoadMenu(IDR_MENU1));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CRect screen;
GetDesktopWindow()->GetWindowRect(screen);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, screen.right, screen.bottom, AfxGetMainWnd());
}//end if
return LRESULT(0);
}
// ******************************
// * *
// * BackToWork *
// * *
// ******************************
//
// Back to Work Handler
//
void CBotDlg::BackToWork()
{
m_nTrayData.hIcon=LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_WORK));
strcpy (m_nTrayData.szTip, "Bot");
m_nTrayData.uFlags = NIF_ICON | NIF_TIP;
Shell_NotifyIcon (NIM_MODIFY, &m_nTrayData);
}

// ******************************
// * *
// * TakeABreak *
// * *
// ******************************
//
// Take A Break Handler
//
void CBotDlg::TakeABreak()
{
m_nTrayData.hIcon=LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_BREAK));
strcpy (m_nTrayData.szTip, "Bot");
m_nTrayData.uFlags = NIF_ICON | NIF_TIP;
Shell_NotifyIcon (NIM_MODIFY, &m_nTrayData);
}




kJeromek aka JeromeKJerome
GeneralRe: Tray Icon Messaging in Dialog based MFC Bot Pin
Ryan Binns11-Jul-04 18:19
Ryan Binns11-Jul-04 18:19 
QuestionHow can I get a Text where mouse cursor is placed? Pin
zeki yugnak11-Jul-04 2:09
zeki yugnak11-Jul-04 2:09 
AnswerRe: How can I get a Text where mouse cursor is placed? Pin
bikram singh11-Jul-04 4:01
bikram singh11-Jul-04 4:01 
AnswerRe: How can I get a Text where mouse cursor is placed? Pin
Michael Dunn11-Jul-04 6:47
sitebuilderMichael Dunn11-Jul-04 6:47 
GeneralRe: How can I get a Text where mouse cursor is placed? Pin
zeki yugnak11-Jul-04 13:41
zeki yugnak11-Jul-04 13:41 
AnswerRe: How can I get a Text where mouse cursor is placed? Pin
Jose Cezar S. Ynion11-Jul-04 23:35
Jose Cezar S. Ynion11-Jul-04 23:35 
GeneralRe: How can I get a Text where mouse cursor is placed? Pin
zeki yugnak12-Jul-04 9:10
zeki yugnak12-Jul-04 9:10 
Questionhow to got the id of motherborad or cpu.. Pin
chedly_ensi11-Jul-04 0:45
chedly_ensi11-Jul-04 0:45 
Generalsound card direct access Pin
X204011-Jul-04 0:43
X204011-Jul-04 0:43 
GeneralRe: sound card direct access Pin
erkanina11-Jul-04 21:02
erkanina11-Jul-04 21:02 
GeneralRe: sound card direct access Pin
X204012-Jul-04 9:31
X204012-Jul-04 9:31 
Generalquery data between dates Pin
Anonymous11-Jul-04 0:30
Anonymous11-Jul-04 0:30 
GeneralLoading a DLL and HEAP problem Pin
Alex H 198310-Jul-04 23:20
Alex H 198310-Jul-04 23:20 
GeneralRe: Loading a DLL and HEAP problem Pin
bikram singh11-Jul-04 0:16
bikram singh11-Jul-04 0:16 
GeneralRe: Loading a DLL and HEAP problem Pin
Alex H 198311-Jul-04 0:20
Alex H 198311-Jul-04 0:20 
GeneralRe: Loading a DLL and HEAP problem Pin
cmk11-Jul-04 1:19
cmk11-Jul-04 1:19 
GeneralCComboBox problem Pin
J.B.10-Jul-04 22:05
J.B.10-Jul-04 22:05 

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.