All pastes #1470964 Raw Edit

segin

public text v1 · immutable
#1470964 ·published 2009-06-23 10:56 UTC
rendered paste body
Function WAIntProc StdCall(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
	Printf(!"hwnd = %#x, umsg = %d, wParam = %#x, lParam = %#x\n",hWnd, uMsg, wParam, lParam)
	Static As Integer msgptr, lastcall
	Static As ZString * 4096 buf
	Select Case uMsg
		Case 273 ' Remote control function s
			Select Case As Const wParam
				Case &h9c70
					doCommand = PSYMP3_PLAY_NEXT
				Case &h9c6d
					If isPaused = 1 Then doCommand = PSYMP3_PAUSE
				Case &h9c6e
					doCommand = PSYMP3_PAUSE
				Case &h9c6f
					doCommand = PSYMP3_STOP
				Case &h9c6c
					doCommand = PSYMP3_PLAY_PREV
			End Select
		Case WM_USER
			'printf(!"WM_USER caught.\n")
			If wParam = KVIRC_WM_USER Then
				Select Case lParam 
					Case KVIRC_WM_USER_CHECK
						Return KVIRC_WM_USER_CHECK_REPLY
					Case KVIRC_WM_USER_GETTITLE
						lastcall = KVIRC_WM_USER_GETTITLE
						buf = mp3artist + " - " + mp3name
						Return Len(buf)
					Case KVIRC_WM_USER_GETFILE
						lastcall = KVIRC_WM_USER_GETTITLE
						' TODO: Sanitize output
						Dim As Integer i
						buf = ""
						For i = 0 To Len(mp3file) - 1
							Select Case mp3file[i]
								Case 32
									buf &= "%20"
								Case Asc("\")
									buf &= "/"
								Case Asc("[")
									buf &= "%5b"
								Case Asc("]")
									buf &= "%5d"
								Case Else
									buf &= Chr(mp3file[i])
							End Select
						Next
						'buf = mp3file
						Return Len(buf)
					Case KVIRC_WM_USER_TRANSFER To KVIRC_WM_USER_TRANSFER + 4096 
						msgptr = lParam - KVIRC_WM_USER_TRANSFER
						Return buf[msgptr]
				End Select
			EndIf
			Select Case lParam
				Case 106
					Return FSOUND_Stream_SetTime(stream, wParam)
				Case 125 ' IPC_GETLISTPOS
					Return Songlist.getPosition()
				Case 124 ' IPC_GETLISTLENGTH
					Return Songlist.getEntries()
				Case 105 ' IPC_GETOUTPUTTIME
					Select Case wParam
						Case 0 ' Current playing time in msec.
							Return FSOUND_Stream_GetTime(stream)
						Case 1 ' Length of song in seconds.
							Return Int(FSOUND_Stream_GetLengthMs(stream)/1000)
					End Select
				Case 251 ' IPC_GET_REPEAT
					Return doRepeat
				Case 253 ' IPC_SET_REPEAT
					If wParam = 0 Or wParam = 1 Then doRepeat = wParam
				Case 104 ' IPC_ISPLAYING
					Select Case As Const isPaused
						Case 1
							Return 3
						Case 0
							Return 1
						Case 2
							Return 0
					End Select
				Case Else
					Return 0
			End Select
		Case WM_GETMINMAXINFO
			' printf(!"WM_GETMINMAXINFO caught.\n")
			Return 0
		Case Else
			Return DefWindowProc(hWnd, uMsg, wParam, lParam)
	End Select
End Function