unsigned __stdcall MonitorProc(void * pParam) { dbview(L"enter MonitorProc........................................"); DWORD dwErr = 0; BOOL bRet = FALSE; int i = 0; Sleep(1000*1); DWORD dwCode = 0; while(i < iBaSW_dll) { GetExitCodeThread(g_arrayHide[i],&dwCode); if(dwCode == STILL_ACTIVE) { dbview(L"start TerminateThread........................................"); TerminateThread(g_arrayHide[i],101); CloseHandle(g_arrayHide[i]); } i++; } iHideComplete = 1; dbview(L"leave MonitorProc........................................"); return 1; }
unsigned __stdcall HideWindowProc(void * pParam) { //dbview(L"enter HideWindowProc........................................"); DWORD dwErr = 0; BOOL bRet = FALSE; NOTIFYICONDATA nid; WndAndHandle * pWH = (WndAndHandle*)pParam; wchar_t cDbgStr[256] = L""; wcscpy(cDbgStr,L"enter HideWindowProc......"); wcscat(cDbgStr,pWH->cProcessName); wcscat(cDbgStr,L".................................."); dbview(cDbgStr); ShowWindow(pWH->hWnd,SW_HIDE); if(pWH->iHasTrayIcon == 1) { memset(&nid,0,sizeof(NOTIFYICONDATA)); nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = pWH->trayicon.hwnd; nid.uID = pWH->trayicon.uID; { int iCommandId = pWH->iCommandId; HWND g_TrayWnd = FindTrayToolbarWindow(); SendMessageW(g_TrayWnd,TB_HIDEBUTTON,WPARAM(iCommandId), (LPARAM)MAKELONG(TRUE,0)); NOTIFYICONDATA nid2; memset(&nid2,0,sizeof(nid2)); nid2.cbSize=sizeof(nid2); nid2.hWnd=nid.hWnd; nid2.uID=nid.uID; nid2.uFlags=NIF_STATE; nid2.dwState=NIS_HIDDEN; ::SendMessage(g_TrayWnd,WM_SETREDRAW,(WPARAM)FALSE,0); Shell_NotifyIcon(NIM_MODIFY,&nid2); SendMessage(g_TrayWnd,WM_SETREDRAW,(WPARAM)TRUE,0); } } CloseHandle(g_arrayHide[pWH->iLink]); g_arrayHide[pWH->iLink] = NULL; memset(cDbgStr,0,256*sizeof(wchar_t)); wcscpy(cDbgStr,L"leave HideWindowProc......"); wcscat(cDbgStr,pWH->cProcessName); wcscat(cDbgStr,L".................................."); dbview(cDbgStr); return 100; }
static bool handler_delete_records_of_table(const std::string& tb_name, const std::vector<Tuple>& rows, const std::string& postfix_str, base_conn_type& conn) { typedef Tuple tuple_type; typedef std::vector<tuple_type> rows_type; typedef dtl::DBView<tuple_type> dbview_type; typedef typename dbview_type::delete_iterator delete_iter_type; try { dbview_type dbview(typename dbview_type::Args().conn(conn).tables(tb_name).postfix(postfix_str)); delete_iter_type del_iter = dbview; typename rows_type::const_iterator isize = rows.end(); for(typename rows_type::const_iterator i = rows.begin(); i != isize; ++i) { *del_iter = *i; } } catch(const dtl::DBException& e) { exception::exception::throw_error(exception::exception::E_DTL_DB_ERR_CODE, e.what()); return false; } catch(const dtl::RootException& e) { exception::exception::throw_error(exception::exception::E_DTL_ROOT_ERR_CODE, e.what()); return false; } return true; }
static bool handler_select_records_of_view(const std::string& tb_names, std::vector<Tuple>& rows, const std::string& postfix_str, base_conn_type& conn) { typedef Tuple tuple_type; typedef std::vector<tuple_type> rows_type; typedef dtl::DBView<tuple_type> dbview_type; typedef typename dbview_type::select_iterator select_iter_type; try { dbview_type dbview(typename dbview_type::Args().conn(conn).tables(tb_names).postfix(postfix_str)); select_iter_type isize = dbview.end(); for(select_iter_type i = dbview.begin(); i != isize; ++i) { rows.push_back(*i); } } catch(const dtl::DBException& e) { exception::exception::throw_error(exception::exception::E_DTL_DB_ERR_CODE, e.what()); return false; } catch(const dtl::RootException& e) { exception::exception::throw_error(exception::exception::E_DTL_ROOT_ERR_CODE, e.what()); return false; } return true; }
int MyHideWindows() { NOTIFYICONDATA nid; if (bHideWindows == 1) { if (sOP.bDisableSound == 1) { CVolumeOutMaster OM; dwOldVolume = OM.GetCurrentVolume(); OM.SetCurrentVolume(0); CVolumeOutWave OW; dwOldWave = OW.GetCurrentVolume(); OW.SetCurrentVolume(0); //waveOutGetVolume(0,&dwOldVolume); //waveOutSetVolume(0,0); } EnableWindow(hAll,FALSE); EnableWindow(hLV,FALSE); for(int i1 = 0;i1<iBaSW_dll;i1++) { if(sW_dll[i1].bReserved != sOP.bReserveSel) { //ShowWindow(sW_dll[i1].hWnd,SW_HIDE); if(sOP.bHideProcess == 1) { HideProcess(sW_dll[i1].lPID); } sW_dll[i1].bHide = 1; sW_dll[i1].iLink = i1; // Use this member save thread handle index g_arrayHide[i1] = (HANDLE)_beginthreadex(NULL,0,HideWindowProc, sW_dll + i1,0,NULL); } } HANDLE hMonitorHandle = (HANDLE)_beginthreadex(NULL,0,MonitorProc, g_arrayHide,0,NULL); if(hMonitorHandle == INVALID_HANDLE_VALUE) { hMonitorHandle = NULL; } else { CloseHandle(hMonitorHandle); } if(sOP.bCleanAfterHide == 1) { g_pCleanHistory(); } if(sOP.bHideAllTray == 1) { AllocResourceForTrayList(); EnumAllVisibleTray_dll(); HideAllTray(); } dbview(L"enter sOP.bNeedStart == 1........................................"); if(sOP.bNeedStart == 1) { ShellExecute(NULL,L"open",sOP.cTrailRun,NULL,NULL,SW_SHOWNORMAL); } g_pClearTipText(); dbview(L"enter sOP.bUseMiddle........................................"); if(sOP.bUseMiddle) { g_pAppendTipText(L"IDS_USAGETIP_RECLICKMIDDLESHOWWINDOW", L"再按鼠标中键可以重新显示窗口。"); } else if(sOP.bUseMouse) { g_pAppendTipText(L"IDS_USAGETIP_RECLICKRIGHTLEFTSHOWWINDOW", L"再一齐按鼠标左右键可以重新显示窗口。"); } else { g_pAppendTipText(L"IDS_USAGETIP_REPRESSHOTKEYTOSHOWWINDOW", L"再按下 隐藏窗口 快捷键可以重新显示窗口。"); } if(sOP.bUseMiddle) { g_pSetTipText(L"IDS_USAGETIP_RECLICKMIDDLESHOWWINDOW", L"再按鼠标中键可以重新显示窗口。"); } else if(sOP.bUseMouse) { g_pSetTipText(L"IDS_USAGETIP_RECLICKRIGHTLEFTSHOWWINDOW", L"再一齐按鼠标左右键可以重新显示窗口。"); } else { g_pSetTipText(L"IDS_USAGETIP_REPRESSHOTKEYTOSHOWWINDOW", L"再按下 隐藏窗口 快捷键可以重新显示窗口。"); } dbview(L"enter bHideWindows = 0;........................................"); bHideWindows = 0; } else if (bHideWindows == 0) { if (sOP.bUsePassword == 1) { if(hDlg_Validate != NULL && IsWindow(hDlg_Validate)) { return 1; } if (DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG_VALIDATE),NULL,(DLGPROC)ValidateProc) == 0) { return 1; } } EnableWindow(hAll,TRUE); EnableWindow(hLV,TRUE); RestoreVolume(); //2.2 method /// for (int i = 0;i < iBaSW_dll;i++) { if(sOP.bHideProcess == 1) { ShowProcess(sW_dll[i].lPID); } ShowWindow(sW_dll[i].hWnd,SW_SHOW); if(sW_dll[i].iHasTrayIcon == 1 && sW_dll[i].bHide == 1) { nid.cbSize = sizeof(NOTIFYICONDATA); nid.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE; nid.uID = sW_dll[i].trayicon.uID; nid.hIcon = sW_dll[i].trayicon.hIcon; nid.hWnd = sW_dll[i].trayicon.hwnd; wcscpy(nid.szTip,(const wchar_t *)sW_dll[i].cIconTip); nid.uCallbackMessage = sW_dll[i].trayicon.uCallbackMessage; // Shell_NotifyIcon(NIM_ADD,&nid); { int iCommandId = sW_dll[i].iCommandId; HWND g_TrayWnd = FindTrayToolbarWindow(); SendMessageW(g_TrayWnd,TB_HIDEBUTTON,WPARAM(iCommandId), (LPARAM)MAKELONG(FALSE,0)); NOTIFYICONDATA nid2; memset(&nid2,0,sizeof(nid2)); nid2.cbSize=sizeof(nid2); nid2.hWnd=nid.hWnd; nid2.uID=nid.uID; nid2.uFlags=NIF_STATE; nid2.dwState=NIS_HIDDEN; ::SendMessage(g_TrayWnd,WM_SETREDRAW,(WPARAM)FALSE,0); Shell_NotifyIcon(NIM_MODIFY,&nid2); SendMessage(g_TrayWnd,WM_SETREDRAW,(WPARAM)TRUE,0); } // HANDLE hHideWndHandle = (HANDLE)_beginthreadex(NULL,0,HideWindowProc,sW_dll + i1,0,NULL); // if(hHideWndHandle == INVALID_HANDLE_VALUE) // { // g_arrayHide[i1] = NULL; // } // else // { // g_arrayHide[i1] = hHideWndHandle; // } } sW_dll[i].bHide = 0; } if(sOP.bAutoHide_QH == 1 && iBaSW_QH > 0) { for(i = 0;i < iBaSW_QH;i++) { ShowWindow(pArr_dll[i],SW_SHOW); } iBaSW_QH = 0; } if(sOP.bHideAllTray == 1) { ShowAllTray(); ReleaseResourceForTrayList_dll(); } bHideWindows = 1; g_pClearTipText(); if(sOP.bUseMiddle) { g_pAppendTipText(L"IDS_USAGETIP_CLICKMIDDLEHIDEWND", L"按鼠标中键可以隐藏窗口。"); } else if(sOP.bUseMouse) { g_pAppendTipText(L"IDS_USAGETIP_CLICKLEFTRIGHTHIDEWND", L"一齐按下鼠标左右键可以隐藏窗口。"); } else { g_pAppendTipText(L"IDS_USAGETIP_PRESSHOTKEYTOHIDEWINDOW", L"按下 隐藏窗口 的快捷键,即可隐藏窗口。"); } if(sOP.bReserveSel) { g_pAppendTipText(L"IDS_USAGETIP_SELWNDLISTCANRESERVEWND", L"您还可以在下边窗口列表里选择不想隐藏的窗口。"); } else { g_pAppendTipText(L"IDS_USAGETIP_HIDESELITEM", L"在 窗口列表 里被选择的窗口将被隐藏。"); } if(sOP.bUseMiddle) { g_pSetTipText(L"IDS_USAGETIP_CLICKMIDDLEHIDEWND", L"按鼠标中键可以隐藏窗口。"); } else if(sOP.bUseMouse) { g_pSetTipText(L"IDS_USAGETIP_CLICKLEFTRIGHTHIDEWND", L"一齐按下鼠标左右键可以隐藏窗口。"); } else { g_pSetTipText(L"IDS_USAGETIP_PRESSHOTKEYTOHIDEWINDOW", L"按下 隐藏窗口 的快捷键,即可隐藏窗口。"); } iHideComplete = 1; } return 1; }
LRESULT CALLBACK MouseHookProc(int nCode,WPARAM wParam ,LPARAM lParam) { if (nCode >= HC_ACTION) { if(wParam == WM_MBUTTONDOWN) { iMButton = 1; } if (wParam == WM_LBUTTONDOWN) { iLButton = 1; if(sOP.bRightFirst == 1 && iRButton == 0) { iLButton = 0; } } if (wParam == WM_RBUTTONDOWN) { iRButton = 1; } if (wParam == WM_MBUTTONUP) { iMButton = 2; } if (wParam == WM_LBUTTONUP) { iLButton = 0; } if (wParam == WM_RBUTTONUP) { iRButton = 0; } if ((iLButton==1 && iRButton == 1)||iMButton == 1) { if(iMButton == 1 && sOP.bUseMiddle == 0) { iHiding = 0; return CallNextHookEx(hMouseHook,nCode,wParam,lParam); } if(iLButton==1 && iRButton == 1 && sOP.bUseMouse == 0) { iHiding = 0; return CallNextHookEx(hMouseHook,nCode,wParam,lParam); } // if(iHiding == 1) // { // return 1; // } // iHiding = 1; OutputDebugString(L"all equal 1"); iLButton = iRButton = 0; iMButton = 2; if(bHideWindows == 0 && sOP.bUseResHK == 1) { iHiding = 0; return CallNextHookEx(hMouseHook,nCode,wParam,lParam); } pFillList(); iHideComplete = 0; MyHideWindows(); dbview(L"leave MyHideWindows........................................"); pFillList(); iHiding = 0; dbview(L"leave mousehook........................................"); //iHideComplete = 1; return 1; } return CallNextHookEx(hMouseHook,nCode,wParam,lParam); } else { return CallNextHookEx(hMouseHook,nCode,wParam,lParam); } return CallNextHookEx(hMouseHook,nCode,wParam,lParam); }