//================================================================================================ //-----------------------------------------------------+++--> T-Clock Menu Command Message Handler: LRESULT OnTClockCommand(HWND hwnd, WPARAM wParam) //----------------------------------+++--> { WORD wID = LOWORD(wParam); switch(wID) { case IDM_REFRESHTCLOCK: RefreshUs(); break; case IDM_SHOWPROP: MyPropertySheet(-1); break; case IDM_PROP_ALARM: MyPropertySheet(1); break; case IDM_EXIT: SendMessage(hwnd,WM_CLOSE,0,0); break; case IDM_SHOWCALENDER: ToggleCalendar(1); // 1=own calendar break; case IDM_DISPLAYPROP: if(api.OS >= TOS_VISTA) api.Exec(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\1\\::{C555438B-3C23-4769-A71F-B6D3D9B6053A}", NULL, NULL); else api.Exec(L"control", L"desk.cpl, display,1", NULL); break; case IDM_VOLUMECONTROL: //-------------------------------+++--> Volume Controls #ifndef _WIN64 # define OPEN_VOLUME L"SndVol32" #else # define OPEN_VOLUME L"SndVol" #endif // _WIN64 api.Exec(OPEN_VOLUME, NULL, NULL); break; case IDM_AUDIOPROP: //----------------------------------+++--> Audio settings / devices api.Exec(L"control", L"mmsys.cpl", NULL); break; case IDM_RECYCLEBIN: api.Exec(L"::{645FF040-5081-101B-9F08-00AA002F954E}", NULL, NULL); break; case IDM_RECYCLEBIN_PURGE:{ SHQUERYRBINFO info = {sizeof(info)}; // Windows seriously asks : SHQueryRecycleBin(NULL, &info); // "are you sure to delete all items" if(info.i64NumItems > 0 || api.OS == TOS_2000) // when the recycle bin is actually empty... SHEmptyRecycleBin(g_hwndTClockMain, NULL, 0); break;} case IDM_MAPDRIVE: //----------------------------------+++--> Map Network Drive WNetConnectionDialog(hwnd, RESOURCETYPE_DISK); break; case IDM_DISCONNECT: //-------------------------+++--> Disconnect Network Drive WNetDisconnectDialog(hwnd, RESOURCETYPE_DISK); break; case IDM_TOGGLE_DT: //---------------------------+++--> Show / Hide the Desktop ToggleDesk(); break; case IDM_QUICKY_WINEXP: { //-----------------//--+++--> Windows Explorer Opened api.Exec(L"Explorer", L"/e, ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", hwnd); break;} case IDM_QUICKY_DOS: { // Command Prompt api.Exec(L"cmd", L"/f:on /t:0a", hwnd); break;} case IDM_QUICKY_EMPTYRB: SHEmptyRecycleBin(0, NULL, SHERB_NOCONFIRMATION); break; case IDM_SHUTDOWN: if(!ShutDown()) MessageBox(0, L"Shutdown Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); break; case IDM_REBOOT: if(!ReBoot()) MessageBox(0, L"Reboot Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); break; case IDM_LOGOFF: if(!LogOff()) MessageBox(0, L"Logoff Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); break; case IDM_FWD_CASCADE: case IDM_FWD_SIDEBYSIDE: case IDM_FWD_STACKED: case IDM_FWD_SHOWDESKTOP: case IDM_FWD_MINALL: case IDM_FWD_UNDO: g_undo=(wID!=IDM_FWD_UNDO); /* fall through */ case IDM_FWD_DATETIME: case IDM_FWD_CUSTOMNOTIFYICONS: case IDM_FWD_TASKMAN: case IDM_FWD_LOCKTASKBAR: case IDM_FWD_LOCKALLTASKBAR: case IDM_FWD_TASKBARPROP: case IDM_FWD_RUNAPP: case IDM_FWD_EXITEXPLORER:{ HWND hwndTray = FindWindowA("Shell_TrayWnd", NULL); if(hwndTray) PostMessage(hwndTray, WM_COMMAND, wID, 0); break;} case IDM_DATETIME_EX:{ HWND hwnd1, hwnd2; int wait = 40; api.Exec(L"timedate.cpl", L"", 0); while((hwnd2=FindWindowA((char*)(uintptr_t)32770,"Date and Time"))==0 && wait--) Sleep(50); if(hwnd2){ SetActiveWindow(hwnd2); wait = 10; while((hwnd1=FindWindowExA(hwnd2,NULL,(char*)(uintptr_t)32770,"Date and Time"))==0 && wait--) Sleep(50); if(hwnd1){ hwnd2 = GetDlgItem(hwnd1,116); if(hwnd2) PostMessage(hwnd2,BM_CLICK,0,0); } } break;} case IDM_CHIME: /// Alarms AlarmChimeEnable(-1); break; case IDM_STOPWATCH: /// Timers DialogStopWatch(); break; case IDM_STOPWATCH_START: case IDM_STOPWATCH_RESUME: if(!IsWindow(g_hDlgStopWatch)) DialogStopWatch(); StopWatch_Resume(g_hDlgStopWatch); break; case IDM_STOPWATCH_STOP: case IDM_STOPWATCH_PAUSE: if(IsWindow(g_hDlgStopWatch)) StopWatch_Pause(g_hDlgStopWatch); break; case IDM_STOPWATCH_RESET: if(IsWindow(g_hDlgStopWatch)) StopWatch_Reset(g_hDlgStopWatch); break; case IDM_STOPWATCH_LAP: if(IsWindow(g_hDlgStopWatch)) StopWatch_Lap(g_hDlgStopWatch,0); break; case IDM_TIMER: DialogTimer(0); break; case IDM_TIMEWATCH: WatchTimer(0); // Shelter All the Homeless Timers. break; case IDM_TIMEWATCHRESET: WatchTimer(1); // Shelter All the Homeless Timers. break; case IDM_SNTP:{ short just_elevated = HIWORD(wParam); if(!just_elevated || HaveSetTimePermissions()) { ReplyMessage(1); NetTimeConfigDialog(0); return 1; // handled } else { if(IsWindow(g_hDlgSNTP)) SendMessage(g_hDlgSNTP, WM_CLOSE, 1, 0); // close window but safe changes } return 0;} case IDM_SYNCTIME: case IDM_SNTP_SYNC:{ short just_elevated = HIWORD(wParam); int can_sync = HaveSetTimePermissions(); if(!just_elevated || can_sync) { ReplyMessage(1); if(can_sync) { SyncTimeNow(); } else { if(api.ExecElevated(GetClockExe(),L"/UAC /Sync",NULL) != 0) { MessageBox(0, L"T-Clock must be elevated to set your system time,\nbut elevation was canceled", L"Time Sync Failed", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); } } return 1; // handled } return 0;} default: #ifdef _DEBUG DBGOUT("%s: unknown ID: %.5i(0x%.4x) (hwnd:%p)", __FUNCTION__, wID, wID, hwnd); #endif // _DEBUG break; } return 0; }
/* This function handles the WM_COMMAND message. */ void FASTCALL ChangeDir_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { static BOOL fListHasFocus = FALSE; switch( id ) { case IDD_NETWORK: if( WNetConnectionDialog( hwnd, WNTYPE_DRIVE ) == WN_SUCCESS ) { #ifndef WIN32 HINSTANCE hinstNetDriver; int iDrive; hinstNetDriver = (HINSTANCE)WNetGetCaps( 0xFFFF ); if( hinstNetDriver ) { LPWNETGETLASTCONNECTION lpDialogAPI; lpDialogAPI = (LPWNETGETLASTCONNECTION)GetProcAddress( hinstNetDriver, (LPSTR)ORD_WNETGETLASTCONNECTION); if( lpDialogAPI != NULL ) if( lpDialogAPI( WNTYPE_DRIVE, &iDrive ) == WN_SUCCESS ) { ++iDrive; DriveListInitialize( GetDlgItem( hwnd, IDD_DRIVELIST ), GetDlgItem( hwnd, IDD_TEMPLIST ), iDrive ); // SendDlgCommand( hwnd, IDD_DRIVELIST, CBN_SELCHANGE ); } } #endif } break; case IDD_DIRECTORYLIST: if( codeNotify == LBN_SETFOCUS ) fListHasFocus = TRUE; else if( codeNotify == LBN_KILLFOCUS ) fListHasFocus = FALSE; else if( codeNotify == LBN_DBLCLK ) { UINT i; DWORD dw; char szDir[_MAX_PATH]; char szCurDir[_MAX_PATH]; LPSTR lpsz; /* On double-click, change directory and reinit the * listbox. But all we stored in the string was * the directory's single name, so we use the bitmap * type to tell if we're below the current directory * (in which case we just chdir to our name) or above * (in which case we prepend "..\"'s as necessary. */ i = ListBox_GetCurSel( hwndCtl ); dw = ListBox_GetItemData( hwndCtl, i ); /* If out bitmap is IDB_FOLDERCLOSED or the root, * then just . If we're IDB_FOLDEROPENSELECT, * don't do anything. If we're IDB_FOLDEROPEN then * we get the full current path and truncate it * after the directory to which we're switching. */ if( IDB_FOLDEROPENSELECT == HIWORD( dw ) ) { id = IDOK; goto CloseDialog; } /* Get get the directory for sub-directory changes. */ ListBox_GetText( hwndCtl, i, szCurDir ); if( IDB_FOLDEROPEN == HIWORD( dw ) && 0 != i ) { /* Get the current path and find us in this path */ GetWindowText( hwndCtl, szDir, sizeof( szDir ) ); lpsz=_fstrstr( szDir, szCurDir ); /* Null terminate right after us. */ *( lpsz + strlen( szCurDir ) ) = '\0'; /* Get this new directory in the right place */ strcpy( szCurDir, szDir ); } /* chdir has a nice way of validating for us. */ if( 0 == _chdir( szCurDir ) ) { /* Get the new full path. */ Amdir_GetCurrentDirectory( szCurDir, _MAX_PATH ); DirectoryListInitialize( hwndCtl, GetDlgItem( hwnd, IDD_TEMPLIST ), szCurDir ); //???? YH18/04/96 AnsiLower( szCurDir ); SetDlgItemText( hwnd, IDD_EDIT, szCurDir ); } } break; case IDD_DRIVELIST: if( codeNotify == CBN_SELCHANGE ) { UINT i, iCurDrive; char szCurDir[ _MAX_PATH ]; char szDrive[ _MAX_PATH ]; /* Enough for drive:volume */ /* Get the first letter in the current selection */ i = ComboBox_GetCurSel( hwndCtl ); ComboBox_GetLBText( hwndCtl, i, szDrive ); iCurDrive = _getdrive(); /* Save in case of restore */ /* Attempt to set the drive and get the current * directory on it. Both must work for the change * to be certain. If we are certain, reinitialize * the directories. Note that we depend on drives * stored as lower case in the combobox. */ if( _chdrive( (int)( szDrive[ 0 ] - 'a' + 1 ) ) == 0 && ( Amdir_GetCurrentDirectory( szCurDir, _MAX_PATH ) != 0 ) ) { DirectoryListInitialize( GetDlgItem( hwnd, IDD_DIRECTORYLIST ), GetDlgItem( hwnd, IDD_TEMPLIST ), szCurDir ); /* Insure that the root is visible (UI guideline) */ SendDlgItemMessage( hwnd, IDD_DIRECTORYLIST, LB_SETTOPINDEX, 0, 0L ); AnsiLower( szCurDir ); SetDlgItemText( hwnd, IDD_EDIT, szCurDir ); break; } /* Changing drives failed so restore drive and selection */ _chdrive( (int)iCurDrive ); wsprintf( szDrive, "%c:", (char)( iCurDrive + 'a' - 1 ) ); ComboBox_SelectString( hwndCtl, -1, szDrive ); } break; case IDD_EDIT: if( codeNotify == EN_UPDATE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { LPCHGDIR lpChgDir; if( fListHasFocus ) { // PostDlgCommand( hwnd, IDD_DIRECTORYLIST, LBN_DBLCLK ); break; } CloseDialog: lpChgDir = (LPCHGDIR)GetWindowLong( hwnd, DWL_USER ); Edit_GetText( GetDlgItem( hwnd, IDD_EDIT ), lpChgDir->szPath, sizeof( lpChgDir->szPath ) ); } case IDCANCEL: { register int i; for( i = IDB_DRIVEMIN; i <= IDB_DRIVEMAX; i++ ) DeleteBitmap( rghBmpDrives[ i - IDB_DRIVEMIN ] ); for( i = IDB_FOLDERMIN; i <= IDB_FOLDERMAX; i++ ) DeleteBitmap( rghBmpFolders[ i - IDB_FOLDERMIN ] ); fBitmapsLoaded = FALSE; _chdrive( iCurDrive ); _chdir( szDefDir ); EndDialog( hwnd, id == IDOK ); break; } } }