Dear Members,
I have main window. It opens entry window, which further opens sub-entry window, which also may open another pop-up window, etc.
In short one window opens another and so on. This is real scenario in my live application to client.
Now I want that when one window_1 opens another window_2, itself (window_1) should remain disabled, i.e. no mouse click should work on it. I can achieve same using 'modal' clause but I do not want that as I may open two window at same time as related information and allow user to click one and refresh in another.
In another programing language I can define window_1 as 'owner' of window_2 and it (window_1) gets auto disabled. Is there anything similar in hmg ?
I have attached sample codes which I used to try the same. I have used both hmg and minigui logic.
Regards,
Anand
define window_1 as 'owner' of window_2
Moderator: Rathinagiri
define window_1 as 'owner' of window_2
- Attachments
-
- win_test.zip
- (140.51 KiB) Downloaded 183 times
Re: define window_1 as 'owner' of window_2
Dear Anand,
It is possible in the Minigui Ex with using OOP mode.
I've attached your updated sample for your review.
Hope give you some idea.
- Attachments
-
- win_test_2.zip
- Sample for Minigui Ex with using command SET OOP ON
- (1.15 KiB) Downloaded 203 times
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: define window_1 as 'owner' of window_2
I have two solutions:
First, by disabling the availability of the "owner" window:
Second, by switching off all events in the "owner" window:
First, by disabling the availability of the "owner" window:
Code: Select all
#include "hmg.ch"
proc main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'Test';
MAIN
DEFINE MAIN MENU
POPUP 'Standard'
ITEM 'Open Window' ACTION {|| DoWindow2() }
END POPUP
END MENU
DEFINE BUTTON B_OK
ROW 20
COL 30
WIDTH 100
HEIGHT 28
ACTION Msgbox('OK')
CAPTION "OK"
END BUTTON
END WINDOW
activate window Form_1
retu
//*****************************************************************************
func DoWindow2()
Local cOwnerFormName:=ThisWindow.Name, cOwnerFormTitle:=ThisWindow.Title
DEFINE WINDOW Form_2 ;
AT 0,0 ;
WIDTH 600 HEIGHT 400 ;
TITLE 'Win 2' ;
ON INIT ( SetProperty( cOwnerFormName, "Enabled", .F.), SetProperty( cOwnerFormName, "Title", cOwnerFormTitle + " - Disabled") ) ;
ON RELEASE ( SetProperty( cOwnerFormName, "Enabled", .T.), SetProperty( cOwnerFormName, "Title", cOwnerFormTitle) ) ;
@ 20,40 BUTTON Button_2 caption 'Win 3' WIDTH 100 HEIGHT 20 ACTION {|| DoWindow3() }
END WINDOW
activate window Form_2
return
//*****************************************************************************
func DoWindow3()
Local cOwnerFormName:=ThisWindow.Name, cOwnerFormTitle:=ThisWindow.Title
DEFINE WINDOW Form_3 ;
AT 0,0 ;
WIDTH 600 HEIGHT 400 ;
TITLE 'Win 3' ;
ON INIT ( SetProperty( cOwnerFormName, "Enabled", .F.), SetProperty( cOwnerFormName, "Title", cOwnerFormTitle + " - Disabled") ) ;
ON RELEASE ( SetProperty( cOwnerFormName, "Enabled", .T.), SetProperty( cOwnerFormName, "Title", cOwnerFormTitle) ) ;
@ 50,100 BUTTON Button_2 caption 'OK' WIDTH 100 HEIGHT 20 ACTION {|| MsgBox('OK') }
END WINDOW
activate window Form_3
return
************************************************************************************
Code: Select all
#include "hmg.ch"
MEMVAR _HMG_SYSDATA
proc main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'Test';
MAIN
DEFINE MAIN MENU
POPUP 'Standard'
ITEM 'Open Window' ACTION {|| DoWindow2() }
END POPUP
END MENU
DEFINE BUTTON B_OK
ROW 20
COL 30
WIDTH 100
HEIGHT 28
ACTION Msgbox('OK')
CAPTION "OK"
END BUTTON
END WINDOW
activate window Form_1
retu
//*****************************************************************************
func DoWindow2()
Local cOwnerFormName:=ThisWindow.Name
DEFINE WINDOW Form_2 ;
AT 0,0 ;
WIDTH 600 HEIGHT 400 ;
TITLE 'Win 2' ;
ON INIT StopEvents( cOwnerFormName, .T. ) ;
ON RELEASE StopEvents( cOwnerFormName, .F. )
@ 20,40 BUTTON Button_2 caption 'Win 3' WIDTH 100 HEIGHT 20 ACTION {|| DoWindow3() }
END WINDOW
activate window Form_2
return
//*****************************************************************************
func DoWindow3()
Local cOwnerFormName:=ThisWindow.Name
DEFINE WINDOW Form_3 ;
AT 0,0 ;
WIDTH 600 HEIGHT 400 ;
TITLE 'Win 3' ;
ON INIT StopEvents( cOwnerFormName, .T. ) ;
ON RELEASE StopEvents( cOwnerFormName, .F. )
@ 50,100 BUTTON Button_2 caption 'OK' WIDTH 100 HEIGHT 20 ACTION {|| MsgBox('OK') }
END WINDOW
activate window Form_3
return
************************************************************************************
Function StopEvents( cForm, lStop )
Local hWnd, hCtrWnd, nPos
DEFAULT cForm := '', lStop := .F.
IF !hb_IsLogical( lStop )
lStop := .F.
ENDIF
IF EMPTY( cForm ) .OR. !_isWindowDefined( cForm )
RETURN Nil
ENDIF
hWnd := GetFormHandle( cForm )
StopWindowEventProcedure (cForm, lStop)
AEVAL( _HMG_SYSDATA[ 4 ], { | hCtrWnd, nPos | IF( hCtrWnd == hWnd, _HMG_StopControlEventProcedure [nPos]:= lStop, Nil ) } )
Return Nil
Re: define window_1 as 'owner' of window_2
Grigory and Edk thanks for the solution.
Edk's 1st solution disables the parent window completely, i.e. no mouse click works. Solves my problem.
Edk's 2nd solution allows mouse click and sets window back to focus but further click does not work. This does not solve as parent window now blocks the called window.
Grigory solution looks advance to me. I am bit novice in understanding the codes used. Though mouse click on parent works but window remains in background. This I will have to further study and understand to use in my codes.
Since my live application is in MiniGUI, compiling the Edk's 1st solution with minigui does not work. Grigory please guide me what changes I need to do to compile it in minigui ?
Regards,
Anand
Edk's 1st solution disables the parent window completely, i.e. no mouse click works. Solves my problem.
Edk's 2nd solution allows mouse click and sets window back to focus but further click does not work. This does not solve as parent window now blocks the called window.
Grigory solution looks advance to me. I am bit novice in understanding the codes used. Though mouse click on parent works but window remains in background. This I will have to further study and understand to use in my codes.
Since my live application is in MiniGUI, compiling the Edk's 1st solution with minigui does not work. Grigory please guide me what changes I need to do to compile it in minigui ?
Regards,
Anand
Re: define window_1 as 'owner' of window_2
Dear Anand,
Thanks for your request!
I've added the following description in the current change log:
Your updated sample for a next build is below:* Updated: Synchronized Extended HMG for compatibility with Official HMG:
Added the set/get 'Enabled' property for the forms:
- ThisWindow|<FormName>.Enabled [ := | --> ] lBoolean
Code: Select all
#include "hmg.ch"
PROCEDURE main
LOCAL cActiveFormName := 'Form_2'
DEFINE WINDOW Form_1 ;
AT 0, 0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'Main Window';
MAIN
DEFINE MAIN MENU
POPUP 'Child Window'
ITEM 'Open Win 2' ACTION {|| DoWindow2() }
END POPUP
END MENU
DEFINE BUTTON B_OK
ROW 20
COL 30
WIDTH 100
HEIGHT 28
ACTION Msgbox( 'OK' )
CAPTION "OK"
END BUTTON
DEFINE TIMER T_1 INTERVAL 250 ACTION SetProperty( ThisWindow.Name, "Enabled", ( _IsWindowActive( cActiveFormName ) == .F. ) )
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
RETURN
*****************************************************************************
PROCEDURE DoWindow2()
LOCAL cActiveFormName := 'Form_3'
LOCAL cOwnerFormName := ThisWindow.Name, cOwnerFormTitle := ThisWindow.Title
DEFINE WINDOW Form_2 ;
AT App.Row + 30, App.Col + 30 ;
WIDTH 600 HEIGHT 400 ;
TITLE 'Win 2' ;
CHILD ;
ON INIT ( SetProperty( cOwnerFormName, "Title", cOwnerFormTitle + " - Disabled" ) ) ;
ON RELEASE ( SetProperty( cOwnerFormName, "Title", cOwnerFormTitle ) ) ;
@ 20, 40 BUTTON Button_2 caption 'Child Win 3' WIDTH 100 HEIGHT 28 ACTION {|| DoWindow3() }
DEFINE TIMER T_1 INTERVAL 250 ACTION SetProperty( ThisWindow.Name, "Enabled", ( _IsWindowActive( cActiveFormName ) == .F. ) )
END WINDOW
ACTIVATE WINDOW Form_2
RETURN
*****************************************************************************
PROCEDURE DoWindow3()
LOCAL cOwnerFormName := ThisWindow.Name, cOwnerFormTitle := ThisWindow.Title
DEFINE WINDOW Form_3 ;
AT App.Row + 60, App.Col + 60 ;
WIDTH 600 HEIGHT 400 ;
TITLE 'Win 3' ;
CHILD ;
ON INIT ( SetProperty( cOwnerFormName, "Title", cOwnerFormTitle + " - Disabled" ) ) ;
ON RELEASE ( SetProperty( cOwnerFormName, "Enabled", .T. ), SetProperty( cOwnerFormName, "Title", cOwnerFormTitle ), ;
DoMethod( cOwnerFormName, "setFocus" ) )
@ 50, 100 BUTTON Button_2 caption 'OK' WIDTH 100 HEIGHT 28 ACTION {|| MsgBox( 'OK' ) }
END WINDOW
ACTIVATE WINDOW Form_3
RETURN
***********************************************************************************
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: define window_1 as 'owner' of window_2
Thanks Grigory.
Waiting for the next build
Regards,
Anand
Waiting for the next build
Regards,
Anand
Re: define window_1 as 'owner' of window_2
MiniGUI 18.09 supports 'enabled' for form now and it is working same as HMG.
Thank you Grigory.
Regards,
Anand
Thank you Grigory.
Regards,
Anand