ReactOS 0.4.15-dev-7958-gcd0bb1a
systempage.cpp File Reference
#include "precomp.h"
#include <share.h>
#include "treeview.h"
#include "uxthemesupp.h"
#include "regutils.h"
#include "utils.h"
Include dependency graph for systempage.cpp:

Go to the source code of this file.

Functions

DWORD GetSystemIniActivation (VOID)
 
DWORD GetWinIniActivation (VOID)
 
static void ToLower (LPWSTR lpszString)
 
INT_PTR CALLBACK FindDialogWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
static void TreeView_SetBOOLCheck (HWND hTree, HTREEITEM htiItem, BOOL bState, BOOL bPropagateStateToParent)
 
static void LoadIniFile (HWND hTree, LPCWSTR lpszIniFile)
 
static void WriteIniFile (HWND hTree, LPCWSTR lpszIniFile)
 
static void Update_Btn_States (HWND hDlg)
 
INT_PTR CommonWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK SystemPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK WinPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

LPCWSTR lpszSystemIni = L"%SystemRoot%\\system.ini"
 
LPCWSTR lpszWinIni = L"%SystemRoot%\\win.ini"
 
static LPCWSTR szMSConfigTok = L";msconfig "
 
static const size_t MSConfigTokLen = 10
 
static HWND hTree = NULL
 
static WCHAR szSearchString [MAX_VALUE_NAME] = L""
 
static BOOL bMatchExactText = FALSE
 
static BOOL bSearchSense = TRUE
 
static BOOL bCaseSensitive = FALSE
 

Function Documentation

◆ CommonWndProc()

INT_PTR CommonWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 484 of file systempage.cpp.

