Trying to "embed" winamp in my app

T

Terry Olsen

Here's another odd request. I want to embed the winamp window in my app. I
have a panel that I want Winamp to be locked to. Using a couple of API
calls, I can set the panel as the parent of the main Winamp window like so:

WinampHndl = FindWindowEx(Nothing, Nothing, "BaseWindow_RootWnd", "Player
Window")
x = SetParent(WinampHndl, Panel1.Handle)

I try using the MoveWindow call like this:

MoveWindow(WinampHndl, Panel1.Left, Panel1.Top, Panel1.Width, 275, True)
Or
MoveWindow(WinampHndl, 0, 0, Panel1.Width, 275, True)

It sets the width & height correctly, but doesn't move the window at all. It
remains at the lower-right corner of the panel. I can drag the winamp window
within the panel to the correct position, then when I move my main app
window around, Winamp stays in the correct place.

I'd like have it "docked" to "fill" the panel. Anyone got any advice?
 
N

Newbie Coder

Terry,

What happens if the user doesn't have WinAmp on their machine or they have
it minimised to system tray? Your functions will fail because the handle
will be zero

Why are you using FindWindowEx & not FindWindow?

Dim intWinAmpHwnd As Int32 = FindWindow("BaseWindow_RootWnd", "Player
Window")

Imports System.Runtime.InteropServices

<DllImport("user32.dll", entrypoint:="FindWindowA", SetLastError:=True)>
_
Private Shared Function FindWindow(ByVal lpClassName As String, _
ByVal lpWindowNamee As String) As Int32
End Function

In the past, I wrote a C++ application that used the WinAmp objects & used
an ini file to set the preferences... At least this way you could be sure to
have WinAmp on the clients machine...

In your code I see you have 275. Why isn't that Panel1.Height? But
personally I would say not to set the WinAmp height to say 10 less than the
panel height & then centre it meaning the starting point would be 5, 5 not
0, 0 & then do the same for the bottom plus left/right edges.

Your MoveWindow function isn't adding the WinAmp window to the container of
the frame, but just setting it to the size of the panel

What does 'x' stand for?

The newsgroup is waiting your response,
 
T

Terry Olsen

Newbie Coder said:
Terry,

What happens if the user doesn't have WinAmp on their machine or they have
it minimised to system tray? Your functions will fail because the handle
will be zero

The program checks to see if Winamp is installed, informs the user that it's
required if not found and exits.
Why are you using FindWindowEx & not FindWindow?

FindWindowEx searches child windows, FindWindow does not. The player window
in Winamp is a child of the main Winamp process.
In your code I see you have 275. Why isn't that Panel1.Height? But
personally I would say not to set the WinAmp height to say 10 less than
the
panel height & then centre it meaning the starting point would be 5, 5 not
0, 0 & then do the same for the bottom plus left/right edges.

275, or actually, 280 is the perfect height for the Winamp window without
the video screen. Any other size than that and it doesn't look right.
Your MoveWindow function isn't adding the WinAmp window to the container
of
the frame, but just setting it to the size of the panel

Yes, I know that; which is why i'm using the x = SetParent(WinampHndl,
Panel1.Handle) to do that. The MoveWindow call is supposed to be "Moving"
the window in addition to setting the window size. It sets the window size
correctly, but doesn't move the window. Why? This is my original question.
What does 'x' stand for?

It doesn't stand for anything other than to check that the SetParent call
was successful.
The newsgroup is waiting your response,

You know what? Forget it. When I ask a simple question, I don't need to
explain my motivation for what I want to do, which is all the responses have
been as of late. "Why do you want to do this?" My answer is, "Why do you
need to know?" Or the assumption in this response that I somehow hadn't
taken into consideration whether or not Winamp would be installed on the
user machine. Or even the statement that the MoveWindow call doesn't add
Winamp to the panel, when the SetParent call was in plain sight on the
previous line. This obviously shows that the responder didn't read the
question with the intent of providing an answer, only to criticize. So
really...forget it. I'll look for other resources.
 
D

Darhl Thomason

Terry Olsen said:
You know what? Forget it. When I ask a simple question, I don't need to
explain my motivation for what I want to do, which is all the responses
have been as of late. "Why do you want to do this?" My answer is, "Why do
you need to know?" Or the assumption in this response that I somehow
hadn't taken into consideration whether or not Winamp would be installed
on the user machine. Or even the statement that the MoveWindow call
doesn't add Winamp to the panel, when the SetParent call was in plain
sight on the previous line. This obviously shows that the responder didn't
read the question with the intent of providing an answer, only to
criticize. So really...forget it. I'll look for other resources.

Terry,

I know my opinion wasn't solicited, but here it is anyway.

Lighten up! My experience in this group and other coding groups is first
that there are a lot of type A personalities out there and they are just
being direct, not being mean or spiteful. "Newbie Coder" is trying to be
helpful and make sure you have all your contingencies accounted for which is
why they asked about what if WinAmp isn't installed. They don't know your
level of coding experience and are really trying to help.

Second, people want to know your motivation for coding a function because
that may help them understand what's going on, or more specifically what you
want to have happen. This will then help them help you come up with a
viable solution for your problem.

You've gotta learn to take what people say, pull out the important stuff you
need and throw the rest away. In short, get over your bad self and let
people try to help you.

d
 
N

Newbie Coder

Well said Darhl

Terry,

You have a panel called Panel1 & then an undeclared variable 'x'. So, my
question was a valid one. As you have an attitude problem then forget it I
will delete the code project I coded for you

I wasn't saying you have to have WinAmp installed on the machine at all. If
you haven't & you run your app then it will fail. The way I was talking
about when I wrote this C++ project a few years ago is I had the WinAmp
object that I included in a setup project which I could call directly.
Therefore this application wouldn't fail as your would do if it cannot get
the handle to the WinAmp window.

Then you were using the wrong API, which is why I corrected you.

As you don't want my help I won't give it to you. You can let an MVP give
you a link to a Google search they performed, but I have the code for you.
Correction - I will delete the project I had for you & let you work it out
for yourself.

Sorry you feel the way you do about me,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top