May 08, 2024, 04:18:51 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Global Classes possible?

Started by Shannara, December 22, 2006, 04:58:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Shannara

At first, I thought I could create a global class by doing the following:


Global myClass;
BaseClass myClass;


And after I create the bugger, I would be able to use it in any class and source file (via extern) in my project. Even though it compiles with no error, on execution, the whole program crashes. Are global classes allowed in Aurora (currently) ? Im thinking i'm trying something that isnt allowed or checked during compilation.
Love is staying up all night with a sick child, or a healthy adult.

Ionic Wind Support Team

Classes are global by default.  If you look at how I remade your project you can see that you only need the definition of the class, the linker figures out the rest.
Ionic Wind Support Team

Shannara

hrm .... ok, so when I do something like frmMain : CWindow,

I should be able to type frmMain.OnClose() in any other class that references the include? That's what I am trying to do, globally access a class instance :)
Love is staying up all night with a sick child, or a healthy adult.

Ionic Wind Support Team

Now that is something different.  You shouldn't really call an OnXXX handler yourself.  If you want to close a window just call it's Destroy method.

If you are trying to access a specific instance of a class from another file then make a global pointer to that instance.

Paul.
Ionic Wind Support Team

Shannara

Hmm, on top of source files, typing the following according to the manual:


global *fMainMenu;
mMainMenu *fMainMenu;


Even if I remove the 2nd line, the following error happens:


File: C:\Projects\Online RPG  Maker (Aurora)\Client\Main.src (8) syntax error - *
Error(s) in compiling "C:\Projects\Online RPG  Maker (Aurora)\Client\Main.src"



It doesnt seem to like the pointer symbol for some reason.
Love is staying up all night with a sick child, or a healthy adult.

Ionic Wind Support Team

The * tells it is a pointer variable.  It is not part of the variable name so nix it from the GLOBAL statement.

global fMainMenu;
mMainMenu *fMainMenu;

Ionic Wind Support Team

Bruce Peaslee

Quote from: Paul Turley on December 22, 2006, 07:39:01 PM
You shouldn't really call an OnXXX handler yourself.ÂÃ, 

Is that true in general? I have been doing something like this:


MainWindow::OnMenuPick(int nID), int
{
ÂÃ,  ÂÃ, select nID
ÂÃ,  ÂÃ, {
ÂÃ,  ÂÃ,  ÂÃ,  case FILE_EXIT:
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  OnClose();
ÂÃ,  ÂÃ,  ÂÃ,  case HELP_ABOUT:
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, MessageBox(this,"Another great one.","About",0);
ÂÃ,  ÂÃ, }
}


In this way I can put all of my checking ("Do you really want to quit?") in one spot.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

That's fine.  It all depends on what the particular handler does.  I have run into problems in the past using MFC code where calling a handler generated another message, etc.
Ionic Wind Support Team