IonicWind Software

Aurora Compiler => GUI => Topic started by: Bruce Peaslee on December 31, 2005, 03:29:00 PM

Title: Dialog Question
Post by: Bruce Peaslee on December 31, 2005, 03:29:00 PM
More OOP confusion ;)

My program has a bunch of child windows. When the mouse hovers over one, another window opens and shows some data. I am now trying to get where if I click on the window, it opens a dialog. The example colorcontrols.src has the dialog defined in main(), but if I do that, how do I then call DoModal from a class method?
Title: Re: Dialog Question
Post by: Bruce Peaslee on December 31, 2005, 03:57:06 PM
OK, I stuck the DoModal call into a subroutine called from the method. At least it appears. Now I will see if I can access the data properly.
Title: Re: Dialog Question
Post by: Parker on December 31, 2005, 04:27:39 PM
As long as the variable hasn't fallen out of scope yet, you can access it, although you'll need a pointer to it first. The 'this' pointer does that for you, so any data and functions can be accessed even if you're not calling it from main(). But once main() returns, you can't access it anymore. Of course, that's not a problem since the program ends when main() returns.
Title: Re: Dialog Question
Post by: Bruce Peaslee on January 01, 2006, 09:34:09 AM
I'm still not getting it.

The program looks something like this:

class mapwindow:cwindow
...
mapwindow::OnLButtonDown
{
// here is where I want to DoModal
}
...
global sub main()
{
// here is where the dialog is defined
def d1 as dlg;
d1.create(...);
...
}
Title: Re: Dialog Question
Post by: Ionic Wind Support Team on January 01, 2006, 10:17:21 AM
There are dozens of ways to do this. Use a variable in your MapWindow class.

dialog *mydialog.

When you create the MapWindow set the variable to the address of the dialog you created.

pMap->myDialog = &d1;

Then you can execute DoModal from that method

myDialog->DoModal();

Another way would be to create the dialog in the MapWindow class..again using the variable in the MapWindow class....using NEW of course

It all depends on what the dialog is used for.  If it is only used by the MapWindow class then let that class manage it, putting it in your  'main' sub is just making you do extra work.  If I were to have a dialog that was only used in a single class then it would be dynamically allocated.

class SomeClass
{
declare OnCreate();
declare SomeClass();
declare _SomeClass();
declare InitStuffDialog();
dialog *ShowStuff;
}

SomeClass::SomeClass()
{
ShowStuff = NULL;
return;
}

SomeClass::_SomeClass()
{
if(ShowStuff)
   Delete ShowStuff;
return;
}

SomeClass::InitStuffDialog()
{
ShowStuff = new(dialog,1);
ShowStuff->Create(...);
ShowStuff->AddControl(...);
...
return;
}

SomeClass::OnCreate(),int;
{
InitStuffDialog();
return;
}


Paul.
Title: Re: Dialog Question
Post by: Bruce Peaslee on January 01, 2006, 09:59:21 PM
Thanks. I will work on this tomorrow.
Title: Re: Dialog Question
Post by: Bruce Peaslee on January 02, 2006, 12:11:17 PM
Quote from: Ionic Wizard on January 01, 2006, 10:17:21 AM
There are dozens of ways to do this...
There are even more ways not to do it!ÂÃ,  ÂÃ, :D

I used the last example and it works perfectly. Thanks for your patience as well as your help.
Title: Re: Dialog Question
Post by: Ionic Wind Support Team on January 02, 2006, 12:12:51 PM
Your welcome ;)

Dialogs will be easier to use as we progress.