ReactOS  0.4.13-dev-551-gf37fb1f
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 :)
459  if (Defrag->GetDefragType() == DefragAnalyze &&
460  !Defrag->HasError() &&
461  !Stopping)
462  { // Show report
463  ReEntrance = true;
464 
466  Dlg, ReportDialogProc, (LPARAM) Defrag);
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  {
500  case IDC_PRIORITY_LIST:
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 }
#define IDI_ICON
Definition: resource.h:5
#define MAKEINTRESOURCE
Definition: winuser.h:591
INT_PTR CALLBACK ReportDialogProc(HWND Dlg, UINT Msg, WPARAM WParam, LPARAM LParam)
LRESULT ExtensiveID
Definition: MainDialog.cpp:12
bool Stopping
Definition: MainDialog.cpp:14
void UpdateDefragInfo(HWND Dlg)
Definition: MainDialog.cpp:94
Defragment * StartDefragThread(wstring Drive, DefragType Method, HANDLE &Handle)
Definition: Unfrag.cpp:132
void Stop(void)
Definition: Defragment.cpp:443
bool IsDoneYet(void)
Definition: Defragment.cpp:151
#define WM_GETTEXT
Definition: winuser.h:1600
static void InitDialog(HWND Dlg)
Definition: MainDialog.cpp:33
void LoadSettings(HWND Dlg)
Definition: MainDialog.cpp:328
wstring GetDefaultTitle(void)
Definition: MainDialog.cpp:148
#define CB_GETCURSEL
Definition: winuser.h:1904
Defragment * Defrag
Definition: Fraginator.cpp:20
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define SetClassLong
Definition: winuser.h:5713
#define IDC_QUIT
Definition: resource.h:10
long LONG
Definition: pedump.c:60
#define ID_MAIN_HELP
Definition: resource.h:39
PWCHAR Drive
Definition: chkdsk.c:73
#define ShellExecute
Definition: shellapi.h:689
LRESULT AnalyzeID
Definition: MainDialog.cpp:10
void SaveSettings(HWND Dlg)
Definition: MainDialog.cpp:263
void SetDoLimitLength(bool L)
Definition: Defragment.h:67
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE GlobalHInstance
Definition: Fraginator.cpp:19
LONG_PTR LPARAM
Definition: windef.h:208
#define SW_SHOW
Definition: winuser.h:769
LRESULT FastID
Definition: MainDialog.cpp:11
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
void SetDisables(HWND Dlg)
Definition: MainDialog.cpp:177
#define BM_CLICK
Definition: winuser.h:1878
void UpdatePriority(HWND Dlg)
Definition: MainDialog.cpp:200
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_TIMER
Definition: winuser.h:1718
#define WM_CLOSE
Definition: winuser.h:1603
wstring OldWindowText
Definition: MainDialog.cpp:422
#define WM_UPDATEINFO
Definition: MainDialog.h:8
bool HasError(void)
Definition: Defragment.cpp:454
#define DialogBoxParam
Definition: winuser.h:5630
static const WCHAR L[]
Definition: oid.c:1250
DefragType GetDefragType(void)
Definition: Defragment.h:57
bool QuitWhenDone
Definition: MainDialog.cpp:13
#define ID
Definition: ruserpass.c:36
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_METHODS_LIST
Definition: resource.h:12
struct @1574 Msg[]
#define IDLETIME
Definition: MainDialog.cpp:421
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define GCL_HICON
Definition: winuser.h:661
#define IDD_REPORT
Definition: resource.h:7
#define SetWindowText
Definition: winuser.h:5723
DefragType
Definition: Unfrag.h:66
#define SendMessage
Definition: winuser.h:5709
#define IDC_PRIORITY_LIST
Definition: resource.h:40
#define LoadIcon
Definition: winuser.h:5679
LONG_PTR LRESULT
Definition: windef.h:209
#define IDC_DRIVES_LIST
Definition: resource.h:13
wstring GetDefragTitle(void)
Definition: MainDialog.cpp:159
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define H
#define IDC_STARTSTOP
Definition: resource.h:11

Referenced by ThreadProc(), and wWinMain().