} key2code_t;
typedef struct {
- WORD idc; // IDC for posting message
- CHAR key; // Virtual key identifier
- BYTE mask; // enable/disable into the various modes.
- INT col; // color used for drawing the text
+ WORD idc; // IDC for posting message
+ CHAR key; // Virtual key identifier
+ BYTE mask; // enable/disable into the various modes.
+ COLORREF col; // color used for drawing the text
} key3code_t;
#define CTRL_FLAG 0x100
{ IDC_BUTTON_DAT, 0, 1, run_dat_sta, NULL, NULL, NULL, },
{ IDC_BUTTON_MP, MODIFIER_INV, 1, run_mp, run_mm, NULL, NULL, },
{ IDC_BUTTON_MS, MODIFIER_INV, 1, run_ms, run_mw, NULL, NULL, },
- { IDC_BUTTON_CANC, 0, 0, run_canc, NULL, NULL, NULL, },
- { IDC_BUTTON_RIGHTPAR, 0, 1, run_rpar, NULL, NULL, NULL, },
- { IDC_BUTTON_LEFTPAR, 0, 0, run_lpar, NULL, NULL, NULL, },
+ { IDC_BUTTON_CANC, NO_CHAIN, 0, run_canc, NULL, NULL, NULL, },
+ { IDC_BUTTON_RIGHTPAR, NO_CHAIN, 1, run_rpar, NULL, NULL, NULL, },
+ { IDC_BUTTON_LEFTPAR, NO_CHAIN, 0, run_lpar, NULL, NULL, NULL, },
};
/*
{
TCHAR buf[32];
DWORD tmp;
+#if _WIN32_WINNT >= 0x0500
+ HKEY hKey;
+#endif
/* Try to load last selected layout */
GetProfileString(TEXT("SciCalc"), TEXT("layout"), TEXT("0"), buf, SIZEOF(buf));
/* memory is empty at startup */
calc.is_memory = FALSE;
+#if _WIN32_WINNT >= 0x0500
+ /* empty these values */
+ calc.sDecimal[0] = TEXT('\0');
+ calc.sThousand[0] = TEXT('\0');
+
+ /* try to open the registry */
+ if (RegOpenKeyEx(HKEY_CURRENT_USER,
+ TEXT("Control Panel\\International"),
+ 0,
+ KEY_QUERY_VALUE,
+ &hKey) == ERROR_SUCCESS) {
+ /* get these values (ignore errors) */
+ tmp = sizeof(calc.sDecimal);
+ RegQueryValueEx(hKey, TEXT("sDecimal"), NULL, NULL, (LPBYTE)calc.sDecimal, &tmp);
+
+ tmp = sizeof(calc.sThousand);
+ RegQueryValueEx(hKey, TEXT("sThousand"), NULL, NULL, (LPBYTE)calc.sThousand, &tmp);
+
+ /* close the key */
+ RegCloseKey(hKey);
+ }
+ /* if something goes wrong, let's apply the defaults */
+ if (calc.sDecimal[0] == TEXT('\0'))
+ _tcscpy(calc.sDecimal, TEXT("."));
+
+ if (calc.sThousand[0] == TEXT('\0'))
+ _tcscpy(calc.sThousand, TEXT(","));
+
+ /* get the string lengths */
+ calc.sDecimal_len = _tcslen(calc.sDecimal);
+ calc.sThousand_len = _tcslen(calc.sThousand);
+#else
/* acquire regional settings */
calc.sDecimal_len = GetProfileString(TEXT("intl"), TEXT("sDecimal"), TEXT("."), calc.sDecimal, SIZEOF(calc.sDecimal));
calc.sThousand_len = GetProfileString(TEXT("intl"), TEXT("sThousand"), TEXT(","), calc.sThousand, SIZEOF(calc.sThousand));
+#endif
}
static void save_config(void)
return 1;
if (!_tcscmp(ClassName, TEXT("Button"))) {
- DWORD dwStyle = GetWindowLong(hCtlWnd, GWL_STYLE) & 0xF;
+ DWORD dwStyle = GetWindowLongPtr(hCtlWnd, GWL_STYLE) & 0xF;
/* Set states for press/release, but only for push buttons */
if (dwStyle == BS_PUSHBUTTON || dwStyle == BS_DEFPUSHBUTTON || dwStyle == BS_OWNERDRAW) {
return str;
}
-static LRESULT CALLBACK DlgStatProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+static INT_PTR CALLBACK DlgStatProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
TCHAR buffer[SIZEOF(calc.buffer)];
DWORD n;
popup.rcMargins.bottom = -1;
popup.rcMargins.left = -1;
popup.rcMargins.right = -1;
- popup.idString = GetWindowLong((HWND)wp, GWL_ID);
+ popup.idString = GetWindowLongPtr((HWND)wp, GWL_ID);
HtmlHelp((HWND)wp, HTMLHELP_PATH("/popups.txt"), HH_DISPLAY_TEXT_POPUP, (DWORD_PTR)&popup);
}
#endif
return 1L;
}
-static LRESULT CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
unsigned int x;
RECT rc;
if (x == RPN_OPERATOR_EQUAL) {
exec_infix2postfix(&calc.code, calc.prev_operator);
rpn_copy(&calc.code, &calc.prev);
- }
+ } else
+ break;
}
/* if no change then quit silently, */
convert_text2number(&calc.code);
cb(&calc.code);
display_rpn_result(hWnd, &calc.code);
+ if (!(function_table[x].range & NO_CHAIN))
+ exec_infix2postfix(&calc.code, RPN_OPERATOR_NONE);
if (function_table[x].range & MODIFIER_INV)
SendDlgItemMessage(hWnd, IDC_CHECK_INV, BM_SETCHECK, 0, 0);
if (function_table[x].range & MODIFIER_HYP)