Shoutbox

open a new form - 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: open a new form (/showthread.php?tid=12516)

open a new form by Bamboe on 07-07-2003 at 10:21 PM

can somebody pleaz tell me how i can open a new form (in c)
i've tried form1->Show(); but it didn't work (the compiler accept it but the plugin won't work anymore).


RE: open a new form by Predatory Kangaroo on 07-08-2003 at 02:58 AM

As Alex has posted many times, he's done this (not in MFC) by doing DialogBox()
I don't know how to use that, but...
And in MFC i think you do it using form1->DoModal


RE: open a new form by allex87 on 07-08-2003 at 03:10 AM

I think API is the easiest way... anyways, if you want a GREAT API tutorial, go to:
http://winprog.net/tutorial/

That's how I started.

Basically, u need a dialog as a resource. Then u call CreateDialog to create that dialog. Then, u handle all the messages in the Dialog Procedure...

BTW, i want to learn MFC.. does anyone know a GOOD tutorial on the net? or a book?

Thanks....


RE: open a new form by Bamboe on 07-08-2003 at 12:04 PM

I don't understand the tutorial, you have to use some code in winMain() but there isn't a winMain() in the msn+ api.

what do you mean with MFC (i am just a newbe in programming)

Can you please give me some example code or the code you used in your plugin?

tnx a lot


RE: open a new form by trax on 07-08-2003 at 12:53 PM

And what is it in vb??

if id o form1.show the whole command doesn't work


RE: open a new form by Xerxis on 07-08-2003 at 01:18 PM

i have opened a post on the same subject, it isn't only a form you can't load, every object you try to load gives that problem, the command isn't parsed anymore

i don't know the solution to that problem but i could use it, so if anyone knows!!!


RE: open a new form by Bamboe on 07-08-2003 at 08:20 PM

allex87 you have made a form before, can i have your sourcecode?


RE: open a new form by allex87 on 07-08-2003 at 09:00 PM

OK... here ya go... this is a snippet from my forthcoming AdvancedN Nickname Changer plugin (still need to work a bit on it).

Put this in the parsecommand:

DialogBox(hDllInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NickChanger);

U must have a dialog in ur resource file with the IDD_DIALOG1 id...
Also you need a dialog procedure (name would be NickChanger).

Here's a sample of a Dialog procedure:

BOOL CALLBACK NickChanger(
    HWND hwndDlg,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
)
{
    switch(uMsg)
    {
    case WM_INITDIALOG:
// do whatever u want when the dialog is initialized
                     break;
    case WM_CLOSE:
        DestroyWindow(hwndDlg);
        break;
    case WM_DESTROY:
// Remember to clean up after urself, after finishing...
        EndDialog(hwndDlg, wParam);
        break;
    default:
        return FALSE;
    }
return TRUE;
}

There... now.. if u progrram in MFC, I am truly sorry, I can't help.. actually, like i've said, I want to learn, I just didn't find a GOOD tutorial that explains everything... :(


RE: open a new form by Whacko on 07-08-2003 at 09:20 PM

hehe... i love Delphi... did it in like 2 seconds :P


RE: open a new form by SilenceTi on 07-08-2003 at 10:33 PM

Where did you get hDllInst from?


RE: open a new form by Bamboe on 07-09-2003 at 07:16 AM

tnx I'll try it later today


RE: open a new form by Bamboe on 07-09-2003 at 03:36 PM

it didn't work :( got these error messages on line in parsecommand:
(DialogBox(hDllInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NickChanger);)

  [C++ Error] MPPluginC.cpp(95): E2451 Undefined symbol 'hDllInst'
  [C++ Error] MPPluginC.cpp(95): E2451 Undefined symbol 'IDD_DIALOG1'
  [C++ Error] MPPluginC.cpp(95): E2034 Cannot convert 'int (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)()'
  [C++ Error] MPPluginC.cpp(95): E2342 Type mismatch in parameter 'lpDialogFunc' (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,unsigned int,unsigned int,long)')


RE: open a new form by n3tfusiOn on 07-10-2003 at 04:56 PM

You have to change :

BOOL APIENTRY DllMain(HANDLE hModule, DWORD nReason, void* pReserved)
{
    return TRUE;
}

by :


HINSTANCE hInst;
HWND hWnd;

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

And call the function by :     

DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NickChanger);

(in the parsecommand )



Thx to allex87 for this tip :)


RE: open a new form by Bamboe on 07-10-2003 at 06:21 PM

tnx, u have one error solves, i still have these three errors:

[C++ Error] MPPluginC.cpp(95): E2451 Undefined symbol 'IDD_DIALOG1'
[C++ Error] MPPluginC.cpp(95): E2034 Cannot convert 'int (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)()'
[C++ Error] MPPluginC.cpp(95): E2342 Type mismatch in parameter 'lpDialogFunc' (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,unsigned int,unsigned int,long)')

in this line: (DialogBox(hDllInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NickChanger)


RE: RE: open a new form by n3tfusiOn on 07-10-2003 at 07:16 PM

quote:
Originally posted by Bamboe
tnx, u have one error solves, i still have these three errors:

[C++ Error] MPPluginC.cpp(95): E2451 Undefined symbol 'IDD_DIALOG1'
[C++ Error] MPPluginC.cpp(95): E2034 Cannot convert 'int (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'int (__stdcall *)()'
[C++ Error] MPPluginC.cpp(95): E2342 Type mismatch in parameter 'lpDialogFunc' (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,unsigned int,unsigned int,long)')

in this line: (DialogBox(hDllInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NickChanger)



you have to :
make a dialog box
import resource in the project (.rc file)  (there is the dlgbox into )
include the resource.h file (auto created by the program )

:)