Old 18th April 2013, 03:52   #1
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
Attempting to write first simple plugin

Hi everyone. I am trying to write a simple plugin that will display a small window in winamp with two buttons on it. One button is for good songs, one button is for songs I don't want to hear often. If I press the 'bad song' button I want the mp3 moved to a specified folder (set in config) so that it isn't in my routine music anymore. The 'good song' button does the same thing but either keeps the song in the normal MP3 folder or moves it back to it. Its basically a permanent favorites manager. I wanted to keep it simple, in config have a 'working folder', a 'good folder', and a 'bad folder'. Plugin checks that current song is in working folder or subdirectory of it and if it is, simply replaces that part of file path with good or bad directory and sends a move command.

What i am hoping is that someone can help me get started by providing the files DrO had supplied before for creating a simple skinned window. (gen_embedwnd) All the resource files have been removed and I can't find the full package to start from anywhere. I have no C++ experience. I am more of a web developer so so far this has been rather daunting but I do love a good challenge.

I can compile a basic plugin in Microsoft Visual C++ 2010 Express, but don't have the plugin window yet or the configuration settings window. Basically I am at step one. Any help would be greatly appreciated. Or even a link to basic source code I can play with.
caleb7777 is offline   Reply With Quote
Old 19th April 2013, 05:34   #2
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
Edit, I got windows more or less figured out, If someone can help me with some simple code so i can save 3 directory settings from the config window it would be appreciated
caleb7777 is offline   Reply With Quote
Old 22nd April 2013, 00:58   #3
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
I have got the plugin working now. It is fully functional just rough around the edges and the window is buggy. I would appreciate some help making it a clean winamp skin dockable window. Any other suggestions would be great too. This is the first time I have touched C++ so there is probably lots you will laugh at, it'll be a fun read for you. In config you set a working directory and up to two destination folders for where the currently playing song will go. It moves the file maintaining any directory structure the file had relative to the working folder path.

Here is how I will use it:
working directory- D:\MP3
destination directory 1- D:\Other MP3

any file not in D:\MP3 is ignored, if you press move file on a file in the working directory, ex:
D:\MP3\the juliets\album\year\01-song.mp3
it will be moved to
D:\Other MP3\the juliets\album\year\01-song.mp3

I have attached all my files so please help me improve this.
Attached Files
File Type: 7z gen_archiver - Copy.7z (34.4 KB, 271 views)
File Type: 7z gen_archiverDLL.7z (32.1 KB, 264 views)
caleb7777 is offline   Reply With Quote
Old 23rd April 2013, 12:22   #4
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
EDIT - above files had a small typo. here is the corrected plugin.

I am still hoping someone can help me improve on this by changing window to winamp skinned dockable or at least provide with the resource files from DrO's work so I can do it myself.
Attached Files
File Type: 7z gen_archiverDLL.7z (32.1 KB, 291 views)
File Type: 7z gen_archiver - Copy.7z (34.3 KB, 281 views)
caleb7777 is offline   Reply With Quote
Old 16th June 2013, 01:08   #5
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,013
Send a message via Skype™ to thinktink
I did a debug compile of your plugin source-code from the gen_archiver - Copy.7z archive with the free version of MSVC++. Dropped it into Winamp's plugin folder and as soon as it tried to paint your window it crashed Winamp hard core phail.

After debugging your source I found the issue. In your WM_PAINT message handler (inside WndProcPlugin), you aren't checking for a NULL file name string pointer before calling strlen(...) on it, and when you call "printText" from there you're not supplying a '\0' string list terminating string. You should probably change that to check for NULL however because the way you're doing the string comparison check is not portable and won't be guaranteed to always work depending on the compiler version or any other potential compiler optimizations you might enable in the future. Comparing string pointer values is a giant no-no if your goal is actually check and compare the contents of two strings, which is not what you're trying to do in the code.

Also, I do believe the text you're printing on the buttons and other windows are getting wiped out by your call to DefWindowProc after you paint the text.

It would probably be easier to convert your windows to either modal or modeless dialog boxes, that way you're not having to play hunt-and-peck with painting stuff yourself.

All the headers you need to compile a skinned window are available in the SDK, you just need include it in your project. "wa_dlg.h" is one of them, I forgot the other ones were, find that one and you'll probably find the others.
thinktink is offline   Reply With Quote
Old 18th June 2013, 00:43   #6
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,013
Send a message via Skype™ to thinktink
I turned all of your windows into dialog boxes and skinned your plugin window. Still need to either add disabling of closing the GenFrame or adding a menu item for the plugin window.
Attached Files
File Type: 7z gen_archiver - Copy.7z (62.8 KB, 260 views)
File Type: 7z gen_archiverDLL.7z (33.2 KB, 261 views)
thinktink is offline   Reply With Quote
Old 19th June 2013, 15:17   #7
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,013
Send a message via Skype™ to thinktink
I was screwing around with Winamp the other day and I noticed that the plugin's gen frame didn't have a title. I discovered that it's because I didn't change SendMessage(GenFrame,WM_SETTEXT...) to SetWindowTextA(...) in the gen frame creation function. Once that's done the gen frame will display the correct title.

I figure posting the solution instead of re-uploading the entire project archive would be easier, so, here it is.
thinktink is offline   Reply With Quote
Old 19th June 2013, 15:39   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
it should accept a unicode title - if it's not then something has messed up the sub-classing of the window which would cause that failure.
DrO is offline   Reply With Quote
Old 19th June 2013, 15:52   #9
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,013
Send a message via Skype™ to thinktink
Quote:
Originally Posted by DrO View Post
it should accept a unicode title ...
It would if it was passing a unicode string to the gen window, however, the plugin's original source code is mostly ansi strings, therefore, using SetWindowTextA is an easier solution.

All I'm doing here really is showing what needs to be done to skin the window, not so much working with unicode strings, I'm leaving that to the original plugin's developer.

Originally, in the projects Debug mode the compiler was, apparently, doing transparent automatic conversions of the strings but in release mode the compiler complained like crazy about mismatched string type parameters, so to the extent I wanted it to compile I changed things around, but no more than what was necessary.
thinktink is offline   Reply With Quote
Old 27th July 2013, 13:46   #10
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
Thanks for the help! I don't understand most of what you said, but I will download and look over carefully what you changed. I could not for the life of me figure out how to use the wa_dlg and ended up cutting and pasting various googled codes until it worked on my system.

Thank you and I will try this
caleb7777 is offline   Reply With Quote
Old 5th August 2013, 19:33   #11
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
Thank you thinktink!
I finally got a chance to look at this today and wow you helped alot.

Thank you helping me skin it and for cleaning my bad code

I fixed the title as per your instructions and I changed some text and spacing etc so it's a little cleaner. This plugin will be very handy to me sorting my library of music. I also changed the one button to 'archive' (it moves the file) and the other button to 'copy' (copies the file) so that I can archive songs that i don't want to hear often, or copy favorites to a folder for easy transfer to vehicle etc.

Only thing I can think of now is that if you close the plugin window, it disappears from the view menu and so can't be reopened without restarting winamp. is there an easy fix for this?
Attached Files
File Type: 7z gen_archiverDLL.7z (33.2 KB, 221 views)
File Type: 7z gen_archiver.7z (58.6 KB, 236 views)
caleb7777 is offline   Reply With Quote
Old 5th August 2013, 19:34   #12
caleb7777
Junior Member
 
Join Date: Jan 2011
Posts: 8
oh also is there an easy way to assign a hotkey to those buttons? so that you can archive or copy from keyboard alone?
caleb7777 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