3
3
* Main window
4
4
*
5
5
* Copyright (C) 2009-2016 wj32
6
+ * Copyright (C) 2017 dmex
6
7
*
7
8
* This file is part of Process Hacker.
8
9
*
@@ -99,6 +100,7 @@ BOOLEAN PhMainWndInitialization(
99
100
_In_ INT ShowCommand
100
101
)
101
102
{
103
+ RTL_ATOM windowAtom ;
102
104
PH_STRING_BUILDER stringBuilder ;
103
105
PH_RECTANGLE windowRectangle ;
104
106
@@ -118,7 +120,7 @@ BOOLEAN PhMainWndInitialization(
118
120
119
121
PhMwpInitializeProviders ();
120
122
121
- if (! PhMwpInitializeWindowClass ())
123
+ if (( windowAtom = PhMwpInitializeWindowClass ()) == INVALID_ATOM )
122
124
return FALSE;
123
125
124
126
windowRectangle .Position = PhGetIntegerPairSetting (L"MainWindowPosition" );
@@ -127,23 +129,27 @@ BOOLEAN PhMainWndInitialization(
127
129
// Create the window title.
128
130
129
131
PhInitializeStringBuilder (& stringBuilder , 100 );
130
- PhAppendStringBuilder2 (& stringBuilder , L"Process Hacker" );
131
132
132
- if (PhCurrentUserName )
133
+ if (PhGetIntegerSetting ( L"EnableWindowText" ) )
133
134
{
134
- PhAppendStringBuilder2 (& stringBuilder , L" [" );
135
- PhAppendStringBuilder (& stringBuilder , & PhCurrentUserName -> sr );
136
- PhAppendCharStringBuilder (& stringBuilder , ']' );
137
- if (KphIsConnected ()) PhAppendCharStringBuilder (& stringBuilder , '+' );
138
- }
135
+ PhAppendStringBuilder2 (& stringBuilder , L"Process Hacker" );
136
+
137
+ if (PhCurrentUserName )
138
+ {
139
+ PhAppendStringBuilder2 (& stringBuilder , L" [" );
140
+ PhAppendStringBuilder (& stringBuilder , & PhCurrentUserName -> sr );
141
+ PhAppendCharStringBuilder (& stringBuilder , ']' );
142
+ if (KphIsConnected ()) PhAppendCharStringBuilder (& stringBuilder , '+' );
143
+ }
139
144
140
- if (WINDOWS_HAS_UAC && PhGetOwnTokenAttributes ().ElevationType == TokenElevationTypeFull )
141
- PhAppendStringBuilder2 (& stringBuilder , L" (Administrator)" );
145
+ if (WINDOWS_HAS_UAC && PhGetOwnTokenAttributes ().ElevationType == TokenElevationTypeFull )
146
+ PhAppendStringBuilder2 (& stringBuilder , L" (Administrator)" );
147
+ }
142
148
143
149
// Create the window.
144
150
145
151
PhMainWndHandle = CreateWindow (
146
- PH_MAINWND_CLASSNAME ,
152
+ MAKEINTATOM ( windowAtom ) ,
147
153
stringBuilder .String -> Buffer ,
148
154
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN ,
149
155
windowRectangle .Left ,
@@ -329,30 +335,28 @@ LRESULT CALLBACK PhMwpWndProc(
329
335
return DefWindowProc (hWnd , uMsg , wParam , lParam );
330
336
}
331
337
332
- BOOLEAN PhMwpInitializeWindowClass (
338
+ RTL_ATOM PhMwpInitializeWindowClass (
333
339
VOID
334
340
)
335
341
{
336
342
WNDCLASSEX wcex ;
337
-
343
+ PPH_STRING className ;
344
+
338
345
memset (& wcex , 0 , sizeof (WNDCLASSEX ));
339
346
wcex .cbSize = sizeof (WNDCLASSEX );
340
347
wcex .style = 0 ;
341
348
wcex .lpfnWndProc = PhMwpWndProc ;
342
349
wcex .cbClsExtra = 0 ;
343
350
wcex .cbWndExtra = 0 ;
344
351
wcex .hInstance = PhInstanceHandle ;
345
- wcex .hIcon = PH_LOAD_SHARED_ICON_LARGE (PhLibImageBase , MAKEINTRESOURCE (IDI_PROCESSHACKER ));
346
- wcex .hCursor = LoadCursor (NULL , IDC_ARROW );
347
- //wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
352
+ className = PhaGetStringSetting (L"MainWindowClassName" );
353
+ wcex .lpszClassName = PhGetStringOrDefault (className , L"MainWindowClassName" );
348
354
wcex .lpszMenuName = MAKEINTRESOURCE (IDR_MAINWND );
349
- wcex .lpszClassName = PH_MAINWND_CLASSNAME ;
355
+ wcex .hCursor = LoadCursor (NULL , IDC_ARROW );
356
+ wcex .hIcon = PH_LOAD_SHARED_ICON_LARGE (PhLibImageBase , MAKEINTRESOURCE (IDI_PROCESSHACKER ));
350
357
wcex .hIconSm = PH_LOAD_SHARED_ICON_SMALL (PhLibImageBase , MAKEINTRESOURCE (IDI_PROCESSHACKER ));
351
358
352
- if (!RegisterClassEx (& wcex ))
353
- return FALSE;
354
-
355
- return TRUE;
359
+ return RegisterClassEx (& wcex );
356
360
}
357
361
358
362
VOID PhMwpInitializeProviders (
@@ -425,7 +429,7 @@ VOID PhMwpInitializeControls(
425
429
3 ,
426
430
3 ,
427
431
PhMainWndHandle ,
428
- ( HMENU ) ID_MAINWND_PROCESSTL ,
432
+ NULL ,
429
433
PhLibImageBase ,
430
434
NULL
431
435
);
@@ -440,7 +444,7 @@ VOID PhMwpInitializeControls(
440
444
3 ,
441
445
3 ,
442
446
PhMainWndHandle ,
443
- ( HMENU ) ID_MAINWND_SERVICETL ,
447
+ NULL ,
444
448
PhLibImageBase ,
445
449
NULL
446
450
);
@@ -455,7 +459,7 @@ VOID PhMwpInitializeControls(
455
459
3 ,
456
460
3 ,
457
461
PhMainWndHandle ,
458
- ( HMENU ) ID_MAINWND_NETWORKTL ,
462
+ NULL ,
459
463
PhLibImageBase ,
460
464
NULL
461
465
);
0 commit comments