The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on November 29, 2007, 01:40:43 PM

Title: line break
Post by: ragdog on November 29, 2007, 01:40:43 PM
hi

i have a problem to send a return to a editbox
if maximal char in a line then return the line


          .elseif eax == EN_CHANGE
               mov eax, wParam
               
            .if ax==1002
                 invoke GetDlgItemText, hWnd, 1002, ADDR sz1, 1024
                 invoke lstrlen, ADDR sz1
                    mov edi,eax
                 invoke SetDlgItemInt, hWnd, 1003, edi, FALSE
                    mov ecx,edi
                    cmp ecx,5 ;maximal char pro line
                    jnz @out
                 ;invoke MessageBox,hWnd,0,0,MB_OK
                 ;<----------------------------------------
             @out:
            .endif


functions this with a EM _ message ??
invoke SendMessage,hEdit,WM_COMMAND,VK_RETURN,NULL ??

ragdog

[attachment deleted by admin]
Title: Re: line break
Post by: ragdog on November 29, 2007, 05:20:02 PM
my first problem is solved

i have the next ::) ::)
do you have an idea how it could work when  paste  a text in the editbox wich is bigger than 61 signs
that there will be an auto line-break change at 61 signs


thanks in forward
ragdog

[attachment deleted by admin]
Title: Re: line break
Post by: Mark Jones on November 29, 2007, 07:57:29 PM
Quote from: ragdog on November 29, 2007, 05:20:02 PM
do you have an idea how it could work when paste a text in the editbox wich is bigger than 61 signs
that there will be an auto line-break change at 61 signs

Consider what you are asking here. You want something to happen when text changes in an edit control. So how do you handle edit control messages? Look at this WndProc I used (a long time ago) in a simple text-to-binary converter:


WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
    mov eax,uMsg
    .if eax==WM_INITDIALOG
        m2m hWnd,hWin
    .elseif eax==WM_COMMAND
        mov eax,wParam
        and eax,0FFFFh
        .if eax==1001                       ; input edit control message?
            .if bClear==0                   ; if this is the first change,
                invoke SetDlgItemText,hWin,1001,addr bClear
                mov bClear,1                ; clear input box (and do not clear it again)
            .endif
            .if bModify==0                  ; if text is new,
                invoke ASCII2BIN            ; convert ascii to binary
            .endif
        .endif
        .if eax==1002                       ; if output edit control message
            .if bModify==0                  ; if text is new
                invoke BIN2ASCII            ; convert binary back into ascii
            .endif
        .endif
    .elseif eax==WM_CLOSE
        invoke DestroyWindow,hWin
    .elseif uMsg==WM_DESTROY
        invoke PostQuitMessage,NULL
    .else
        invoke DefWindowProc,hWin,uMsg,wParam,lParam
        ret
    .endif
    mov bModify,0                           ; reset changed flag
    xor eax,eax
    ret
WndProc endp


Here bModify was just a global byte, set to 1, inside each procedure to indicate that text had been converted. The first time you click into the ASCII edit control, it is cleared. Then anything you type there is converted into binary and displayed in the second edit control, and vice-versa.
Title: Re: line break
Post by: ragdog on November 29, 2007, 08:57:15 PM
thanks for you reply!

i cannot found any lib or function ASCII2BIN and BIN2ASCII

can you post this ?

ragdog
Title: Re: line break
Post by: Mark Jones on November 30, 2007, 12:54:19 AM
I thought someone might ask. ASCII2BIN/BIN2ASCII are private functions, not part of the MASM32 package. (There is a dword to binary routine in the m32lib folder however.) These routines should probably not be posted because they are a common homework assignment.