From 6b8387b849cfcc7229b7b85ec24ae24670858641 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 20 Aug 2022 21:49:30 -0400 Subject: fix compile errors on linux, probably --- src/input.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/input.cpp b/src/input.cpp index c1dcd536..592d5e50 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1271,6 +1271,7 @@ static void RamSearchOpNE(void) { } extern int globalCheatDisabled; +extern unsigned int FrozenAddressCount; static void ToggleCheats() { FCEUI_GlobalToggleCheat(globalCheatDisabled); -- cgit v1.2.3 From 319b365787926a031d6e429d2b1299e85ff0f625 Mon Sep 17 00:00:00 2001 From: harry Date: Sun, 21 Aug 2022 14:57:03 -0400 Subject: Cheats config improvements for Qt GUI. Added global cheat enable/disable hotkey functionality. Added code to raise and set focus on cheat dialog when attempting to open it when it is already opened. Add code to update/refresh cheat dialog when loading a new ROM. --- src/drivers/Qt/CheatsConf.cpp | 29 ++++++++++++++++++++++++++++- src/drivers/Qt/CheatsConf.h | 1 + src/drivers/Qt/ConsoleWindow.cpp | 15 +++++++++++++++ src/drivers/Qt/ConsoleWindow.h | 1 + src/drivers/Qt/config.cpp | 3 +++ src/drivers/Qt/config.h | 2 +- src/drivers/Qt/fceuWrapper.cpp | 3 +++ 7 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp index d995700d..79cc3c60 100644 --- a/src/drivers/Qt/CheatsConf.cpp +++ b/src/drivers/Qt/CheatsConf.cpp @@ -52,6 +52,9 @@ void openCheatDialog(QWidget *parent) { if (win != NULL) { + win->activateWindow(); + win->raise(); + win->setFocus(); return; } win = new GuiCheatsDialog_t(parent); @@ -198,6 +201,18 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) vbox1->addLayout(hbox); + hbox = new QHBoxLayout(); + lbl = new QLabel(tr("Type:")); + typeEntry = new QComboBox(); + typeEntry->addItem(tr("0: Periodic Set (Every Frame)"), 0 ); + typeEntry->addItem(tr("1: Substitute/Freeze"), 1 ); + typeEntry->setCurrentIndex(1); + + hbox->addWidget(lbl,1); + hbox->addWidget(typeEntry,10); + + vbox1->addLayout(hbox); + hbox = new QHBoxLayout(); addCheatBtn = new QPushButton(tr("Add")); @@ -435,6 +450,8 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) setLayout(mainLayout); + modCheatBtn->setDefault(true); + connect(srchResetBtn, SIGNAL(clicked(void)), this, SLOT(resetSearchCallback(void))); connect(knownValBtn, SIGNAL(clicked(void)), this, SLOT(knownValueCallback(void))); connect(eqValBtn, SIGNAL(clicked(void)), this, SLOT(equalValueCallback(void))); @@ -719,6 +736,8 @@ void GuiCheatsDialog_t::showActiveCheatList(bool redraw) { win = this; + enaCheats->setChecked(!globalCheatDisabled); + actvCheatRedraw = redraw; if (redraw) @@ -871,6 +890,7 @@ void GuiCheatsDialog_t::addActvCheat(void) uint32 a = 0; uint8 v = 0; int c = -1; + int t = 1; std::string name, cmpStr; a = strtoul(cheatAddrEntry->displayText().toStdString().c_str(), NULL, 16); @@ -890,8 +910,10 @@ void GuiCheatsDialog_t::addActvCheat(void) name = cheatNameEntry->text().toStdString(); + t = typeEntry->currentData().toInt(); + FCEU_WRAPPER_LOCK(); - FCEUI_AddCheat(name.c_str(), a, v, c, 1); + FCEUI_AddCheat(name.c_str(), a, v, c, t); FCEU_WRAPPER_UNLOCK(); showActiveCheatList(true); @@ -921,6 +943,7 @@ void GuiCheatsDialog_t::deleteActvCheat(void) cheatAddrEntry->setText(tr("")); cheatValEntry->setText(tr("")); cheatCmpEntry->setText(tr("")); + typeEntry->setCurrentIndex(0); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::updateCheatParameters(void) @@ -969,6 +992,8 @@ void GuiCheatsDialog_t::updateCheatParameters(void) //printf("Name: %s \n", name.c_str() ); + type = typeEntry->currentData().toInt(); + FCEU_WRAPPER_LOCK(); FCEUI_SetCheat(row, &name, a, v, c, s, type); @@ -1022,6 +1047,8 @@ void GuiCheatsDialog_t::actvCheatItemClicked(QTreeWidgetItem *item, int column) } cheatNameEntry->setText(tr(name.c_str())); + + typeEntry->setCurrentIndex(type); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::globalEnableCheats(int state) diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h index c06e9f75..4eab63a9 100644 --- a/src/drivers/Qt/CheatsConf.h +++ b/src/drivers/Qt/CheatsConf.h @@ -67,6 +67,7 @@ protected: QLineEdit *neValEntry; QLineEdit *grValEntry; QLineEdit *ltValEntry; + QComboBox *typeEntry; QFont font; int fontCharWidth; diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 9332dac4..23e4bf40 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -862,6 +862,7 @@ void consoleWin_t::initHotKeys(void) connect( Hotkeys[ HK_TOGGLE_BG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleBackground(void)) ); connect( Hotkeys[ HK_TOGGLE_FG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleForeground(void)) ); connect( Hotkeys[ HK_FKB_ENABLE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleFamKeyBrdEnable(void)) ); + connect( Hotkeys[ HK_TOGGLE_ALL_CHEATS ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleGlobalCheatEnable(void)) ); connect( Hotkeys[ HK_SAVE_STATE_0 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState0(void)) ); connect( Hotkeys[ HK_SAVE_STATE_1 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState1(void)) ); @@ -3173,6 +3174,20 @@ void consoleWin_t::toggleFamKeyBrdEnable(void) toggleFamilyKeyboardFunc(); } +extern int globalCheatDisabled; + +void consoleWin_t::toggleGlobalCheatEnable(void) +{ + FCEU_WRAPPER_LOCK(); + FCEUI_GlobalToggleCheat(globalCheatDisabled); + FCEU_WRAPPER_UNLOCK(); + + g_config->setOption("SDL.CheatsDisabled", globalCheatDisabled); + g_config->save(); + + updateCheatDialog(); +} + void consoleWin_t::warnAmbiguousShortcut( QShortcut *shortcut) { char stmp[256]; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 4586e06b..d4451965 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -415,6 +415,7 @@ class consoleWin_t : public QMainWindow void toggleBackground(void); void toggleForeground(void); void toggleFamKeyBrdEnable(void); + void toggleGlobalCheatEnable(void); void saveState0(void); void saveState1(void); void saveState2(void); diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 386571ee..25442b96 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -83,6 +83,9 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut, const case HK_CHEAT_MENU: name = "CheatMenu"; keySeq = ""; title = "Open Cheat Window"; group = "Tools"; break; + case HK_TOGGLE_ALL_CHEATS: + name = "ToggleCheats"; keySeq = ""; title = "Toggle Global Cheat Enable"; group = "Tools"; + break; case HK_BIND_STATE: name = "BindState"; keySeq = ""; title = "Bind Save State to Movie"; group = "Movie"; break; diff --git a/src/drivers/Qt/config.h b/src/drivers/Qt/config.h index 0bb68e78..d719f12d 100644 --- a/src/drivers/Qt/config.h +++ b/src/drivers/Qt/config.h @@ -53,7 +53,7 @@ enum HOTKEY { // Display HK_TOGGLE_FG, HK_TOGGLE_BG, HK_TOGGLE_INPUT_DISPLAY, HK_LAG_COUNTER_DISPLAY, - HK_CHEAT_MENU, HK_LOAD_LUA, + HK_CHEAT_MENU, HK_TOGGLE_ALL_CHEATS, HK_LOAD_LUA, HK_MUTE_CAPTURE, HK_FA_LAG_SKIP, HK_VOLUME_DOWN, HK_VOLUME_UP, diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 8c5ef9e7..12790b69 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -39,6 +39,7 @@ #include "Qt/unix-netplay.h" #include "Qt/AviRecord.h" #include "Qt/HexEditor.h" +#include "Qt/CheatsConf.h" #include "Qt/SymbolicDebug.h" #include "Qt/CodeDataLogger.h" #include "Qt/ConsoleDebugger.h" @@ -352,6 +353,8 @@ int LoadGame(const char *path, bool silent) debugSymbolTable.loadGameSymbols(); + updateCheatDialog(); + CDLoggerROMChanged(); int state_to_load; -- cgit v1.2.3 From 26c3919358d1fd20b1b14b544e0ff0169347acb7 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 21 Aug 2022 15:06:03 -0400 Subject: winport: tidy edit control sanitization --- src/drivers/win/window.cpp | 361 +++++++++++++++++++++++---------------------- src/drivers/win/window.h | 16 +- 2 files changed, 191 insertions(+), 186 deletions(-) diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index d2ba531e..72e03fa9 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -3283,72 +3283,129 @@ POINT CalcSubWindowPos(HWND hDlg, POINT* conf) return pt; } -LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) +bool IsInputLegal(bool (*IsLetterLegal)(char letter), char letter) { - bool through = true; - INT_PTR result = 0; + return !IsLetterLegal || letter == VK_BACK || GetKeyState(VK_CONTROL) & 0x8000 || IsLetterLegal(letter); +} - switch (msg) - { - case WM_PASTE: - { +bool IsLetterLegalGG(char letter) +{ + char ch = toupper(letter); + for (int i = 0; GameGenieLetters[i]; ++i) + if (GameGenieLetters[i] == ch) + return true; + return false; +} - bool (*IsLetterLegal)(char) = GetIsLetterLegal(GetDlgCtrlID(hwnd)); +bool IsLetterLegalHex(char letter) +{ + return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f'; +} - if (IsLetterLegal) - { - if (OpenClipboard(hwnd)) - { - HANDLE handle = GetClipboardData(CF_TEXT); - if (handle) - { +bool IsLetterLegalMemwatchAddress(char letter) +{ + //accept normal hex stuff + if(letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f') + return true; + + //accept prefixes + if(letter == 'x' || letter == 'X' || letter == '!') + return true; - // get the original clipboard string - char* clipStr = (char*)GlobalLock(handle); + return false; +} - // check if the text in clipboard has illegal characters - int len = strlen(clipStr); - for (int i = 0; i < len; ++i) - { - if (!IsLetterLegal(clipStr[i])) - { - through = false; - // Show Edit control tip, just like the control with ES_NUMBER do - ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal); - break; - } - } - GlobalUnlock(handle); - CloseClipboard(); - } - } - } - } - break; - case WM_CHAR: - { - bool(*IsLetterLegal)(char) = GetIsLetterLegal(GetDlgCtrlID(hwnd)); - through = IsInputLegal(IsLetterLegal, wP); - if (!through) - ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal); - } - } +bool IsLetterLegalHexList(char letter) +{ + return IsLetterLegalHex(letter) || letter == ',' || letter == ' '; +} - return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result; +bool IsLetterLegalCheat(char letter) +{ + return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?'; +} + +bool IsLetterLegalSize(char letter) +{ + return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B'; +} + +bool IsLetterLegalDec(char letter) +{ + return letter >= '0' && letter <= '9' || letter == '-' || letter == '+'; +} + +bool IsLetterLegalFloat(char letter) +{ + return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+'; +} + +bool IsLetterLegalDecHexMixed(char letter) +{ + return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+'; +} + +bool IsLetterLegalUnsignedDecHexMixed(char letter) +{ + return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$'; +} + +wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter)) +{ + if (IsLetterLegal == &IsLetterLegalGG) + return L"You can only type Game Genie characters:\nA P Z L G I T Y E O X U K S V N"; + if (IsLetterLegal == &IsLetterLegalHex) + return L"You can only type characters for hexadecimal number (0-9,A-F)."; + if (IsLetterLegal == &IsLetterLegalHexList) + return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)"; + if (IsLetterLegal == &IsLetterLegalCheat) + return + L"The cheat code comes into the following 2 formats:\n" + "AAAA:VV freezes the value in Address $AAAA to $VV.\n" + "AAAA?CC:VV changes the value in Address $AAAA to $VV only when it's $CC.\n" + "All the characters are hexadecimal number (0-9,A-F).\n"; + if (IsLetterLegal == &IsLetterLegalFloat) + return L"You can only type decimal number (decimal point is acceptable)."; + if (IsLetterLegal == &IsLetterLegalSize) + return L"You can only type decimal number followed with B, KB or MB."; + if (IsLetterLegal == &IsLetterLegalDec) + return L"You can only type decimal number (sign character is acceptable)."; + if (IsLetterLegal == &IsLetterLegalDecHexMixed) + return + L"You can only type decimal or hexademical number\n" + "(sign character is acceptable).\n\n" + "When your number contains letter A-F,\n" + "it is regarded as hexademical number,\n" + "however, if you want to express a heademical number\n" + "but all the digits are in 0-9,\n" + "you must add a $ prefix to prevent ambiguous.\n" + "eg. 10 is a decimal number,\n" + "$10 means a hexademical number that is 16 in decimal."; + if (IsLetterLegal == &IsLetterLegalUnsignedDecHexMixed) + return + L"You can only type decimal or hexademical number.\n\n" + "When your number contains letter A-F,\n" + "it is regarded as hexademical number,\n" + "however, if you want to express a heademical number\n" + "but all the digits are in 0-9,\n" + "you must add a $ prefix to prevent ambiguous.\n" + "eg. 10 is a decimal number,\n" + "$10 means a hexademical number that is 16 in decimal."; + + return L"Your input contains invalid characters."; } // return a letter legal checking function for the specified control with the given id -bool inline (*GetIsLetterLegal(UINT id))(char letter) +IsLetterLegalProc GetIsLetterLegalProc(UINT id) { switch (id) { - // Game genie text in Cheat and Game Genie Encoder/Decoder case IDC_CHEAT_GAME_GENIE_TEXT: case IDC_GAME_GENIE_CODE: - return IsLetterLegalGG; - - // Addresses in Debugger + return &IsLetterLegalGG; + + // Addresses in Debugger case IDC_DEBUGGER_VAL_PCSEEK: case IDC_DEBUGGER_VAL_PC: case IDC_DEBUGGER_VAL_A: @@ -3356,66 +3413,123 @@ bool inline (*GetIsLetterLegal(UINT id))(char letter) case IDC_DEBUGGER_VAL_Y: case IDC_DEBUGGER_BOOKMARK: - // Debugger -> Add breakpoint + // Debugger -> Add breakpoint case IDC_ADDBP_ADDR_START: case IDC_ADDBP_ADDR_END: - // Array Size, Init value in Symbolic Name in Debugger + // Array Size, Init value in Symbolic Name in Debugger case IDC_EDIT_SYMBOLIC_ARRAY: case IDC_EDIT_SYMBOLIC_INIT: - // Address, Value, Compare, Known Value, Note equal, Greater than and Less than in Cheat + // Address, Value, Compare, Known Value, Note equal, Greater than and Less than in Cheat case IDC_CHEAT_ADDR: case IDC_CHEAT_VAL: case IDC_CHEAT_COM: case IDC_CHEAT_VAL_KNOWN: case IDC_CHEAT_VAL_NE_BY: case IDC_CHEAT_VAL_GT_BY: case IDC_CHEAT_VAL_LT_BY: - // Address, Value and Compare in Game Genie Encoder/Decoder + // Address, Value and Compare in Game Genie Encoder/Decoder case IDC_GAME_GENIE_ADDR: case IDC_GAME_GENIE_VAL: case IDC_GAME_GENIE_COMP: - // Address controls in Memory watch + // Address controls in Memory watch case MW_ADDR00: case MW_ADDR01: case MW_ADDR02: case MW_ADDR03: case MW_ADDR04: case MW_ADDR05: case MW_ADDR06: case MW_ADDR07: case MW_ADDR08: case MW_ADDR09: case MW_ADDR10: case MW_ADDR11: case MW_ADDR12: case MW_ADDR13: case MW_ADDR14: case MW_ADDR15: case MW_ADDR16: case MW_ADDR17: case MW_ADDR18: case MW_ADDR19: case MW_ADDR20: case MW_ADDR21: case MW_ADDR22: case MW_ADDR23: + return &IsLetterLegalMemwatchAddress; + case IDC_EDIT_COMPAREADDRESS: - return IsLetterLegalHex; + return &IsLetterLegalHex; - // Specific Address in RAM Search - // RAM Watch / RAM Search / Cheat -> Add watch (current only in adding watch operation) + // Specific Address in RAM Search + // RAM Watch / RAM Search / Cheat -> Add watch (current only in adding watch operation) case IDC_EDIT_COMPAREADDRESSES: - return IsLetterLegalHexList; + return &IsLetterLegalHexList; - // Size multiplier and TV Aspect in Video Config + // Size multiplier and TV Aspect in Video Config case IDC_WINSIZE_MUL_X: case IDC_WINSIZE_MUL_Y: case IDC_TVASPECT_X: case IDC_TVASPECT_Y: - return IsLetterLegalFloat; + return &IsLetterLegalFloat; - // Cheat code in Cheat + // Cheat code in Cheat case IDC_CHEAT_TEXT: - return IsLetterLegalCheat; + return &IsLetterLegalCheat; - // PRG ROM, PRG RAM, PRG NVRAM, CHR ROM, CHR RAM and CHR NVRAM in NES Header Editor + // PRG ROM, PRG RAM, PRG NVRAM, CHR ROM, CHR RAM and CHR NVRAM in NES Header Editor case IDC_PRGROM_EDIT: case IDC_PRGRAM_EDIT: case IDC_PRGNVRAM_EDIT: case IDC_CHRROM_EDIT: case IDC_CHRRAM_EDIT: case IDC_CHRNVRAM_EDIT: - return IsLetterLegalSize; + return &IsLetterLegalSize; - // Specific value, Different by and Modulo in RAM search + // Specific value, Different by and Modulo in RAM search case IDC_EDIT_COMPAREVALUE: case IDC_EDIT_DIFFBY: case IDC_EDIT_MODBY: - { - extern char rs_t; - switch (rs_t) - { - case 's': return IsLetterLegalDecHexMixed; - case 'u': return IsLetterLegalUnsignedDecHexMixed; - case 'h': return IsLetterLegalHex; + { + extern char rs_t; + switch (rs_t) + { + case 's': return &IsLetterLegalDecHexMixed; + case 'u': return &IsLetterLegalUnsignedDecHexMixed; + case 'h': return &IsLetterLegalHex; + } } - } } return NULL; } +LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) +{ + bool through = true; + INT_PTR result = 0; + + switch (msg) + { + case WM_PASTE: + { + + bool (*IsLetterLegal)(char) = GetIsLetterLegalProc(GetDlgCtrlID(hwnd)); + + if (IsLetterLegal) + { + if (OpenClipboard(hwnd)) + { + HANDLE handle = GetClipboardData(CF_TEXT); + if (handle) + { + + // get the original clipboard string + char* clipStr = (char*)GlobalLock(handle); + + // check if the text in clipboard has illegal characters + int len = strlen(clipStr); + for (int i = 0; i < len; ++i) + { + if (!IsLetterLegal(clipStr[i])) + { + through = false; + // Show Edit control tip, just like the control with ES_NUMBER do + ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal); + break; + } + } + GlobalUnlock(handle); + CloseClipboard(); + } + } + } + } + break; + + case WM_CHAR: + { + IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd)); + through = IsInputLegal(isLetterLegal, wP); + if (!through) + ShowLetterIllegalBalloonTip(hwnd, isLetterLegal); + } + } + + return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result; +} + void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter)) { wchar_t* title = L"Unacceptable Character"; @@ -3431,102 +3545,3 @@ void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter)) // make a sound MessageBeep(0xFFFFFFFF); } - -inline wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter)) -{ - if (IsLetterLegal == IsLetterLegalGG) - return L"You can only type Game Genie characters:\nA P Z L G I T Y E O X U K S V N"; - if (IsLetterLegal == IsLetterLegalHex) - return L"You can only type characters for hexadecimal number (0-9,A-F)."; - if (IsLetterLegal == IsLetterLegalHexList) - return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)"; - if (IsLetterLegal == IsLetterLegalCheat) - return - L"The cheat code comes into the following 2 formats:\n" - "AAAA:VV freezes the value in Address $AAAA to $VV.\n" - "AAAA?CC:VV changes the value in Address $AAAA to $VV only when it's $CC.\n" - "All the characters are hexadecimal number (0-9,A-F).\n"; - if (IsLetterLegal == IsLetterLegalFloat) - return L"You can only type decimal number (decimal point is acceptable)."; - if (IsLetterLegal == IsLetterLegalSize) - return L"You can only type decimal number followed with B, KB or MB."; - if (IsLetterLegal == IsLetterLegalDec) - return L"You can only type decimal number (sign character is acceptable)."; - if (IsLetterLegal == IsLetterLegalDecHexMixed) - return - L"You can only type decimal or hexademical number\n" - "(sign character is acceptable).\n\n" - "When your number contains letter A-F,\n" - "it is regarded as hexademical number,\n" - "however, if you want to express a heademical number\n" - "but all the digits are in 0-9,\n" - "you must add a $ prefix to prevent ambiguous.\n" - "eg. 10 is a decimal number,\n" - "$10 means a hexademical number that is 16 in decimal."; - if (IsLetterLegal == IsLetterLegalUnsignedDecHexMixed) - return - L"You can only type decimal or hexademical number.\n\n" - "When your number contains letter A-F,\n" - "it is regarded as hexademical number,\n" - "however, if you want to express a heademical number\n" - "but all the digits are in 0-9,\n" - "you must add a $ prefix to prevent ambiguous.\n" - "eg. 10 is a decimal number,\n" - "$10 means a hexademical number that is 16 in decimal."; - - return L"Your input contains invalid characters."; -} - -inline bool IsInputLegal(bool (*IsLetterLegal)(char letter), char letter) -{ - return !IsLetterLegal || letter == VK_BACK || GetKeyState(VK_CONTROL) & 0x8000 || IsLetterLegal(letter); -} - -inline bool IsLetterLegalGG(char letter) -{ - char ch = toupper(letter); - for (int i = 0; GameGenieLetters[i]; ++i) - if (GameGenieLetters[i] == ch) - return true; - return false; -} - -inline bool IsLetterLegalHex(char letter) -{ - return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f'; -} - -inline bool IsLetterLegalHexList(char letter) -{ - return IsLetterLegalHex(letter) || letter == ',' || letter == ' '; -} - -inline bool IsLetterLegalCheat(char letter) -{ - return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?'; -} - -inline bool IsLetterLegalSize(char letter) -{ - return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B'; -} - -inline bool IsLetterLegalDec(char letter) -{ - return letter >= '0' && letter <= '9' || letter == '-' || letter == '+'; -} - -inline bool IsLetterLegalFloat(char letter) -{ - return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+'; -} - -inline bool IsLetterLegalDecHexMixed(char letter) -{ - return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+'; -} - -inline bool IsLetterLegalUnsignedDecHexMixed(char letter) -{ - return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$'; -} diff --git a/src/drivers/win/window.h b/src/drivers/win/window.h index 0127ad97..28d10a0a 100644 --- a/src/drivers/win/window.h +++ b/src/drivers/win/window.h @@ -128,19 +128,9 @@ struct HOTKEYMENUINDEX { void UpdateMenuHotkeys(FCEUMENU_INDEX index); int GetCurrentContextIndex(); -inline bool (*GetIsLetterLegal(UINT id))(char letter); -inline wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter)); -void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter)); -inline bool IsInputLegal(bool(*IsLetterLegal)(char letter), char letter); -inline bool IsLetterLegalGG(char letter); -inline bool IsLetterLegalHex(char letter); -inline bool IsLetterLegalHexList(char letter); -inline bool IsLetterLegalCheat(char letter); -inline bool IsLetterLegalDec(char letter); -inline bool IsLetterLegalSize(char letter); -inline bool IsLetterLegalFloat(char letter); -inline bool IsLetterLegalDecHexMixed(char letter); -inline bool IsLetterLegalUnsignedDecHexMixed(char letter); +typedef bool (*IsLetterLegalProc)(char); +bool IsLetterLegalHex(char letter); +void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc); extern WNDPROC DefaultEditCtrlProc; extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT msg, WPARAM wP, LPARAM lP); -- cgit v1.2.3 From f6f13d6843c112c8c8a473bb2f589ef760ef13f1 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 21 Aug 2022 15:25:13 -0400 Subject: winport - change input filter functions to take an index so they can search for a prefix (at index 0 perhaps) and use it on the memwatch. it's better to do these things based on strings and not chars but that's just how we have it setup for now --- src/drivers/win/debuggersp.cpp | 20 +++++++------ src/drivers/win/debuggersp.h | 1 - src/drivers/win/monitor.cpp | 3 +- src/drivers/win/window.cpp | 68 ++++++++++++++++++++++-------------------- src/drivers/win/window.h | 4 +-- 5 files changed, 51 insertions(+), 45 deletions(-) diff --git a/src/drivers/win/debuggersp.cpp b/src/drivers/win/debuggersp.cpp index 1f78660f..8cf8c093 100644 --- a/src/drivers/win/debuggersp.cpp +++ b/src/drivers/win/debuggersp.cpp @@ -21,6 +21,7 @@ #include "common.h" #include "utils/xstring.h" #include "debuggersp.h" +#include "window.h" #include "../../fceu.h" #include "../../debug.h" #include "../../conddebug.h" @@ -60,6 +61,7 @@ bool symbRegNames = true; int debuggerWasActive = 0; char temp_chr[40] = {0}; char delimiterChar[2] = "#"; + INT_PTR CALLBACK nameDebuggerBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); extern WNDPROC DefaultEditCtrlProc; @@ -153,10 +155,10 @@ int parseLine(char* line, Name* n) if (llen == 5) // Offset size of normal lines of the form $XXXX { if (line[0] != '$' - || !IsLetterLegalHex(line[1]) - || !IsLetterLegalHex(line[2]) - || !IsLetterLegalHex(line[3]) - || !IsLetterLegalHex(line[4]) + || !IsLetterLegalHex(0,line[1]) + || !IsLetterLegalHex(1,line[2]) + || !IsLetterLegalHex(2,line[3]) + || !IsLetterLegalHex(3,line[4]) ) { return 4; @@ -166,10 +168,10 @@ int parseLine(char* line, Name* n) { int i; if (line[0] != '$' - || !IsLetterLegalHex(line[1]) - || !IsLetterLegalHex(line[2]) - || !IsLetterLegalHex(line[3]) - || !IsLetterLegalHex(line[4]) + || !IsLetterLegalHex(0,line[1]) + || !IsLetterLegalHex(1,line[2]) + || !IsLetterLegalHex(2,line[3]) + || !IsLetterLegalHex(3,line[4]) || line[5] != '/' ) { @@ -178,7 +180,7 @@ int parseLine(char* line, Name* n) for (i=6;line[i];i++) { - if (!IsLetterLegalHex(line[i])) + if (!IsLetterLegalHex(i,line[i])) { return 6; } diff --git a/src/drivers/win/debuggersp.h b/src/drivers/win/debuggersp.h index 01b7d907..3bd04d65 100644 --- a/src/drivers/win/debuggersp.h +++ b/src/drivers/win/debuggersp.h @@ -61,7 +61,6 @@ void DeleteAllDebuggerBookmarks(); void FillDebuggerBookmarkListbox(HWND hwnd); void GoToDebuggerBookmark(HWND hwnd); -extern bool IsLetterLegalHex(char c); bool DoSymbolicDebugNaming(int offset, HWND parentHWND); bool DoSymbolicDebugNaming(int offset, int size, HWND parentHWND); diff --git a/src/drivers/win/monitor.cpp b/src/drivers/win/monitor.cpp index 376e96e5..037f5b73 100644 --- a/src/drivers/win/monitor.cpp +++ b/src/drivers/win/monitor.cpp @@ -3,6 +3,7 @@ #include "debugger.h" #include "debuggersp.h" #include "memwatch.h" +#include "window.h" #include "../../fceu.h" #include "../../debug.h" #include "../../conddebug.h" @@ -120,7 +121,7 @@ BOOL updateResults(HWND hwndDlg, int rule) for (unsigned int j=0;j= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f'; } -bool IsLetterLegalMemwatchAddress(char letter) +bool IsLetterLegalMemwatchAddress(int index, char letter) { //accept normal hex stuff if(letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f') return true; //accept prefixes - if(letter == 'x' || letter == 'X' || letter == '!') - return true; + if(index == 0) + { + if(letter == 'x' || letter == 'X' || letter == '!') + return true; + } return false; } -bool IsLetterLegalHexList(char letter) +bool IsLetterLegalHexList(int index, char letter) { - return IsLetterLegalHex(letter) || letter == ',' || letter == ' '; + return IsLetterLegalHex(index,letter) || letter == ',' || letter == ' '; } -bool IsLetterLegalCheat(char letter) +bool IsLetterLegalCheat(int index, char letter) { return letter >= '0' && letter <= ':' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '?'; } -bool IsLetterLegalSize(char letter) +bool IsLetterLegalSize(int index, char letter) { return letter >= '0' && letter <= '9' || letter == 'm' || letter == 'M' || letter == 'k' || letter == 'K' || letter == 'b' || letter == 'B'; } -bool IsLetterLegalDec(char letter) +bool IsLetterLegalDec(int index, char letter) { return letter >= '0' && letter <= '9' || letter == '-' || letter == '+'; } -bool IsLetterLegalFloat(char letter) +bool IsLetterLegalFloat(int index, char letter) { return letter >= '0' && letter <= '9' || letter == '.' || letter == '-' || letter == '+'; } -bool IsLetterLegalDecHexMixed(char letter) +bool IsLetterLegalDecHexMixed(int index, char letter) { return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$' || letter == '-' || letter == '+'; } -bool IsLetterLegalUnsignedDecHexMixed(char letter) +bool IsLetterLegalUnsignedDecHexMixed(int index, char letter) { return letter >= '0' && letter <= '9' || letter >= 'A' && letter <= 'F' || letter >= 'a' && letter <= 'f' || letter == '$'; } -wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter)) +wchar_t* GetLetterIllegalErrMsg(IsLetterLegalProc proc) { - if (IsLetterLegal == &IsLetterLegalGG) + if (proc == &IsLetterLegalGG) return L"You can only type Game Genie characters:\nA P Z L G I T Y E O X U K S V N"; - if (IsLetterLegal == &IsLetterLegalHex) + if (proc == &IsLetterLegalHex) return L"You can only type characters for hexadecimal number (0-9,A-F)."; - if (IsLetterLegal == &IsLetterLegalHexList) + if (proc == &IsLetterLegalHexList) return L"You can only type characters for hexademical number (0-9,A-F), each number is separated by a comma (,)"; - if (IsLetterLegal == &IsLetterLegalCheat) + if (proc == &IsLetterLegalCheat) return L"The cheat code comes into the following 2 formats:\n" "AAAA:VV freezes the value in Address $AAAA to $VV.\n" "AAAA?CC:VV changes the value in Address $AAAA to $VV only when it's $CC.\n" "All the characters are hexadecimal number (0-9,A-F).\n"; - if (IsLetterLegal == &IsLetterLegalFloat) + if (proc == &IsLetterLegalFloat) return L"You can only type decimal number (decimal point is acceptable)."; - if (IsLetterLegal == &IsLetterLegalSize) + if (proc == &IsLetterLegalSize) return L"You can only type decimal number followed with B, KB or MB."; - if (IsLetterLegal == &IsLetterLegalDec) + if (proc == &IsLetterLegalDec) return L"You can only type decimal number (sign character is acceptable)."; - if (IsLetterLegal == &IsLetterLegalDecHexMixed) + if (proc == &IsLetterLegalDecHexMixed) return L"You can only type decimal or hexademical number\n" "(sign character is acceptable).\n\n" @@ -3381,7 +3384,7 @@ wchar_t* GetLetterIllegalErrMsg(bool(*IsLetterLegal)(char letter)) "you must add a $ prefix to prevent ambiguous.\n" "eg. 10 is a decimal number,\n" "$10 means a hexademical number that is 16 in decimal."; - if (IsLetterLegal == &IsLetterLegalUnsignedDecHexMixed) + if (proc == &IsLetterLegalUnsignedDecHexMixed) return L"You can only type decimal or hexademical number.\n\n" "When your number contains letter A-F,\n" @@ -3485,9 +3488,9 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) case WM_PASTE: { - bool (*IsLetterLegal)(char) = GetIsLetterLegalProc(GetDlgCtrlID(hwnd)); + IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd)); - if (IsLetterLegal) + if (isLetterLegal) { if (OpenClipboard(hwnd)) { @@ -3502,11 +3505,11 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) int len = strlen(clipStr); for (int i = 0; i < len; ++i) { - if (!IsLetterLegal(clipStr[i])) + if (!isLetterLegal(i,clipStr[i])) { through = false; // Show Edit control tip, just like the control with ES_NUMBER do - ShowLetterIllegalBalloonTip(hwnd, IsLetterLegal); + ShowLetterIllegalBalloonTip(hwnd, isLetterLegal); break; } } @@ -3520,8 +3523,9 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) case WM_CHAR: { + int len = GetWindowTextLength(hwnd); IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd)); - through = IsInputLegal(isLetterLegal, wP); + through = IsInputLegal(isLetterLegal, len, wP); if (!through) ShowLetterIllegalBalloonTip(hwnd, isLetterLegal); } @@ -3530,10 +3534,10 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) return through ? CallWindowProc(DefaultEditCtrlProc, hwnd, msg, wP, lP) : result; } -void ShowLetterIllegalBalloonTip(HWND hwnd, bool(*IsLetterLegal)(char letter)) +void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc proc) { wchar_t* title = L"Unacceptable Character"; - wchar_t* msg = GetLetterIllegalErrMsg(IsLetterLegal); + wchar_t* msg = GetLetterIllegalErrMsg(proc); EDITBALLOONTIP tip; tip.cbStruct = sizeof(EDITBALLOONTIP); diff --git a/src/drivers/win/window.h b/src/drivers/win/window.h index 28d10a0a..da716a69 100644 --- a/src/drivers/win/window.h +++ b/src/drivers/win/window.h @@ -128,8 +128,8 @@ struct HOTKEYMENUINDEX { void UpdateMenuHotkeys(FCEUMENU_INDEX index); int GetCurrentContextIndex(); -typedef bool (*IsLetterLegalProc)(char); -bool IsLetterLegalHex(char letter); +typedef bool (*IsLetterLegalProc)(int index, char ch); +bool IsLetterLegalHex(int index, char letter); void ShowLetterIllegalBalloonTip(HWND hwnd, IsLetterLegalProc); extern WNDPROC DefaultEditCtrlProc; -- cgit v1.2.3 From 5230d2eacd5b64b0ebf2d6c1af3ee6edcc82d3a3 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 21 Aug 2022 15:28:06 -0400 Subject: winport - change memwatch addresses to support lower case (partial revert of f0396ef980a8a72d39fd5541c2d04ba497162915) --- src/drivers/win/res.rc | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 2b467b92..88d77f03 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -684,53 +684,53 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN GROUPBOX "",IDC_STATIC,3,0,126,200 GROUPBOX "",IDC_STATIC,131,0,128,200 - EDITTEXT MW_ADDR00,6,17,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR00,6,17,30,14,0 EDITTEXT MW_NAME00,41,17,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR01,6,32,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR01,6,32,30,14,0 EDITTEXT MW_NAME01,41,32,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR02,6,47,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR02,6,47,30,14,0 EDITTEXT MW_NAME02,41,47,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR03,6,62,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR03,6,62,30,14,0 EDITTEXT MW_NAME03,41,62,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR04,6,77,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR04,6,77,30,14,0 EDITTEXT MW_NAME04,41,77,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR05,6,92,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR05,6,92,30,14,0 EDITTEXT MW_NAME05,41,92,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR06,6,107,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR06,6,107,30,14,0 EDITTEXT MW_NAME06,41,107,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR07,6,122,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR07,6,122,30,14,0 EDITTEXT MW_NAME07,41,122,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR08,6,137,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR08,6,137,30,14,0 EDITTEXT MW_NAME08,41,137,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR09,6,152,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR09,6,152,30,14,0 EDITTEXT MW_NAME09,41,152,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR10,6,167,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR10,6,167,30,14,0 EDITTEXT MW_NAME10,41,167,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR11,6,182,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR11,6,182,30,14,0 EDITTEXT MW_NAME11,41,182,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR12,135,17,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR12,135,17,30,14,0 EDITTEXT MW_NAME12,171,17,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR13,135,32,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR13,135,32,30,14,0 EDITTEXT MW_NAME13,171,32,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR14,135,47,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR14,135,47,30,14,0 EDITTEXT MW_NAME14,171,47,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR15,135,62,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR15,135,62,30,14,0 EDITTEXT MW_NAME15,171,62,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR16,135,77,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR16,135,77,30,14,0 EDITTEXT MW_NAME16,171,77,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR17,135,92,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR17,135,92,30,14,0 EDITTEXT MW_NAME17,171,92,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR18,135,107,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR18,135,107,30,14,0 EDITTEXT MW_NAME18,171,107,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR19,135,122,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR19,135,122,30,14,0 EDITTEXT MW_NAME19,171,122,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR20,135,137,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR20,135,137,30,14,0 EDITTEXT MW_NAME20,171,137,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR21,135,152,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR21,135,152,30,14,0 EDITTEXT MW_NAME21,171,152,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR22,135,167,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR22,135,167,30,14,0 EDITTEXT MW_NAME22,171,167,55,14,ES_AUTOHSCROLL - EDITTEXT MW_ADDR23,135,182,30,14,ES_UPPERCASE + EDITTEXT MW_ADDR23,135,182,30,14,0 EDITTEXT MW_NAME23,171,182,55,14,ES_AUTOHSCROLL LTEXT "Name",IDC_STATIC,41,7,20,8 LTEXT "Address",IDC_STATIC,6,7,26,8 -- cgit v1.2.3 From 7806b24388291a15b5cda04531c23ed417339ab7 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 21 Aug 2022 15:35:45 -0400 Subject: winport - fix prefix checking on memwatch addresses (fixes #496) --- src/drivers/win/window.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index b3f7d64b..3effd90d 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -3523,9 +3523,10 @@ LRESULT APIENTRY FilterEditCtrlProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) case WM_CHAR: { - int len = GetWindowTextLength(hwnd); + DWORD cpBegin, cpEnd; + SendMessage(hwnd, EM_GETSEL, (LPARAM)&cpBegin, (LPARAM)&cpEnd); IsLetterLegalProc isLetterLegal = GetIsLetterLegalProc(GetDlgCtrlID(hwnd)); - through = IsInputLegal(isLetterLegal, len, wP); + through = IsInputLegal(isLetterLegal, (int)cpBegin, wP); if (!through) ShowLetterIllegalBalloonTip(hwnd, isLetterLegal); } -- cgit v1.2.3