flat assembler
Message board for the users of flat assembler.

Index > Windows > About TRACKBAR_CLASS :TBM_SETPOS help

Author
Thread Post new topic Reply to topic
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 03 Dec 2005, 03:57
I have this code, the player is work fine but can any body help how to make the track bar as indicator of the song ( like in winamp):

Code:
;base on iczelion : mp3demo by Ron Thomas
; compile by fasmw 1.60

format PE GUI 4.0
entry start
include 'PCOUNT\mci.inc'
include 'win32a.inc'

MCIWNDF_NOOPEN  equ 8000h
MCI_PLAY                             equ 806h

IDC_LISTMP3        = 3001
ID_TRACKBAR       = 3002
ID_CAPTION         = 101
ID_MESSAGE         = 102
ID_ICONERROR       = 201
ID_ICONINFORMATION = 202
ID_ICONQUESTION    = 203
ID_ICONWARNING     = 204
ID_TOPMOST         = 301

section '.data' data readable writeable
   menuPt          POINT
   AddFilter       db "(*.mid,*.wav,*.mp3,*.rmi,*.aif,*.au,*.snd)",0,"*.mid;*.wav;*.mp3;*.rmi;*.aif;*.au;*.snd",0
                   db "All Files (*.*)",0,"*.*",0,0
   AddFileN:       times 260 db 0
   AddTitle        db "Select a music file:",0
   buf4:           times 1024 db 0
   SelName:        times 520 db 0
   inst            dd ?
   flags           dd ?
   hmenu           dd ?
   mcihwnd         dd ?
   Mp3End          dd ?
   TimerID         dd ?
   hwndtrack       dd ?
   Trackcaption    db "Track",0
   TrackClass      db TRACKBAR_CLASS,0

section '.code' code readable executable

  start:

        invoke  GetModuleHandle,0
        mov     [inst], eax
        invoke  InitCommonControls
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,0

proc DialogProc,hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_INITDIALOG
        je      wminitdialog
        cmp     [msg],WM_COMMAND
        je      wmcommand
        cmp     [msg], WM_CONTEXTMENU
        je      wmcontextmenu
        cmp     [msg], WM_TIMER
        je      wmtimer
        cmp     [msg],WM_CLOSE
        je      wmclose
        xor     eax,eax
        jmp     finish
  wminitdialog:
        invoke CreateWindowEx,0,TrackClass,Trackcaption, WS_CHILD+WS_VISIBLE+TBS_AUTOTICKS+TBS_ENABLESELRANGE,1,1,268,30, [hwnddlg],ID_TRACKBAR,[inst],NULL
        mov [hwndtrack],eax
        invoke SendMessage,[hwndtrack], TBM_SETPAGESIZE,0,1
        invoke LoadIcon,[inst],4
        invoke SendMessage,[hwnddlg],WM_SETICON,ICON_BIG,eax
        invoke LoadMenu, [inst],5
        invoke  GetSubMenu,eax,0
        mov  [hmenu],eax
        jmp     processed
  wmcommand:
        mov     edx, [wparam]
        shr     edx, 16
        cmp     edx,LBN_DBLCLK
        je      playtrack
        cmp     [wparam],BN_CLICKED shl 16 + IDOK
        je      playtrack
        cmp     [wparam], BN_CLICKED shl 16 + IDCANCEL
        je      stoptrack
        cmp     [wparam], 0xFFFF and 5001
        je      addtrack
        cmp     [wparam], 0xFFFF and 5002
        je      deletetrack
        jmp     processed

        addtrack:
                mov     eax, [hwnddlg]
                stdcall test_browse,eax, buf4
                jmp     processed
        playtrack:
                invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_GETCURSEL, 0, 0
                cmp eax, LB_ERR
                je processed
                invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_GETTEXT, eax, SelName
                invoke SendMessage, [mcihwnd], WM_CLOSE, 0, 0
                invoke MCIWndCreate, [hwnddlg], [inst], WS_CHILD or MCIWNDF_NOOPEN, SelName
                mov [mcihwnd],eax
                pop eax     ;For some reason 4 things are pushed onto stack unnecessarily
                pop eax     ;so they have to be popped off the stack to prevent crashing
                pop eax     ;Thanks to Ron Thomas for spotting that one!
                pop eax
                invoke SendMessage, [mcihwnd], MCI_PLAY, 0, 0
                invoke SendMessage, [mcihwnd], MCIWNDM_GETEND, 0, 0
                mov [Mp3End], eax
                invoke SetTimer, [hwnddlg], 1, 1000, NULL
                mov [TimerID], eax
                jmp     processed
        deletetrack:
                invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_GETCURSEL, 0, 0
                cmp eax, LB_ERR
                je next1
                push eax
                invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_DELETESTRING, eax, 0
                pop eax
                cmp eax, 0
                jna     next2
                dec eax
        next2:
                invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_SETCURSEL, eax, 0
        next1:
                mov eax, NULL
                jmp     processed
        stoptrack:
                invoke SendMessage, [mcihwnd], WM_CLOSE, 0, 0
                invoke KillTimer, [hwnddlg], [TimerID]
                jmp     processed
  wmcontextmenu:
        invoke  GetCursorPos,menuPt
        invoke  TrackPopupMenu,[hmenu],TPM_RIGHTBUTTON, [menuPt.x],[menuPt.y],0,[hwnddlg],NULL
        jmp     processed
  wmtimer:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_TOPMOST
        cmp     eax,BST_CHECKED
        jne     wmtimerend
        invoke SendMessage, [mcihwnd], MCIWNDM_GETPOSITIONA, 0, 0
        cmp eax, [Mp3End]
        jne wmtimerend
        invoke KillTimer, [hwnddlg], [TimerID]
        invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_GETCOUNT, 0, 0
        mov edx, eax
        push edx
        invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_GETCURSEL, 0, 0
        pop edx
        inc eax
        cmp eax, edx
        jne wmtimer1
        invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_SETCURSEL, 0, 0
        jmp wmtimer2
        wmtimer1:
                invoke SendDlgItemMessage, [hwnddlg], IDC_LISTMP3, LB_SETCURSEL, eax, 0
        wmtimer2:
                jmp playtrack
        wmtimerend:
                jmp     processed
  wmclose:
        invoke SendMessage, [mcihwnd], WM_CLOSE, 0, 0
        invoke  EndDialog,[hwnddlg],0
  processed:
        mov     eax,1
  finish:
        pop     edi esi ebx
        return
endp
proc test_browse,hDlg, buf4
        .bi  OPENFILENAME
        .pv  rd 1
        .buffer: times 512 db ?
    enter
    push ebx
    push edi
    lea  ebx, [.bi]
    invoke RtlZeroMemory,ebx,sizeof.OPENFILENAME

    mov  [ebx+OPENFILENAME.lStructSize],sizeof.OPENFILENAME
    mov eax, [hDlg]
    mov  [ebx+OPENFILENAME.hwndOwner],eax
    mov eax, [inst]
    mov [ebx+OPENFILENAME.hInstance],eax
    mov  [ebx+OPENFILENAME.lpstrFilter],AddFilter
    mov  [ebx+OPENFILENAME.lpstrFile],AddFileN
    mov  [ebx+OPENFILENAME.nMaxFile], 260
    mov  [ebx+OPENFILENAME.Flags], OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST+OFN_LONGNAMES+OFN_EXPLORER+OFN_HIDEREADONLY
    mov  [ebx+OPENFILENAME.lpstrTitle], AddTitle
    invoke GetOpenFileName, ebx
    cmp eax, 0
    je f
    invoke SendDlgItemMessage, [hDlg], IDC_LISTMP3, LB_GETCURSEL, 0, 0
    inc eax
    invoke SendDlgItemMessage, [hDlg], IDC_LISTMP3, LB_INSERTSTRING, eax, AddFileN
    invoke SendDlgItemMessage, [hDlg], IDC_LISTMP3, LB_SETCURSEL, eax, 0
  f:
  pop edi
  pop ebx
  return
endp

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL',\
          comdlg32, 'COMDLG32.dll',\
          MSVFW32,'msvfw32.dll',\
          comctl32,'comctl32.dll'

  include '\apia\kernel32.inc'
  include '\apia\user32.inc'
  include '\apia\comdlg32.inc'
  include '\apia\msvfw32.inc'
  include '\apia\comctl32.inc'

section '.rsrc' resource data readable

  directory RT_DIALOG,dialogs,\
            RT_ICON,icons,\
            RT_GROUP_ICON,group_icons,\
            RT_MENU,menus

  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration

  resource icons,\
           3,LANG_NEUTRAL,icon_data

  resource group_icons,\
           4,LANG_NEUTRAL,main_icon

  resource menus,\
           5,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu

  icon main_icon,icon_data,'icon.ico'

  dialog demonstration,'','MP3 Player',10, 10, 178, 200,WS_CAPTION+DS_CENTER+WS_SYSMENU
  dialogitem 'STATIC','PlayList:',-1,3,27,70,8,WS_VISIBLE
  dialogitem 'LISTBOX','',IDC_LISTMP3,3,36,171,141,WS_VISIBLE+LBS_NOINTEGRALHEIGHT+LBS_NOTIFY+WS_HSCROLL+WS_VSCROLL+WS_TABSTOP
  dialogitem 'BUTTON','Play',IDOK,3,181,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
  dialogitem 'BUTTON','Stop',IDCANCEL,48,181,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
  dialogitem 'BUTTON','Continously',ID_TOPMOST,110,181,60,13,WS_VISIBLE+WS_TABSTOP+BS_AUTOCHECKBOX
  enddialog

  menu main_menu
       menuitem '',0,MFR_POPUP+MFR_END
                menuitem 'Add Track',5001,0
                menuitem 'Delete Track',5002,0
                menuseparator
                menuitem 'File Info',5003, MFR_END
    


I has tray to make "Mp3End" as the maximum range but i have problem how to convert from dword to word cause
invoke SendMessage, [hwndtrack],TBM_SETRANGE,TRUE, lparam<== dword of min and max range

so i try another way that i set range between 0 - 1000 and tray this

[pos/Mp3End]*1000

Code:
push ecx
push eax
mov eax, [pos]
mov ecx, [Mp3End]
div ecx
mov ecx,1000
mul ecx
pop ecx
pop eax
    

but this code give an error in "div" code

can anybody help solve this problem.

my regard
Senolc_eht

ps: if get error in the dialog demonstration,'','MP3 Player',10, 10, 178, 200,WS_CAPTION+DS_CENTER+WS_SYSMENU tray change to dialog demonstration,'MP3 Player',10, 10, 178, 200,WS_CAPTION+DS_CENTER+WS_SYSMENU


Description: include for mci cons create by Lord Rhesus
Download
Filename: mci.inc
Filesize: 2.64 KB
Downloaded: 290 Time(s)

Description: include file for msvfw32.dll function
Download
Filename: msvfw32.inc
Filesize: 1.66 KB
Downloaded: 280 Time(s)


_________________
sorry if i always asking.....
Post 03 Dec 2005, 03:57
View user's profile Send private message Yahoo Messenger Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 03 Dec 2005, 09:53
Quote:
I has tray to make "Mp3End" as the maximum range but i have problem how to convert from dword to word cause
invoke SendMessage, [hwndtrack],TBM_SETRANGE,TRUE, lparam<== dword of min and max range

if you wan't to set range from 0 to Mp3End, then:
Code:
mov eax,[Mp3End]
shl eax,16   ; shift value to high word
invoke SendMessage, [hwndtrack],TBM_SETRANGE,TRUE, eax    
Post 03 Dec 2005, 09:53
View user's profile Send private message Visit poster's website Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 07 Mar 2006, 04:48
Thanks for the help...
Post 07 Mar 2006, 04:48
View user's profile Send private message Yahoo 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.