ReactOS 0.4.15-dev-7924-g5949c20
MainDialog.h File Reference
#include <windows.h>
Include dependency graph for MainDialog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WM_UPDATEINFO   (WM_USER + 1)
 

Functions

INT_PTR CALLBACK MainDialogProc (HWND Dlg, UINT Msg, WPARAM WParam, LPARAM LParam)
 

Macro Definition Documentation

◆ WM_UPDATEINFO

#define WM_UPDATEINFO   (WM_USER + 1)

Definition at line 8 of file MainDialog.h.

Function Documentation

◆ MainDialogProc()

INT_PTR CALLBACK MainDialogProc ( HWND  Dlg,
UINT  Msg,
WPARAM  WParam,
LPARAM  LParam 
)

Definition at line 424 of file MainDialog.cpp.

425{
426 static bool ReEntrance = false;
427
428 switch (Msg)
429 {
430 case WM_INITDIALOG:
431 Stopping = false;
432 SetWindowText (Dlg, GetDefaultTitle().c_str());
433 SetDisables (Dlg);
434 InitDialog (Dlg);
435 SetTimer (Dlg, 1, IDLETIME, NULL);
437 QuitWhenDone = false;
438 LoadSettings (Dlg);
439 UpdatePriority (Dlg);
440 return (1);
441
442
443 case WM_TIMER:
444 if (Defrag != NULL && !ReEntrance)
445 {
446 wstring NewTitle;
447
448 SendMessage (Dlg, WM_UPDATEINFO, 0, 0);
449
450 NewTitle = GetDefragTitle ();
451 if (NewTitle != OldWindowText)
452 {
453 OldWindowText = NewTitle;
454 SetWindowText (Dlg, NewTitle.c_str());
455 }
456
457 if (Defrag->IsDoneYet() || Defrag->HasError())
458 { // This is the code executed when defragging is finished (or stopped :)
460 !Defrag->HasError() &&
461 !Stopping)
462 { // Show report
463 ReEntrance = true;
464
467
468 ReEntrance = false;
469 }
470
471 delete Defrag;
472 Defrag = NULL;
473 SetDisables (Dlg);
474 SetWindowText (Dlg, GetDefaultTitle().c_str());
475
476 Stopping = false;
477
478 if (QuitWhenDone)
479 SendMessage (GetDlgItem (Dlg, IDC_QUIT), BM_CLICK, 0, 0);
480 }
481 }
482
483 SetTimer (Dlg, 1, IDLETIME, NULL);
484 return (0);
485
486
487 case WM_UPDATEINFO:
488 UpdateDefragInfo (Dlg);
489 return (1);
490
491
492 case WM_CLOSE:
493 SendMessage (GetDlgItem (Dlg, IDC_QUIT), BM_CLICK, 0, 0);
494 return (1);
495
496
497 case WM_COMMAND:
498 switch (LOWORD(WParam))
499 {
501 UpdatePriority (Dlg);
502 return (1);
503
504
505 case ID_MAIN_HELP:
506 ShellExecute (Dlg, L"open", L"Fraginator.chm", L"", L".", SW_SHOW);
507 return (1);
508
509
510 case IDC_QUIT:
511 if (Defrag == NULL)
512 { // This is the code executing when quitting
513 SaveSettings (Dlg);
514 EndDialog (Dlg, 0);
515 }
516 else
517 { // Tell defragging to finish and disable our button
518 QuitWhenDone = true;
521 }
522 return (1);
523
524
525 case IDC_STARTSTOP:
526 if (Defrag == NULL)
527 { // L"Start"
528 wchar_t Drive[10];
529 LRESULT ID;
530 DefragType Method;
531 HANDLE H;
532
533 if (Defrag != NULL)
534 return (1);
535
537 sizeof (Drive) - 1, (LPARAM) Drive);
538
539 if (wcslen(Drive) != 2 || Drive[1] != L':')
540 return (1);
541
543 Method = DefragInvalid;
544 if (ID == AnalyzeID)
545 Method = DefragAnalyze;
546 else
547 if (ID == FastID)
548 Method = DefragFast;
549 else
550 if (ID == ExtensiveID)
551 Method = DefragExtensive;
552
553 if (Method != DefragInvalid)
554 {
555 Defrag = StartDefragThread (Drive, Method, H);
556 Defrag->SetDoLimitLength (false);
557 SetWindowText (Dlg, GetDefragTitle().c_str());
558 SetDisables (Dlg);
559 }
560 }
561 else
562 { // L"Stop"
563 Stopping = true;
564 Defrag->Stop ();
567 }
568 return (1);
569 }
570 }
571
572 // Otherwise, return 0 to say we did not process the message.
573 return (0);
574}
Defragment * Defrag
Definition: Fraginator.cpp:20
HINSTANCE GlobalHInstance
Definition: Fraginator.cpp:19
static void InitDialog(HWND Dlg)
Definition: MainDialog.cpp:33
void SetDisables(HWND Dlg)
Definition: MainDialog.cpp:177
wstring GetDefragTitle(void)
Definition: MainDialog.cpp:159
bool QuitWhenDone
Definition: MainDialog.cpp:13
LRESULT FastID
Definition: MainDialog.cpp:11
#define IDLETIME
Definition: MainDialog.cpp:421
wstring GetDefaultTitle(void)
Definition: MainDialog.cpp:148
bool Stopping
Definition: MainDialog.cpp:14
LRESULT ExtensiveID
Definition: MainDialog.cpp:12
LRESULT AnalyzeID
Definition: MainDialog.cpp:10
void UpdatePriority(HWND Dlg)
Definition: MainDialog.cpp:200
void UpdateDefragInfo(HWND Dlg)
Definition: MainDialog.cpp:94
wstring OldWindowText
Definition: MainDialog.cpp:422
#define WM_UPDATEINFO
Definition: MainDialog.h:8
INT_PTR CALLBACK ReportDialogProc(HWND Dlg, UINT Msg, WPARAM WParam, LPARAM LParam)
Defragment * StartDefragThread(wstring Drive, DefragType Method, HANDLE &Handle)
Definition: Unfrag.cpp:132
DefragType
Definition: Unfrag.h:67
@ DefragExtensive
Definition: Unfrag.h:70
@ DefragAnalyze
Definition: Unfrag.h:71
@ DefragInvalid
Definition: Unfrag.h:68
@ DefragFast
Definition: Unfrag.h:69
void SaveSettings(void)
Definition: settings.c:115
void LoadSettings(void)
Definition: settings.c:53
#define IDI_ICON
Definition: resource.h:5
PWCHAR Drive
Definition: chkdsk.c:73
bool IsDoneYet(void)
Definition: Defragment.cpp:151
void Stop(void)
Definition: Defragment.cpp:443
void SetDoLimitLength(bool L)
Definition: Defragment.h:67
DefragType GetDefragType(void)
Definition: Defragment.h:57
bool HasError(void)
Definition: Defragment.cpp:454
struct @1632 Msg[]
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IDC_DRIVES_LIST
Definition: resource.h:13
#define IDD_REPORT
Definition: resource.h:7
#define IDC_PRIORITY_LIST
Definition: resource.h:40
#define IDC_QUIT
Definition: resource.h:10
#define ID_MAIN_HELP
Definition: resource.h:39
#define IDC_METHODS_LIST
Definition: resource.h:12
#define IDC_STARTSTOP
Definition: resource.h:11
#define H
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define ID
Definition: ruserpass.c:36
#define ShellExecute
Definition: shellapi.h:693
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_CLOSE
Definition: winuser.h:1621
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_GETTEXT
Definition: winuser.h:1618
#define DialogBoxParam
Definition: winuser.h:5764
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1742
#define BM_CLICK
Definition: winuser.h:1917
#define LoadIcon
Definition: winuser.h:5813
#define SendMessage
Definition: winuser.h:5843
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SW_SHOW
Definition: winuser.h:775
#define SetWindowText
Definition: winuser.h:5857
#define CB_GETCURSEL
Definition: winuser.h:1943
#define GCL_HICON
Definition: winuser.h:666
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define SetClassLong
Definition: winuser.h:5847
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by ThreadProc(), and wWinMain().