PDA

View Full Version : Help with dialog


SuperKOSTYA
01-19-2007, 02:06 PM
Hi All! I'm beginner at script writing, but I need help: (лучше заменить хотя бы таким словом) heart of problem is to create of non-modal dialog window & to use drag'n'drop interface. In the given bellow code I tried to make a non-modal dialog window, but a new-created window blinks some time and disappears immediately after creating. I'm in panic, ‘cause I've spent two senseless days trying to solve the problem.


//*******************************************************

class MyDialog : GeDialog
{
public:
MyDialog(d);
CreateLayout();
AskClose();
}

MyDialog::MyDialog(d)
{
super(d);
}

//*****************************************
MyDialog::CreateLayout()
{
SetTitle("Non modal window");
AddGroupBeginV(100010,BFV_CENTER, 1, "", 0);
AddStaticText(100011, 0, 0, 0, "YO!", 0);
AddEditText(100011, 0 , 200, 10);
AddButton(1001, BFV_CENTER, 100, 10, "Button");
AddGroupEnd();
AddDlgGroup(DLG_OK | DLG_CANCEL);
return TRUE;
}

MyDialog::AskClose()
{
return FALSE;
}


main(doc,op)
{
CallCommand(13957); //Clear Console Entries
var x=new(MyDialog,1);

x->Open(true,100,100); //Open the dialog
}

Darter
01-20-2007, 11:13 AM
Here's a working version of your dialog. I've included a derived class from MenuPlugin, based on the SDK example file. This means that the dialog can now be loaded from the Plugins menu.

Before using, make sure that you provide a plugin ID as indicated at the beginning of the code. IDs between 1000001-1000010 can be used for development but you must obtain a unique ID from Plugin Cafe before releasing a plugin.


//**********Non-modal Dialog***************

var PLUGIN_ID = //Insert plugin ID here!!

class MyDialog : GeDialog
{
public:
MyDialog();
CreateLayout();
AskClose();
}

MyDialog::MyDialog()
{
super(PLUGIN_ID);
}

//*********************************************
MyDialog::CreateLayout()
{
SetTitle("Non modal window");

AddGroupBeginV(100010,BFV_CENTER, 1, "", 0);
{
AddGroupSpace(4,4);
AddGroupBorder(BORDER_OUT);
AddGroupBorderSpace(4,4,4,4);
AddStaticText(100011, 0, 0, 0, "YO!", 0);
AddEditText(100011, 0 , 200, 10);
AddButton(1001, BFV_CENTER, 100, 10, "Button");
AddGroupEnd();
}
AddDlgGroup(DLG_OK | DLG_CANCEL);
return TRUE;
}

MyDialog::AskClose()
{
return FALSE;
}
//**********************************************
class MyMenuPlugin : MenuPlugin
{
public:
MyMenuPlugin();

GetID();
GetName();
GetHelp();
GetState();
Execute(doc);

RestoreLayout(secret);
}

MyMenuPlugin::MyMenuPlugin()
{
super();
}

MyMenuPlugin::GetState()
{
return CMD_ENABLED;
}

MyMenuPlugin::GetID()
{
return PLUGIN_ID;
}

MyMenuPlugin::GetName()
{
return "Kostya's Plugin";
}

MyMenuPlugin::GetHelp()
{
return "Yo dude";
}

var d;

MyMenuPlugin::Execute(doc)
{
d->Open(TRUE, -1, -1);
}

MyMenuPlugin::RestoreLayout(secret)
{
if (!d) d = new(MyDialog);
d->RestoreLayout(secret);
}


main()
{
d = new(MyDialog);

Register(MyMenuPlugin);
}

SuperKOSTYA
01-22-2007, 02:41 PM
Great! Thank you for your help! But what can you advice me about to create a non-modal window directly in script manager without using a MenuPlugin (after Execute-button pressing). Is it real?

Darter
01-22-2007, 08:39 PM
No, it's not possible to use dialogs with scripts so you'll have to create a Menu Plugin to put your dialog to use.

SuperKOSTYA
01-23-2007, 06:52 AM
Well. Thank you for your worry about my problem! It made me clear :thumbsup:

CGTalk Moderation
01-23-2007, 06:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.