@@ -48,10 +48,10 @@ typedef struct _EDIT_CONTEXT
48
48
INT CXBorder ;
49
49
INT ImageWidth ;
50
50
INT ImageHeight ;
51
- HWND WindowHandle ;
52
51
WNDPROC DefaultWindowProc ;
53
52
HFONT WindowFont ;
54
53
HIMAGELIST ImageListHandle ;
54
+ PPH_STRING CueBannerText ;
55
55
} EDIT_CONTEXT , * PEDIT_CONTEXT ;
56
56
57
57
HICON PhpSearchBitmapToIcon (
@@ -68,17 +68,19 @@ VOID PhpSearchFreeTheme(
68
68
}
69
69
70
70
VOID PhpSearchInitializeFont (
71
- _Inout_ PEDIT_CONTEXT Context
71
+ _Inout_ PEDIT_CONTEXT Context ,
72
+ _In_ HWND WindowHandle
72
73
)
73
74
{
74
75
if (Context -> WindowFont )
75
76
DeleteFont (Context -> WindowFont );
76
77
77
- Context -> WindowFont = PhCreateCommonFont (10 , FW_MEDIUM , Context -> WindowHandle );
78
+ Context -> WindowFont = PhCreateCommonFont (10 , FW_MEDIUM , WindowHandle );
78
79
}
79
80
80
81
VOID PhpSearchInitializeTheme (
81
- _Inout_ PEDIT_CONTEXT Context
82
+ _Inout_ PEDIT_CONTEXT Context ,
83
+ _In_ HWND WindowHandle
82
84
)
83
85
{
84
86
Context -> CXWidth = PH_SCALE_DPI (20 );
@@ -88,7 +90,7 @@ VOID PhpSearchInitializeTheme(
88
90
{
89
91
HTHEME themeDataHandle ;
90
92
91
- if (themeDataHandle = OpenThemeData (Context -> WindowHandle , VSCLASS_EDIT ))
93
+ if (themeDataHandle = OpenThemeData (WindowHandle , VSCLASS_EDIT ))
92
94
{
93
95
//IsThemePartDefined_I(themeDataHandle, EP_EDITBORDER_NOSCROLL, EPSHV_NORMAL);
94
96
@@ -167,14 +169,15 @@ VOID PhpSearchGetButtonRect(
167
169
168
170
VOID PhpSearchDrawButton (
169
171
_Inout_ PEDIT_CONTEXT Context ,
172
+ _In_ HWND WindowHandle ,
170
173
_In_ HDC Hdc ,
171
174
_In_ RECT WindowRect ,
172
175
_In_ RECT ButtonRect
173
176
)
174
177
{
175
178
if (Context -> ThemeSupport ) // HACK
176
179
{
177
- if (GetFocus () == Context -> WindowHandle )
180
+ if (GetFocus () == WindowHandle )
178
181
{
179
182
//switch (Context->ColorMode)
180
183
//{
@@ -255,7 +258,7 @@ VOID PhpSearchDrawButton(
255
258
FillRect (Hdc , & ButtonRect , GetStockBrush (DC_BRUSH ));
256
259
break ;
257
260
case 1 : // Old colors
258
- SetTextColor (Hdc , GetSysColor (COLOR_HIGHLIGHTTEXT ));
261
+ // SetTextColor(Hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
259
262
SetDCBrushColor (Hdc , RGB (99 , 99 , 99 ));
260
263
FillRect (Hdc , & ButtonRect , GetStockBrush (DC_BRUSH ));
261
264
break ;
@@ -279,7 +282,7 @@ VOID PhpSearchDrawButton(
279
282
FillRect (Hdc , & ButtonRect , GetStockBrush (DC_BRUSH ));
280
283
break ;
281
284
case 1 : // Old colors
282
- SetTextColor (Hdc , GetSysColor (COLOR_HIGHLIGHTTEXT ));
285
+ // SetTextColor(Hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
283
286
SetDCBrushColor (Hdc , RGB (78 , 78 , 78 ));
284
287
FillRect (Hdc , & ButtonRect , GetStockBrush (DC_BRUSH ));
285
288
break ;
@@ -302,7 +305,7 @@ VOID PhpSearchDrawButton(
302
305
FillRect (Hdc , & ButtonRect , GetSysColorBrush (COLOR_WINDOW ));
303
306
break ;
304
307
case 1 : // Old colors
305
- SetTextColor (Hdc , GetSysColor (COLOR_HIGHLIGHTTEXT ));
308
+ // SetTextColor(Hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
306
309
SetDCBrushColor (Hdc , RGB (60 , 60 , 60 ));
307
310
FillRect (Hdc , & ButtonRect , GetStockBrush (DC_BRUSH ));
308
311
break ;
@@ -315,7 +318,7 @@ VOID PhpSearchDrawButton(
315
318
}
316
319
}
317
320
318
- if (Edit_GetTextLength (Context -> WindowHandle ) > 0 )
321
+ if (Edit_GetTextLength (WindowHandle ) > 0 )
319
322
{
320
323
PhImageListDrawIcon (
321
324
Context -> ImageListHandle ,
@@ -372,6 +375,12 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
372
375
context -> ImageListHandle = NULL ;
373
376
}
374
377
378
+ if (context -> CueBannerText )
379
+ {
380
+ PhDereferenceObject (context -> CueBannerText );
381
+ context -> CueBannerText = NULL ;
382
+ }
383
+
375
384
SetWindowLongPtr (hWnd , GWLP_WNDPROC , (LONG_PTR )oldWndProc );
376
385
PhRemoveWindowContext (hWnd , SHRT_MAX );
377
386
PhFree (context );
@@ -451,11 +460,12 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
451
460
{
452
461
if (context -> ThemeSupport )
453
462
{
454
- FrameRect (bufferDc , & windowRect , GetSysColorBrush (COLOR_WINDOWFRAME ));
463
+ SetDCBrushColor (bufferDc , RGB (0x8f , 0x8f , 0x8f ));
464
+ FrameRect (bufferDc , & windowRect , GetStockBrush (DC_BRUSH ));
455
465
}
456
466
else
457
467
{
458
- SetDCBrushColor (bufferDc , RGB (0 , 0 , 0 )); // RGB(65, 65, 65)
468
+ SetDCBrushColor (bufferDc , RGB (43 , 43 , 43 ));
459
469
FrameRect (bufferDc , & windowRect , GetStockBrush (DC_BRUSH ));
460
470
}
461
471
@@ -466,8 +476,8 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
466
476
{
467
477
if (context -> ThemeSupport )
468
478
{
469
- SetDCBrushColor (bufferDc , RGB (0 , 0 , 0 )); // RGB(65, 65, 65)
470
- FrameRect (bufferDc , & windowRect , GetStockBrush ( DC_BRUSH ));
479
+ // SetDCBrushColor(bufferDc, RGB(43, 43, 43 ));
480
+ FrameRect (bufferDc , & windowRect , GetSysColorBrush ( COLOR_WINDOWFRAME ));
471
481
}
472
482
else
473
483
{
@@ -479,7 +489,7 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
479
489
}
480
490
481
491
// Draw the button.
482
- PhpSearchDrawButton (context , bufferDc , windowRect , buttonRect );
492
+ PhpSearchDrawButton (context , hWnd , bufferDc , windowRect , buttonRect );
483
493
484
494
BitBlt (hdc , bufferRect .left , bufferRect .top , bufferRect .right , bufferRect .bottom , bufferDc , 0 , 0 , SRCCOPY );
485
495
SelectBitmap (bufferDc , oldBufferBitmap );
@@ -586,8 +596,8 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
586
596
case WM_THEMECHANGED :
587
597
{
588
598
PhpSearchFreeTheme (context );
589
- PhpSearchInitializeTheme (context );
590
- PhpSearchInitializeFont (context );
599
+ PhpSearchInitializeTheme (context , hWnd );
600
+ PhpSearchInitializeFont (context , hWnd );
591
601
592
602
// Reset the client area margins.
593
603
SendMessage (hWnd , EM_SETMARGINS , EC_LEFTMARGIN , MAKELPARAM (0 , 0 ));
@@ -663,6 +673,73 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
663
673
RedrawWindow (hWnd , NULL , NULL , RDW_FRAME | RDW_INVALIDATE );
664
674
}
665
675
break ;
676
+ case WM_PAINT :
677
+ {
678
+ if (
679
+ PhIsNullOrEmptyString (context -> CueBannerText ) ||
680
+ GetFocus () == hWnd ||
681
+ Edit_GetTextLength (hWnd ) > 0
682
+ )
683
+ {
684
+ return CallWindowProc (oldWndProc , hWnd , uMsg , wParam , lParam );
685
+ }
686
+
687
+ HDC hdc = (HDC )wParam ? (HDC )wParam : GetDC (hWnd );
688
+
689
+ if (hdc )
690
+ {
691
+ HDC bufferDc ;
692
+ RECT clientRect ;
693
+ HFONT oldFont ;
694
+ HBITMAP bufferBitmap ;
695
+ HBITMAP oldBufferBitmap ;
696
+
697
+ GetClientRect (hWnd , & clientRect );
698
+
699
+ bufferDc = CreateCompatibleDC (hdc );
700
+ bufferBitmap = CreateCompatibleBitmap (hdc , clientRect .right , clientRect .bottom );
701
+ oldBufferBitmap = SelectBitmap (bufferDc , bufferBitmap );
702
+
703
+ SetBkMode (bufferDc , TRANSPARENT );
704
+
705
+ if (context -> ThemeSupport )
706
+ {
707
+ SetTextColor (bufferDc , RGB (170 , 170 , 170 ));
708
+ SetDCBrushColor (bufferDc , RGB (60 , 60 , 60 ));
709
+ FillRect (bufferDc , & clientRect , GetStockBrush (DC_BRUSH ));
710
+ }
711
+ else
712
+ {
713
+ SetTextColor (bufferDc , GetSysColor (COLOR_GRAYTEXT ));
714
+ FillRect (bufferDc , & clientRect , GetSysColorBrush (COLOR_WINDOW ));
715
+ }
716
+
717
+ oldFont = SelectFont (bufferDc , GetWindowFont (hWnd ));
718
+ clientRect .left += 2 ;
719
+ DrawText (
720
+ bufferDc ,
721
+ context -> CueBannerText -> Buffer ,
722
+ (UINT )context -> CueBannerText -> Length / 2 ,
723
+ & clientRect ,
724
+ DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP
725
+ );
726
+ clientRect .left -= 2 ;
727
+ SelectFont (bufferDc , oldFont );
728
+
729
+ BitBlt (hdc , clientRect .left , clientRect .top , clientRect .right , clientRect .bottom , bufferDc , 0 , 0 , SRCCOPY );
730
+ SelectBitmap (bufferDc , oldBufferBitmap );
731
+ DeleteBitmap (bufferBitmap );
732
+ DeleteDC (bufferDc );
733
+
734
+ if (!(HDC )wParam )
735
+ {
736
+ ReleaseDC (hWnd , hdc );
737
+ }
738
+ }
739
+
740
+ return DefWindowProc (hWnd , uMsg , wParam , lParam );
741
+ }
742
+ break ;
666
743
}
667
744
668
745
return CallWindowProc (oldWndProc , hWnd , uMsg , wParam , lParam );
@@ -703,7 +780,6 @@ VOID PhCreateSearchControl(
703
780
PEDIT_CONTEXT context ;
704
781
705
782
context = PhAllocateZero (sizeof (EDIT_CONTEXT ));
706
- context -> WindowHandle = WindowHandle ;
707
783
context -> ThemeSupport = !!PhGetIntegerSetting (L"EnableThemeSupport" ); // HACK
708
784
context -> ColorMode = PhGetIntegerSetting (L"GraphColorMode" );
709
785
@@ -712,7 +788,7 @@ VOID PhCreateSearchControl(
712
788
713
789
// Set initial text
714
790
if (BannerText )
715
- Edit_SetCueBannerText ( WindowHandle , BannerText );
791
+ context -> CueBannerText = PhCreateString ( BannerText );
716
792
717
793
// Subclass the Edit control window procedure.
718
794
context -> DefaultWindowProc = (WNDPROC )GetWindowLongPtr (WindowHandle , GWLP_WNDPROC );
0 commit comments