View Full Version : Any Visual Basic programmers out there?
Ximo
29th December 2001, 23:35
I'm making a plugin for :winamp: using Visual Basic and GenWrapper, and I've come across some problems and found a workaround for most. So I would like to know if there are any other Visual Basic programmers out there that has made plugins for :winamp:, and if there are any, what problems have you come across?
Visual Basic is the world's most popular programming language, :winamp: is the world's most popular audio player and Mike's the world's most famous Llama, so there are probably a lot of peeps that can make plugins for :winamp: in VB! if there were more documentation and examples on making :winamp: plugins, we would probably get more plugins :up:
So - can anybody who has made a :winamp: plugin in Visual Basic share their knowledge and experiences? Alright then, I'll start!!
Problem: Non-modal forms (forms that aren't on top of another, like messageboxes) aren't allowed with VB ActiveX plugins, so you have to show forms like Form1.Show 1. That makes your forms on top of :winamp: and the user can't use :winamp: while your form is shown. Somehow this isn't the same for the Configure form which can be non-modal.
Workaround: Nope.. I put an icon in systray for my plugin instead, but some probably need a nonmodal form.
Problem: Since non-modal forms aren't allowed, you can't use the MsgBox function to show a messagebox either! Only in your Configure form which is non-modal..
Workaround: Nada.. no way to bug the user! :mad:
Problem: If :winamp: is set to be Always On Top, my forms fall behind :winamp:'s windows even if they are modal.
Workaround: Yep! I've got a code that checks the state of the Always On Top switch on the clutterbar and sets your form on top if :winamp: is! it can check the state of any other button (shuffle, repeat ++) as well, really sweet!
And I've got a module (other than the one in NSDN) that communicates with :winamp: using the API calls + that it can check the state of :winamp:'s buttons.
That's all I could think of. If you've got anything to share please reply to this post and spread the wisdom. Especially if you know a way to make DLLs that work as plugins so I can forget about GenWrapper and non-modal forms :D
Pvs3
2nd January 2002, 02:31
I could only find the solution for one problem.
The Always Ont Top one.
I know winamp can be setted to be always on top
but so can your plugin (if you do not already know) :
Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Public Const HWND_TOPMOST = -1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
That should be written in a module
SetWindowPos Form.hwnd, HWND_TOPMOST, Form.Left / 15, _
Form.Top / 15, Form.Width / 15, _
Form.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
And that in the Form_Load sub.
I tried that GenWrapper.dll but you can not make a serious plugin with it. And I still make EXE plugins.
You should alse check out CallDlls.vbp in the samples directory.
But the other problems remain.:blah:
Check this Plugin. (http://users.rol.ro/pvs3/hardwarcontrolls.exe)
Ximo
2nd January 2002, 15:05
Yep, that's the code I used and it works perfectly! But if my form was on top and the user turned off Always On Top in Winamp, my form still remained on top while Winamp wasn't! So I modified a code I found that retrieves the status of a button or menu item, and using this you can make your form always on top if Winamp is, and not if Winamp isn't.. Voilá!
Put this at the top of a module:
Public Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Public Declare Function GetMenuState Lib "user32" _
(ByVal hmenu As Long, _
ByVal wID As Long, _
ByVal wFlags As Long) As Long
'These are the IPC names that you can retrieve the status for:
Public Const WA_TOGGLEPREFERENCES = 40012
Public Const WA_TOGGLEABOUT = 40041
Public Const WA_TOGGLEAUTOSCROLL As Long = 40189
Public Const WA_TOGGLEALWAYSONTOP As Long = 40019
Public Const WA_TOGGLEWINDOWSHADE As Long = 40064
Public Const WA_TOGGLEPLAYLISTWINDOWSHADE As Long = 40266
Public Const WA_TOGGLEDOUBLESIZE As Long = 40165
Public Const WA_TOGGLEEQ As Long = 40036
Public Const WA_TOGGLEPLAYLIST As Long = 40040
Public Const WA_TOGGLEMAINWINDOW As Long = 40258
Public Const WA_TOGGLEMINIBROWSER As Long = 40298
Public Const WA_TOGGLEEASYMOVE As Long = 40186
Public Const WA_TOGGLEREPEAT As Long = 40022
Public Const WA_TOGGLESHUFFLE As Long = 40023
'I copied these from the VB IPC module that you can find
'here: http://www.winamp.com/nsdn/vault/WinAMP_VB.jhtml
'That module lets you communicate with Winamp, neat!
And place this further down in the module:
Public Function GetButtonStatus(ButtonName As Long) As Integer
'Gets the status of a button, referenced by its IPC name.
'WinampID has to be Winamp's .hwnd. This can be found
'using the WinAMP_FindWindow function in the VB IPC
'module that you can download from NSDN's Code Vault
'here: http://www.winamp.com/nsdn/vault/WinAMP_VB.jhtml
Dim hmenu As Long
hmenu = GetSystemMenu(WinampID, 0)
If GetMenuState(hmenu, ButtonName, 0) = 8 Then
GetButtonStatus = 1
Else
GetButtonStatus = 0
End If
'Returns:
'0 if off
'1 if on
'-1 if error
End Function
To check if Winamp's playlist is shown:
If GetButtonStatus(TOGGLE_PLAYLIST) = 1 Then
MsgBox "The playlist is shown"
End If
If GetButtonStatus(TOGGLE_PLAYLIST) = 0 Then
MsgBox "The playlist is closed"
End If
And to set your form Always On Top if Winamp is, include the SetWindowPos code (see the post above) into the top of a module and put this in your form's Form_Load:
If GetButtonStatus(TOGGLE_ALWAYS_ON_TOP) = 1 Then
SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / 15, _
Me.Top / 15, Me.Width / 15, _
Me.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
End If
You should probably also put this code into Form_LostFocus in case the user turns on/off Always On Top in Winamp after the form is loaded, but I can't promiss that it works since I haven't tested it hard enough yet :D
Ps. I tried to make this as understandable as possible but if you have any questions, email me!
Ximo
2nd January 2002, 15:37
I tried that GenWrapper.dll but you can not make a
serious plugin with it. And I still make EXE plugins.
You should alse check out CallDlls.vbp in the samples directory.
How do you make EXE plugins? I haven't got the samples, can you send it my email address? Do you also have a complete project that shows me how you do it that you can send me? Let me know if you want my codes..
Check this Plugin. (http://users.rol.ro/pvs3/hardwarcontrolls.exe)
The URL didn't work.. :weird: nice site thou! I learned some words in Romanian..
Anyway, thanks for the answer. La multi ani, sarbatori fericite! :cool:
Any others into VB..?
Pvs3
2nd January 2002, 16:20
I misstyped the Url in tat link for the Winamp Plugin (http://www.users.rol.ro/pvs3/HardwarControlls.exe) ,This one will work. I can not send you the source for that plugin because you will not understad anything, it's all messed up because i tried to make it work with GenWrapper :(. But i made this Winamp example plugin (http://www.users.rol.ro/pvs3/HandyAmp.zip) you can understand this one.:)
Pvs3
3rd January 2002, 22:14
I would like to have your codes because i tried, i tried and i tried and i could NOT add a file to the playslist :cry: . And thanks for your post about Always on top , i did not know how to get the state of a button. :)
Ximo
5th January 2002, 17:36
This is from a Winamp module I found that's really good. I can upload the module and an example if you want it..
Add this to a module:
'Sends text messages using COPYDATASTRUCT
Public Declare Function SendMessageCDS Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As COPYDATASTRUCT) As Long
'Copies a string to its Address, used for SendMessageCDS
Declare Function lstrcpy Lib "kernel32" _
Alias "lstrcpyA" _
(ByVal lpString1 As String, _
ByVal lpString2 As String) As Long
Public Function WM_AddPlaylist(FileName As String)
'This adds the song to the playlist
If Right(FileName, 1) = "\" Then
FileName = Mid(FileName, 1, Len(FileName) - 1)
End If
Dim cds As COPYDATASTRUCT
cds.dwData = 100
cds.lpData = lstrcpy(FileName, FileName)
cds.cbData = Len(FileName) + 1
SendMessageCDS WinampID, &H4A, 0&, cds
End Function
Public Function WM_OpenFile(FileName As String)
'I couldn't include all the other codes here, but you
'can use your own codes to send messages to Winamp
'CLEAR_PLAYLIST
WM_AddPlaylist (FileName)
'GO_END_PLAYLIST
'PLAY_TRACK
End Function
Use like this:
WM_AddPlayList("C:\Parazitii - Nu ma schimbi.mp3")
WM_OpenFile("C:\Parazitii - Nu ma schimbi.mp3") (yep, the romanian rapper.. he's really good)
Ximo
5th January 2002, 19:14
The problem with making plugins with VB and GenWrapper is that the forms have to be non-modal, so you can't use Winamp when your form is shown. But someone told me a way to do it :D With this neat API call you can show your form non-modally and it works perfectly!
Public Declare Function ShowWindow Lib "user32.dll" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_HIDE = 0
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_RESTORE = 9
Public Const SW_SHOW = 5
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOWNORMAL = 1
And simply use it like this:
ShowWindow Form1.hwnd, SW_SHOW
ShowWindow Form1.hwnd, SW_HIDE
Put the SW_SHOW command in IRjlWinAmpGenPlugin_Initialize and your form will show up modally when Winamp starts.. Use the same code to open the Configure window too, it works perfectly!! Oh, I love APIs :)
wa21guy
21st March 2002, 11:45
Ximo - You are god. Thank you!!!
wa21guy
31st March 2002, 05:25
One more question - How can I minimize/maximize the window in the system tray?? It lets me hide the window when show is FALSE but when I set it to TRUE I get an ActiveX error.
Ethan
Ximo
31st March 2002, 13:23
I'm glad that you found the codes useful :D
To hide or show your form you should use ShowWindow Form1.hwnd, SW_SHOW and ShowWindow Form1.hwnd, SW_HIDE (or you can use SW_MINIMIZE and SW_RESTORE).. That should work without problems. Use it to maximize the form when the user clicks the system tray icon, and to minimized it to the system tray again when you want to do that. Do you have a working system tray code already?
wa21guy
5th April 2002, 08:31
Well, I have the system tray code working and everything but heres the problem. When the user minimizes Winamp to the system tray, the HIDE option works great. But when it is minimized to the taskbar it doesnt want to seem to work correctly. Can anyone give me some sample working code to make this happen?
Thanks
I am trying to make a visual plugin for :winamp: in VB but i can not use HLS, and it's vary hard to make a color fade with RGB, I found something about that in NSDN but in C++, i've translated it in VB code but it did not work, the languages are not vary similar, I was wondering if any of you guys know how to do that.
itsr0y
12th July 2002, 15:06
I have a quick question for VB Plugins - is there any way to be able to use the debugger while running the project as a Winamp plugin (activex dll)?
Gourou
12th July 2002, 21:18
no
Pvs3
14th August 2002, 16:03
Since winamp 3 has been released, does any1 have an idea how to make a Vb plugin for it. Maby i am asking too soon but who knows.
YtseJam
14th August 2002, 16:08
You can't make plug-ins(components now) for Winamp3 using VB, C++ only.
Trekkan
15th August 2002, 06:42
Yeah, real slick move that was...
cw@idviate.com
16th August 2002, 04:29
If components are just C++ DLLs, seems like someone could just cook up an ActiveX interface. Not that I'm going to do it, of course.
cw
liquidmotion
17th August 2002, 05:09
i wrote a VB vis plugin for wa2.xx one time. it was alright, and it made use of expression evaluation to make semi-custom displays :)
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.