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.
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.
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 :)
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.
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.
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;
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.
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.