News:

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

editcontrol in dialog not displaying

Started by Rainstorm, November 02, 2008, 08:15:48 AM

Previous topic - Next topic

Rainstorm

the dialog displays at add edi, 24. the initial text is not displayed in the box though
       add edi, 22+2
;      memalign edi, 4
       invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, addr editbox_title, -1,
                                   edi, LENGTHOF editbox_title
       add edi, LENGTHOF editbox_title*2


Also the dialog still doesn't display if i add the WS_TABSTOP style to the editbox

       mov dword ptr [edi+0] ,   ES_LEFT or ES_AUTOHSCROLL or WS_CHILD or WS_VISIBLE or WS_TABSTOP   ; style


thx

jj2007

Ok, try
       invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, addr editbox_title, -1,
                                   edi, LENGTHOF editbox_title*2

Rainstorm

doesn't make any diff
(tried it with edi at 22 & 24.. same results)

MichaelW

I didn't have time to test or examine the dump closely, but this version is supposed to dump a working template. Build as a console app so the print macro will work.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc

    _DlgEdit MACRO quoted_initial_text,dstyle,tx,ty,wd,ht,ctlID
      align_4 edi
      mov DWORD PTR [edi+0],  WS_VISIBLE or WS_CHILD or dstyle
      mov WORD  PTR [edi+8],  tx
      mov WORD  PTR [edi+10], ty
      mov WORD  PTR [edi+12], wd
      mov WORD  PTR [edi+14], ht
      mov WORD  PTR [edi+16], ctlID
      mov WORD  PTR [edi+18], 0FFFFh
      mov WORD  PTR [edi+20], 0081h   ;; edit control
      add edi, 22
      ustring quoted_initial_text
      align_2 edi
      add edi, 2
    ENDM
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      hInstance dd 0
      buffer    db 2000 dup(0)
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

DlgProc proc hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
    SWITCH uMsg

      CASE WM_INITDIALOG

      CASE WM_COMMAND

        .IF wParam == IDCANCEL
          invoke EndDialog, hDlg, 0
        .ENDIF

      CASE WM_CLOSE

         invoke EndDialog, hDlg, 0

    ENDSW
    xor eax, eax
    ret
DlgProc endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    invoke GetModuleHandle, NULL
    mov hInstance, eax
    Dialog "Test", \
           "MS Sans Serif",10, \
           WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
           2,0,0,100,75,1024

    _DlgEdit "initial text",WS_BORDER,6,5,85,30,100

    DlgButton "Close",0,34,45,30,10,IDCANCEL

    mov ecx, edi
    sub ecx, esi
    invoke HexDump, esi, ecx, ADDR buffer

    print ADDR buffer,13,10

    CallModalDialog hInstance, 0, DlgProc, 12345
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


40 08 08 00 00 00 00 00 - 02 00 00 00 00 00 64 00
4B 00 00 00 00 00 54 00 - 65 00 73 00 74 00 00 00
0A 00 4D 00 53 00 20 00 - 53 00 61 00 6E 00 73 00
20 00 53 00 65 00 72 00 - 69 00 66 00 00 00 00 00
00 00 80 50 00 00 00 00 - 06 00 05 00 55 00 1E 00
64 00 FF FF 81 00 69 00 - 6E 00 69 00 74 00 69 00
61 00 6C 00 20 00 74 00 - 65 00 78 00 74 00 00 00
00 00 00 00 00 00 00 50 - 00 00 00 00 22 00 2D 00
1E 00 0A 00 02 00 FF FF - 80 00 43 00 6C 00 6F 00
73 00 65 00 00 00 00 00 -

eschew obfuscation

jj2007

Quote from: Rainstorm on November 04, 2008, 08:13:24 PM
doesn't make any diff
I checked the docu again, and you are right, it's cchWideChar. No luck...
Does the call to MultiByteToWideChar succeed?
Could you post your current code?

jj2007

           .if uMsg == WM_COMMAND                    ; lParam = handle of control
               movzx ecx, word ptr [wParam]          ; low word of wParam - control identifier
               ; movzx ebx, word ptr [wParam+2]        ; ebx?? high word of wParam - notification msg
               .if ecx == IDCANCEL
                   invoke GetDlgItemText, hdlg, IDCANCEL, addr editcontrol_buff, 1000
                   jmp end_dialog
               .endif
      jmp false_

Gotcha!

(ebx is not the culprit, but not a good idea either)

EDIT: Code attached.

[attachment deleted by admin]

Rainstorm

#21
damnn!!!     
missed that : |
appreciate all the testing & assistance everyone,
thx.

edit
--------
i took out the memalign edi, 2 line too since the WORD alignment as mentioned in the documentation there seems right,
jj wrote..
Quote(ebx is not the culprit, but not a good idea either)
just curious, why its not a good idea there



jj2007

Quote from: Rainstorm on November 06, 2008, 11:01:49 AM
jj wrote..
Quote(ebx is not the culprit, but not a good idea either)
why is it not a good idea there?

I am not sure, but I vaguely remember that using esi edi ebx in callback procedures may choke the OS... the question is then if DlgProc qualifies as a callback proc. Apart from these "legal" aspects, it seemed to work (although it does not anything useful - ebx does not appear a second time in your code).

Rainstorm

was just trying stuff when i put it there, but I wasn't aware of the ebx thing, thanks.
also i changed the jmp false_ to jmp true_ since the app processed the msg.

Rainstorm

#24
jmp false_ might be better on second thoughts

just a few more more questions. I have'nt included a winmain there & though it seems to work proper, would it be safer to have a WinMain ?

another thing is i don't know why i can't get the msgbox after the 'call create_dialog' instruction,.. to display. think i'm miscalculating the flow somewhere. - I was thinking that after the below code the control would return back to after the 'call create_dialog' instruction in the beginning.    ExitMsgLoop:
          mov eax, msg.wParam
          ret

[attachment deleted by admin]

Rainstorm

there are 2 ret instructions in my code, one in theWndProc corresponds to returns to calls made by the system & the other one after   mov eax, msg.wParam in the Messageloop which should return back to the next instruction after my call