|
General Talk And Support General talk and peer-to-peer support about BS.Player and other video and audio multimedia players. |
| LinkBack | Thread Tools | Search this Thread | Display Modes |
| |||
BSP_GetFileName and VB 6 Public Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As Long) As Long Public Declare Function CopyDataSendMessage Lib "user32" Alias _ "SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByRef lParam As COPYDATASTRUCT) As Long Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _ (ByVal lpString1 As String, ByVal lpString2 As String) _ As Long Public Type COPYDATASTRUCT dwData As Long cbData As Long lpData As Long End Type Public Const WM_COPYDATA = &H4A Public Const BSP_GetFileName = &H1010B Public bspClass As String Public hWndBSPlayer As Long Public RetVal As Long Public Function BSGetCurrentFile() As String Dim nullpos As Integer bspClass = "BSPlayer" hWndBSPlayer = FindWindow(bspClass, 0) If hWndBSPlayer = 0 Then 'can't find BSPlayer BSGetCurrentFile = "" Exit Function End If Dim buffer As String * 256 Dim cds As COPYDATASTRUCT cds.dwData = BSP_GetFileName cds.lpData = lstrcpy(buffer, buffer) ' Copies filename to itself. Nothing happens, but returns the address for the pointer to the string! cds.cbData = 4 RetVal = CopyDataSendMessage(hWndBSPlayer, WM_COPYDATA, Form1.hwnd, cds) nullpos = InStr(buffer, Chr(0)) If nullpos > 1 Then BSGetCurrentFile = Left(buffer, nullpos - 1) End Function the code executes correctly and CopyDataSendMessage returns a value of 1 but the currently open filename isn't returned. I'm using BSPlayer Pro Version 1.22 Build 817, 24. Feb 2005. I am using a very similar routine to open a file, and that works fine. Any help would be appreciated. |
| |||
Ok ignore the previous. I should have been using varptr to get a pointer to buffer and for some reason it doesn't work with a fixed length string. However it now returns a value which contains only question marks followed by an I. eg. ????????????i. Having searched through previous posts I found that someone else is having the same problem. Does anyone have a fix? |
| |||
Can you post your routine to open a file? Thanks P.S. I'm trying to find a solution to this problem, but I have no time now... If I can resolve this I'll make you know!
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
Routine to open file as requested: Public Sub BSPAddFile(filename As String) ' Adds a file to the playlist hWndBSPlayer = FindWindow(bspClass, 0) If hWndBSPlayer = 0 Then 'can't find BSPlayer Exit Sub End If Dim cds As COPYDATASTRUCT cds.dwData = BSP_OpenFile cds.lpData = lstrcpy(filename, filename) ' Copies filename to itself. Nothing happens, ' but returns the address for the pointer to the string! cds.cbData = Len(filename) + 1 RetVal = CopyDataSendMessage(hWndBSPlayer, WM_COPYDATA, 0&, cds) End Sub |
| ||||
Is this post perhaps of any use to you?
__________________ Help2Help (click) BSplayer: simply the best & most versatile (Build 1072 Dutch language here!) When posting always mention your computer's OS and the version and build number(!) of BS.Player as used by you, as well as - if applicable and especially when encountering problems - the type(s) of the file(s) mentioned in your post. Private messages/Visitor messages are NOT for seeking personal help with respect to BS.Player! Instead use the forums! |
| |||
Unfortunally it didn't help me... :( But thanks for the link :) Quote:
@immortal Thank you for providing the OpenFile code, my fault was that I used VarPtr instead of lstrcpy... :P Thank you. I hope someone will solve the retrive filename issue
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
I encountered other problems with the SendMessage call. For BSP_GetSkin the behaviour is the same as for BSP_GetFileName. Every time I send a seeking position to BSplayer with the BSP_Seek message, BSplayer seek bar moves to time 00:20:40. The same behaviour for the BSP_SetVol message, but this time BSplayer goes to 100% Volume level. No problems with BSP_GETVERSION, BSP_OpenFile (thanks to immortal), BSP_GetMovLen, BSP_GetMovPos, BSP_GetVol, BSP_SetSkin, BSP_LoadSub, BSP_LoadAudio, BSP_LoadPlaylist, BSP_LoadPlaylistInt and with all BSP_(action) actions. The only Action I can't use is BSP_VolUp. When I send this action (BSP_VolUp=1) BSplayer does nothing. With BSP_GetStatus I have a strange behaviour: I get the STOP, PLAY and PAUSE status, but Instead of "No movie open" (value=4) I get value=-1 ....
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
I don't know anything about VB, but I just want to report that I don't have problems using BSP_GetFileName with C++. This does not solve your problem, but at least you know it's not a bug in BSplayer. Rafke P. |
| |||
In fact I think it's a VB problem, or (maybe ONLY) our fault. It seems like the handle of the program is passed in a bad way (this is my conclusion after reading the post linked by BSPeter, and since the BSP_GetSkin and BSP_GetFileName commands are the only ones that require the program to send BSplayer its handle)... but I don't know why (I'm not a skilled programmer) If anybody can tell me something about BSP_Seek and BSP_SetVol commands (if you Rafke want to try them, and maybe also BSP_GetStatus, in c++) I will know if it's a BSplayer or VB problem. Thank you :) bye
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
Tizio, I will try the other commands in the following days. This is the way I send the message in C++ : Code: SendMessage(bsp_hand,WM_COPYDATA,WPARAM(appHWND),(LPARAM)&cds); I will report back on the other commands. Rafke EDIT: I just tried the GetStatus command and I can confirm the behaviour you're seeing : when no file is open the command returns -1 EDIT2: The SetVol command is working, but the volume slider on the skin doesn't follow.The volume, however, is set correctly. |
| |||
Thank you Rafke for your tests!! Yes, it's typecasting (AFAIK), but I don't know how to cast a WPARAM in VB, have to search the web . For cds (I think) I don't need to typecast since it works ok with OpenFile and SetSkin... For SetVol I have to try a different way, but I don't think it's the correct one :?.. we will see... I'm "glad" to know that at least the GetStatus command doesn't work also with C++ (it's not my fault :) ) Thak you again :D
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
Ok, BSP_SetVol and BSP_Seek now work perfectly (my error was that I sent the address of the value and not the value itself to BSplayer :P ). And I can confirm that the volume slider on the skin doesn't follow the volume level (and no OSD about volume changes are shown). I tried typecasting my appHWND, but it didn't work :( ... WPARAM is (in Win32 systems) a 32bit value passed as a parameter to a window procedure or callback function, and my appHWND (Form1.hWnd) is a Long value (4byte=32bit), but with value between -2.147.483.648 and 2.147.483.647, so I typecasted it to Single (4byte=32bit), which has values between -3,402823E38 and -1,401298E-45 for negative values and between 1,401298E-45 and 3,402823E38 for positive values (but since the handle has no decimals it's of no use typecating this way...). BTW, the value sent to BSplayer is a 32bit value, the same as WPARAM typecasted values... and the handle value is correct (I checked it with other programs that retrieve the program handle)... I have no more ideas :? Now the only problematic commands are: BSP_GetSkin, BSP_GetFileName and BSP_VolUp. Bye
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
Today I tested GetSkin and VolUp. Both work as they should. With the VolUp even the volume slider on the skin works. I still have one idea left for you and the topicstarter: maybe you are passing the wrong handle (all the rest looks OK to me). Output the handle somewhere (in a textbox or something) and then check with another application. @Tizio, since you know Girder you can use that to check the handle : add a new command go to targetting options and drag the crosshair to your application check what handle corresponds to the result. I know Girder is not made for these sort of things, but it was the first that came to mind. I tested it and it works, but feel free to use what you like. Rafke |
| |||
Quote:
Thank you anyway for the suggestion :) VolDown works perfectly for me, and the volume slider moves while I change the volume value, but (I don't know why) VolUp doesn't work. And I've noticed that also BSP_OpenSub = 62 doesn't work, while BSP_LoadSub works.... :shock: :roll: I don't know what to do (I will pass to c++ when I will have more time :) )
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
I don't know if this will make any sense (I had too much wine and know [censored] about VB), but maybe it helps. Compare your code to the c++ code Code: cds.lpData = lstrcpy(buffer, buffer) ' Copies filename to itself. Nothing happens, but returns the address for the pointer to the string! Now here is the C++ code Code: adr=&buf; cds.lpData=&adr; adr contains the adress of the pointer to buffer, but lpData contains the adress of the pointer to the adres of the pointer to the buffer I tried to fix it in VB6 and didn't succeed, but I hope this is somehow of use to you. Rafke P. EDIT:On a more sober note: this doesn't explain why the open file is working though. |
| |||
Thank you Rafke for the clues, but it seems I can't obtain the address of the variable (only the pointer to it). And searching on the web I found bad behaviours with VB when you try to send API calls by sending the pointer or the address of a variable (plus VB uses UNICODE strings, instead of ANSI that are used for API calls, but neither canverting the string to ANSI works)... I have an idea, maybe to read the portion of memory of the pointer sent to BSplayer, but I have no time at the moment.. (There are a lot of problems when the few things you know are self and quick learned :roll: and that is my VB knowledge)
__________________ BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer BSP Definitions Manager (v1.02) BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051) |
| |||
Re:BSP_GetFileName and VB 6
This the correct method. Try it and tell me if it works. Public Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As Long) As Long Public Declare Function CopyDataSendMessage Lib "user32" Alias _ "SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByRef lParam As COPYDATASTRUCT) As Long Public Type COPYDATASTRUCT dwData As Long cbData As Long lpData As Long End Type Public Const WM_COPYDATA = &H4A Public Const BSP_GetFileName = &H1010B Public bspClass As String Public hWndBSPlayer As Long Public RetVal As Long Public Function BSGetCurrentFile() As String Dim nullpos As Integer bspClass = "BSPlayer" hWndBSPlayer = FindWindow(bspClass, vbNullString) If hWndBSPlayer = 0 Then 'can't find BSPlayer BSGetCurrentFile = "" Exit Function End If Dim buffer As String Dim cds As COPYDATASTRUCT buffer = Space$(256) cds.dwData = BSP_GetFileName cds.lpData = VarPtr(buffer) cds.cbData = 4 RetVal = CopyDataSendMessage(hWndBSPlayer, WM_COPYDATA, Form1.hwnd, cds) buffer = StrConv(buffer, vbUnicode) nullpos = InStr(buffer, vbNullChar) If nullpos > 1 Then BSGetCurrentFile = Left(buffer, nullpos - 1) End Function |
Tags |
bspgetfilename |
Thread Tools | Search this Thread |
Display Modes | |
| |