News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

select file of the list

Started by 03.jose, July 30, 2012, 09:09:38 AM

Previous topic - Next topic

03.jose

this is what I showed in result:

--in RichMasm:** RichMasm warning: Exit code 'still active' **
--in the windows:
                   Line 580
                   eax      1
                   ebx       6820384 (this data is variable)
                   $tvi.pszText  ejemplo1.txt

CreateFile soluciones
     $pFile2 problemas\ejemplo1.txt
     eax       416  (this data is variable)

CreateFile ShellExecute with pFile
     ecx       42
     $eax     [problemas\ejemplo1.txt]

i try with the seccion soluciones but showed the same data

jj2007

So you see that whatever you select, you always get ejemplo1.txt, i.e. the first item on the list. That is not working. You need the correct item, and that can be done with a WM_NOTIFY handler that sets a global variable lastItem (you can use another name):

    .elseif eax == WM_NOTIFY
            cmp      wParam, TV_OPTIONS
            jne      PassThrough

            mov      esi, lParam
            mov      ecx, [esi.NMHDR.code]
            .if ecx==TVN_SELCHANGED
                  mov eax, [esi.NM_TREEVIEW.itemNew.hItem]
                  .data?
                  lastItem dd ?
                  .code
                  mov lastItem, eax
            .endif
            cmp      ecx, TVN_SELCHANGING
            jne      PassThrough

Then, you can use lastItem here:
    ;#####   mira si fue seleccionado
    lea      ecx, TempBuffer
    mov      byte ptr [ecx], 0
    mov      tvi.imask, TVIF_TEXT or TVIF_HANDLE
    mov edi, lastItem
    mov      tvi.hItem, edi
    mov      tvi.pszText, ecx
    mov      tvi.cchTextMax, TempBufSize
    invoke   SendMessage, hTVOptions, TVM_GETITEM, 0, addr tvi
    xchg eax, ebx
    deb 1, "File A, GETITEM", eax, tvi.hItem, $tvi.pszText, tvi.imask

I hope this helps :icon14:

03.jose

this is great!! now sends the correct filename ... but now I have the problem that for some reason I do not open the file txt / asm or run the exe

I guess the problem is when you send or receive the address of the file to open / run

I've attached the file so you can see as I have

thanks for the help

dedndave

we get spoiled using the GetOpenFilename and GetSaveFilename dialogs - lol
with a listview, you may have to convert a name to a fully qualified path

jj2007

With lastItem, everything becomes a lot simpler...:

ShowSelected proc uses ebx esi edi
LOCAL tvi:TVITEM, SmallBuffer[30]:BYTE, BigBuffer[60]:BYTE
  lea esi, SmallBuffer
  lea edi, BigBuffer
  mov tvi.imask, TVIF_TEXT or TVIF_HANDLE
  m2m tvi.hItem, lastItem
  mov tvi.pszText, esi
  mov tvi.cchTextMax, sizeof SmallBuffer
  invoke SendMessage, hTVOptions, TVM_GETITEM, 0, addr tvi
  mov ecx, len(esi)   ; len is Masm32, Len is MasmBasic
  mov eax, [esi+ecx-4]   ; get the extension
  or eax, 20202000h   ; make all lowercase
  .if eax=="txt."      ; .txt
   invoke lstrcpy, edi, chr$("problemas\")
   invoke lstrcat, edi, esi
   invoke ShellExecute, 0, 0, edi, 0, 0, SW_NORMAL
;   deb 4, "Txt file", eax, $esi, $edi
  .elseif eax=="msa."   ; .asm
   invoke lstrcpy, edi, chr$("soluciones\")
   invoke lstrcat, edi, esi
   invoke ShellExecute, 0, 0, edi, 0, 0, SW_NORMAL
;   deb 4, "Asm file", eax, $esi, $edi
  .elseif eax=="exe."   ; .exe
   invoke lstrcpy, edi, chr$("ejecutables\")
   invoke lstrcat, edi, esi
   invoke WinExec, edi, SW_NORMAL
;   deb 4, "Exe file", eax, $esi
  .else
   MsgBox 0, esi, "ERROR: Unknown file", MB_OK
  .endif
    ret
ShowSelected endp

03.jose

You saved me! thanks!! this is what I needed and did not know how to express it in assembler :greenclp:

jj2007

Glad I could help - and hopefully you will remain an active member of the forum :icon14: