Fehler in Programm mit MCI (WinAPI-MASM32 Easy Code)

Hier könnt ihr sowohl zur x86 Architektur als auch zu Win32ASM Fragen stellen.

Moderatoren: crack, Krüsty, Marwin

Fehler in Programm mit MCI (WinAPI-MASM32 Easy Code)

Beitragvon c.m.obrecht » Dienstag 15. Juli 2008, 09:29

Ich habe dieses Programm mit Hilfe von EasyCode MASM erstellt. Für die mciSendString-Funktion "play MyAlias from" habe ich Code aus einem funktionierenden Programm genommen, einem Vorgänger wo jeweils bei Knopfdruck 10 Sek. gesprungen wurde; allerdings funktioniert diese Funktion da nicht... Sollte wie beim Media Player bei Ziehen des Trackbars zu der gewünschten Position springen. Es geschieht allerdings einfach nichts; wenn ich eine MessageBox anzeigen lasse beim Ziehen erscheint diese.
Code: Alles auswählen
forward DB " play MyAlias from ", 0
sforward DB 255 Dup(?), 0
curpos Proc

invoke mciSendString, addr cpos, addr spos, 255, 0
invoke StrToInt, addr spos
mov zahlpos, eax
ret
curpos EndP
setpos Proc
Invoke GetWindowItem, winhWnd, IDC_WINDOW1_SLIDER2
Invoke SendMessage, Eax, TBM_GETPOS, TRUE, NULL

Invoke wsprintf, Addr pos, Addr sformat, Eax
Invoke mciSendString, Addr forward, Addr pos, 0, 0
;Invoke MessageBox, 0, Addr forward, Addr pos, 0
ret
setpos EndP

goback Proc

Mov Eax, zahlpos
sub eax, tensec
invoke wsprintf, addr sforward, addr sformat, eax
Invoke mciSendString, Addr forward, Addr sforward, 0, 0
Invoke MessageBox, 0, Addr forward, Addr sforward, 0
ret
goback endp

Window1Slider2 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

.If uMsg == WM_LBUTTONUP



         Call setpos



      .EndIf


und der gesamte Quellcode (Design des Forms ist nicht ersichtlich da mit Formdesigner erstellt)

Code: Alles auswählen
Include   comdlg32.inc
IncludeLib   Comdlg32.lib

Include   shell32.inc
IncludeLib   shell32.lib

Include   \masm32\include\winmm.inc
includelib \masm32\lib\winmm.lib

includelib \masm32\lib\shlwapi.lib
include \masm32\include\shlwapi.inc

.Const

.Data?
szFileName DB 255 Dup(?), 0
szFehler DB 100 Dup(?), 0
winhWnd DD ?

spos DB 255 Dup (?), 0
zahlpos DD ?
zahl DD ?
laenge DD ?
sBuffer DB 255 Dup(?), 0

volstr DB 4 Dup(?), 0
pos DB 255 Dup (?), 0

sforward DB 255 Dup(?), 0
.Data

inull DD 0
status DB "status MyAlias length", 0
cpos DB "status MyAlias position ",0
fehler DB "Fehler bein Öffnen der Datei/keine kompatible Mediendatei oder von dieser Windows-Version nicht unterstützt", 0
sformat DB "%i", 0
mcivolstr DB "setaudio MyAlias volume to ", 0
infoTitel DB "geöffnete Datei", 0

tensec DD 10000
forward DB " play MyAlias from ", 0

ofn                  OPENFILENAME   <0>

open1 DB "open ", 1024 Dup(?), 0
open2 DB " type MPEGVideo alias MyAlias",0         
play DB "play MyAlias",0
stop DB "stop MyAlias",0
filename DB 1024 dup(?)
close DB "close MyAlias", 0
mci3 DB 0

.Code

Window1Procedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   .If uMsg == WM_CREATE
 Mov Eax, hWnd
 Mov winhWnd, Eax
 Invoke DragAcceptFiles, Eax, 255
      Return TRUE

      .ElseIf uMsg == WM_VSCROLL

Call setvolume




.ElseIf uMsg == WM_TIMER
 .If wParam == 1
    Call curpos
    Invoke GetWindowItem, winhWnd, IDC_WINDOW1_SLIDER2
    Invoke SendMessage, Eax, TBM_SETPOS, zahlpos, zahlpos



