Old 2nd November 2005, 17:24   #1
c3lica
Junior Member
 
Join Date: Nov 2005
Posts: 6
WM_COMMAND problems

I am using vb.net but cant get the wm_commands to work. I think I am doing everything right. Any suggestions.

Thanks

'Functions
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

'Constants
Public Const WM_COMMAND = &H111
Public Const WM_USER = &H400

'Variables
Public hwndWinamp As Long

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

hwndWinamp = FindWindow("Winamp v1.x", vbNullString)

End Sub

Private Sub cmdPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPlay.Click

SendMessage(hwndWinamp, WM_COMMAND, 40045, 0)

End Sub

Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click

SendMessage(hwndWinamp, WM_COMMAND, 40047, 0)

End Sub
c3lica is offline   Reply With Quote
Old 8th November 2005, 17:46   #2
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Did you check if the handle is valid?


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 9th November 2005, 00:19   #3
c3lica
Junior Member
 
Join Date: Nov 2005
Posts: 6
i tried getting the handle from a point on the winamp window and it would come back the same sometimes and different others but would never work. How can I check for sure?
c3lica is offline   Reply With Quote
Old 10th November 2005, 23:13   #4
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
PHP Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As StringByVal lpWindowName As String) As Long


Private Sub Form_Load()
Dim hWinamp As Long

hWinamp 
FindWindow("Winamp v1.x"vbNullString)

If (
hWinampThen
Debug
.Print "Winamp is running"
Else
Debug.Print "Winamp is not running"
End If

End Sub 
Been a while since I use VB


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 11th November 2005, 18:37   #5
c3lica
Junior Member
 
Join Date: Nov 2005
Posts: 6
i run that and it says winamp is running regardless of weather or not it is. also i have to change .print to .write but thats not really important.

also. when i search for the class "Winamp v1.x" through Spy++ it only comes up when winamp is running so i think findwindow might be messing up.
c3lica is offline   Reply With Quote
Old 13th November 2005, 12:56   #6
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Quote:
Originally posted by c3lica
i run that and it says winamp is running regardless of weather or not it is
That's impossible. Maybe you have another application runing with same class, or you think Winamp is close but it stills on process...

The code that I passed you is one of the ABC of developing Winamp


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump