Go Back   Winamp Forums > Developer Center > Winamp Development

Reply
Thread Tools Search this Thread Display Modes
Old 4th June 2007, 07:31   #1
tuffguy
Junior Member
 
Join Date: May 2007
Posts: 4
Dialog Box title showing as 4 boxes?

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.

PHP Code:
// 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 hInstULONG ul_reason_for_callLPVOID 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 hwndUINT messageWPARAM wParamLPARAM 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 (
!= && 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***91;i***93;);
        }*/
        
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 65536ini_file="winamp.ini";

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

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

__declspecdllexport winampGeneralPurposePlugin winampGetGeneralPurposePlugin()
{
    return &
plugin;

tuffguy is offline   Reply With Quote
Old 4th June 2007, 21:24   #2
tuffguy
Junior Member
 
Join Date: May 2007
Posts: 4
Okay I tried doing just a tiny test plug-in, and the text still gets all garbled up, shows up as these little boxes.



PHP Code:
// 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 hInstULONG ul_reason_for_callLPVOID 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()
{
}

__declspecdllexport winampGeneralPurposePlugin winampGetGeneralPurposePlugin()
{
    return &
plugin;

tuffguy is offline   Reply With Quote
Old 4th June 2007, 22:07   #3
DrO
-
 
DrO's Avatar
 
Join Date: Sep 2003
Location: UK
Posts: 22,210
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
DrO is offline   Reply With Quote
Old 4th June 2007, 22:15   #4
tuffguy
Junior Member
 
Join Date: May 2007
Posts: 4
Thanks a lot dude! That was it, it's fixed now.
tuffguy is offline   Reply With Quote
Reply
Go Back   Winamp 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