Open and Close a window
- Juan Carlos
- Posts: 887
- Joined: Mon Sep 06, 2010 1:02 pm
Open and Close a window
I want open and close a external window from a program for example a window with a picture and after close this window no closing the main program.
How do you it?
How do you it?
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Open and Close a window
I don't understand what you mean.... do you want to close a window of another program from your Hollywood script? That isn't possible of course unless the other program is a Hollywood script as well.
Re: Open and Close a window
Not exactly sure what you mean. Do you wnat to open another Hollywood window, show f.ex a picture within that and close it again. If so, createdisplay,OpenDisplay(),selctdisplay and FreeDisplay() are your friends.
Look to help/14 display library/
If you want to run an external (non Hollywood one) progam to show content I guess it will not be easily possible, on Amiga et al via some DOS scripting, but on other systems it wil be harder.
Edit: Oh, Andreas was quicker...
Look to help/14 display library/
If you want to run an external (non Hollywood one) progam to show content I guess it will not be easily possible, on Amiga et al via some DOS scripting, but on other systems it wil be harder.
Edit: Oh, Andreas was quicker...
- Juan Carlos
- Posts: 887
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Open and Close a window
I want open a new window from a Hollywood program, and close this window no closing the main window program, for example to make a about window with my picturem but I tryed to made this but only I got closed the both windows the window with my picture and the program.
Re: Open and Close a window
@Juan Carlos
Look at function p_ShowInfo(). It creates a second display, opens and activates its window and then puts all info there. It waits for the left click to close. The parent window is kept open all the time in the back. Hope it helps.
If there is a better way to do it, I too want to know how.
Regards
Take a look at version 0.2 of my simple script for icon2png here: http://forums.hollywood-mal.com/viewtop ... 1342#p6689I want open and close a external window from a program for example a window with a picture and after close this window no closing the main program.
How do you it?
Look at function p_ShowInfo(). It creates a second display, opens and activates its window and then puts all info there. It waits for the left click to close. The parent window is kept open all the time in the back. Hope it helps.
If there is a better way to do it, I too want to know how.
Regards
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
Re: Open and Close a window
I see. To close a window by hitting the close gadget, but don't quit the main programm you need to use an eventhandler and listen to the close window event. If the close gadget will get clicked it triggers an event with the ID of the window whose close gadget was clicked. You need to write your own close window routine though.Juan Carlos wrote:I want open a new window from a Hollywood program, and close this window no closing the main window program, for example to make a about window with my picturem but I tryed to made this but only I got closed the both windows the window with my picture and the program.
Something like I wrote below - here window 1 is the main window and quits the entire program, while hitting another window close gadget will close the window clicked:
Code: Select all
Function p_closewindow(msg)
Switch msg.id
Case 1:
end
default:
freedisplay(msg.id)
endswitch
EndFunction
InstallEventHandler({ closewindow = p_closewindow} )
Repeat
WaitEvent
Forever
- Juan Carlos
- Posts: 887
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Open and Close a window
Thanks to all for your help, I'll test your suggestions to get close only the window opened.
- Juan Carlos
- Posts: 887
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Open and Close a window
I have this code but the new screen doesn't close, it close my program where is the mistake:
Code: Select all
Function p_Sobre()
CreateDisplay(2, {Title=BSobre$.." "..Head$, Width = 480, Height = 230, Color=$f0f0f0, Active = True, NoClose=False,
Borderless = False, KeepProportions=True, Sizeable = False, Fixed=True, NoModeSwitch=True, NoHide=True})
OpenDisplay(2)
DisplayBrush(200, 0, #CENTER)
BrushToGray(200)
Wait(10)
DisplayBrushFX(200, 0, #CENTER, #BLEND)
SetFont(#SANS, 14)
SetFontColor(#BLACK)
TextOut(210, 85, Head$)
TextOut(210, 100, SoProgra$)
TextOut(210, 115, SoTexto$)
TextOut(210, 130, "(c) Morgue Soft Ltd."..Year$)
TextOut(210, 145, "www.morguesoft.eu")
TextOut(210, 160, "Software Made in Spain")
EndFunction
Function p_Salir(msg)
Switch msg.id
Case 1:
Quitar=SystemRequest(SalAvi1$, SalPeti1$, Aceptar$, #REQICON_QUESTION)
If Quitar=True
End()
Else
Return()
EndIf
Case 2:
FreeDisplay(2) ;FreeDisplay(msg.id)
EndSwitch
EndFunction
InstallEventHandler({CloseWindow=p_Salir})
Re: Open and Close a window
I might be wrong but I think you have to install a handler for every window you open. Every handler can point to same function using a switch to distinguish between window id's
Or you can use separate functions. Press the "o"-key to open the new window in these examples.
Anyone elses comment and ideas are welcome on this matter!
Code: Select all
Function p_Sobre()
CreateDisplay(2,{Width = 480, Height = 230, Active = True})
OpenDisplay(2)
NPrint("text")
InstallEventHandler({CloseWindow = p_Salir})
EndFunction
Function p_Salir(msg)
Switch msg.id
Case 1:
res=SystemRequest("Quit?", "Do you want to quit?", "OK!|Cancel", #REQICON_QUESTION)
If res = 1
End()
Else
SelectDisplay(1)
Return()
EndIf
Case 2:
CloseDisplay(2)
SelectDisplay(1)
FreeDisplay(2)
EndSwitch
EndFunction
Function p_OpenWinTwo()
If IsKeyDown("o") Or IsKeyDown("O")
p_Sobre()
EndIf
EndFunction
SetInterval(2, p_OpenWinTwo, 1000/12)
InstallEventHandler({CloseWindow = p_Salir})
Repeat
WaitEvent
Forever
Anyone elses comment and ideas are welcome on this matter!
Code: Select all
Function p_Sobre()
CreateDisplay(2,{Width = 480, Height = 230, Active = True})
OpenDisplay(2)
NPrint("text")
InstallEventHandler({CloseWindow = p_Salir2})
EndFunction
Function p_Salir1()
res=SystemRequest("Quit?", "Do you want to quit?", "OK!|Cancel", #REQICON_QUESTION)
If res = 1
End()
Else
SelectDisplay(1)
Return()
EndIf
EndFunction
Function p_Salir2()
CloseDisplay(2)
SelectDisplay(1)
FreeDisplay(2)
EndFunction
Function p_OpenWinTwo()
If IsKeyDown("o") Or IsKeyDown("O")
p_Sobre()
EndIf
EndFunction
SetInterval(2, p_OpenWinTwo, 1000/12)
InstallEventHandler({CloseWindow = p_Salir1})
Repeat
WaitEvent
Forever
_____________________________________
Hollywood 6.1
Hollywood 6.1
- Juan Carlos
- Posts: 887
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Open and Close a window
@fjudde
Thank you for your help and examples. I shall test both.
Thank you for your help and examples. I shall test both.