Shoutbox

Using DialogBox function - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Using DialogBox function (/showthread.php?tid=12679)

Using DialogBox function by oberststen on 07-09-2003 at 09:18 PM

hey i'm new on C++, i tried to use the DialogBox when i recieve the "/xjaime" but it don't work, any ideas? or it just simply don't work?


RE: Using DialogBox function by allex87 on 07-09-2003 at 09:22 PM

It does work...
How did u call it? Can u post here the full src code?


RE: Using DialogBox function by oberststen on 07-09-2003 at 09:36 PM

here it is, i only paste the important parts

#include "resource.h"

LRESULT CALLBACK    Help(HWND, UINT, WPARAM, LPARAM);

HINSTANCE hInst;
HWND hWnd;

MPPLUGIN_RETURN_BOOL ParseCommand(/*[in]*/  const char* sCommand,
                                  /*[in]*/  const char* sCommandArg,
                                  /*[in]*/  PLUGIN_PARAM* pParam,
                                  /*[out]*/ char* sResult)
{
    if(stricmp(sCommand, "/xhelp") == 0)
    {
        DialogBox(hInst, (LPCTSTR)IDD_HELP, hWnd, (DLGPROC)Help);

        strcpy(sResult, "");
        return TRUE;
    }

    else if(stricmp(sCommand, "/xping") == 0)
    {
        strcpy(sResult, sCCNotify);
        strcat(sResult, "smppg"); //The notify code must be 5 characters long
        strcat(sResult, "Ping?");
        return TRUE;
    }
    return FALSE;
}

LRESULT CALLBACK Help(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG:
                return TRUE;

        case WM_COMMAND:
            if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
            {
                EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            break;
    }
    return FALSE;
}


RE: Using DialogBox function by allex87 on 07-10-2003 at 02:00 AM

Well... I think hInst is not really initialized...
So.. DllMain should be:

BOOL APIENTRY DllMain( HINSTANCE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved)
{
    hInst = hModule;
        return TRUE;
}


RE: Using DialogBox function by oberststen on 07-10-2003 at 03:27 AM

it doesn't work... i get to errors


RE: Using DialogBox function by allex87 on 07-10-2003 at 03:31 AM

what errors?


RE: Using DialogBox function by mikelo2k on 07-10-2003 at 03:37 AM

Ok, how about you try debugging and some error checking api.
Right after the dialog box param call, put the following:
int x = GetLastError();

x will contain the error code. Now since you probably dont know how to debug a DLL, wsprintf() the code with "%i" into a string and messagebox it. Once you have the error code, post it here or consult your Win32 API manual.

There can be many reasons for the dialog not showing, sometimes if you have common controls (which you may) then you have to initialize common control sex ;)


RE: Using DialogBox function by allex87 on 07-10-2003 at 03:39 AM

Or do as described my "Debug plugins" thread....
http://shoutbox.menthix.net/showthread.php?tid=12615


RE: Using DialogBox function by oberststen on 07-10-2003 at 03:23 PM

hmmm, something that i don't understand... i need to modify the APIEntry to

BOOL APIENTRY DllMain( HINSTANCE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved)
{
hInst = hModule;
        return TRUE;
}

and replace the original apientry? i didn't understand that


RE: RE: Using DialogBox function by n3tfusiOn on 07-10-2003 at 05:00 PM

quote:
Originally posted by oberststen
hmmm, something that i don't understand... i need to modify the APIEntry to

BOOL APIENTRY DllMain( HINSTANCE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved)
{
hInst = hModule;
        return TRUE;
}

and replace the original apientry? i didn't understand that


yes , and that work lol :)
RE: Using DialogBox function by oberststen on 07-10-2003 at 06:53 PM

that funcion works the same? (with the same parameters?)


RE: Using DialogBox function by allex87 on 07-11-2003 at 11:27 AM

DJMystic... that only applies if you supply the DialogBox with the HWND of the parent window (in win32 API, not MFC). If u're using MFC, call it like:    ::DialogBox()