Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CodeBlocks DeleD Plugins Templates

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Plugins
View previous topic :: View next topic  
Author Message
Il Buzzo
DeleD PRO user


Joined: 12 Aug 2004
Posts: 271
Location: Italy

PostPosted: Tue Nov 08, 2005 12:41 am    Post subject: CodeBlocks DeleD Plugins Templates Reply with quote

Hi Guys,
It's me Wink, I'm just releasing CodeBlocks templates to make DeleD plugins in an easier way.
You can download as usual from my site at the following address:
http://www.ilbuzzo.net/downloads/DeleDCodeBlocksTemplates.zip

These templates are intended to be used with Visual C++ Toolkit 2003 compiler and CodeBlocks (I've used these as strarting point to write DeleD Level Preview).
Anyway if you have comments or some troubles let me know and I'll fix or try to solve.
Bye Wink.
Back to top
View user's profile Send private message Visit poster's website
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Tue Nov 08, 2005 12:56 pm    Post subject: Reply with quote

Cool I was just thinking about this as I loaded up the forum. Thanks. I've been waiting for this since you brought it up in chat. Laughing

Maybe I can get my dqm exporter working in Deled. Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Tue Nov 08, 2005 4:43 pm    Post subject: Reply with quote

So I just throw whatever code I want inside PluginExecute? I've never even so much as looked at DLL code before, so this is new territory to me.

Why do you link to user32.lib? I've never had to link to that to user messagebox, it's always automatic..or is this because it's a DLL? Can I make a .rc file with some premade dialogs and stuff and use them?

It seems like it just runs through PluginExecute once and it's done? No room for a DlgProc in there? Laughing

Probably stupid questions, but I have no clue. Embarassed
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Tue Nov 08, 2005 7:25 pm    Post subject: Reply with quote

Vampyre_Dark wrote:
So I just throw whatever code I want inside PluginExecute? I've never even so much as looked at DLL code before, so this is new territory to me.

It seems like it just runs through PluginExecute once and it's done? No room for a DlgProc in there? Laughing

Probably stupid questions, but I have no clue. Embarassed


The PluginExecute function is called by DeleD when you press the relevant plugin button under the Plugins menu. Inside the PluginExecute function, you can place your own code, whatever you want. I'm not sure what a DlgProc means, but if you want to use regular Windows Forms, that's no problem at all.

I usually just create a form in the PluginExecute function and use something like MyForm.ShowModal to display the form. The form has its own functions and may send data to DeleD or receive data from DeleD using the callback function also provided in the plugin architecture. Just fill a callback structure (see example plugin) and feed it to the callback routine.

I guess I should start writing a Plugin manual now that more people are getting interested in writing DeleD plugins! Laughing
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Tue Nov 08, 2005 7:33 pm    Post subject: Reply with quote

A DlgProc is a Dialog Callback function, similar to a WndProc. Maybe Delphi doesn't use this? But in C/C++ You need a callback function for your dialogs and windows to use, and you handle all the messages.

Code:
LRESULT CALLBACK DlgProcStart(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HRESULT hRes;

    switch(msg)
    {

        case WM_INITDIALOG:
        {
            SetWindowText(hDlg,APP_TITLE);
            SetForegroundWindow(hDlg);

        }break;


       case WM_COMMAND:
       {
            switch( LOWORD(wParam) )
            {

                case IDC_START_NEW:
                {
                    //start a new promotion dialog
                    if (DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PROMNEW),
                        hDlg, (DLGPROC)DlgProcPromNew) == 0)
                    {
                        EndDialog(hDlg,0);
                    }
                    break;
                }


                case IDC_START_QUIT:
                {
                    //quit the program, and use the special
                    //return value 1 to signal the main program
                    //to quit also
                    EndDialog(hDlg,1);
                    break;
                }
            }break;
        }


        //window being destroyed
        case WM_CLOSE:
        case WM_QUIT:
        case WM_DESTROY:
        {
            SetActivePage(PAGE_NONE);
            EndDialog(hDlg,0);
            break;
        }

        default:
            return false; // Didn't handle message
    }

    return TRUE;
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Il Buzzo
DeleD PRO user


Joined: 12 Aug 2004
Posts: 271
Location: Italy

PostPosted: Tue Nov 08, 2005 7:59 pm    Post subject: Reply with quote

Hi Guys,
Ok let me answer some questions before:

Quote:
So I just throw whatever code I want inside PluginExecute? I've never even so much as looked at DLL code before, so this is new territory to me.

Why do you link to user32.lib? I've never had to link to that to user messagebox, it's always automatic..or is this because it's a DLL? Can I make a .rc file with some premade dialogs and stuff and use them?

It seems like it just runs through PluginExecute once and it's done? No room for a DlgProc in there?


Just like Jeroen explained, you just need to put all code that needs to be executed when plugin is recalled.
To be more clear, just say you want to create an options dialog (like in my DeleD Level Preview) you create a resource file with dialog and a DlgProc, so then in execute code you can run it and let user choose his favourite options to export level. Wink

Maybe you have set user32.lib linkage in automatic but actually to use MessageBox() you need to link user32.lib.

As explained before, yes you can but because of a limitation of visualc++ toolkit you need to download cvtres.exe somewhere over the internet (you'll find, or mail me) and add in visual c++ advanced settings the following item (in link object files to dynamic link libraries) $link_resobjects. You must put cvtres.exe in bin dir in Visual c++ toolkit 2003 path.

DlgProc can be put where you want (outside PluginExecute() ) and you recall your dialog (a modal or non modal ) inside PluginExecute().

OK I hope to have been of help, but owing to the fact that I think that a sample is better than an explanation I'll post soon a simple one.

Bye and if you have other questions let me know Wink.
Back to top
View user's profile Send private message Visit poster's website
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Tue Nov 08, 2005 8:55 pm    Post subject: Reply with quote

I have CVTRes. That really should be included in the PSDK.

I have never had to link to user32, or a few other standard DLLs with any compiler I have used to make windows apps. *shrug* I always figured they were put in automatically when compiling a windows app. Just curious.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Il Buzzo
DeleD PRO user


Joined: 12 Aug 2004
Posts: 271
Location: Italy

PostPosted: Tue Nov 08, 2005 10:07 pm    Post subject: Reply with quote

Hi Guys,
I've just released a sample project with an options dialog.
As you'll see there are:

resource.rc
dialog.h
resource.h

in which are defined dialog, dialog procedure and resource names.
You can download sample at the following address:
http://www.ilbuzzo.net/downloads/dialog_plugin_test.zip
I hope it could be of help.

Well, owing to the fact I've always used MinGW with Dev-cpp I've always linked to each lib needed in code::blocks with Visual C++ too.

Anyway Bye Wink
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum