IonicWind Software

Aurora Compiler => GUI => Topic started by: ExMember001 on August 02, 2006, 04:49:24 PM

Title: parent to child window
Post by: ExMember001 on August 02, 2006, 04:49:24 PM
i will use the mouseleave_win example to show what i mean..
i try to set the color of the hoverwindow to black, what do i forget to do ?
i think youll say that i dont tell the pointer which window to use, but in this situation how can i do that?, i dont see it at all...


//small example of how to use the _TrackMouseEvent API function
//For Aurora version 1.0 or greater
//Compile as WINDOWS target


DECLARE IMPORT,_TrackMouseEvent(tme as TRACKMOUSEEVENT),INT;

struct TRACKMOUSEEVENT
{
    unsigned INT cbSize;
    unsigned INT dwFlags;
    unsigned INT hwndTrack;
    unsigned INT dwHoverTime;
}

CONST TME_HOVER = 1;
CONST TME_LEAVE = 2;
CONST WM_MOUSEHOVER = 0x2A1;
CONST WM_MOUSELEAVE = 0x2A3;

class HoverWindow:CWindow
{
declare HoverWindow();
declare OnMouseMove(int x,int y,int flags),int;
declare WndProc(unsigned int message, unsigned int wparam, unsigned int lparam),int;
declare OnTimer(int nIDEvent),int;
CWindow *popup;
int bHover;
}

class MainWindow:CWindow
{
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;

HoverWindow *hw;
}

class PopupWindow:CWindow
{
}

int run;

global sub main()
{
MainWindow win;
HoverWindow child;
PopupWindow child2;
win.Create(0,0,300,100,AWS_CAPTION | AWS_SYSMENU | AWS_AUTODRAW | AWS_VISIBLE | AWS_BORDER,0,"HoverDemo",0);
child.Create(10,10,60,60,AWS_VISIBLE|AWS_BORDER|AWS_CHILD,0,"",win);
//create the popup invisible
child2.Create(100,10,120,60,AWS_CHILD|AWS_AUTODRAW|AWS_BORDER,0,"Popup Info",win);
child2.SetWindowColor(RGB(255,255,0));
child2.DrawMode(TRANSPARENT);
child2.WriteText(5,5,"Just some info");
child2.WriteText(5,20,"For your program");
child.popup = &child2;

Win.AddControl(CTBUTTON,"Color",230,10,50,20,0x50010000,0x0,1);

win.CenterWindow();
run = 1;
do
{
wait();
} until run = 0;
return;
}

MainWindow::OnClose(),int
{
run = 0;
return true;
}

MainWindow::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nid {
case 1:
hw->setwindowcolor(rgb(0,0,0));
}
}

HoverWindow::HoverWindow()
{
popup = null;
bHover = false;
return;
}

HoverWindow::OnMouseMove(int x,int y,int flags),int
{
if(bHover = false)
{
TRACKMOUSEEVENT tme;
tme.cbSize = LEN(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = m_hwnd;
tme.dwHoverTime = 25;
_TrackMouseEvent(tme);
}
return true;
}

HoverWindow::OnTimer(int nIDEvent),int
{
popup->ShowWindow(SWHIDE);
StopTimer();
return true;
}

HoverWindow::WndProc(unsigned int message, unsigned int wparam, unsigned int lparam),int
{
POINT pt;
select message
{
case WM_MOUSEHOVER:
bHover = true;
SetWindowColor(RGB(255,0,0));
StartTimer(2500); //close the popup after a few seconds
popup->ShowWindow(SWSHOW);
case WM_MOUSELEAVE:
bHover = false;
SetWindowColor(RGB(255,255,255));
StopTimer();
popup->ShowWindow(SWHIDE);

}
return CWindow!!WndProc(message,wParam,lParam);
}
Title: Re: parent to child window
Post by: kryton9 on August 02, 2006, 05:07:10 PM
Not sure of what exactly you wanted, but if you just change your color from

case WM_MOUSELEAVE:
bHover = false;
SetWindowColor(RGB(255,255,255));
StopTimer();
popup->ShowWindow(SWHIDE);


To This:
case WM_MOUSELEAVE:
bHover = false;
SetWindowColor(RGB(0,0,0));
StopTimer();
popup->ShowWindow(SWHIDE);

When you leave the mouse it turns black.

If you wanted the main windows black:
global sub main()
{
MainWindow win;
HoverWindow child;
PopupWindow child2;
win.Create(0,0,300,100,AWS_CAPTION | AWS_SYSMENU | AWS_AUTODRAW | AWS_VISIBLE | AWS_BORDER,0,"HoverDemo",0);
win.SetWindowColor(RGB(0,0,0));  // <<<<<<<<<<<< add this line here
child.Create(10,10,60,60,AWS_VISIBLE|AWS_BORDER|AWS_CHILD,0,"",win);
Title: Re: parent to child window
Post by: ExMember001 on August 02, 2006, 05:26:11 PM
sorry forgot to add, i want to set it using the new color button create on the Mainwindow
if i click the button, i want the hoverwindow to turn black
Title: Re: parent to child window
Post by: kryton9 on August 02, 2006, 06:10:23 PM
Since MainWindow is derived from the base class CWindow, you just use that.
I commented the line where the change was made.

//small example of how to use the _TrackMouseEvent API function
//For Aurora version 1.0 or greater
//Compile as WINDOWS target


DECLARE IMPORT,_TrackMouseEvent(tme as TRACKMOUSEEVENT),INT;

struct TRACKMOUSEEVENT
{
ÂÃ,  ÂÃ,  unsigned INT cbSize;
ÂÃ,  ÂÃ,  unsigned INT dwFlags;
ÂÃ,  ÂÃ,  unsigned INT hwndTrack;
ÂÃ,  ÂÃ,  unsigned INT dwHoverTime;
}

CONST TME_HOVER = 1;
CONST TME_LEAVE = 2;
CONST WM_MOUSEHOVER = 0x2A1;
CONST WM_MOUSELEAVE = 0x2A3;

class HoverWindow:CWindow
{
declare HoverWindow();
declare OnMouseMove(int x,int y,int flags),int;
declare WndProc(unsigned int message, unsigned int wparam, unsigned int lparam),int;
declare OnTimer(int nIDEvent),int;
CWindow *popup;
int bHover;
}

class MainWindow:CWindow
{
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;

HoverWindow *hw;
}

class PopupWindow:CWindow
{
}

int run;

global sub main()
{
MainWindow win;
HoverWindow child;
PopupWindow child2;
win.Create(0,0,300,100,AWS_CAPTION | AWS_SYSMENU | AWS_AUTODRAW | AWS_VISIBLE | AWS_BORDER,0,"HoverDemo",0);
//win.SetWindowColor(RGB(0,0,0));
child.Create(10,10,60,60,AWS_VISIBLE|AWS_BORDER|AWS_CHILD,0,"",win);
//create the popup invisible
child2.Create(100,10,120,60,AWS_CHILD|AWS_AUTODRAW|AWS_BORDER,0,"Popup Info",win);
child2.SetWindowColor(RGB(255,255,0));
child2.DrawMode(TRANSPARENT);
child2.WriteText(5,5,"Just some info");
child2.WriteText(5,20,"For your program");
child.popup = &child2;

Win.AddControl(CTBUTTON,"Color",230,10,50,20,0x50010000,0x0,1);

win.CenterWindow();
run = 1;
do
{
wait();
} until run = 0;
return;
}

MainWindow::OnClose(),int
{
run = 0;
return true;
}

MainWindow::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nid {
case 1:
CWindow.setwindowcolor(rgb(0,0,0));// <<<<<<<<<<<<<ÂÃ,  Since MainWindow is derived from CWindow, you just use that.
}
}

HoverWindow::HoverWindow()
{
popup = null;
bHover = false;
return;
}

HoverWindow::OnMouseMove(int x,int y,int flags),int
{
if(bHover = false)
{
TRACKMOUSEEVENT tme;
tme.cbSize = LEN(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = m_hwnd;
tme.dwHoverTime = 25;
_TrackMouseEvent(tme);
}
return true;
}

HoverWindow::OnTimer(int nIDEvent),int
{
popup->ShowWindow(SWHIDE);
StopTimer();
return true;
}

HoverWindow::WndProc(unsigned int message, unsigned int wparam, unsigned int lparam),int
{
POINT pt;
select message
{
case WM_MOUSEHOVER:
bHover = true;
SetWindowColor(RGB(255,0,0));
StartTimer(2500); //close the popup after a few seconds
popup->ShowWindow(SWSHOW);
case WM_MOUSELEAVE:
bHover = false;
SetWindowColor(RGB(255,255,255));
StopTimer();
popup->ShowWindow(SWHIDE);

}
return CWindow!!WndProc(message,wParam,lParam);
}


You can just change the line to this to have more fun with the button :)
CWindow.setwindowcolor(rgb(Rand(255),Rand(255),Rand(255)));// <<<<<<<<<<<<<  Since MainWindow is derived from CWindow, you just use that.
Title: Re: parent to child window
Post by: ExMember001 on August 02, 2006, 06:38:03 PM
misunderstood again but its not a problem because you try to help  ;D
changing backgroung color of the mainwindow from the Mainwindow class is easy ..

ill try to be more explicit ;)

