Page 1 of 1

Open modal window before the main window

Posted: Thu Dec 23, 2010 12:24 am
by pctoledo
How to open modal window before the main window?

I tried that, but it did not work:

Code: Select all

#include "hmg.ch"

Function Main

Local oMainWindow

	With Object oMainWindow := Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 400
		:Height		:= 200
		:Title		:= 'System Demo'
		:Type		:= WND_MAIN
		:OnInit		:= { || Password_(), oMainWindow:Maximize() }
		:OnRelease	:= { || Close_Win() }

	End With

	oMainWindow:Activate()

Return

Function Password_()
Local oModalPass, oButton1

	With Object oModalPass	:= Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 200
		:Height		:= 100
		:Title		:= 'Password'
		:Type		:= WND_MODAL
		:OnInit		:= { || ( oModalPass:Center() ) } 

		With Object oButton1 := Button():New()
			:Row		:= 40
			:Col		:= 40
			:Caption	:= 'Close Window Password'
			:OnClick	:= { || oModalPass:Release() }
		End With

	End With

	oModalPass:Activate()

return .T.

Function Close_Win()
Local oModalClose, oButton2

	With Object oModalClose	:= Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 200
		:Height		:= 100
		:Title		:= 'Close System'
		:Type		:= WND_MODAL
		:OnInit		:= { || ( oModalClose:Center() ) } 

		With Object oButton2 := Button():New()
			:Row		:= 40
			:Col		:= 40
			:Caption	:= 'Close System'
			:OnClick	:= { || oModalClose:Release() }
		End With

	End With

	oModalClose:Activate()

return .T.
I wanted to open a window Password before the main window. And when you finish the main window, open another modal window.

Re: Open modal window before the main window

Posted: Thu Dec 23, 2010 2:28 am
by Rathinagiri
pctoledo wrote:How to open modal window before the main window?

I tried that, but it did not work:

Code: Select all

#include "hmg.ch"

Function Main

Local oMainWindow

	With Object oMainWindow := Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 400
		:Height		:= 200
		:Title		:= 'System Demo'
		:Type		:= WND_MAIN
		:OnInit		:= { || Password_(), oMainWindow:Maximize() }
		:OnRelease	:= { || Close_Win() }

	End With

	oMainWindow:Activate()

Return

Function Password_()
Local oModalPass, oButton1

	With Object oModalPass	:= Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 200
		:Height		:= 100
		:Title		:= 'Password'
		:Type		:= WND_MODAL
		:OnInit		:= { || ( oModalPass:Center() ) } 

		With Object oButton1 := Button():New()
			:Row		:= 40
			:Col		:= 40
			:Caption	:= 'Close Window Password'
			:OnClick	:= { || oModalPass:Release() }
		End With

	End With

	oModalPass:Activate()

return .T.

Function Close_Win()
Local oModalClose, oButton2

	With Object oModalClose	:= Window():New()
		:Row		:= 10
		:Col		:= 10
		:Width		:= 200
		:Height		:= 100
		:Title		:= 'Close System'
		:Type		:= WND_MODAL
		:OnInit		:= { || ( oModalClose:Center() ) } 

		With Object oButton2 := Button():New()
			:Row		:= 40
			:Col		:= 40
			:Caption	:= 'Close System'
			:OnClick	:= { || oModalClose:Release() }
		End With

	End With

	oModalClose:Activate()

return .T.
I wanted to open a window Password before the main window. And when you finish the main window, open another modal window.
You can open the main window with 'noshow' clause. So, the modal window will be shown to the user first. From the modal window, you can show or close the main window as the case may be.

Re: Open modal window before the main window

Posted: Thu Dec 23, 2010 4:37 am
by pctoledo
rathinagiri wrote:You can open the main window with 'noshow' clause.
Hi Rathinagiri, thanks for the help, but in my example, how can I use the noshow clause?

Code: Select all

With Object oMainWindow := Window():New()
   :Row      := 10
   :Col      := 10
   :Width      := 400
   :Height      := 200
   :Title      := 'System Demo'
   :Type      := WND_MAIN
   :OnInit      := { || Password_(), oMainWindow:Maximize() }
   :OnRelease   := { || Close_Win() }

End With
Another question, in lines 868 and 896 of the file hmg.ch has:

[:Visible := <.lVisible.> ] ;; //line 868
[:Visible := !<.lNoVisible.> ] ;; //line 896

This is correct?

Re: Open modal window before the main window

Posted: Thu Dec 23, 2010 5:10 am
by Rathinagiri
I am sorry, I was talking about HMG3. :(

Let me see how to do this in HMG4 too.