.EndIf


.ElseIf uMsg == WM_DROPFILES
   Mov szFileName, 0
        Invoke DragQueryFile, wParam, 0, Addr szFileName, SizeOf szFileName
      invoke mciSendString, ADDR stop, ADDR mci3,0,0
    Invoke mciSendString, Addr close, Addr mci3, 0, 0


        Jmp abspielen


   .ElseIf uMsg == WM_CLOSE
      Invoke mciSendString, Addr stop, Addr mci3, 0, 0
        Invoke mciSendString, Addr close, Addr mci3, 0, 0
      Invoke IsModal, hWnd
      .If Eax
         Invoke EndModal, hWnd, IDCANCEL
         Return TRUE
      .EndIf

      .ElseIf uMsg == WM_COMMAND
         Mov Eax, wParam
         .If Ax == IDC_WINDOW1_BUTTON1
            Shr Eax, 16

            .If Ax == BN_CLICKED

Mov ofn.lStructSize, SizeOf OPENFILENAME
    ;Push hParent
     ;Pop ofn.hWndOwner
    ;Push hInstance
    ;Pop ofn.hInstance
    ;Push lpFilter
    ;Pop ofn.lpstrFilter
    Push Offset szFileName
    Pop ofn.lpstrFile
    Mov ofn.nMaxFile, SizeOf szFileName
   ; Push lpTitle
   ; Pop ofn.lpstrTitle
    Mov ofn.Flags,              OFN_EXPLORER or OFN_FILEMUSTEXIST or \
                                OFN_LONGNAMES


        Invoke GetOpenFileName, Addr ofn
        Invoke mciSendString, Addr stop, Addr mci3, 0, 0
        Invoke mciSendString, Addr close, Addr mci3, 0, 0
abspielen: Mov open1[5], 0       ;open ,0 und nicht weiter, string leeren
Invoke GetShortPathName, Addr szFileName, Addr filename, 255
Lea Esi, open1
 FindLastByte:
  lodsb
  Or al, al
  jnz FindLastByte
 
  dec esi
  mov edi, esi
  lea esi, filename
  CatStrings:
  lodsb
  Or al, al
  jz Done
  stosb
  jmp CatStrings
 
 Done:
  mov al, 0
  stosb


                 ;Start:     
  lea esi, open1
 FindLastByte2:
  lodsb
  Or al, al
  jnz FindLastByte2
 
  dec esi
  mov edi, esi
  lea esi, open2
  CatStrings2:
  lodsb
  Or al, al
  jz Done2
  stosb
  jmp CatStrings2
 
 Done2:
  mov al, 0
  stosb

            lea eax, open1
                   
            invoke mciSendString, eax, ADDR mci3,0,0
                                   
           
                lea ebx, mci3
                lea eax, play
                Invoke mciSendString, Eax, Ebx, 0, 0
                Cmp Eax, 0
                Je ok
                Invoke mciGetErrorString, Eax, Addr szFehler, 100
                Invoke MessageBox, winhWnd, Addr szFehler, Addr fehler, MB_OK Or MB_ICONERROR

ok:  Call setvolume
     Call getlength
     
     Invoke GetWindowItem, winhWnd, IDC_WINDOW1_SLIDER2

     Invoke SendMessage, Eax, TBM_SETRANGEMAX, NULL, laenge
;Invoke SetScrollRange, Eax, TBHSCROLL, inull, laenge, FALSE ;ebenfalls falsch


.EndIf
.EndIf

.If Ax == IDC_WINDOW1_BUTTON2
            Shr Eax, 16

            .If Ax == BN_CLICKED

              Invoke mciSendString, Addr stop, Addr mci3, 0, 0
              Invoke mciSendString, Addr close, Addr mci3, 0, 0
            .EndIf
            .EndIf

             


.If Ax == IDC_WINDOW1_BUTTON3
            Shr Eax, 16

            .If Ax == BN_CLICKED

              Invoke mciSendString, Addr stop, Addr mci3, 0, 0

            .EndIf
            .EndIf

            .If Ax == IDC_WINDOW1_BUTTON4
            Shr Eax, 16

            .If Ax == BN_CLICKED

              lea ebx, mci3
                Lea Eax, play
                Invoke mciSendString, Eax, Ebx, 0, 0
                Call setvolume
            .EndIf
            .EndIf

            .If Ax == IDC_WINDOW1_BUTTON5
               Shr Eax, 16
               .If Ax == BN_CLICKED
                  Invoke mciSendString, Addr stop, Addr mci3, 0, 0
        Invoke mciSendString, Addr close, Addr mci3, 0, 0
                     Jmp abspielen
                  .EndIf
                  .EndIf

                  .If Ax == IDC_WINDOW1_BUTTON6
               Shr Eax, 16
               .If Ax == BN_CLICKED
                  Invoke MessageBox, 0, Addr szFileName, Addr infoTitel, MB_ICONINFORMATION
                  .EndIf
                  .EndIf

                  .If Ax == IDC_WINDOW1_BUTTON7
            Shr Eax, 16

            .If Ax == BN_CLICKED

              Call goback
            .EndIf
            .EndIf

            .If Ax == IDC_WINDOW1_BUTTON8
            Shr Eax, 16

            .If Ax == BN_CLICKED

             
            .EndIf
            .EndIf

     


   .EndIf
   Return FALSE
Window1Procedure EndP
setvolume Proc
   Mov mcivolstr[28], 0
   Mov volstr, 0000
Invoke GetWindowItem, winhWnd, IDC_WINDOW1_SLIDER1
Invoke SendMessage, Eax, TBM_GETPOS, TRUE, NULL
Invoke wsprintf, Addr volstr, Addr sformat, Eax

Lea Esi, mcivolstr
FindLastByte3:
  lodsb
  Or al, al
  Jnz FindLastByte3
 
  dec esi
  mov edi, esi
  Lea Esi, volstr
CatStrings1:
  lodsb
  Or al, al
  Jz Done1
  stosb
  Jmp CatStrings1
 
Done1:
  mov al, 0
  stosb


                 ;Start:     
  lea esi, open1
 FindLastByte2:
  lodsb
  Or al, al
  jnz FindLastByte2
 
  dec esi
  mov edi, esi
  lea esi, open2
CatStrings3:
  lodsb
  Or al, al
  Jz Done3
  stosb
  Jmp CatStrings3
 
Done3:
  mov al, 0
  stosb
Lea Eax, mcivolstr

Invoke mciSendString, Eax, 0, 0, 0
Ret
setvolume EndP
getlength Proc

invoke mciSendString, addr status, addr sBuffer,255, 0

invoke StrToInt, addr sBuffer

 
mov laenge, eax
ret
getlength endp

curpos Proc

invoke mciSendString, addr cpos, addr spos, 255, 0
invoke StrToInt, addr spos
mov zahlpos, eax
ret
curpos EndP
setpos Proc
Invoke GetWindowItem, winhWnd, IDC_WINDOW1_SLIDER2
Invoke SendMessage, Eax, TBM_GETPOS, TRUE, NULL

Invoke wsprintf, Addr pos, Addr sformat, Eax
Invoke mciSendString, Addr forward, Addr pos, 0, 0
;Invoke MessageBox, 0, Addr forward, Addr pos, 0
ret
setpos EndP

goback Proc

Mov Eax, zahlpos
sub eax, tensec
invoke wsprintf, addr sforward, addr sformat, eax
Invoke mciSendString, Addr forward, Addr sforward, 0, 0
Invoke MessageBox, 0, Addr forward, Addr sforward, 0
ret
goback endp

Window1Button1 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button1 EndP


Window1Button2 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

   Return FALSE
Window1Button2 EndP

Window1Slider1 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Slider1 EndP

Window1Static1 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Static1 EndP

Window1Button3 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button3 EndP

Window1Button4 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button4 EndP


Window1Static2 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Static2 EndP

Window1Static3 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Static3 EndP

Window1Slider2 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

.If uMsg == WM_LBUTTONUP



         Call setpos



      .EndIf

   Return FALSE
Window1Slider2 EndP

Window1Button5 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button5 EndP

Window1Button6 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button6 EndP

Window1Button7 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button7 EndP

Window1Button8 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   Return FALSE
Window1Button8 EndP
c.m.obrecht
Newbie
 
Beiträge: 4
Registriert: Montag 5. März 2007, 13:45

Zurück zu Assembler

 


  • { RELATED_TOPICS }
    Antworten
    Zugriffe
    Letzter Beitrag

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder

cron