sunghsia
µù¥U®É¶¡: 2003-06-13 ¤å³¹: 52 ¨Ó¦Û: ¥x¥_
²Ä 1 ¼Ó
|
µoªí©ó: ¬P´Á¤» ¤E¤ë 24, 2005 8:54 pm ¤å³¹¥DÃD: ±±¨î Wave Volumn µ¶q |
|
|
****************************************************************************************
* ¦©¹ô¦Ü *.prg ©Î WaveVolumnµ¶q±±¨î.prg
* ±ýÂ÷¶}µ{¦¡®É, ½ÐÂIÀ»[®ØªºªÅ¥Õ¦a¤è]
* ¥»µ{¦¡¦³¤@¤p¯ÊÂI,·íµ¶q½Õ¦Ü³Ì¤p®É,¥¿Å¦³®É·|[¼È®É]¿ù»~
* §ä¤F«Ü¤[,³£¨S¦³¬Ý¨ì¥Îvfp±±¨îwaveµ¶qªºµ{¦¡,©Ò¥H½Ð¤j®aÀH«K¶K,»¡¤£©w¦³¤H¥¿¶·n¦¹¤pµ{¦¡
****************************************************************************************
ouserform=CREATEOBJECT ("userform")
ouserform.SHOW
DEFINE CLASS userform AS form
name="Form1"
caption="Form1"
left=47
top=46
width=100
height=173
maxbutton=.F.
closable=.F.
showwindow=2
showtips=.T.
visible=.T.
add object shpae1 AS Shape with left=0,top=0,width=94,height=170, backstyle=0, specialEffect=0, tooltiptext="ÂIÀ»Â÷¶}!!"
add object shpae2 AS Shape with left=7,top=72,width=80,height=2, specialEffect=0
add object label1 AS Label with left=10,top=12,autosize=.T. , caption=[Wave Output]
add object label2 AS Label with left=10,top=28,autosize=.T. , caption=[¥¿Å]
add object label3 AS Label with left=10,top=80,autosize=.T. , caption=[µ¶q]
add object timer1 AS Timer with enabled=.F. , interval=200
PROCEDURE INIT
this.addobject ("HSlider" , "Slider" , "COMCTL.Slider.1") &&«Ø¥ß Slider ª«¥ó
this.HSlider.move(16,40,58,30)
this.HSlider.min= -32767
this.HSlider.max= 32767
this.HSlider.tickStyle=3
this.addobject ("VSlider" , "Slider" , "COMCTL.Slider.1") &&«Ø¥ß Slider ª«¥ó
this.VSlider.move(32,92,76,76)
this.VSlider.min= -32767
this.VSlider.max= 32767
this.VSlider.tickStyle=3
this.VSlider.orientation=1
DECLARE INTEGER waveOutGetVolume IN winmm INTEGER hwo, INTEGER @ pdwVolume
DECLARE INTEGER waveOutSetVolume IN winmm INTEGER hwo, INTEGER dwVolume
this.timer1.enabled=.T.
* ------- ¤U±ªºµ{¦¡½X,·|¦Û°Ê¶}±Òwindowsªºµ¶q±±¨î,±zn¬Oı±o·Ð,¥i¥H§â¥¦mark ------
DECLARE INTEGER ShellExecute IN shell32 INTEGER, STRING, STRING, STRING, STRING, INTEGER
DECLARE INTEGER GetWindowsDirectory IN kernel32 STRING @ lpBuffer, INTEGER nSize
p=space(254)
L = GetWindowsDirectory (@p,255)
p= left(p,L)
if file("&p\Sndvol32.exe")
= ShellExecute (0, "open", "&p\Sndvol32.exe", "", "", 1)
endif
* ----------------------------------------------------------------------
ENDPROC
PROCEDURE ERROR
LPARAMETERS nError, cMethod, nLine
messagebox("¿ù»~½X: "+ltrim(str(nError))+chr(13)+Message()+chr(13)+chr(13)+"½Ð¦w¸Ë ActiveX"+chr(13)+" (©Î)"+chr(13)+"±N PROCEDURE INIT ¨Æ¥óùتº COMCTL.Slider.1 ´«¦¨ MSComctlLib.Slider.2 ¸Õ¸Õ",16)
QUIT
ENDPROC
PROCEDURE ACTIVATE
_screen.windowstate=1
_screen.visible=.F.
READ EVENTS
ENDPROC
PROCEDURE shpae1.CLICK &&Â÷¶}
RELEASE DLL
CLEAR EVENTS
_screen.visible=.T.
_screen.windowstate=2
ENDPROC
PROCEDURE Timer1.Timer
thisform.¨ú±oµ¶q
ENDPROC
PROCEDURE ¨ú±oµ¶q
DECLARE RtlMoveMemory IN kernel32 As CopyMemory STRING @ Destination, INTEGER @ Source, INTEGER nLength
sVolume = 0
= waveOutGetVolume (-1, @sVolume)
iVol = REPL(chr(0),4)
= CopyMemory (@iVol, sVolume, len(iVol))
lVol = this.buf2word(left(iVol,2))
rVol = this.buf2word(right(iVol,2))
lVol= iif(lVol<0 , lVol+65536 , lVol)
rVol= iif(lVol<0 , rVol+65536 , rVol)
vMax = max(lVol , rVol)
do case
case rVol > lVol
this.HSlider.Value = 32767 * (vMax - lVol) / vMax
case lVol > rVol
this.HSlider.Value = -32767 * (vMax - rVol) / vMax
case rVol = lVol
this.HSlider.Value = 0
endcase
vMax = vMax - 32768
this.VSlider.Value = -vMax
ENDPROC
PROCEDURE ³]©wµ¶q
DECLARE RtlMoveMemory IN kernel32 As CopyMemory INTEGER @ Destination, STRING @ Source, INTEGER nLength
vMax = -this.VSlider.Value + 32768
if this.HSlider.Value < 0
lVol = vMax
rVol = vMax * (this.HSlider.Value + 32767) / 32767
else
rVol = vMax
lVol = vMax * Abs(this.HSlider.Value - 32767) / 32767
endIf
lVol = iif(lVol>32767 , lVol-65536 , lVol) && lVol = val(str( iif(lVol>32767 , lVol-65536 , lVol) ))
rVol = iif(rVol>32767 , rVol-65536 , rVol) && ""
sVol = 0
iVol = left(this.num2Dword(lVol),2) + left(this.num2Dword(rVol),2)
= CopyMemory (@sVol, iVol, len(iVol))
= waveOutSetVolume (-1, sVol)
ENDPROC
PROCEDURE buf2word (lcBuffer)
RETURN asc(substr(lcBuffer, 1,1)) + asc(substr(lcBuffer, 2,1)) * 256
ENDPROC
PROCEDURE num2Dword (tnNum)
lcresult = chr(0)+chr(0)+chr(0)+chr(0)
local c0,c1,c2,c3
c3 = chr(int(tnNum/(256^3)))
tnNum = mod(tnNum,256^3)
c2 = chr(int(tnNum/(256^2)))
tnNum = mod(tnNum,256^2)
c1 = chr(int(tnNum/256))
c0 = chr(mod(tnNum,256))
RETURN c0+c1+c2+c3
ENDPROC
ENDDEFINE
DEFINE CLASS Slider AS OLEcontrol
visible=.T.
PROCEDURE MouseDOWN
LPARAMETERS button, shift, x, y
thisform.timer1.enabled=.F.
ENDPROC
PROCEDURE mouseUP
LPARAMETERS button, shift, x, y
thisform.³]©wµ¶q
thisform.timer1.enabled=.T.
ENDPROC
ENDDEFINE |
|