Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found the solution. The reason why the code doesn't seem to be making any effect in my application is because it is making effect only to MyMainDialog. When typing in the Edit Control, the OnChar() being called if from CEdit, so that is the one I have to intercept. You are not allowed to overwrite CEdit::OnChar(). The solution is to create a class that derives from CEdit and then intercept the OnChar() from that class. You you also have to use your class instead of CEdit for manipulating your Edit Control.</p> <p>My code was then reformulated to this:</p> <p>OnChar():</p> <pre><code>void CustomEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if(nChar == '.' &amp;&amp; checkPoint == true) //Is a point and there is already a point { //Show message } else if(nChar == '.' &amp;&amp; checkPoint == false) //Is a point but there is no point { CEdit::OnChar(nChar, nRepCnt, nFlags); } if((nChar &lt; '0' || nChar &gt; '9') &amp;&amp; nChar != 8) //Is not a number or backspace { //Show message } else //Valid { CEdit::OnChar(nChar, nRepCnt, nFlags); } } </code></pre> <p>OnKeyDown():</p> <pre><code>void CustomEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { CString temp; this-&gt;GetWindowTextA(temp); if(temp.Find('.') == -1) checkPoint = false; //There is no point else checkPoint = true; //There is a point CEdit::OnKeyDown(nChar, nRepCnt, nFlags); } </code></pre> <p>Hope this helps anyone with a similar question. By the way, there are many classes and automated solutions in the internet, I did this manually for learning purposes.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload