// add your message handler code here and/or call default
//
mytaskbardeleteicon( getsafehwnd(), 100 );
cwnd::onclose();
}
//---------------------------------------------------------------------------------------
//
// function:
// void cmainwindow::onsyscommand( uint nid, lparam lparam )
// purpose:
// when window were minimumized, the window should be hide,
// we use on_syscommand message and message handle to do this
// comments:
//
//---------------------------------------------------------------------------------------
void cmainwindow::onsyscommand( uint nid, lparam lparam )
{
if ( nid==sc_minimize )
{
showwindow( sw_hide );
boolwndhadshow = false;
}
else
cwnd::onsyscommand( nid, lparam );
}
//---------------------------------------------------------------------------------------
//
// function: void cmainwindow::onbrowsebutonclicked ()
// purpose: message handler of ok button
// comments:
//
//---------------------------------------------------------------------------------------
void cmainwindow::onbrowsebutonclicked ()
{
//
// must call imalloc::free to free the memory by this pointer
//
lpmalloc pmalloc;
browseinfo bi;
char pszdirname[max_path];// save the directory name
lpitemidlist pidl;
//
// if retrieve a handle to the shell allocator's imalloc interface sucessfuly
//
if (succeeded(shgetmalloc(&pmalloc)))
{
zeromemory(&bi,sizeof(bi));
bi.hwndowner = getsafehwnd();
bi.pidlroot = null;
bi.pszdisplayname = pszdirname;
bi.lpsztitle = _t("select the file or folder which will be supervised:");
bi.ulflags = bif_browseincludefiles;
bi.lpfn = null;
bi.lparam = 0;
if ((pidl = ::shbrowseforfolder(&bi)) != null)
{
//
// get full path user selected
//
if (::shgetpathfromidlist(pidl, pszdirname))
m_objectpath.setwindowtext(pszdirname);
}
pmalloc->free(pidl);
pmalloc->release();
}
//
// try to detect the inspect object is directory or file
// can also use:
// dword getfileattributes(lpctstr lpfilename);
//
dword objecttype;
objecttype = getfileattributes(pszdirname);
if(objecttype & file_attribute_directory)
{
m_groupboxfi.setwindowtext (_t("folder supervised:"));
m_groupboxfs.setwindowtext (_t("folder size limitation"));
}
else
{
m_groupboxfi.setwindowtext (_t("file supervised:"));
m_groupboxfs.setwindowtext (_t("file size limitation"));
}
//
//enable the cancel button
//
m_cancel.enablewindow(true);
}
//---------------------------------------------------------------------------------------
//
// function: void cmainwindow::onokbuttonclicked ()
// purpose: message handler of ok button
// comments:
// this function transfer a structure's pointer
// as a lpvoid parameter to worker thread. this is the normal way
// to handle the worker thread parameters. besides, you can also
// input a address of an object directly.
//
//---------------------------------------------------------------------------------------
void cmainwindow::onokbuttonclicked ()
{
m_cancel.enablewindow( false );
showwindow( sw_hide );
boolwndhadshow = false;
//
// reset the manual event object before start worker thread
//
m_eventstopwatch.resetevent ();
//
// prepare the parameter for worker thread
// sometimes if you only need m_hwnd, you can also
// input &m_hwnd directly there
//
threadparam * pthreadparam=new threadparam;