diff options
author | George Hazan <george.hazan@gmail.com> | 2012-05-30 18:48:40 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-05-30 18:48:40 +0000 |
commit | c9816719b87cb6115cd2480c8d2d7c6410acf37e (patch) | |
tree | 1f4063d40084a4dff01ebd3e39bcf7b03a70015f /protocols/Weather/weather_popup.cpp | |
parent | 4540036e07fce39b653bbb2777df48f451368e67 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@242 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Weather/weather_popup.cpp')
-rw-r--r-- | protocols/Weather/weather_popup.cpp | 459 |
1 files changed, 225 insertions, 234 deletions
diff --git a/protocols/Weather/weather_popup.cpp b/protocols/Weather/weather_popup.cpp index 6e55f7ad14..88133f8a2d 100644 --- a/protocols/Weather/weather_popup.cpp +++ b/protocols/Weather/weather_popup.cpp @@ -131,23 +131,22 @@ LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa HANDLE hContact;
hContact = PUGetContact(hWnd);
- switch(message)
- {
- case WM_COMMAND:
- ID = opt.LeftClickAction;
- if (ID != IDM_M7) PUDeletePopUp(hWnd);
- SendMessage(hPopupWindow, ID, (WPARAM)hContact, 0);
- return TRUE;
-
- case WM_CONTEXTMENU:
- ID = opt.RightClickAction;
- if (ID != IDM_M7) PUDeletePopUp(hWnd);
- SendMessage(hPopupWindow, ID, (WPARAM)hContact, 0);
- return TRUE;
-
- case UM_FREEPLUGINDATA:
- CallService(MS_SKIN2_RELEASEICON, (WPARAM)PUGetPluginData(hWnd), 0);
- return FALSE;
+ switch(message) {
+ case WM_COMMAND:
+ ID = opt.LeftClickAction;
+ if (ID != IDM_M7) PUDeletePopUp(hWnd);
+ SendMessage(hPopupWindow, ID, (WPARAM)hContact, 0);
+ return TRUE;
+
+ case WM_CONTEXTMENU:
+ ID = opt.RightClickAction;
+ if (ID != IDM_M7) PUDeletePopUp(hWnd);
+ SendMessage(hPopupWindow, ID, (WPARAM)hContact, 0);
+ return TRUE;
+
+ case UM_FREEPLUGINDATA:
+ CallService(MS_SKIN2_RELEASEICON, (WPARAM)PUGetPluginData(hWnd), 0);
+ return FALSE;
}
return DefWindowProc(hWnd, message, wParam, lParam);
@@ -159,49 +158,48 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam {
POINT pt;
HMENU hMenu;
- switch (uMsg)
- {
- case IDM_M2: // brief info
- BriefInfo(wParam, 0);
- break;
-
- case IDM_M3: // read complete forecast
- LoadForecast(wParam, 0);
- break;
-
- case IDM_M4: // display weather map
- WeatherMap(wParam, 0);
+ switch (uMsg) {
+ case IDM_M2: // brief info
+ BriefInfo(wParam, 0);
+ break;
+
+ case IDM_M3: // read complete forecast
+ LoadForecast(wParam, 0);
+ break;
+
+ case IDM_M4: // display weather map
+ WeatherMap(wParam, 0);
+ break;
+
+ case IDM_M5: // open history window
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, wParam, 0);
+ break;
+
+ case IDM_M6: // open external log
+ ViewLog(wParam, 0);
+ break;
+
+ case IDM_M7: // display contact menu
+ hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,wParam,0);
+ GetCursorPos(&pt);
+ hPopupContact = (HANDLE)wParam;
+ TrackPopupMenu(hMenu,TPM_LEFTALIGN,pt.x,pt.y,0,hWnd,NULL);
+ DestroyMenu(hMenu);
+ break;
+
+ case IDM_M8: // display contact detail
+ CallService(MS_USERINFO_SHOWDIALOG, wParam, 0);
+
+ case WM_COMMAND: //Needed by the contact's context menu
+ if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)hPopupContact))
break;
+ return FALSE;
- case IDM_M5: // open history window
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, wParam, 0);
- break;
-
- case IDM_M6: // open external log
- ViewLog(wParam, 0);
- break;
-
- case IDM_M7: // display contact menu
- hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,wParam,0);
- GetCursorPos(&pt);
- hPopupContact = (HANDLE)wParam;
- TrackPopupMenu(hMenu,TPM_LEFTALIGN,pt.x,pt.y,0,hWnd,NULL);
- DestroyMenu(hMenu);
- break;
-
- case IDM_M8: // display contact detail
- CallService(MS_USERINFO_SHOWDIALOG, wParam, 0);
-
- case WM_COMMAND: //Needed by the contact's context menu
- if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)hPopupContact))
- break;
- return FALSE;
+ case WM_MEASUREITEM: //Needed by the contact's context menu
+ return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam);
- case WM_MEASUREITEM: //Needed by the contact's context menu
- return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam);
-
- case WM_DRAWITEM: //Needed by the contact's context menu
- return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam);
+ case WM_DRAWITEM: //Needed by the contact's context menu
+ return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);//FALSE;
@@ -209,6 +207,13 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam //============ POPUP OPTIONS ============
+// used to select the menu item for popup action menu
+static void SelectMenuItem(HMENU hMenu, int Check)
+{
+ for (int i=0; i <= GetMenuItemCount(hMenu)-1; i++)
+ CheckMenuItem(hMenu, i, MF_BYPOSITION|((int)GetMenuItemID(hMenu, i) == Check)*8);
+}
+
// temporary read the current option to memory
// but does not write to the database
void ReadPopupOpt(HWND hdlg)
@@ -253,194 +258,180 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) HWND button;
HANDLE hContact;
- switch (msg)
- {
- case WM_INITDIALOG:
- TranslateDialogDefault(hdlg);
- SaveOptions();
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+ SaveOptions();
+
+ // click actions
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
+ GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
+ DestroyMenu(hMenu);
+
+ // other options
+ CheckDlgButton(hdlg, IDC_E, opt.UsePopup);
+ CheckDlgButton(hdlg, IDC_POP2, opt.AlertPopup);
+ CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup);
+ CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange);
+ CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings);
+ SetDlgItemText(hdlg,IDC_PText, opt.pText);
+ SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
+ // setting popup delay option
+ _ltot(opt.pDelay, str, 10);
+ SetDlgItemText(hdlg,IDC_DELAY, str);
+ if (opt.pDelay == -1)
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
+ else if (opt.pDelay == 0)
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
+ else
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
+ //Colours. First step is configuring the colours.
+ SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_SETCOLOUR,0,opt.BGColour);
+ SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_SETCOLOUR,0,opt.TextColour);
+ //Second step is disabling them if we want to use default Windows ones.
+ CheckDlgButton(hdlg, IDC_USEWINCOLORS,opt.UseWinColors?BST_CHECKED:BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !opt.UseWinColors);
+ EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !opt.UseWinColors);
+
+ // buttons
+ SendMessage(GetDlgItem(hdlg,IDC_PREVIEW), BUTTONSETASFLATBTN, 0, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_PDEF), BUTTONSETASFLATBTN, 0, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_LeftClick), BUTTONSETASFLATBTN, 0, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_RightClick), BUTTONSETASFLATBTN, 0, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_VAR3), BUTTONSETASFLATBTN, 0, 0);
+ return TRUE;
+
+ case WM_COMMAND:
+ // enable the "apply" button
+ if (HIWORD(wParam)==BN_CLICKED && GetFocus()==(HWND)lParam)
+ SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ if (!((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) &&
+ (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())))
+ SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ //These are simple clicks: we don't save, but we tell the Options Page to enable the "Apply" button.
+ switch(LOWORD(wParam)) {
+ case IDC_BGCOLOUR: //Fall through
+ case IDC_TEXTCOLOUR:
+ // select new colors
+ if (HIWORD(wParam) == CPN_COLOURCHANGED)
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_USEWINCOLORS:
+ // use window color - enable/disable color selection controls
+ EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !(opt.UseWinColors));
+ EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !(opt.UseWinColors));
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_E:
+ case IDC_CH:
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_RightClick:
+ // right click action selection menu
+ button = GetDlgItem(hdlg, IDC_RightClick);
+ GetWindowRect(button, &pos);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu1, 0);
+ SelectMenuItem(hMenu1, opt.RightClickAction);
+ ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
+ if (ID) opt.RightClickAction = ID;
+ DestroyMenu(hMenu);
- // click actions
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
- GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
DestroyMenu(hMenu);
+ break;
+
+ case IDC_LeftClick:
+ // left click action selection menu
+ button = GetDlgItem(hdlg, IDC_LeftClick);
+ GetWindowRect(button, &pos);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu1, 0);
+ SelectMenuItem(hMenu1, opt.LeftClickAction);
+ ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
+ if (ID) opt.LeftClickAction = ID;
+ DestroyMenu(hMenu);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
+ DestroyMenu(hMenu);
+ break;
+
+ case IDC_PD1:
+ // Popup delay setting from PopUp plugin
+ SetDlgItemText(hdlg, IDC_DELAY, _T("0"));
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
+ break;
- // other options
- CheckDlgButton(hdlg, IDC_E, opt.UsePopup);
- CheckDlgButton(hdlg, IDC_POP2, opt.AlertPopup);
- CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup);
- CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange);
- CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings);
+ case IDC_PD2:
+ // Popup delay = permanent
+ SetDlgItemText(hdlg, IDC_DELAY, _T("-1"));
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
+ break;
+
+ case IDC_DELAY:
+ // if text is edited
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
+ break;
+
+ case IDC_PDEF:
+ // set the default value for popup texts
+ SetTextDefault("Pp");
SetDlgItemText(hdlg,IDC_PText, opt.pText);
SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
- // setting popup delay option
- _ltot(opt.pDelay, str, 10);
- SetDlgItemText(hdlg,IDC_DELAY, str);
- if (opt.pDelay == -1)
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
- else if (opt.pDelay == 0)
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
- else
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
- //Colours. First step is configuring the colours.
- SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_SETCOLOUR,0,opt.BGColour);
- SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_SETCOLOUR,0,opt.TextColour);
- //Second step is disabling them if we want to use default Windows ones.
- CheckDlgButton(hdlg, IDC_USEWINCOLORS,opt.UseWinColors?BST_CHECKED:BST_UNCHECKED);
- EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !opt.UseWinColors);
- EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !opt.UseWinColors);
-
- // buttons
- SendMessage(GetDlgItem(hdlg,IDC_PREVIEW), BUTTONSETASFLATBTN, 0, 0);
- SendMessage(GetDlgItem(hdlg,IDC_PDEF), BUTTONSETASFLATBTN, 0, 0);
- SendMessage(GetDlgItem(hdlg,IDC_LeftClick), BUTTONSETASFLATBTN, 0, 0);
- SendMessage(GetDlgItem(hdlg,IDC_RightClick), BUTTONSETASFLATBTN, 0, 0);
- SendMessage(GetDlgItem(hdlg,IDC_VAR3), BUTTONSETASFLATBTN, 0, 0);
-
- return TRUE;
-
- case WM_COMMAND:
- // enable the "apply" button
- if (HIWORD(wParam)==BN_CLICKED && GetFocus()==(HWND)lParam)
- SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
- if (!((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) &&
- (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())))
- SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
- //These are simple clicks: we don't save, but we tell the Options Page to enable the "Apply" button.
- switch(LOWORD(wParam))
- {
- case IDC_BGCOLOUR: //Fall through
- case IDC_TEXTCOLOUR:
- // select new colors
- if (HIWORD(wParam) == CPN_COLOURCHANGED)
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_USEWINCOLORS:
- // use window color - enable/disable color selection controls
- EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !(opt.UseWinColors));
- EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !(opt.UseWinColors));
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_E:
- case IDC_CH:
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_RightClick:
- // right click action selection menu
- button = GetDlgItem(hdlg, IDC_RightClick);
- GetWindowRect(button, &pos);
-
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
- hMenu1 = GetSubMenu(hMenu, 0);
- CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu1, 0);
- SelectMenuItem(hMenu1, opt.RightClickAction);
- ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
- if (ID) opt.RightClickAction = ID;
- DestroyMenu(hMenu);
-
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
- hMenu1 = GetSubMenu(hMenu, 0);
- GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
- DestroyMenu(hMenu);
- break;
-
- case IDC_LeftClick:
- // left click action selection menu
- button = GetDlgItem(hdlg, IDC_LeftClick);
- GetWindowRect(button, &pos);
-
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
- hMenu1 = GetSubMenu(hMenu, 0);
- CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu1, 0);
- SelectMenuItem(hMenu1, opt.LeftClickAction);
- ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
- if (ID) opt.LeftClickAction = ID;
- DestroyMenu(hMenu);
-
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
- hMenu1 = GetSubMenu(hMenu, 0);
- GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
- DestroyMenu(hMenu);
- break;
-
- case IDC_PD1:
- // Popup delay setting from PopUp plugin
- SetDlgItemText(hdlg, IDC_DELAY, _T("0"));
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
- break;
-
- case IDC_PD2:
- // Popup delay = permanent
- SetDlgItemText(hdlg, IDC_DELAY, _T("-1"));
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
- break;
-
- case IDC_DELAY:
- // if text is edited
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
- break;
-
- case IDC_PDEF:
- // set the default value for popup texts
- SetTextDefault("Pp");
- SetDlgItemText(hdlg,IDC_PText, opt.pText);
- SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
- wfree(&opt.pText);
- wfree(&opt.pTitle);
- break;
-
- case IDC_VAR3:
- // display variable list
- _tcscpy(str, _T(" \n")); // to make the message box wider
- _tcscat(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
- _tcscat(str, _T("\n"));
- _tcscat(str, TranslateT("%[..]\tcustom variables"));
- MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
- break;
-
- case IDC_PREVIEW:
- // popup preview
- hContact = opt.DefStn;
- ReadPopupOpt(hdlg); // read new options to memory
- WeatherPopup((WPARAM)opt.DefStn, (BOOL)TRUE); // display popup using new opt
- DestroyOptions();
- LoadOptions(); // restore old option in memory
- opt.DefStn = hContact;
- break;
- }
+ wfree(&opt.pText);
+ wfree(&opt.pTitle);
break;
- //End WM_COMMAND
- case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- ReadPopupOpt(hdlg);
-
- // save the options, and update main menu
- SaveOptions();
- UpdatePopupMenu(opt.UsePopup);
- return TRUE;
- }
- }
+
+ case IDC_VAR3:
+ // display variable list
+ _tcscpy(str, _T(" \n")); // to make the message box wider
+ _tcscat(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
+ _tcscat(str, _T("\n"));
+ _tcscat(str, TranslateT("%[..]\tcustom variables"));
+ MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
+ break;
+
+ case IDC_PREVIEW:
+ // popup preview
+ hContact = opt.DefStn;
+ ReadPopupOpt(hdlg); // read new options to memory
+ WeatherPopup((WPARAM)opt.DefStn, (BOOL)TRUE); // display popup using new opt
+ DestroyOptions();
+ LoadOptions(); // restore old option in memory
+ opt.DefStn = hContact;
break;
+ }
+ break;
+
+ case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY: {
+ ReadPopupOpt(hdlg);
+
+ // save the options, and update main menu
+ SaveOptions();
+ UpdatePopupMenu(opt.UsePopup);
+ return TRUE;
+ }
+ }
+ break;
}
return FALSE;
}
-
-// used to select the menu item for popup action menu
-void SelectMenuItem(HMENU hMenu, int Check)
-{
- int i;
- for (i=0; i<=GetMenuItemCount(hMenu)-1; i++)
- CheckMenuItem(hMenu, i, MF_BYPOSITION|((int)GetMenuItemID(hMenu, i) == Check)*8);
-}
-
|