the button is create on the mainwindow.. and is controled from the mainwindow class..
the HoverWindow is a child of Mainwindow controled from the Hoverwindow class

if i click the button i want the hoverwindow (child of Mainwindow) to turn black. i've try setting a pointer HoverWindow *hw; in the mainwindow class
then use hw->setwindowcolor(rgb(0,0,0)); in the Mainwindow::Oncontrol Method but this doesnt work...

Last times i got this problem Paul tell me that i forgot to Set the Pointer, and i understand how now ... but this time its a different situation and i dont see the solution...

Title: Re: parent to child window
Post by: Ionic Wind Support Team on August 02, 2006, 08:41:08 PM
You're just not setting the pointer again Krypt.

In your MainWindow definition you have:


HoverWindow *hw;

But there is no where in the code that you have

win.hw = ????

So in Main you could set it up like so:


.....
win.hw = child; // ADD THIS
win.CenterWindow();
run = 1;
do
{
wait();
} until run = 0;
return;


Quote
Since MainWindow is derived from the base class CWindow, you just use that.
I commented the line where the change was made.

Sorry but that is wrong.
Title: Re: parent to child window
Post by: kryton9 on August 02, 2006, 08:54:36 PM
What I don't understand is why is it that:
child.popup = &child2;  In this you are assigning the address of child2
win.hw = child2;  Why no the address of Child 2 here also?

As later in the code popup->ShowWindow(SWSHOW);   of course works
then why does this line work, when the pointer is assigned a different way
hw->WriteText(5,5,"Just some info");

This code works, but changes to random colors instead of just black:
//small example of how to use the _TrackMouseEvent API function
//For Aurora version 1.0 or greater
//Compile as WINDOWS target


DECLARE IMPORT,_TrackMouseEvent(tme as TRACKMOUSEEVENT),INT;

struct TRACKMOUSEEVENT
{
ÂÃ,  ÂÃ,  unsigned INT cbSize;
ÂÃ,  ÂÃ,  unsigned INT dwFlags;
ÂÃ,  ÂÃ,  unsigned INT hwndTrack;
ÂÃ,  ÂÃ,  unsigned INT dwHoverTime;
}

CONST TME_HOVER = 1;
CONST TME_LEAVE = 2;
CONST WM_MOUSEHOVER = 0x2A1;
CONST WM_MOUSELEAVE = 0x2A3;

class HoverWindow:CWindow
{
declare HoverWindow();
declare OnMouseMove(int x,int y,int flags),int;
declare WndProc(unsigned int message, unsigned int wparam, unsigned int lparam),int;
declare OnTimer(int nIDEvent),int;
CWindow *popup;
int bHover;
}

class MainWindow:CWindow
{
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;

HoverWindow *hw;
}

class PopupWindow:CWindow
{
}

int run;

global sub main()
{
MainWindow win;
HoverWindow child;
PopupWindow child2;
win.Create(0,0,300,100,AWS_CAPTION | AWS_SYSMENU | AWS_AUTODRAW | AWS_VISIBLE | AWS_BORDER,0,"HoverDemo",0);
//win.SetWindowColor(RGB(0,0,0));
child.Create(10,10,60,60,AWS_VISIBLE|AWS_BORDER|AWS_CHILD,0,"",win);
//create the popup invisible
child2.Create(100,10,120,60,AWS_CHILD|AWS_AUTODRAW|AWS_BORDER,0,"Popup Info",win);
child2.SetWindowColor(RGB(255,255,0));
child2.DrawMode(TRANSPARENT);
child2.WriteText(5,5,"Just some info");
child2.WriteText(5,20,"For your program");
child.popup = &child2;
win.hw = child2;
Win.AddControl(CTBUTTON,"Color",230,10,50,20,0x50010000,0x0,1);

win.CenterWindow();
run = 1;
do
{
wait();
} until run = 0;
return;
}

MainWindow::OnClose(),int
{
run = 0;
return true;
}

MainWindow::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nid {
case 1:
hw->setwindowcolor(rgb(Rand(255),Rand(255),Rand(255)));// <<<<<<<<<<<<<ÂÃ,  Since MainWindow is derived from CWindow, you just use that.
hw->WriteText(5,5,"Just some info");
hw->WriteText(5,20,"For your program");
}
}

HoverWindow::HoverWindow()
{
popup = null;
bHover = false;
return;
}

HoverWindow::OnMouseMove(int x,int y,int flags),int
{
if(bHover = false)
{
TRACKMOUSEEVENT tme;
tme.cbSize = LEN(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = m_hwnd;
tme.dwHoverTime = 25;
_TrackMouseEvent(tme);
}
return true;
}

HoverWindow::OnTimer(int nIDEvent),int
{
popup->ShowWindow(SWHIDE);
StopTimer();
return true;
}

HoverWindow::WndProc(unsigned int message, unsigned int wparam, unsigned int lparam),int
{
POINT pt;
select message
{
case WM_MOUSEHOVER:
bHover = true;
SetWindowColor(RGB(255,0,0));
StartTimer(2500); //close the popup after a few seconds
popup->ShowWindow(SWSHOW);
case WM_MOUSELEAVE:
bHover = false;
SetWindowColor(RGB(255,255,255));
StopTimer();
popup->ShowWindow(SWHIDE);

}
return CWindow!!WndProc(message,wParam,lParam);
}
Title: Re: parent to child window
Post by: Ionic Wind Support Team on August 02, 2006, 09:10:26 PM
Calm down.

The compiler is smart enough to know what to do.  The & operator is really optional in this case and is allowed since I am so used to typing it.
Title: Re: parent to child window
Post by: kryton9 on August 02, 2006, 09:12:31 PM
Ok, I tried it with the &child and without and it works either way for both of them.

To make the above work, you have to click on the button, then go over and hover over the square and then press spacebar to change the colors as you need to hover to see the popup :)
It times out so you have to rehover and keep hitting spacebar, so fun.

Glad Krypt tried this example out... the answer by Paul is shedding more light while at the same time letting me realize I got a long way to go :)

Posted while you did too :)
Title: Re: parent to child window
Post by: kryton9 on August 02, 2006, 09:14:25 PM
QuoteThe compiler is smart enough to know what to do.  The & operator is really optional in this case and is allowed since I am so used to typing it.

ok Paul, you are closer to that IDE request on that thread for the read my mind and write the code addition :)
Title: Re: parent to child window
Post by: ExMember001 on August 03, 2006, 12:05:51 AM
thanx, i think i got it now ..
i know it was something like that ..
Me and pointers are not very good friends at the moment .. but it will come ;)
Title: Re: parent to child window
Post by: ExMember001 on August 03, 2006, 01:00:31 AM
strange, it works nice on the example but doing the samething in my code crash the program when it start..

line197 -> create the pointer

line 334 -> set the pointer

line 731 -> set the color to the child

now i'm lost lol  :o
Title: Re: parent to child window
Post by: ExMember001 on August 03, 2006, 08:59:16 PM
forget that i've change the way i handle this now ;)