int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { InitializeCriticalSection(&cs_CountThread); /*LANGID lid = LOBYTE (GetUserDefaultUILanguage()); if (lid != LANG_RUSSIAN) {return (0);}*/ App.CreateWnd(hInstance,lpCmdLine,nShowCmd,WndProc); App.CreateTreeView(); App.ParseMainFolder(); MSG msg; App.CreateToolBar(); //_beginthreadex(NULL,0,LogWindow,(void *)123,0,NULL); //_beginthreadex(NULL,0,LogWindow,(void *)123,0,NULL); //_beginthreadex(NULL,0,LogWindow,(void *)123,0,NULL); while(GetMessage(&msg,0,0,0)==TRUE) { TranslateMessage(&msg); DispatchMessage(&msg); } App.DeleteTrayIcon(); return 0; }
LRESULT CALLBACK WndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { LPNMHDR hdr; TVITEM tvit; INITLSTR(); TBBUTTON tbButton={LOWORD(lParam)-160, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0}; switch(Msg) { case WM_DESTROY: App.TreeViewDelFile(0); PostQuitMessage(0); break; case WM_SIZE: MoveWindow(App.hTreeView,0,44,LOWORD(lParam),HIWORD(lParam)-44,TRUE); SendMessage(App.hToolBar,TB_AUTOSIZE,0,0); SendMessage(App.hToolBar,TB_DELETEBUTTON,0,0); SendMessage(App.hToolBar,TB_INSERTBUTTON,0,(LPARAM)&tbButton); SendMessage(App.hToolBar,TB_AUTOSIZE,0,0); break; case WM_COMMAND: if ((HWND)lParam==App.hToolBar) { switch (wParam) { case 123: //destroy button switch (DialogBoxW(App.hIns,MAKEINTRESOURCE(IDD_RESETDEL),hWnd,(DLGPROC)DlgResetProc)) { case IDRESET: App.TreeViewDelFile(0); break; case IDRESETDEL: tvit.hItem = TreeView_GetSelection(App.hTreeView); if (tvit.hItem!=0) { App.TreeViewDelFile(tvit.hItem); } else { MessageBox(hWnd,lStr(UNSELECT),lStr2(UERROR),MB_OK); } break; } break; case 124: //activate monitoring button if (!App.readyMon) { ShowWindow(App.hWnd,SW_MINIMIZE); ShowWindow(App.hWnd,SW_HIDE); App.readyMon=false; _beginthreadex(NULL,0,ThreadPrepareMon,(void *)123,0,NULL); } break; case 125: if (SendMessage(App.hToolBar,TB_ISBUTTONCHECKED,125,0)) { SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE); } else { SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE); } break; case 126: DialogBoxW(App.hIns,MAKEINTRESOURCE(IDD_DIALOGABOUT),hWnd,(DLGPROC)DlgAboutProc); break; } } break; case WM_NOTIFY: hdr = (LPNMHDR) lParam; if (hdr->code==NM_DBLCLK) { tvit.mask = TVIF_PARAM; tvit.hItem = TreeView_GetSelection(App.hTreeView); TreeView_GetItem(App.hTreeView,&tvit); switch (tvit.lParam) { case 10://Project _beginthreadex(NULL,0,ThreadScanFolder,(void *)TreeView_GetSelection(App.hTreeView),0,NULL); break; case 20://Category of log message _beginthreadex(NULL,0,ThreadScanFile,(void *)TreeView_GetSelection(App.hTreeView),0,NULL); break; case 30: _beginthreadex(NULL,0,LogWindow,(void *)TreeView_GetSelection(App.hTreeView),0,NULL); break; } } if (hdr->code==NM_CLICK) { App.alert=false; } if (hdr->code==TTN_GETDISPINFO) { LPTOOLTIPTEXT lpttt; lpttt = (LPTOOLTIPTEXT) lParam; lpttt->hinst = App.hIns; // Specify the resource identifier of the descriptive // text for the given button. UINT idButton = lpttt->hdr.idFrom; switch (idButton) { case 123: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UDESTOY); break; case 124: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UMON); break; case 125: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UTOP); break; case 126: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UABOUTBUTTON); break; } } break; case WM_TRAYMSG: switch ((UINT)lParam) { case WM_LBUTTONUP: if (App.readyMon) { App.readyMon=false; ShowWindow(App.hWnd,SW_SHOW); ShowWindow(App.hWnd,SW_RESTORE); SetForegroundWindow(App.hTreeView); App.DeleteTrayIcon(); } break; } break; default: return DefWindowProc(hWnd,Msg,wParam,lParam); } return (0); }