Open and Close a window

Find quick help here to get you started with Hollywood
User avatar
Juan Carlos
Posts: 502
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Open and Close a window

Post by Juan Carlos » Fri Apr 22, 2016 2:54 pm

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?

User avatar
airsoftsoftwair
Posts: 3121
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Open and Close a window

Post by airsoftsoftwair » Fri Apr 22, 2016 10:16 pm

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.

zylesea
Posts: 201
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Open and Close a window

Post by zylesea » Fri Apr 22, 2016 10:24 pm

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...

User avatar
Juan Carlos
Posts: 502
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Re: Open and Close a window

Post by Juan Carlos » Sat Apr 23, 2016 1:15 pm

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.

User avatar
emeck
Posts: 74
Joined: Fri Apr 03, 2015 3:17 pm

Re: Open and Close a window

Post by emeck » Sat Apr 23, 2016 11:47 pm

@Juan Carlos
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?
Take a look at version 0.2 of my simple script for icon2png here: http://forums.hollywood-mal.com/viewtop ... 1342#p6689

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

zylesea
Posts: 201
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Open and Close a window

Post by zylesea » Sun Apr 24, 2016 10:22 am

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.
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.
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     


User avatar
Juan Carlos
Posts: 502
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Re: Open and Close a window

Post by Juan Carlos » Mon Apr 25, 2016 7:41 pm

Thanks to all for your help, I'll test your suggestions to get close only the window opened.

User avatar
Juan Carlos
Posts: 502
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Re: Open and Close a window

Post by Juan Carlos » Sun May 08, 2016 1:22 pm

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})

User avatar
fjudde
Posts: 20
Joined: Tue Dec 01, 2015 2:59 pm
Location: Stockholm, Sweden

Re: Open and Close a window

Post by fjudde » Sun May 08, 2016 4:46 pm

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

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
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_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

User avatar
Juan Carlos
Posts: 502
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Re: Open and Close a window

Post by Juan Carlos » Mon May 09, 2016 12:28 pm

@fjudde
Thank you for your help and examples. I shall test both.

Post Reply