News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

I'm losing it again..

Started by K_F, October 04, 2013, 07:36:27 PM

Previous topic - Next topic

K_F

I'm playing around with an EditBox (standalone) and trying to insert a "0" when the user deletes the last number in the box.
The idea is to detect when the edit box has zero characters in it.. then do the insertion.

I've limited the control text length to 3 numbers.

With both these SendMessages I get a value of 7, no matter how many numbers there are in the box ????
The API says that GETTEXT should return the exact string length !!

Quote
   .if uMsg == WM_COMMAND
      HiWord (wParam)
      .if eax == EN_UPDATE
@@:
;         invoke SendMessage, hWnd, WM_GETTEXT, 256, ADDR stz_Temp
         invoke SendMessage, hWnd, WM_GETTEXTLENGTH, NULL, NULL
         invoke   dwtoa, eax, ADDR stz_Temp
         Invoke MessageBox, hWnd, ADDR stz_Temp, TextAddr("WM_GETTEXT"), MB_OK
I get the same story with  EN_CHANGE notification.

Another thing is what character does the system insert into the empty spaces => Space ??
I must be missing something  :dazzled:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

K_F

Quickly give me a hammer.. I want to hit myself with it...
Not to worry... suddenly made some progress :idea:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Adamanteus

That's need to do by hook, checking all messages to edit window, that could change it content.

K_F

I was re-routing the editbox's parent window messages to the edtbox winproc and forgot about the parents hWnd value.
So WM_GETTEXT message was being sent to the parent window instead of the editbox.
So naturally the parent window caption never changed size  :biggrin:

Damm.. It had me fooked for a few hours.
:P :P
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

hutch--

Van,

Use a normal subclass and scan the length of the text in the edit box. Kiddies stuff.  :biggrin: Once you have this up and going, detect if there is only a single zero and delete it if the user presses a non zero numeric key.

Zen

Van,   
...Good to hear that a simple segment of source code is causing extreme distress and anxiety,...:icon_mrgreen:
A suggestion: (HUTCH is right, see above) it has been my experience that writing some code to validate the contents of an edit box (or text box) is almost always necessary (but, it's a pain in the ass to write it). And, assembly is perfect for this.
The typical computer user can be so annoying.
...That's something I'm quite experienced at,...thinking like an annoying person. :icon_mrgreen:

K_F

Ja, thanks
I think I was a bit tired this morning, finally coming to the end of this part of my project, so wasn't thinking straight.
This week-end I'm having a complete break... fix up my garden before spring disappears - up at 6:00 tomorrow   :eusa_boohoo:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

K_F

#7
Nothing like a sorted garden to sort one's brain out... shyte my back's buggered..  :biggrin:
This'll do for the time being

Quote
;-----------------------------------------------------------------------------
;winResultedtMBTB:   Control Edit box entry values
;-----------------------------------------------------------------------------
winResultedtMBTB Proc hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

local SelStart:DWord
local SelEnd:DWord

   .if uMsg == WM_COMMAND

      HiWord (wParam)
      .if eax == EN_UPDATE
@@:
         invoke   SendMessage, myControlz.hedtMBTB, WM_GETTEXT, 256, ADDR stz_Temp
         invoke   atodw, ADDR stz_Temp
         mov      ResTypeStruct.i_MBTB, eax
         invoke   dwtoa, ResTypeStruct.i_MBTB, ADDR stz_Temp
         invoke   SendMessage, myControlz.hedtMBTB, WM_SETTEXT, NULL, ADDR stz_Temp
         invoke   SendMessage, myControlz.hedtMBTB, WM_GETTEXT, 256, ADDR stz_Temp
         invoke   SendMessage, myControlz.hedtMBTB, EM_SETSEL, eax,eax

      .elseif eax == EN_CHANGE
         jmp      @B

      .elseif eax == EN_KILLFOCUS
         invoke   Compare_MBNumbers
      .endif
    ; -------------------------------------------
    ; The ^$&£ other KillFocus
    ; -------------------------------------------
   .elseif uMsg == WM_KILLFOCUS
      invoke   Compare_MBNumbers

    ; -------------------------------------------
    ; Accept only 0 - 9
    ; -------------------------------------------
    .elseif uMsg == WM_CHAR
      mov      eax, wParam
      cmp      eax, "0"
      jae      @F
      Return   TRUE
@@:      
      cmp      eax, "9"
      jle      @F
      Return   TRUE
@@:
    ; -------------------------------------------
    ; Accept BackSpace and Return
    ; -------------------------------------------
   .elseif uMsg == WM_KEYDOWN
      mov      eax, wParam
      .if   eax == VK_BACK
         invoke   SendMessage, hWnd, EM_GETSEL, ADDR SelStart, ADDR SelEnd
         mov      eax, SelStart
         .if   eax == SelEnd
            .if SelEnd >= 1
               dec      eax
               invoke   SendMessage, hWnd, EM_SETSEL, eax, SelEnd
               invoke   SendMessage, hWnd, WM_CUT, 0, 0
            .endif
         .else
            invoke   SendMessage, hWnd, WM_CUT, 0, 0
         .endif
      .elseif eax == VK_RETURN
         invoke SetFocus, myControlz.hedtMBHB
      .endif
   .endif
   Return FALSE

winResultedtMBTB EndP
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'