485{
488
489 switch (message)
490 {
491 case WM_INITDIALOG:
492 {
493 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
494
495 //
496 // Initialize the styles.
497 //
498 TreeView_Set3StateCheck(hSystemTree);
499 SetWindowTheme(hSystemTree, L"Explorer", NULL);
500
501 TreeView_SetIndent(hSystemTree, TreeView_GetIndent(hSystemTree) + 2);
502
503 /* Load data */
505
506 /* Select the first item */
507 TreeView_SelectItem(hSystemTree, TreeView_GetRoot(hSystemTree)); // Is it really necessary?
508 SetFocus(hSystemTree);
509
510 Update_Btn_States(hDlg);
511
512 return TRUE;
513 }
514
515 case WM_DESTROY:
516 {
518 return FALSE;
519 }
520
521 case WM_COMMAND:
522 {
523 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
524
525 switch (LOWORD(wParam))
526 {
528 {
529 TreeView_UpItem(hSystemTree, TreeView_GetSelection(hSystemTree));
530 PropSheet_Changed(GetParent(hDlg), hDlg);
531 return TRUE;
532 }
533
535 {
536 TreeView_DownItem(hSystemTree, TreeView_GetSelection(hSystemTree));
537 PropSheet_Changed(GetParent(hDlg), hDlg);
538 return TRUE;
539 }
540
542 {
544 TreeView_SetBOOLCheck(hSystemTree, hItem, TRUE, TRUE);
545 TreeView_SelectItem(hSystemTree, hItem);
546 Update_Btn_States(hDlg);
547
548 PropSheet_Changed(GetParent(hDlg), hDlg);
549
550 return TRUE;
551 }
552
554 {
555 for (HTREEITEM htiIterator = TreeView_GetRoot(hSystemTree) ; htiIterator ; htiIterator = TreeView_GetNextSibling(hSystemTree, htiIterator))
556 TreeView_SetBOOLCheck(hSystemTree, htiIterator, TRUE, TRUE);
557
558 Update_Btn_States(hDlg);
559
560 PropSheet_Changed(GetParent(hDlg), hDlg);
561
562 return TRUE;
563 }
564
566 {
568 TreeView_SetBOOLCheck(hSystemTree, hItem, FALSE, TRUE);
569 TreeView_SelectItem(hSystemTree, hItem);
570
571 Update_Btn_States(hDlg);
572
573 PropSheet_Changed(GetParent(hDlg), hDlg);
574
575 return TRUE;
576 }
577
579 {
580 for (HTREEITEM htiIterator = TreeView_GetRoot(hSystemTree) ; htiIterator ; htiIterator = TreeView_GetNextSibling(hSystemTree, htiIterator))
581 TreeView_SetBOOLCheck(hSystemTree, htiIterator, FALSE, TRUE);
582
583 Update_Btn_States(hDlg);
584
585 PropSheet_Changed(GetParent(hDlg), hDlg);
586
587 return TRUE;
588 }
589
591 {
592 DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_FIND_DIALOG), hDlg /* hMainWnd */, FindDialogWndProc, (LPARAM)hSystemTree);
593 return TRUE;
594 }
595
597 {
598 HTREEITEM hInsertAfter = TreeView_GetSelection(hSystemTree);
599 HTREEITEM hNewItem = InsertItem(hSystemTree, L"", TreeView_GetParent(hSystemTree, hInsertAfter), hInsertAfter);
600 TreeView_EditLabel(hSystemTree, hNewItem);
601 TreeView_SelectItem(hSystemTree, hNewItem);
602
603 PropSheet_Changed(GetParent(hDlg), hDlg);
604
605 return TRUE;
606 }
607
609 {
610 TreeView_EditLabel(hSystemTree, TreeView_GetSelection(hSystemTree));
611 return TRUE;
612 }
613
615 {
616 TreeView_DeleteItem(hSystemTree, TreeView_GetSelection(hSystemTree));
617 Update_Btn_States(hDlg);
618 PropSheet_Changed(GetParent(hDlg), hDlg);
619 return TRUE;
620 }
621
622 default:
623 return FALSE;
624 }
625 // return FALSE;
626 }
627
629 {
630 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
631
632 /* Retrieve the new checked state of the item and handle the notification */
633 HTREEITEM hItemChanged = (HTREEITEM)lParam;
634
635 //
636 // State before | State after
637 // -------------------------------
638 // 0 (unchecked) | 1 (checked)
639 // 1 (checked) | 0 (unchecked)
640 // 2 (grayed) | 1 (checked) --> this case corresponds to the former
641 // | with 0 == 2 mod 2.
642 //
643 UINT uiCheckState = TreeView_GetCheckState(hSystemTree, hItemChanged) % 2;
644 TreeView_SetBOOLCheck(hSystemTree, hItemChanged, uiCheckState ? FALSE : TRUE, TRUE);
645 TreeView_SelectItem(hSystemTree, hItemChanged);
646 Update_Btn_States(hDlg);
647
648 PropSheet_Changed(GetParent(hDlg), hDlg);
649
650 return TRUE;
651 }
652
653 case WM_NOTIFY:
654 {
655 if (((LPNMHDR)lParam)->idFrom == IDC_SYSTEM_TREE)
656 {
657 switch (((LPNMHDR)lParam)->code)
658 {
659 case NM_CLICK:
660 {
661 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
662
663 DWORD dwpos = GetMessagePos();
664 TVHITTESTINFO ht = {};
665 ht.pt.x = GET_X_LPARAM(dwpos);
666 ht.pt.y = GET_Y_LPARAM(dwpos);
667 MapWindowPoints(HWND_DESKTOP /*NULL*/, hSystemTree, &ht.pt, 1);
668
669 TreeView_HitTest(hSystemTree, &ht);
670
671 if (TVHT_ONITEMSTATEICON & ht.flags)
672 {
673 PostMessage(hDlg, UM_CHECKSTATECHANGE, 0, (LPARAM)ht.hItem);
674
675 // Disable default behaviour. Needed for the UM_CHECKSTATECHANGE
676 // custom notification to work as expected.
678 }
679 /*
680 else
681 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
682 */
683
684 return TRUE;
685 }
686
687 case TVN_KEYDOWN:
688 {
689 if (((LPNMTVKEYDOWN)lParam)->wVKey == VK_SPACE)
690 {
691 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
692
693 HTREEITEM hti = TreeView_GetSelection(hSystemTree);
694
695 // Hack the tree item state. This is needed because whether or not
696 // TRUE is being returned, the default implementation of SysTreeView32
697 // is always being processed for a key down !
698 if (GetWindowLongPtr(hSystemTree, GWL_STYLE) & TVS_CHECKBOXES)
699 {
701 }
702
703 PostMessage(hDlg, UM_CHECKSTATECHANGE, 0, (LPARAM)hti);
704
705 // Disable default behaviour. Needed for the UM_CHECKSTATECHANGE
706 // custom notification to work as expected.
708 }
709
710 return TRUE;
711 }
712
713 case TVN_ENDLABELEDIT:
714 {
715 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
716
717 /*
718 * Ehh yes, we have to deal with a "dialog proc", which is quite different from a "window proc":
719 *
720 * (excerpt from: MSDN library http://msdn.microsoft.com/en-us/library/ms645469(VS.85).aspx)
721 *
722 * Return Value
723 * ============
724 * INT_PTR
725 *
726 * Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not.
727 * If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response
728 * to the message.
729 *
730 * If the dialog box procedure processes a message that requires a specific return value, the dialog box procedure
731 * should set the desired return value by calling SetWindowLong(hwndDlg, DWLP_MSGRESULT, lResult) immediately before
732 * returning TRUE. Note that you must call SetWindowLong immediately before returning TRUE; doing so earlier may result
733 * in the DWLP_MSGRESULT value being overwritten by a nested dialog box message.
734 *
735 * [...]
736 *
737 * Remarks
738 * =======
739 * You should use the dialog box procedure only if you use the dialog box class for the dialog box. This is the default
740 * class and is used when no explicit class is specified in the dialog box template. Although the dialog box procedure
741 * is similar to a window procedure, it must not call the DefWindowProc function to process unwanted messages. Unwanted
742 * messages are processed internally by the dialog box window procedure.
743 *
744 */
745
746 // A arranger un peu ???? Certainement.
747 TVITEMW truc = ((LPNMTVDISPINFO)lParam)->item;
748 if (truc.pszText)
749 {
750 if (!*truc.pszText)
751 TreeView_DeleteItem(hSystemTree, truc.hItem);
752
753 PropSheet_Changed(GetParent(hDlg), hDlg);
754
756 }
757 else
759
760 Update_Btn_States(hDlg);
761 return TRUE;
762 }
763
764 case TVN_SELCHANGED:
765 Update_Btn_States(hDlg);
766 return TRUE;
767
768 default:
769 return FALSE;
770 }
771 }
772 else
773 {
774 switch (((LPNMHDR)lParam)->code)
775 {
776 case PSN_APPLY:
777 {
778 // TODO: Enum the items.
779 // HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
780 //
782
783 /* TODO: see :
784 *
785 * dll/win32/devmgr/advprop.c: PropSheet_RebootSystem(hwndDlg);
786 * include/psdk/prsht.h:#define PropSheet_RebootSystem(d) SendMessage(d,PSM_REBOOTSYSTEM,0,0)
787 *
788 * dll/shellext/deskadp/deskadp.c: PropSheet_RestartWindows(GetParent(This->hwndDlg));
789 * dll/shellext/deskmon/deskmon.c: PropSheet_RestartWindows(GetParent(This->hwndDlg));
790 * include/psdk/prsht.h:#define PropSheet_RestartWindows(d) SendMessage(d,PSM_RESTARTWINDOWS,0,0)
791 *
792 * for their usage.
793 */
795 //PropSheet_RestartWindows(GetParent(hDlg));
796
798
799 // Since there are nothing to modify, applying modifications
800 // cannot return any error.
802 //PropSheet_UnChanged(GetParent(hDlg) /*hMainWnd*/, hDlg);
803 return TRUE;
804 }
805
806 case PSN_HELP:
807 {
808 MessageBox(hDlg, _T("Help not implemented yet!"), _T("Help"), MB_ICONINFORMATION | MB_OK);
809 return TRUE;
810 }
811
812 case PSN_KILLACTIVE: // Is going to lose activation.
813 {
814 // Changes are always valid of course.
816 return TRUE;
817 }
818
819 case PSN_QUERYCANCEL:
820 {
821 // Allows cancellation since there are nothing to cancel...
823 return TRUE;
824 }
825
827 {
828 HWND hSystemTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
829
830 // Give the focus on and select the first item.
832
833 SetWindowLongPtr(hDlg, DWLP_MSGRESULT, (LONG_PTR)hSystemTree);
834 return TRUE;
835 }
836
837 //
838 // DO NOT TOUCH THESE NEXT MESSAGES, THEY ARE OK LIKE THIS...
839 //
840 case PSN_RESET: // Perform final cleaning, called before WM_DESTROY.
841 return TRUE;
842
843 case PSN_SETACTIVE: // Is going to gain activation.
844 {
846 return TRUE;
847 }
848
849 default:
850 break;
851 }
852 }
853
854 return FALSE;
855 }
856
857 default:
858 return FALSE;
859 }
860
861 // return FALSE;
862}
#define IDC_BTN_SYSTEM_UP
Definition: resource.h:61
#define IDC_BTN_SYSTEM_DOWN
Definition: resource.h:62
#define IDC_BTN_SYSTEM_DISABLE
Definition: resource.h:64
#define IDC_BTN_SYSTEM_ENABLE
Definition: resource.h:63
#define IDC_BTN_SYSTEM_FIND
Definition: resource.h:65
#define IDC_BTN_SYSTEM_NEW
Definition: resource.h:66
#define IDC_BTN_SYSTEM_EDIT
Definition: resource.h:67
#define IDC_SYSTEM_TREE
Definition: resource.h:68
void TreeView_Set3StateCheck(HWND hTree)
Definition: treeview.c:24
void TreeView_Cleanup(HWND hTree)
Definition: treeview.c:87
void TreeView_DownItem(HWND hTree, HTREEITEM htiItemToDown)
Definition: treeview.c:186
HTREEITEM InsertItem(HWND hTree, LPCWSTR szName, HTREEITEM hParent, HTREEITEM hInsertAfter)
Definition: treeview.c:95
void TreeView_UpItem(HWND hTree, HTREEITEM htiItemToUp)
Definition: treeview.c:204
#define IDC_BTN_SYSTEM_DISABLE_ALL
Definition: resource.h:45
#define IDC_BTN_SYSTEM_ENABLE_ALL
Definition: resource.h:44
#define IDC_BTN_SYSTEM_DELETE
Definition: resource.h:46
#define IDD_FIND_DIALOG
Definition: resource.h:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define UM_CHECKSTATECHANGE
Definition: comctl32supp.h:16
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
static const struct newhuff ht[]
Definition: huffman.h:296
#define PSN_QUERYINITIALFOCUS
Definition: settings.cpp:98
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PropSheet_CancelToClose(d)
Definition: prsht.h:343
#define PSN_QUERYCANCEL
Definition: prsht.h:123
#define PSN_KILLACTIVE
Definition: prsht.h:116
#define PSN_APPLY
Definition: prsht.h:117
#define PSNRET_NOERROR
Definition: prsht.h:129
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define PropSheet_RebootSystem(d)
Definition: prsht.h:350
#define PSN_HELP
Definition: prsht.h:119
#define PSN_RESET
Definition: prsht.h:118
#define PSN_SETACTIVE
Definition: prsht.h:115
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define TVN_KEYDOWN
Definition: commctrl.h:3713
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2673
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3481
#define TreeView_SetIndent(hwnd, indent)
Definition: commctrl.h:3438
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3264
#define NM_CLICK
Definition: commctrl.h:130
#define TVN_ENDLABELEDIT
Definition: commctrl.h:3744
#define TreeView_SetItemState(hwndTV, hti, data, _mask)
Definition: commctrl.h:3592
#define TVHT_ONITEMSTATEICON
Definition: commctrl.h:3531
#define TVS_CHECKBOXES
Definition: commctrl.h:3255
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3475
#define TVIS_STATEIMAGEMASK
Definition: commctrl.h:3288
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3467
#define TreeView_GetIndent(hwnd)
Definition: commctrl.h:3435
#define INDEXTOSTATEIMAGEMASK(i)
Definition: commctrl.h:2328
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3504
#define TreeView_GetCheckState(hwndTV, hti)
Definition: commctrl.h:3596
#define LPNMTVDISPINFO
Definition: commctrl.h:3676
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3513
#define LVIS_FOCUSED
Definition: commctrl.h:2318
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3415
#define WM_NOTIFY
Definition: richedit.h:61
Definition: inflate.c:139
Definition: tftpd.h:60
HTREEITEM hItem
Definition: commctrl.h:3317
LPWSTR pszText
Definition: commctrl.h:3320
INT_PTR CALLBACK FindDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: systempage.cpp:72
static void Update_Btn_States(HWND hDlg)
Definition: systempage.cpp:392
static void TreeView_SetBOOLCheck(HWND hTree, HTREEITEM htiItem, BOOL bState, BOOL bPropagateStateToParent)
Definition: systempage.cpp:170
static void LoadIniFile(HWND hTree, LPCWSTR lpszIniFile)
Definition: systempage.cpp:238
static void WriteIniFile(HWND hTree, LPCWSTR lpszIniFile)
Definition: systempage.cpp:343
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
#define _T(x)
Definition: vfdio.h:22
LONG_PTR LPARAM
Definition: windef.h:208
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
#define VK_SPACE
Definition: winuser.h:2219
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define HWND_DESKTOP
Definition: winuser.h:1209
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MB_OK
Definition: winuser.h:790
#define PostMessage
Definition: winuser.h:5832
HWND WINAPI GetParent(_In_ HWND)
#define MessageBox
Definition: winuser.h:5822
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define MB_ICONINFORMATION
Definition: winuser.h:802
#define WM_DESTROY
Definition: winuser.h:1609
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GWL_STYLE
Definition: winuser.h:852
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by SystemPageWndProc(), and WinPageWndProc().

◆ FindDialogWndProc()

INT_PTR CALLBACK FindDialogWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 72 of file systempage.cpp.

76{
78
79 switch (message)
80 {
81 case WM_INITDIALOG:
82 {
83 hTree = (HWND)lParam;
84
86 Button_SetCheck(GetDlgItem(hDlg, IDC_RB_FIND_DOWN), (bSearchSense ? BST_CHECKED : BST_UNCHECKED)); // TRUE == down, FALSE == up.
87 Button_SetCheck(GetDlgItem(hDlg, IDC_RB_FIND_UP ), (bSearchSense ? BST_UNCHECKED : BST_CHECKED )); // TRUE == down, FALSE == up.
89
93
94 return TRUE;
95 }
96
97 case WM_COMMAND:
98 {
99 switch (LOWORD(wParam))
100 {
101 case IDOK:
102 {
103 TVITEMEXW tvItemEx;
104 HTREEITEM htiIterator;
106 WCHAR szTemp[MAX_VALUE_NAME];
107
110 (Button_GetCheck(GetDlgItem(hDlg, IDC_RB_FIND_UP )) == BST_UNCHECKED)); // TRUE == down, FALSE == up.
112
114 wcscpy(szTemp, szSearchString);
115 if (!bCaseSensitive)
116 ToLower(szTemp);
117
122 htiIterator ;
123 htiIterator = (bSearchSense ? TreeView_GetNext(hTree, htiIterator)
124 : TreeView_GetPrev(hTree, htiIterator)))
125 {
126 SecureZeroMemory(&tvItemEx, sizeof(tvItemEx));
127
128 tvItemEx.hItem = htiIterator; // Handle of the item to be retrieved
129 tvItemEx.mask = TVIF_HANDLE | TVIF_TEXT;
130 tvItemEx.pszText = label;
131 tvItemEx.cchTextMax = MAX_VALUE_NAME;
132 TreeView_GetItem(hTree, &tvItemEx);
133 if (!bCaseSensitive)
134 ToLower(label);
135
136 if (bMatchExactText ? (_tcscmp(label, szTemp) == 0) : !!_tcsstr(label, szTemp)) // <-- hackish. A arranger.
137 {
138 TreeView_SelectItem(hTree, htiIterator);
139 EndDialog(hDlg, LOWORD(wParam));
140 return TRUE;
141 }
142 //MessageBox(NULL, label, _T("Info"), MB_ICONINFORMATION | MB_OK);
143 }
144
145 // FIXME: Localize!
146 MessageBoxW(hDlg, L"No correspondence found.", szAppName, MB_ICONINFORMATION | MB_OK);
149 //EndDialog(hDlg, LOWORD(wParam));
150 return TRUE;
151 }
152
153 case IDCANCEL:
154 EndDialog(hDlg, LOWORD(wParam));
155 return TRUE;
156
157 default:
158 //break;
159 return FALSE;
160 }
161 }
162 }
163
164 return FALSE;
165}
#define MAX_VALUE_NAME
Definition: control.c:28
HTREEITEM TreeView_GetFirst(HWND hTree)
Definition: treeview.c:224
HTREEITEM TreeView_GetNext(HWND hTree, HTREEITEM hItem)
Definition: treeview.c:263
HTREEITEM TreeView_GetLast(HWND hTree)
Definition: treeview.c:240
HTREEITEM TreeView_GetPrev(HWND hTree, HTREEITEM hItem)
Definition: treeview.c:245
#define IDC_TXT_FIND_TEXT
Definition: resource.h:100
#define IDC_RB_FIND_DOWN
Definition: resource.h:105
#define IDC_RB_FIND_UP
Definition: resource.h:104
#define IDC_CBX_FIND_FROM_BEGINNING
Definition: resource.h:103
#define IDC_CBX_FIND_MATCH_CASE
Definition: resource.h:102
#define IDC_CBX_FIND_WHOLE_WORD_ONLY
Definition: resource.h:101
HANDLE HWND
Definition: compat.h:19
#define _tcscmp
Definition: tchar.h:1424
static const WCHAR label[]
Definition: itemdlg.c:1546
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:701
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TVIF_HANDLE
Definition: commctrl.h:3270
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
TCHAR szAppName[128]
Definition: solitaire.cpp:18
LPWSTR pszText
Definition: commctrl.h:3350
int cchTextMax
Definition: commctrl.h:3351
HTREEITEM hItem
Definition: commctrl.h:3347
static BOOL bCaseSensitive
Definition: systempage.cpp:56
static HWND hTree
Definition: systempage.cpp:52
static WCHAR szSearchString[MAX_VALUE_NAME]
Definition: systempage.cpp:53
static BOOL bSearchSense
Definition: systempage.cpp:55
static void ToLower(LPWSTR lpszString)
Definition: systempage.cpp:59
static BOOL bMatchExactText
Definition: systempage.cpp:54
#define SecureZeroMemory
Definition: winbase.h:1713
#define Button_GetCheck(hwndCtl)
Definition: windowsx.h:31
#define Edit_SetSel(hwndCtl, ichStart, ichEnd)
Definition: windowsx.h:110
#define Edit_GetText(hwndCtl, lpch, cchMax)
Definition: windowsx.h:94
#define Edit_SetText(hwndCtl, lpsz)
Definition: windowsx.h:112
#define Button_SetCheck(hwndCtl, check)
Definition: windowsx.h:35
#define IDCANCEL
Definition: winuser.h:831
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define IDOK
Definition: winuser.h:830
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _tcsstr
Definition: xmlstorage.h:199

Referenced by CommonWndProc().

◆ GetSystemIniActivation()

DWORD GetSystemIniActivation ( VOID  )

Definition at line 34 of file systempage.cpp.

35{
36 DWORD dwSystemIni = 0;
37 RegGetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\state", L"system.ini", &dwSystemIni);
38 return dwSystemIni;
39}
LONG RegGetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, OUT LPDWORD lpData OPTIONAL)
Definition: regutils.c:95
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ GetWinIniActivation()

DWORD GetWinIniActivation ( VOID  )

Definition at line 41 of file systempage.cpp.

42{
43 DWORD dwWinIni = 0;
44 RegGetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\state", L"win.ini", &dwWinIni);
45 return dwWinIni;
46}

◆ LoadIniFile()

static void LoadIniFile ( HWND  hTree,
LPCWSTR  lpszIniFile 
)
static

Definition at line 238 of file systempage.cpp.

239{
240 // Ouverture en lecture (sans création de fichier si celui-ci n'esistait pas déjà)
241 // d'un flux en mode texte, avec permission de lecture seule.
242 DWORD dwNumOfChars = ExpandEnvironmentStringsW(lpszIniFile, NULL, 0);
243 LPWSTR lpszFileName = (LPWSTR)MemAlloc(0, dwNumOfChars * sizeof(WCHAR));
244 ExpandEnvironmentStringsW(lpszIniFile, lpszFileName, dwNumOfChars);
245
246 FILE* ini_file = _wfsopen(lpszFileName, L"rt", _SH_DENYWR); // r+t <-- read write text ; rt <-- read text
247 MemFree(lpszFileName);
248
249 if (!ini_file)
250 return; // error
251
252 WCHAR szLine[MAX_VALUE_NAME] = L"";
253 TVINSERTSTRUCT tvis;
254 HTREEITEM hParent = TVI_ROOT;
255 BOOL bIsSection = FALSE;
256 LPWSTR lpsz1 = NULL;
257 LPWSTR lpsz2 = NULL;
258
259 while (!feof(ini_file) && fgetws(szLine, _ARRAYSIZE(szLine), ini_file))
260 {
261 /* Skip hypothetical starting spaces or newline characters */
262 lpsz1 = szLine;
263 while (*lpsz1 == L' ' || *lpsz1 == L'\r' || *lpsz1 == L'\n')
264 ++lpsz1;
265
266 /* Skip empty lines */
267 if (!*lpsz1)
268 continue;
269
270 /* Find the last newline character (if exists) and replace it by the NULL terminator */
271 lpsz2 = lpsz1;
272 while (*lpsz2)
273 {
274 if (*lpsz2 == L'\r' || *lpsz2 == L'\n')
275 {
276 *lpsz2 = L'\0';
277 break;
278 }
279
280 ++lpsz2;
281 }
282
283 /* Check for new sections. They should be parent of ROOT. */
284 if (*lpsz1 == L'[')
285 {
286 bIsSection = TRUE;
287 hParent = TVI_ROOT;
288 }
289
290 SecureZeroMemory(&tvis, sizeof(tvis));
291 tvis.hParent = hParent;
292 tvis.hInsertAfter = TVI_LAST;
293 tvis.itemex.mask = TVIF_TEXT; // TVIF_HANDLE | TVIF_TEXT;
294 tvis.itemex.pszText = lpsz1;
295 tvis.itemex.hItem = TreeView_InsertItem(hTree, &tvis);
296
297 /* The special ";msconfig " token disables the line */
298 if (!bIsSection && _wcsnicmp(lpsz1, szMSConfigTok, MSConfigTokLen) == 0)
299 TreeView_SetBOOLCheck(hTree, tvis.itemex.hItem, FALSE, TRUE);
300 else
301 TreeView_SetBOOLCheck(hTree, tvis.itemex.hItem, TRUE, TRUE);
302
303 /*
304 * Now, all the elements will be children of this section,
305 * until we create a new one.
306 */
307 if (bIsSection)
308 {
309 bIsSection = FALSE;
310 hParent = tvis.itemex.hItem;
311 }
312 }
313
314 fclose(ini_file);
315 return;
316
318 /*
319 HTREEITEM hItem[16];
320
321 hItem[0] = InsertItem(hTree, _T("B"),TVI_ROOT,TVI_LAST);
322 hItem[1] = InsertItem(hTree, _T("C"),TVI_ROOT,TVI_LAST);
323 hItem[2] = InsertItem(hTree, _T("A"),TVI_ROOT,TVI_LAST);
324 hItem[3] = InsertItem(hTree, _T("D"),TVI_ROOT,TVI_LAST);
325 hItem[4] = InsertItem(hTree, _T("D-1"),hItem[3] ,TVI_LAST);
326 hItem[5] = InsertItem(hTree, _T("D-2"),hItem[3] ,TVI_LAST);
327 hItem[9] = InsertItem(hTree, _T("D-2-1"),hItem[5],TVI_LAST);
328 hItem[6] = InsertItem(hTree, _T("D-3"),hItem[3] ,TVI_LAST);
329 hItem[7] = InsertItem(hTree, _T("D-3-1"),hItem[6],TVI_LAST);
330 hItem[10] = InsertItem(hTree, _T("D-3-1-1"),hItem[7],TVI_LAST);
331 hItem[11] = InsertItem(hTree, _T("D-3-1-2"),hItem[7],TVI_LAST);
332 hItem[12] = InsertItem(hTree, _T("D-3-1-3"),hItem[7],TVI_LAST);
333 hItem[13] = InsertItem(hTree, _T("D-3-1-4"),hItem[7],TVI_LAST);
334 hItem[14] = InsertItem(hTree, _T("D-3-1-5"),hItem[7],TVI_LAST);
335 hItem[15] = InsertItem(hTree, _T("D-3-1-6"),hItem[7],TVI_LAST);
336 hItem[13] = InsertItem(hTree, _T("E"),TVI_ROOT,TVI_LAST);
337 */
339
340}
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
PVOID MemAlloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: utils.c:33
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
unsigned int BOOL
Definition: ntddk_ex.h:94
_Check_return_ _CRTIMP FILE *__cdecl _wfsopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode, _In_ int _ShFlag)
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define TVI_LAST
Definition: commctrl.h:3370
#define TVINSERTSTRUCT
Definition: commctrl.h:3402
#define TVI_ROOT
Definition: commctrl.h:3368
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define _SH_DENYWR
Definition: share.h:15
static const size_t MSConfigTokLen
Definition: systempage.cpp:29
static LPCWSTR szMSConfigTok
Definition: systempage.cpp:28
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CommonWndProc().

