← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3172: enforce number-only rules when dropping text on a text box

 

------------------------------------------------------------
revno: 3172
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2013-01-19 15:27:28 +0100
message:
  enforce number-only rules when dropping text on a text box
modified:
  dwt/src/widgets/TextBox.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/src/widgets/TextBox.cpp'
--- dwt/src/widgets/TextBox.cpp	2013-01-18 21:28:38 +0000
+++ dwt/src/widgets/TextBox.cpp	2013-01-19 14:27:28 +0000
@@ -139,11 +139,16 @@
 			STGMEDIUM stgmedium;
 			if(pDataObj->GetData(&formatetc, &stgmedium) == S_OK) {
 				if(stgmedium.tymed == TYMED_HGLOBAL && stgmedium.hGlobal) {
-					auto text = reinterpret_cast<LPCTSTR>(::GlobalLock(stgmedium.hGlobal));
-					if(text) {
-						moveCaret(pt);
-						w->replaceSelection(text);
+					auto buf = reinterpret_cast<LPCTSTR>(::GlobalLock(stgmedium.hGlobal));
+					if(buf) {
+						tstring text { buf };
 						::GlobalUnlock(stgmedium.hGlobal);
+						if(w->hasStyle(ES_NUMBER) && text.find_first_not_of(_T("0123456789")) != tstring::npos) {
+							w->sendMessage(WM_CHAR, 'A'); // simulate a key press to show the error popup
+						} else {
+							moveCaret(pt);
+							w->replaceSelection(text);
+						}
 					}
 				}
 				::ReleaseStgMedium(&stgmedium);