News:

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

How i get the Handle from an item in my Dialog Box

Started by ferby, February 26, 2009, 08:30:10 PM

Previous topic - Next topic

ferby

Hello,

i have create a dialog box



    Dialog "Dialog With Icon", "Tahoma", 9, \          ; caption,font,pointsize
            WS_OVERLAPPED or DS_CENTER or WS_VISIBLE, \     ; style
            3, \                                            ; control count
            0,0,166,70, \                                  ; x y co-ordinates
            1024                                            ; memory buffer size

    DlgStatic "MASM32 Pure And Simple Dialogs",0,8,8,150,9,100
DlgEdit WS_BORDER or WS_TABSTOP,8,18,150,12,1000
DlgButton "OK",WS_TABSTOP,8,33,150,15,IDOK

    invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT, 32
CallModalDialog hInstance,h_window,DlgProc, eax
    invoke GlobalFree, eax


when the OK Button is presst i want to get the text from the EDIT Item


maybe so:

DlgProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

; COMMAND
    .if uMsg == WM_COMMAND
   
    ; OK BUTTON
      .if wParam == IDOK
     
      invoke SendMessage, ????????, WM_GETTEXT, NULL, NULL
      ; SAVE TEXT [..]
        invoke EndDialog,hWin,0
      .endif

; CLOSE
    .elseif uMsg == WM_CLOSE
      invoke EndDialog,hWin,0
    .endif

xor eax, eax
    ret

DlgProc endp



but what is the handle for the edit item to get the text with invoke SendMessage, ????????, WM_GETTEXT, NULL, NULL


donkey

GetDlgItem will return the handle of the item given it's ID

invoke GetDlgItem, hDlg, 1002
mov hControl, eax
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

peaslee

This dialog is from a resource file, but I can't get the column to add.


DlgCarsProc proc hWnd:HWND, iMsg:DWORD, wParam:WPARAM, lParam:LPARAM
;===================================================================

   LOCAL lvc:LV_COLUMN
   
   .if iMsg == WM_INITDIALOG
      invoke GetDlgItem,hWnd,IDC_LSV_CARS
      mov    hLV, eax
      mov    lvc.imask, LVCF_TEXT + LVCF_WIDTH
      mov    lvc.pszText, offset chDlgCarsHeading1
      mov    lvc.lx, 150
      invoke SendMessage, hLV, LVM_INSERTCOLUMN, 0, addr lvc
   .elseif iMsg == WM_CLOSE
      invoke EndDialog, hWnd, NULL   
   .else
      mov    eax, FALSE
      ret   
   .endif
   mov    eax, TRUE
   ret
   
DlgCarsProc endp
Bruce Peaslee
"Reality is a crutch for those who can't do drugs."

Mark Jones

Quote from: donkey on February 26, 2009, 08:37:23 PM
GetDlgItem will return the handle of the item given it's ID

...provided the dialog was created with DialogBoxParam and not CreateDialogParam... ::)

If you're familiar with the OllyDbg debugger, load the executable into that, scroll down to a few lines before the call to GetDlgItem, press F2 to place a breakpoint there, press F9 to execute to the breakpoint, then press F8 to step through the call to GetDlgItem. You might be getting this result:

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

peaslee

#4
No luck. I tried debugging as was suggested, but it looks fine. The dialog opens, but there is no heading.

[EDIT]

Per MSDN: "Columns are visible only in report (details) view."

I mistakenly thought this was the default. I'm back on track now.
Bruce Peaslee
"Reality is a crutch for those who can't do drugs."