This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 6/6] Use a splitbutton to show the view choosing popup menu
Pass WM_NOTIFY notifications for child controls of the property page through
to OnMessageCommand as well.
Future-proof RootPage::OnMessageCmd() to check the notification code.
Give IDC_CHOOSE_VIEW button the BS_SPLITBUTTON style, and handle the
BCN_DROPDOWN notification from that to show the view choosing menu.
---
choose.cc | 34 +++++++++++++++++++---------------
proppage.cc | 10 +++++++---
res.rc | 6 +++---
root.cc | 3 +++
4 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/choose.cc b/choose.cc
index 19c1fc9..ecfd5f1 100644
--- a/choose.cc
+++ b/choose.cc
@@ -385,17 +385,18 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
Log (LOG_BABBLE) << "OnMesageCmd " << id << " " << hwndctl << " " << code << endLog;
#endif
- if (code == EN_CHANGE && id == IDC_CHOOSE_SEARCH_EDIT)
+ if (code == EN_CHANGE)
{
- SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL);
- return true;
- }
- else if (code != BN_CLICKED && code != EN_CHANGE)
- {
- // Not a click notification, we don't care.
- return false;
+ if (id == IDC_CHOOSE_SEARCH_EDIT)
+ {
+ SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL);
+ return true;
+ }
+ else
+ return false;
}
-
+ else if (code == BN_CLICKED)
+ {
switch (id)
{
case IDC_CHOOSE_CLEAR_SEARCH:
@@ -422,10 +423,6 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
changeTrust (TRUST_TEST);
break;
- case IDC_CHOOSE_VIEW:
- selectView();
- break;
-
case IDC_CHOOSE_HIDE:
chooser->setObsolete (!IsButtonChecked (id));
break;
@@ -433,9 +430,16 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
// Wasn't recognized or handled.
return false;
}
-
- // Was handled since we never got to default above.
return true;
+ }
+ else if (code == BCN_DROPDOWN)
+ {
+ if (id == IDC_CHOOSE_VIEW)
+ selectView();
+ }
+
+ // we don't care.
+ return false;
}
static void
diff --git a/proppage.cc b/proppage.cc
index c03e5f7..31f439f 100644
--- a/proppage.cc
+++ b/proppage.cc
@@ -139,7 +139,9 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
}
case WM_NOTIFY:
- switch (((NMHDR FAR *) lParam)->code)
+ {
+ NMHDR *pNmHdr = (NMHDR *) lParam;
+ switch (pNmHdr->code)
{
case PSN_APPLY:
{
@@ -256,10 +258,12 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam)
}
default:
{
- // Unrecognized notification
- return FALSE;
+ // Pass unrecognized notifications to WM_COMMAND handler
+ return OnMessageCmd (pNmHdr->idFrom, pNmHdr->hwndFrom,
+ pNmHdr->code);
}
}
+ }
break;
case WM_COMMAND:
{
diff --git a/res.rc b/res.rc
index 0d124a6..2cdacfb 100644
--- a/res.rc
+++ b/res.rc
@@ -318,8 +318,8 @@ END
// Left-aligned controls.
#define SETUP_VIEW_X (7)
-#define SETUP_VIEW_W (26)
-#define SETUP_SEARCH_X (SETUP_VIEW_X + SETUP_VIEW_W + 125)
+#define SETUP_VIEW_W (33)
+#define SETUP_SEARCH_X (SETUP_VIEW_X + SETUP_VIEW_W + 2)
#define SETUP_SEARCH_W (32)
#define SETUP_SEARCHTEXT_X (SETUP_SEARCH_X + SETUP_SEARCH_W + 2)
#define SETUP_SEARCHTEXT_W (60)
@@ -333,7 +333,7 @@ CAPTION "Cygwin Setup - Select Packages"
FONT 8, "MS Shell Dlg"
BEGIN
PUSHBUTTON "&View", IDC_CHOOSE_VIEW, SETUP_VIEW_X, 30, SETUP_VIEW_W,
- 14, WS_EX_RIGHT
+ 14, BS_SPLITBUTTON
RTEXT "&Search", IDC_STATIC, SETUP_SEARCH_X, 33, SETUP_SEARCH_W,
10, SS_CENTERIMAGE, WS_EX_RIGHT
EDITTEXT IDC_CHOOSE_SEARCH_EDIT, SETUP_SEARCHTEXT_X, 30,
diff --git a/root.cc b/root.cc
index edf7a91..80f3162 100644
--- a/root.cc
+++ b/root.cc
@@ -227,6 +227,9 @@ directory_contains_wrong_version (HWND h)
bool
RootPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
{
+ if ((code != BN_CLICKED) && (code != EN_CHANGE))
+ return false;
+
switch (id)
{
--
2.8.3