PDA

View Full Version : Dialog Box title showing as 4 boxes?


tuffguy
4th June 2007, 07:31
So I'm new to Windows API programming, and I'm trying to create a simple dialog box for a general purpose plugin configuration.

The dialog box shows up fine, except the dialog box title isn't showing up. Instead I'm seeing 4 boxes, like the string is corrupt or something.

Any idea what is going on here?

SetWindowText(hwndDlg,PLUGIN_DESC);

is what should be setting it, but it's not.


// Winamp general purpose plug-in mini-SDK
// Copyright (C) 1997, Justin Frankel/Nullsoft

#include <windows.h>
#include <process.h>

#include "gen.h"
#include "resource.h"

#define SYSTRAY_ICON_BASE 1024

BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}

int config_enabled=0;

BOOL CALLBACK ConfigProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
void config();
void quit();
int init();
void config_write();
void config_read();

#define PLUGIN_DESC "Test Title"

winampGeneralPurposePlugin plugin =
{
GPPHDR_VER,
PLUGIN_DESC,
init,
config,
quit,
};

void config()
{
DialogBox(plugin.hDllInstance,MAKEINTRESOURCE(IDD_DIALOG1),plugin.hwndParent,ConfigProc);

}

void quit()
{
config_write();
config_enabled=0;
}

WNDPROC lpWndProcOld;
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_USER+2707)
{
switch (LOWORD(lParam))
{
case WM_LBUTTONDOWN:
if (config_enabled) switch (LOWORD(wParam))
{
case 1024:
{
int a;
if ((a=SendMessage(hwnd,WM_USER,0,104)) == 0) // not playing, let's hit prev
{
SendMessage(hwnd,WM_COMMAND,40044,0);
}
else if (a != 3 && SendMessage(hwnd,WM_USER,0,105) > 2000) // restart
{
SendMessage(hwnd,WM_COMMAND,40045,0);
}
else
{ // prev
SendMessage(hwnd,WM_COMMAND,40044,0);
}
}
return 0;
case 1025:
SendMessage(hwnd,WM_COMMAND,40045+(SendMessage(hwnd,WM_USER,0,104) == 1),0);
return 0;
case 1026:
SendMessage(hwnd,WM_COMMAND,40047 + ((GetKeyState(VK_SHIFT) & (1<<15))?100:0) ,0);
return 0;
case 1027:
SendMessage(hwnd,WM_COMMAND,40048,0);
return 0;
case 1028:
SetForegroundWindow(hwnd);
if (GetKeyState(VK_CONTROL) & (1<<15))
SendMessage(hwnd,WM_COMMAND,40185,0);
else if (GetKeyState(VK_SHIFT) & (1<<15))
SendMessage(hwnd,WM_COMMAND,40187,0);
else
SendMessage(hwnd,WM_COMMAND,40029,0);
return 0;
}
break;
}
}
return CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam);
}

int init()
{
config_read();

lpWndProcOld = (WNDPROC)SetWindowLong(plugin.hwndParent,GWL_WNDPROC,(LONG)WndProc);

return 0;
}



BOOL CALLBACK ConfigProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
/* int i;
for (i = 0; i < NUM_ICONS; i++)
{
CheckDlgButton(hwndDlg,IDC_PREV+i,(config_enabled&(1<<i))?BST_CHECKED:BST_UNCHECKED);
SetDlgItemText(hwndDlg,IDC_PREV+i,tips[i]);
}*/
SetWindowText(hwndDlg,PLUGIN_DESC);
}
break;
case WM_COMMAND:
/* if (LOWORD(wParam) >= IDC_PREV && LOWORD(wParam) <= IDC_PREV5)
{
int i;
config_enabled=0;
for (i = 0; i < NUM_ICONS; i++)
if (IsDlgButtonChecked(hwndDlg,IDC_PREV+i))
config_enabled |= 1<<i;
do_icons();
}*/
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hwndDlg,0);
}
break;
}
return FALSE;
}

char *ini_file=0;

void config_read()
{
ini_file=(char*)SendMessage(plugin.hwndParent,WM_USER,0,334);
if ((unsigned int)ini_file < 65536) ini_file="winamp.ini";

config_enabled = GetPrivateProfileInt(PLUGIN_DESC,"BEN",config_enabled,ini_file);
}

void config_write()
{
char string[32];
wsprintf(string,"%d",config_enabled);
WritePrivateProfileString(PLUGIN_DESC,"BEN",string,ini_file);
}

__declspec( dllexport ) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin()
{
return &plugin;
}

tuffguy
4th June 2007, 21:24
Okay I tried doing just a tiny test plug-in, and the text still gets all garbled up, shows up as these little boxes.

http://www.zifiniti.com/wtf.png


// Winamp general purpose plug-in mini-SDK
// Copyright (C) 1997, Justin Frankel/Nullsoft

#include <windows.h>
#include "gen.h"
int init();
void config();
void quit();

BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}

winampGeneralPurposePlugin plugin =
{
GPPHDR_VER,
"TEST",
init,
config,
quit,
};


int init()
{
return 0;
}

void config()
{
MessageBox(NULL,"Test config","Testing...",MB_YESNO);
}

void quit()
{
}

__declspec( dllexport ) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin()
{
return &plugin;
}

DrO
4th June 2007, 22:07
to me that looks like you've got it building as a unicode dll (is UNICODE defined anywhere in the project settings) and hence why you're seeing that messed up text - though i'm sure the compiler should through a few warnings/errors up in that case to not allow it through. other than that i don't know what else would cause it

-daz

tuffguy
4th June 2007, 22:15
Thanks a lot dude! That was it, it's fixed now.