News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Back to supeclassing

Started by Neil, April 28, 2012, 03:31:52 PM

Previous topic - Next topic

Neil

This is going back a while to a post where I had 10 superclassed Edit boxes. This worked OK with manual tabbing, so I decided to change it to Auto tabbing, now this works fine going forward i.e. inputting digits the problen is when Backspace is pressed. If the Edit box is waiting for the second digit & Backspace is pressed the first digit is erased & the cursor flashes in the first position, but if the Edit box is waiting for the first digit then the cursor goes back to the previous Edit box but doen't erase the second digit it flashes in front of it so Backspace has to be pressed again before the digit is erased this is not ideal & it also throws my count out.
Before I post the code I'll explain what the variables do :-

icount = Total number of digits input, Maximum 20
posflag when zero = waiting for first digit (Tens)
posflag when 1 = waiting for second digit (Units)

Here is the code :-

EditWndProc PROC hEdit:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

        .if uMsg==WM_CHAR
        mov eax,wParam
        .if (al>="0" && al<="9")
        cmp icount,20               ;20 digits input?
        jne @F                      ;No, go to accept
        xor eax,eax
        ret
       
@@:   inc icount                  ;Digits input = digits input+1
        cmp posflag,1              ;Is it units?
        jne @F                       ;No, goto tens
        dec posflag
        invoke CallWindowProc,OldWndProc,hEdit,uMsg,eax,lParam
        cmp icount,20
        je @here
        invoke GetWindow,hEdit,GW_HWNDNEXT
        invoke SetFocus,eax

@here: xor eax,eax
          ret

@@:  inc posflag
        invoke CallWindowProc,OldWndProc,hEdit,uMsg,eax,lParam
        xor eax,eax
        ret

        .elseif al==VK_BACK     ;Backspace
        push eax                    ;Save backspace
        cmp icount,0               ;Any digits input?
        jne @F                       ;Yes, go to delete
        pop eax                     ;No, clean stack
        xor eax,eax
        ret

;******************* PROBLEM STARTS HERE *******************

@@:   dec icount                  ;Digits input = Digits input-1
          cmp posflag,0             ;Is it waiting for tens
          jne units                    ;No, go to units
          cmp icount,0
          je @F
          inc posflag                 ;Set to wait for tens 
          invoke GetWindow,hEdit,GW_HWNDPREV
          invoke SetFocus,eax
       
@@:  pop eax                      ;Restore backspace
        invoke CallWindowProc,OldWndProc,hEdit,uMsg,eax,lParam ;DOES NOTHING
        xor eax,eax
        ret

;****************** END OF PROBLEM **********************

units: dec posflag
        pop eax
        invoke CallWindowProc,OldWndProc,hEdit,uMsg,eax,lParam
        xor eax,eax
        ret
        .endif

dedndave

i think i would create an array or structure so that each edit control has it's own set of variables
when you receive a message, you figure out what the index is and address it from a register
you may be able to use EDX in this case, if it doesn't run you out of registers
if you had more API calls, you might use EBX, ESI, or EDI to hold the index

Neil

Yes Dave, something to think about & also looking at the code I see that the branch is incorrect when there has been no input, back to the drawing board :(