View Single Post
Old 26th February 2007, 10:01   #1
5ven
Junior Member
 
Join Date: Feb 2007
Posts: 4
Newbie and first general plugin

Hi,

I am trying make a general plugin, just to test some concepts and things. I've got the SDK installed, also Visual C++ Express and Dev C++, too. I downloaded the empty general plugin- and compiled it successfully.

Now I have been trying to accomplish something more advanced than a MessageBox - I would like to have a DialogBox instead that would appear on clicking the "Configure selected plugin". I've read through some GPL plugins' code and checked the SDK's tray plugin. With the help of these I have got to the point where I got no compilation errors - but no DialogBox, either.

Here is the code that I have written:

--------------- gen_test.h---------------------------
#ifndef gen_test_h
#define gen_test_h
#include <windows.h>
#include "resource.h"

typedef struct {
int version;
char *description;
int (*init)();
void (*config)();
void (*quit)();
HWND hwndParent;
HINSTANCE hDllInstance;
} winampGeneralPurposePlugin;

BOOL CALLBACK ConfigProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);

#define GPPHDR_VER 0x10

extern "C" winampGeneralPurposePlugin *gen_plugins[256];
typedef winampGeneralPurposePlugin * (*winampGeneralPurposePluginGetter)();
#endif
---------------------------------------------

-------------------gen_test.cpp--------------
#include "gen_test.h"
#define PLUGINNAME "Test v0.2"
#define PLUGIN_DESC "Test plugin"


BOOL APIENTRY _DllMainCRTStartup(HANDLE hMod, DWORD r, void *empty){
return 1;
}

HWND hConfigDialog = NULL;
HWND hAddDialog = NULL;

extern "C" winampGeneralPurposePlugin plugin;


int init() {return 0;}

void config() {
DialogBox(plugin.hDllInstance,MAKEINTRESOURCE(IDD_CONFIG),NULL,ConfigProc);
}


void quit() {}

winampGeneralPurposePlugin plugin = {
GPPHDR_VER,
PLUGINNAME,
init,
config,
quit,
0
};

BOOL CALLBACK ConfigProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
switch (message) {
case WM_INITDIALOG : {
hConfigDialog = hwnd;
// SetWindowText(hwndDlg,PLUGIN_DESC);
SetWindowText( hwnd, "Test" );
//SetDlgItemText(hwndDlg,IDC_EDIT1,"WinApi");
ShowWindow(hwnd,SW_SHOW);
}
return TRUE;
case WM_COMMAND: {
break;
}
}
return FALSE;
}

extern "C" __declspec( dllexport ) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin(){
return &plugin;
}
--------------------------------------------------

---------------------resource.h-------------------
#define IDD_CONFIG 101
#define IDC_EDIT1 102
--------------------------------------------------

I am suspecting that something might be missing at ConfigProc.
5ven is offline   Reply With Quote