◆ SystemPageWndProc()

INT_PTR CALLBACK SystemPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 868 of file systempage.cpp.

869{
870 static LPCWSTR lpszIniFile = NULL;
871
872 if (message == WM_INITDIALOG)
873 lpszIniFile = (LPCWSTR)((LPPROPSHEETPAGE)lParam)->lParam;
874
875 if ( (message == WM_NOTIFY) && (((LPNMHDR)lParam)->code == PSN_APPLY) )
876 wParam = (WPARAM)lpszIniFile;
877
878 return CommonWndProc(hDlg, message, wParam, lParam);
879}
INT_PTR CommonWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: systempage.cpp:484
UINT_PTR WPARAM
Definition: windef.h:207
struct tagNMHDR * LPNMHDR

Referenced by CreatePropSheet(), InitializeTabCtrl(), and OnCreate().

◆ ToLower()

static void ToLower ( LPWSTR  lpszString)
static

Definition at line 59 of file systempage.cpp.

60{
61 if (!lpszString)
62 return;
63
64 while (*lpszString)
65 {
66 *lpszString = towlower(*lpszString);
67 ++lpszString;
68 }
69}
#define towlower(c)
Definition: wctype.h:97

Referenced by FindDialogWndProc().

◆ TreeView_SetBOOLCheck()

static void TreeView_SetBOOLCheck ( HWND  hTree,
HTREEITEM  htiItem,
BOOL  bState,
BOOL  bPropagateStateToParent 
)
static

Definition at line 170 of file systempage.cpp.

171{
172 if (!hTree || !htiItem)
173 return;
174
175 TreeView_SetCheckState(hTree, htiItem, bState);
176
177 /*
178 * Add or remove the token for tree leaves only.
179 */
180 if (!TreeView_GetChild(hTree, htiItem))
181 {
182 /* 1- Retrieve properties */
183 TVITEMEXW tvItemEx;
184 SecureZeroMemory(&tvItemEx, sizeof(tvItemEx));
185
186 tvItemEx.hItem = htiItem; // Handle of the item to be retrieved.
187 tvItemEx.mask = TVIF_HANDLE | TVIF_TEXT;
189 tvItemEx.pszText = label;
190 tvItemEx.cchTextMax = MAX_VALUE_NAME;
191 TreeView_GetItem(hTree, &tvItemEx);
192
193 if (!bState)
194 {
195 /* 2- Add the token IF NEEDED */
196 if ((wcslen(tvItemEx.pszText) < MSConfigTokLen) || (_wcsnicmp(tvItemEx.pszText, szMSConfigTok, MSConfigTokLen) != 0))
197 {
198 LPWSTR newLabel = (LPWSTR)MemAlloc(0, (_tcslen(tvItemEx.pszText) + MSConfigTokLen + 1) * sizeof(WCHAR));
199 wcscpy(newLabel, szMSConfigTok);
200 wcscat(newLabel, tvItemEx.pszText);
201 tvItemEx.pszText = newLabel;
202
203 TreeView_SetItem(hTree, &tvItemEx);
204
205 MemFree(newLabel);
206 }
207 }
208 else
209 {
210 /* 2- Remove the token IF NEEDED */
211 if ((wcslen(tvItemEx.pszText) >= MSConfigTokLen) && (_wcsnicmp(tvItemEx.pszText, szMSConfigTok, MSConfigTokLen) == 0))
212 {
213 LPWSTR newLabel = (LPWSTR)MemAlloc(0, (_tcslen(tvItemEx.pszText) - MSConfigTokLen + 1) * sizeof(WCHAR));
214 wcscpy(newLabel, tvItemEx.pszText + MSConfigTokLen);
215 tvItemEx.pszText = newLabel;
216
217 TreeView_SetItem(hTree, &tvItemEx);
218
219 // TODO: if one finds tvItemEx.pszText == L"", one can
220 // directly remove the item (cf. message TVN_ENDLABELEDIT).
221
222 MemFree(newLabel);
223 }
224 }
225 }
227
228 for (HTREEITEM htiIterator = TreeView_GetChild(hTree, htiItem) ; htiIterator ; htiIterator = TreeView_GetNextSibling(hTree, htiIterator))
229 TreeView_SetBOOLCheck(hTree, htiIterator, bState, FALSE);
230
231 if (bPropagateStateToParent)
233
234 return;
235}
void TreeView_PropagateStateOfItemToParent(HWND hTree, HTREEITEM htiItem)
Definition: treeview.c:135
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3466
#define TreeView_SetCheckState(hwndTV, hti, fCheck)
Definition: commctrl.h:3593
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define _tcslen
Definition: xmlstorage.h:198

Referenced by CommonWndProc(), LoadIniFile(), and TreeView_SetBOOLCheck().

◆ Update_Btn_States()

static void Update_Btn_States ( HWND  hDlg)
static

Definition at line 392 of file systempage.cpp.

393{
395
399
400 //
401 // "Up" / "Down" buttons.
402 //
403 if (htiPrev)
405 else
407
408 if (htiNext)
410 else
412
413 //
414 // "Enable" / "Disable" buttons.
415 //
416 UINT uCheckState = TreeView_GetCheckState(hTree, hti);
417 if (uCheckState == 0)
418 {
421 }
422 else if (uCheckState == 1)
423 {
426 }
427 else if (uCheckState == 2)
428 {
431 }
432 else
433 {
436 }
437
438 //
439 // "Enable all" / "Disable all" buttons.
440 //
442 if (uRootCheckState == 0)
443 {
446 }
447 else if (uRootCheckState == 1)
448 {
451 }
452 else if (uRootCheckState == 2)
453 {
456 }
457 else
458 {
461 }
462
463 //
464 // "Search" / "Edit" / "Delete" buttons.
465 //
467 {
471 }
472 else
473 {
477 }
478
479 return;
480}
UINT TreeView_GetRealSubtreeState(HWND hTree, HTREEITEM htiSubtreeItem)
Definition: treeview.c:111
#define TreeView_GetPrevSibling(hwnd, hitem)
Definition: commctrl.h:3468
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by CommonWndProc().

◆ WinPageWndProc()

INT_PTR CALLBACK WinPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 882 of file systempage.cpp.

883{
884 static LPCWSTR lpszIniFile = NULL;
885
886 if (message == WM_INITDIALOG)
887 lpszIniFile = (LPCWSTR)((LPPROPSHEETPAGE)lParam)->lParam;
888
889 if ( (message == WM_NOTIFY) && (((LPNMHDR)lParam)->code == PSN_APPLY) )
890 wParam = (WPARAM)lpszIniFile;
891
892 return CommonWndProc(hDlg, message, wParam, lParam);
893}

Referenced by CreatePropSheet().

◆ WriteIniFile()

static void WriteIniFile ( HWND  hTree,
LPCWSTR  lpszIniFile 
)
static

Definition at line 343 of file systempage.cpp.

344{
345 // Ouverture en écriture (avec création de fichier si celui-ci n'esistait pas déjà)
346 // d'un flux en mode texte, avec permission de lecture seule.
347#if 0
348 DWORD dwNumOfChars = ExpandEnvironmentStringsW(lpszIniFile, NULL, 0);
349 LPWSTR lpszFileName = MemAlloc(0, dwNumOfChars * sizeof(WCHAR));
350 ExpandEnvironmentStringsW(lpszIniFile, lpszFileName, dwNumOfChars);
351#else
352 // HACK: delete these following lines when the program will be ready.
353 DWORD dwNumOfChars = ExpandEnvironmentStringsW(lpszIniFile, NULL, 0) + 11;
354 LPWSTR lpszFileName = (LPWSTR)MemAlloc(0, dwNumOfChars * sizeof(WCHAR));
355 ExpandEnvironmentStringsW(lpszIniFile, lpszFileName, dwNumOfChars);
356 wcscat(lpszFileName, L"__tests.ini");
357 // END HACK.
358#endif
359
360 FILE* ini_file = _wfsopen(lpszFileName, L"wt", _SH_DENYRW); // w+t <-- write read text ; wt <-- write text
361 MemFree(lpszFileName);
362
363 if (!ini_file)
364 return; // error
365
366
367 TVITEMEXW tvItemEx;
369 // WCHAR szLine[MAX_VALUE_NAME] = L"";
370
371 // for (HTREEITEM htiIterator = TreeView_GetRoot(hTree) ; htiIterator ; htiIterator = TreeView_GetNextSibling(hTree, htiIterator))
372 for (HTREEITEM htiIterator = TreeView_GetFirst(hTree) ; htiIterator ; htiIterator = TreeView_GetNext(hTree, htiIterator))
373 {
374 SecureZeroMemory(&tvItemEx, sizeof(tvItemEx));
375
376 tvItemEx.hItem = htiIterator; // Handle of the item to be retrieved.
377 tvItemEx.mask = TVIF_HANDLE | TVIF_TEXT;
378 tvItemEx.pszText = label;
379 tvItemEx.cchTextMax = MAX_VALUE_NAME;
380 TreeView_GetItem(hTree, &tvItemEx);
381
382 // Write into the file.
383 wcscat(label, L"\n");
384 fputws(label, ini_file);
385 }
386
387 fclose(ini_file);
388 return;
389}
_Check_return_opt_ _CRTIMP int __cdecl fputws(_In_z_ const wchar_t *_Str, _Inout_ FILE *_File)
#define _SH_DENYRW
Definition: share.h:14

Referenced by CommonWndProc().

Variable Documentation

◆ bCaseSensitive

BOOL bCaseSensitive = FALSE
static

◆ bMatchExactText

BOOL bMatchExactText = FALSE
static

Definition at line 54 of file systempage.cpp.

Referenced by FindDialogWndProc().

◆ bSearchSense

BOOL bSearchSense = TRUE
static

Definition at line 55 of file systempage.cpp.

Referenced by FindDialogWndProc().

◆ hTree

◆ lpszSystemIni

LPCWSTR lpszSystemIni = L"%SystemRoot%\\system.ini"

Definition at line 23 of file systempage.cpp.

Referenced by CreatePropSheet().

◆ lpszWinIni

LPCWSTR lpszWinIni = L"%SystemRoot%\\win.ini"

Definition at line 24 of file systempage.cpp.

Referenced by CreatePropSheet().

◆ MSConfigTokLen

const size_t MSConfigTokLen = 10
static

Definition at line 29 of file systempage.cpp.

Referenced by LoadIniFile(), and TreeView_SetBOOLCheck().

◆ szMSConfigTok

LPCWSTR szMSConfigTok = L";msconfig "
static

Definition at line 28 of file systempage.cpp.

Referenced by LoadIniFile(), and TreeView_SetBOOLCheck().

◆ szSearchString

WCHAR szSearchString[MAX_VALUE_NAME] = L""
static

Definition at line 53 of file systempage.cpp.

Referenced by FindDialogWndProc().