IonicWind Software

Aurora Compiler => GUI => Topic started by: Bruce Peaslee on December 16, 2005, 11:28:07 AM

Title: Window handle
Post by: Bruce Peaslee on December 16, 2005, 11:28:07 AM
It may be because I'm still struggling a little with OOPÂÃ,  ;) , but I've having trouble passing the window handle to the MessageBox function. I want to give a message if the user clicks a menu item that is not yet implemented. It works fine if I put zero, but I want the box to stay in front until cleared by the user.
Title: Re: Window handle
Post by: Zen on December 16, 2005, 11:45:19 AM
Ha ha i had that problem.

if you are calling you MessageBox from within your class. ie your OnDestroy() method. You can do the following MessageBox(this,"Goodbye","Destroy");

But if you are running the messagebox from within your main subroutine then use the name of your class variable.

mywindow win;
messagebox(win,"Hello","Test");

Hope this is what you are after.
Lewis
Title: Re: Window handle
Post by: Bruce Peaslee on December 16, 2005, 11:53:59 AM
Perfect. Thanks.
Title: Re: Window handle
Post by: Zen on December 16, 2005, 11:56:58 AM
Your welcome. Iasked the same thing a few days ago. Ive never done OOP apart from in PHP which is a lot different apart from i understand how it is meant to work.

So i guess we are in the same boat here. :D Hey did anyone ever tell you, you look a lot like bruce willis? ::)

Lewis
Title: Re: Window handle
Post by: Parker on December 16, 2005, 12:49:18 PM
PHP is interpreted, so they're free to do it however they want. I would use lists and descriptors of arguments to do that in an interpreted language, but it's done very differently in a compiler. Well, in the end the way its handled is different.
Title: Re: Window handle
Post by: Bruce Peaslee on December 16, 2005, 01:08:05 PM
New question.

"This" worked when I used it in MessageBox, but now I want to use another method, WriteText, in myWindow::OnSize.


this.WriteText(10,10,"Whatever");


fails. So does


winMain.WriteText(10,10,"Whatever");
Title: Re: Window handle
Post by: Parker on December 16, 2005, 01:10:14 PM
"this" is a pointer. Messagebox probably expects a window pointer, so it works there. But you need to do this:

*this.something();

Hopefully Paul will add the -> operator, then we can do this->something();.
Title: Re: Window handle
Post by: Zen on December 16, 2005, 01:10:38 PM
Because it is in a class method. Just call WriteText(...); without a prefix as it will automaticly do it for the class the method is within.

If it was not in a class then you would call classVar.WriteText(...);

Lewis
Title: Re: Window handle
Post by: Parker on December 16, 2005, 01:12:44 PM
You can use either method. The way of calling with the this pointer is more explicit and shows more what you're trying to do, but either way works fine.
Title: Re: Window handle
Post by: Zen on December 16, 2005, 01:14:36 PM
Yes i remember when i was doing Java at university we got told to use the this operator because it was good programming practise and it helps other developers to know what you are doing with your code.

Lewis
Title: Re: Window handle
Post by: Bruce Peaslee on December 16, 2005, 02:25:56 PM
Thanks guys.

Here is the snippet of the code I am playing with. It recenters the string "Skeleton" when the window is resized.


myWindow::OnSize(int nType, int cx, int cy), int
{
def clientRect as rect;
def textSize as point;
def x,y as int;

SetWindowColor(GetSysColor(15)); // also clears screen
SetFont("Comic Sans MS",10,800);
FrontPen(RGB(0,0,0));
BackPen(GetSysColor(15));
textSize = GetTextSize("Skeleton");
clientRect = GetClientRect();
x = (clientRect.right - clientRect.left - textSize.x)/2; // to center text
y = 10;
WriteText(x,y,"Skeleton");
Return 0;
}


It gave me a little problem until I realized that OnSize was being called when the window first appears.
Title: Re: Window handle
Post by: Parker on December 16, 2005, 02:43:10 PM
Just a sidenote, Lewis - look in profile settings, avatars, actors, Bruce Willis, you'll see the same picture as peaslee has, so I don't think it's a personal picture  ;)
Title: Re: Window handle
Post by: Bruce Peaslee on December 16, 2005, 02:58:55 PM
Quote from: Parker on December 16, 2005, 02:43:10 PM
Just a sidenote, Lewis - look in profile settings, avatars, actors, Bruce Willis, you'll see the same picture as peaslee has, so I don't think it's a personal pictureÂÃ,  ;)

I think he gotcha, Parker.ÂÃ,  ;)
Title: Re: Window handle
Post by: Zen on December 16, 2005, 03:34:56 PM
Quote from: Parker on December 16, 2005, 02:43:10 PM
Just a sidenote, Lewis - look in profile settings, avatars, actors, Bruce Willis, you'll see the same picture as peaslee has, so I don't think it's a personal picture  ;)

He He. Just a joke.

Lewis
Title: Re: Window handle
Post by: Parker on December 16, 2005, 03:49:04 PM
Oh, okay then :) I guess I didn't get it. Lewis, has anyone told you how much you look like a cube  ::)
Title: Re: Window handle
Post by: Zen on December 16, 2005, 03:55:30 PM
He He. Im sorry if you didnt catch on. It must of been my british humor :D

Lewis