flat assembler
Message board for the users of flat assembler.

Index > Windows > Devices list pogam

Author
Thread Post new topic Reply to topic
viki



Joined: 03 Jan 2006
Posts: 40
Location: Czestochowa, Poland
viki 15 Mar 2006, 16:07
This is a source and the exe file which add all devices to the listbox. This file based on example from The Assembly Programming Master Book. Additionali the window and listbox are sizable. Hope someone can use this
Code:
format PE GUI 4.0 
entry start 

include 'win32a.inc'

IDC_Cancel = 1
IDC_Static1 = 2 
IDC_Static2 = 3 
IDC_Edit1 = 4 
IDC_List = 5
IDC_About = 6
IDC_Listbox1 = 7
LB_ADDSTRING = 180h

section '.data' data readable writeable 
  hList         dd ?
  hButton       dd ?
  about_text    db 'Kompilacja FASM v1.65',0dh,0ah,'Testowanie ListBoxa',0dh,0ah,'Viki 2006',0
  about_caption db 'About',0
  priz          db 0
  roo           db '?:\',0
  buffer        db 40 dup(0)
  typ0          db '',0
  typ1          db '',0
  typ2          db ' stacja dyskietek',0
  typ3          db ' dysk twady',0
  typ4          db ' dysk sieciowy',0
  typ5          db ' cd-rom',0
  typ6          db ' ram dysk',0
  index         dd typ0
                dd typ1
                dd typ2
                dd typ3
                dd typ4
                dd typ5
                dd typ6
  client        RECT

section '.code' code readable executable
  start:
    invoke GetModuleHandle,0
    invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
    or eax,eax
    jz exit
  exit:
    invoke ExitProcess,0

;-------------------------------------------------------------------------
proc DialogProc hwnddlg,msg,wparam,lparam
;-------------------------------------------------------------------------
    push   ebx esi edi
    cmp    [msg],WM_INITDIALOG
    je     wminitdialog
    cmp    [msg],WM_SIZE
    je     wmsize
    cmp    [msg],WM_COMMAND
    je     wmcommand
    cmp    [msg],WM_CLOSE
    je     wmclose
    xor    eax,eax
    jmp    finish
  wminitdialog:
    invoke  GetDlgItem, [hwnddlg],IDC_Listbox1
    mov     [hList],eax
    invoke  GetDlgItem, [hwnddlg],IDC_List
    mov     [hButton],eax

    invoke  GetClientRect,[hwnddlg],client
    mov     eax,[client.bottom]
    sub     eax,30
    invoke  MoveWindow,[hList],[client.left],[client.top],[client.right],eax,TRUE

    mov     eax,[client.right]
    sub     eax,82
    mov     [client.right],eax

    mov     eax,[client.bottom]
    sub     eax,27

    invoke  MoveWindow,[hButton],[client.right],eax,80,25,TRUE
    xor    eax,eax
    jmp    processed
  wmsize:
    invoke  GetClientRect,[hwnddlg],client
    mov     eax,[client.bottom]
    sub     eax,30
    invoke  MoveWindow,[hList],[client.left],[client.top],[client.right],eax,TRUE

    mov     eax,[client.right]
    sub     eax,82
    mov     [client.right],eax

    mov     eax,[client.bottom]
    sub     eax,27

    invoke  MoveWindow,[hButton],[client.right],eax,80,25,TRUE
    xor    eax,eax
    jmp    processed
  wmcommand:
    cmp    [wparam],BN_CLICKED shl 16 + IDC_Cancel
    je     wmclose
    cmp    [wparam],BN_CLICKED shl 16 + IDC_List
    je     addtolist
    cmp    [wparam],BN_CLICKED shl 16 + IDC_About
    je     showinfo
    jmp    processed
  showinfo:
    invoke MessageBox,[hwnddlg],about_text,about_caption,MB_OK
    jmp    processed
  addtolist:
    mov    ecx, 'A'
  loo:
    push   ecx
    mov    [roo], cl
    invoke GetDriveType,roo
    cmp    [priz], 0
    jz     _all
    cmp    eax, 2
    jb     l3
  _all:
    shl    eax,2
    push   eax
    invoke lstrcpy,buffer,roo
    pop    ebx
    invoke lstrcat,buffer,[ebx+index]
    invoke SendDlgItemMessage,[ebp+08h],IDC_Listbox1,LB_ADDSTRING,0,buffer
  l3:
    pop    ecx
    inc    ecx
    cmp    ecx, 91
    jne    loo
    jmp    processed
  wmclose:
    invoke EndDialog,[hwnddlg],0
  processed:
    mov    eax,1
  finish:
    pop    edi esi ebx
    ret
endp

section '.idata' import data readable writeable
  library kernel32,'KERNEL32.DLL',user32,'USER32.DLL',comdlg32,'COMDLG32.dll'
  include '\apia\kernel32.inc'
  include '\apia\user32.inc' 
  include '\apia\comdlg32.inc' 

section '.rsrc' resource data readable
  directory RT_DIALOG,dialogs
  resource dialogs,37,LANG_TURKISH+SUBLANG_DEFAULT,demonstration
    dialog demonstration,'Devices list',100,100,185,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+WS_SIZEBOX
    ;dialogitem 'BUTTON','Cancel',IDC_Cancel,130,156,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
    ;dialogitem 'BUTTON','About',IDC_About,80,156,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
    ;dialogitem 'STATIC','Press "List" button to add',IDC_Static1,10,10,200,8,WS_VISIBLE
    ;dialogitem 'STATIC','all devices to the listbox.',IDC_Static2,10,18,200,8,WS_VISIBLE
    dialogitem 'LISTBOX',NULL,IDC_Listbox1, 10, 30, 165, 100, WS_VISIBLE+WS_BORDER+WS_VSCROLL
    ;dialogitem 'EDIT','',IDC_Edit1,10,120,165,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP
    dialogitem 'BUTTON','List',IDC_List,130,140,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
  enddialog
    


Description:
Download
Filename: devices.zip
Filesize: 1.06 KB
Downloaded: 214 Time(s)

Post 15 Mar 2006, 16:07
View user's profile Send private message Reply with quote
blacky



Joined: 06 Apr 2006
Posts: 32
Location: JA
blacky 06 Apr 2006, 23:10
Im new to fasm, but before the Populating of the list, add:
SendMessage(hList , LB_RESETCONTENT , (WPARAM)0 , (LPARAM)0);
So it will not keep adding to the previous list.

Code:
  addtolist:
       invoke SendMessage, [hList],LB_RESETCONTENT, 0,0
    mov    ecx, 'A'   
    
Post 06 Apr 2006, 23:10
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.