// function: bool mytaskbaraddicon(hwnd hwnd,uint uid, hicon hicon, lpstr lpsztip)
// purpose: add icon in the statu area on the task bar
// comments:
//
//---------------------------------------------------------------------------------------
bool mytaskbaraddicon(hwnd hwnd,uint uid, hicon hicon, lpstr lpsztip)
{
bool bresult;
notifyicondata tnid;
tnid.cbsize = sizeof(notifyicondata);
tnid.hwnd = hwnd;
tnid.uid = uid;
tnid.uflags = nif_icon | nif_tip | nif_message;
tnid.ucallbackmessage = user_wm_notifyicon; // callback message
tnid.hicon = hicon; // icon used
if (lpsztip)
lstrcpyn(tnid.sztip, lpsztip, sizeof(tnid.sztip));
else
tnid.sztip[0] = '\0';
//
// send nim_add to create icon
//
bresult = shell_notifyicon(nim_add, &tnid);
if (hicon) destroyicon(hicon);
return bresult;
}
//---------------------------------------------------------------------------------------
//
// function: bool mytaskbardeleteicon(hwnd hwnd, uint uid)
// purpose: delete icon in the statu area on the task bar
// comments:
//
//---------------------------------------------------------------------------------------
bool mytaskbardeleteicon(hwnd hwnd, uint uid)
{
bool bresult;
notifyicondata tnid;
tnid.cbsize = sizeof(notifyicondata);
tnid.hwnd = hwnd;
tnid.uid = uid;
//
//send nim_delete to create icon
//
bresult = shell_notifyicon(nim_delete, &tnid);
return bresult;
}
//---------------------------------------------------------------------------------------
//
// function: lresult cmainwindow::onmyiconnotify( wparam wparam, lparam lparam )
// purpose: call back function of message mywm_notifyicon
// comments:
//
//---------------------------------------------------------------------------------------
lresult cmainwindow::onmyiconnotify( wparam wparam, lparam lparam )
{
uint nid;
uint umousemsg;
nid = (uint)wparam;
umousemsg = (uint) lparam;
//
// show or hide window
//
if (umousemsg == wm_lbuttondown) // click on icon
{
if ( boolwndhadshow )
showwindow( sw_hide );
else
showwindow( sw_shownormal );
boolwndhadshow = ~boolwndhadshow;
}
return true;
}
//---------------------------------------------------------------------------------------
//
// function:
// lresult cmainwindow::onshowappiconic( wparam wparam, lparam lparam )
// purpose:
// message handler of show icon on statu bar
// and hide the window when programe run
// comments:
// call back function of message mywm_showappiconic
//
//---------------------------------------------------------------------------------------
lresult cmainwindow::onshowappiconic( wparam wparam, lparam lparam )
{
hicon theicon = loadicon(afxgetinstancehandle(),
makeintresource(idr_file_inspector) );
mytaskbaraddicon(getsafehwnd(),
100,
theicon,
_t("file/folder supervisor"));
showwindow( sw_hide );
boolwndhadshow = false;
return 1;
}
//---------------------------------------------------------------------------------------
//
// function: void cmainwindow::onclose()
// purpose:
// when you want to close programe, the icon should
// be delete from statue area on task bar,
// we can use wm_close message and message handler to do this
// comments:
//
//---------------------------------------------------------------------------------------
void cmainwindow::onclose()
{
//