aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-07-06 19:43:10 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-07-06 21:30:49 +1000
commit171b886bc5652da63b5ed549c755aa3fa3337eab (patch)
tree1524df15d393acd1c3a70f77906717c2da7d99a9
parent219964095a1f4678d8c8e7ae2685c52392161ca2 (diff)
downloadwix-171b886bc5652da63b5ed549c755aa3fa3337eab.tar.gz
wix-171b886bc5652da63b5ed549c755aa3fa3337eab.tar.bz2
wix-171b886bc5652da63b5ed549c755aa3fa3337eab.zip
Split up ThemeDefWindowProc so that the right message handling code is shared with PanelWndProc.
-rw-r--r--src/dutil/thmutil.cpp235
1 files changed, 132 insertions, 103 deletions
diff --git a/src/dutil/thmutil.cpp b/src/dutil/thmutil.cpp
index 75b0e4a0..6025749e 100644
--- a/src/dutil/thmutil.cpp
+++ b/src/dutil/thmutil.cpp
@@ -334,6 +334,13 @@ static void GetControlDimensions(
334static HRESULT SizeListViewColumns( 334static HRESULT SizeListViewColumns(
335 __inout THEME_CONTROL* pControl 335 __inout THEME_CONTROL* pControl
336 ); 336 );
337static LRESULT CALLBACK ControlGroupDefWindowProc(
338 __in_opt THEME* pTheme,
339 __in HWND hWnd,
340 __in UINT uMsg,
341 __in WPARAM wParam,
342 __in LPARAM lParam
343 );
337static LRESULT CALLBACK PanelWndProc( 344static LRESULT CALLBACK PanelWndProc(
338 __in HWND hWnd, 345 __in HWND hWnd,
339 __in UINT uMsg, 346 __in UINT uMsg,
@@ -860,7 +867,14 @@ extern "C" LRESULT CALLBACK ThemeDefWindowProc(
860 switch (uMsg) 867 switch (uMsg)
861 { 868 {
862 case WM_NCCREATE: 869 case WM_NCCREATE:
863 OnNcCreate(pTheme, hWnd, lParam); 870 if (pTheme->hwndParent)
871 {
872 AssertSz(FALSE, "WM_NCCREATE called multiple times");
873 }
874 else
875 {
876 OnNcCreate(pTheme, hWnd, lParam);
877 }
864 break; 878 break;
865 879
866 case WM_NCHITTEST: 880 case WM_NCHITTEST:
@@ -877,41 +891,6 @@ extern "C" LRESULT CALLBACK ThemeDefWindowProc(
877 } 891 }
878 break; 892 break;
879 893
880 case WM_DRAWITEM:
881 ThemeDrawControl(pTheme, reinterpret_cast<LPDRAWITEMSTRUCT>(lParam));
882 return TRUE;
883
884 case WM_CTLCOLORBTN: __fallthrough;
885 case WM_CTLCOLORSTATIC:
886 {
887 HBRUSH hBrush = NULL;
888 if (ThemeSetControlColor(pTheme, reinterpret_cast<HDC>(wParam), reinterpret_cast<HWND>(lParam), &hBrush))
889 {
890 return reinterpret_cast<LRESULT>(hBrush);
891 }
892 }
893 break;
894
895 case WM_SETCURSOR:
896 if (ThemeHoverControl(pTheme, hWnd, reinterpret_cast<HWND>(wParam)))
897 {
898 return TRUE;
899 }
900 break;
901
902 case WM_PAINT:
903 if (::GetUpdateRect(hWnd, NULL, FALSE))
904 {
905 PAINTSTRUCT ps;
906 ::BeginPaint(hWnd, &ps);
907 if (hWnd == pTheme->hwndParent)
908 {
909 ThemeDrawBackground(pTheme, &ps);
910 }
911 ::EndPaint(hWnd, &ps);
912 }
913 return 0;
914
915 case WM_SIZING: 894 case WM_SIZING:
916 if (pTheme->fAutoResize) 895 if (pTheme->fAutoResize)
917 { 896 {
@@ -952,70 +931,10 @@ extern "C" LRESULT CALLBACK ThemeDefWindowProc(
952 return 0; 931 return 0;
953 } 932 }
954 break; 933 break;
955
956 case WM_TIMER:
957 OnBillboardTimer(pTheme, hWnd, wParam);
958 break;
959
960 case WM_NOTIFY:
961 if (lParam)
962 {
963 LPNMHDR pnmhdr = reinterpret_cast<LPNMHDR>(lParam);
964 switch (pnmhdr->code)
965 {
966 // Tab/Shift+Tab support for rich-edit control.
967 case EN_MSGFILTER:
968 {
969 MSGFILTER* msgFilter = reinterpret_cast<MSGFILTER*>(lParam);
970 if (WM_KEYDOWN == msgFilter->msg && VK_TAB == msgFilter->wParam)
971 {
972 BOOL fShift = 0x8000 & ::GetKeyState(VK_SHIFT);
973 HWND hwndFocus = ::GetNextDlgTabItem(hWnd, msgFilter->nmhdr.hwndFrom, fShift);
974 ::SetFocus(hwndFocus);
975 return 1;
976 }
977 break;
978 }
979
980 // Hyperlink clicks from rich-edit control.
981 case EN_LINK:
982 return SUCCEEDED(OnRichEditEnLink(lParam, pnmhdr->hwndFrom, hWnd));
983
984 // Clicks on a hypertext/syslink control.
985 case NM_CLICK: __fallthrough;
986 case NM_RETURN:
987 if (ControlIsType(pTheme, static_cast<DWORD>(pnmhdr->idFrom), THEME_CONTROL_TYPE_HYPERTEXT))
988 {
989 PNMLINK pnmlink = reinterpret_cast<PNMLINK>(lParam);
990 LITEM litem = pnmlink->item;
991 ShelExec(litem.szUrl, NULL, L"open", NULL, SW_SHOWDEFAULT, hWnd, NULL);
992 return 1;
993 }
994
995 return 0;
996 }
997 }
998 break;
999
1000 case WM_COMMAND:
1001 switch (HIWORD(wParam))
1002 {
1003 case BN_CLICKED:
1004 if (lParam)
1005 {
1006 const THEME_CONTROL* pControl = FindControlFromHWnd(pTheme, (HWND)lParam);
1007 if (pControl && OnButtonClicked(pTheme, hWnd, pControl))
1008 {
1009 return 0;
1010 }
1011 }
1012 break;
1013 }
1014 break;
1015 } 934 }
1016 } 935 }
1017 936
1018 return ::DefWindowProcW(hWnd, uMsg, wParam, lParam); 937 return ControlGroupDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam);
1019} 938}
1020 939
1021 940
@@ -4846,6 +4765,119 @@ LExit:
4846} 4765}
4847 4766
4848 4767
4768static LRESULT CALLBACK ControlGroupDefWindowProc(
4769 __in_opt THEME* pTheme,
4770 __in HWND hWnd,
4771 __in UINT uMsg,
4772 __in WPARAM wParam,
4773 __in LPARAM lParam
4774 )
4775{
4776 if (pTheme)
4777 {
4778 switch (uMsg)
4779 {
4780 case WM_DRAWITEM:
4781 ThemeDrawControl(pTheme, reinterpret_cast<LPDRAWITEMSTRUCT>(lParam));
4782 return TRUE;
4783
4784 case WM_CTLCOLORBTN: __fallthrough;
4785 case WM_CTLCOLORSTATIC:
4786 {
4787 HBRUSH hBrush = NULL;
4788 if (ThemeSetControlColor(pTheme, reinterpret_cast<HDC>(wParam), reinterpret_cast<HWND>(lParam), &hBrush))
4789 {
4790 return reinterpret_cast<LRESULT>(hBrush);
4791 }
4792 }
4793 break;
4794
4795 case WM_SETCURSOR:
4796 if (ThemeHoverControl(pTheme, hWnd, reinterpret_cast<HWND>(wParam)))
4797 {
4798 return TRUE;
4799 }
4800 break;
4801
4802 case WM_PAINT:
4803 if (::GetUpdateRect(hWnd, NULL, FALSE))
4804 {
4805 PAINTSTRUCT ps;
4806 ::BeginPaint(hWnd, &ps);
4807 if (hWnd == pTheme->hwndParent)
4808 {
4809 ThemeDrawBackground(pTheme, &ps);
4810 }
4811 ::EndPaint(hWnd, &ps);
4812 }
4813 return 0;
4814
4815 case WM_TIMER:
4816 OnBillboardTimer(pTheme, hWnd, wParam);
4817 break;
4818
4819 case WM_NOTIFY:
4820 if (lParam)
4821 {
4822 LPNMHDR pnmhdr = reinterpret_cast<LPNMHDR>(lParam);
4823 switch (pnmhdr->code)
4824 {
4825 // Tab/Shift+Tab support for rich-edit control.
4826 case EN_MSGFILTER:
4827 {
4828 MSGFILTER* msgFilter = reinterpret_cast<MSGFILTER*>(lParam);
4829 if (WM_KEYDOWN == msgFilter->msg && VK_TAB == msgFilter->wParam)
4830 {
4831 BOOL fShift = 0x8000 & ::GetKeyState(VK_SHIFT);
4832 HWND hwndFocus = ::GetNextDlgTabItem(hWnd, msgFilter->nmhdr.hwndFrom, fShift);
4833 ::SetFocus(hwndFocus);
4834 return 1;
4835 }
4836 break;
4837 }
4838
4839 // Hyperlink clicks from rich-edit control.
4840 case EN_LINK:
4841 return SUCCEEDED(OnRichEditEnLink(lParam, pnmhdr->hwndFrom, hWnd));
4842
4843 // Clicks on a hypertext/syslink control.
4844 case NM_CLICK: __fallthrough;
4845 case NM_RETURN:
4846 if (ControlIsType(pTheme, static_cast<DWORD>(pnmhdr->idFrom), THEME_CONTROL_TYPE_HYPERTEXT))
4847 {
4848 PNMLINK pnmlink = reinterpret_cast<PNMLINK>(lParam);
4849 LITEM litem = pnmlink->item;
4850 ShelExec(litem.szUrl, NULL, L"open", NULL, SW_SHOWDEFAULT, hWnd, NULL);
4851 return 1;
4852 }
4853
4854 return 0;
4855 }
4856 }
4857 break;
4858
4859 case WM_COMMAND:
4860 switch (HIWORD(wParam))
4861 {
4862 case BN_CLICKED:
4863 if (lParam)
4864 {
4865 const THEME_CONTROL* pControl = FindControlFromHWnd(pTheme, (HWND)lParam);
4866 if (pControl && OnButtonClicked(pTheme, hWnd, pControl))
4867 {
4868 return 0;
4869 }
4870 }
4871 break;
4872 }
4873 break;
4874 }
4875 }
4876
4877 return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
4878}
4879
4880
4849static LRESULT CALLBACK PanelWndProc( 4881static LRESULT CALLBACK PanelWndProc(
4850 __in HWND hWnd, 4882 __in HWND hWnd,
4851 __in UINT uMsg, 4883 __in UINT uMsg,
@@ -4861,7 +4893,8 @@ static LRESULT CALLBACK PanelWndProc(
4861 case WM_NCCREATE: 4893 case WM_NCCREATE:
4862 { 4894 {
4863 LPCREATESTRUCTW lpcs = reinterpret_cast<LPCREATESTRUCTW>(lParam); 4895 LPCREATESTRUCTW lpcs = reinterpret_cast<LPCREATESTRUCTW>(lParam);
4864 ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(lpcs->lpCreateParams)); 4896 pTheme = reinterpret_cast<THEME*>(lpcs->lpCreateParams);
4897 ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pTheme));
4865 } 4898 }
4866 break; 4899 break;
4867 4900
@@ -4873,13 +4906,9 @@ static LRESULT CALLBACK PanelWndProc(
4873 case WM_NCHITTEST: 4906 case WM_NCHITTEST:
4874 return HTCLIENT; 4907 return HTCLIENT;
4875 break; 4908 break;
4876
4877 case WM_DRAWITEM:
4878 ThemeDrawControl(pTheme, reinterpret_cast<LPDRAWITEMSTRUCT>(lParam));
4879 return TRUE;
4880 } 4909 }
4881 4910
4882 return ThemeDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam); 4911 return ControlGroupDefWindowProc(pTheme, hWnd, uMsg, wParam, lParam);
4883} 4912}
4884 4913
4885 4914