Page 1 of 1

DEFINE WINDOW properties

Posted: Thu Nov 28, 2019 10:44 am
by bpd2000
Hi
We have DEFINE WINDOW properties like ThisWindow.Handle --> nFormHandle

But how to define / create properties like ThisWindow.Name --> cFormName

Re: DEFINE WINDOW properties

Posted: Thu Nov 28, 2019 11:30 am
by edk
Sorry but I do not understand.
Semi-OOP object ThisWindow.Name does exist. You can with the object ThisWindow.<Property/MethodName> use any method or property associated with the form.

Re: DEFINE WINDOW properties

Posted: Thu Nov 28, 2019 12:12 pm
by bpd2000
Hi
You are correct that Semi-OOP object ThisWindow.Name does exist.
I would like to know what is the form name of opened/focused window
We can create such OOP style to get Form name easily

Re: DEFINE WINDOW properties

Posted: Thu Nov 28, 2019 7:37 pm
by edk
Do you mean something like this?:

Code: Select all

#include "hmg.ch"

#xtranslate FocusedWindow . <p:Title,NotifyIcon,NotifyTooltip,FocusedControl,Name,Row,Col,Width,Height> => GetProperty ( GetFormNameByIndex( _HMG_LastActiveFormIndex )  , <"p"> )
#xtranslate FocusedWindow . <p:Title,Cursor,NotifyIcon,NotifyTooltip,Row,Col,Width,Height> := <arg> => SetProperty ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , <"p"> , <arg> )
#xtranslate FocusedWindow . <p:Activate,Center,Redraw,CenterDesktop,Release,Maximize,Minimize,Restore,Show,Hide,SetFocus> [ () ] => DoMethod ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , <"p"> )
#xtranslate FocusedWindow . <p:CenterIn> (\<arg\>) => DoMethod ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , \<"p"\> , \<"arg"\> )
#xtranslate FocusedWindow . <p:HANDLE,INDEX,IsMinimized,IsMaximized,ClientAreaWidth,ClientAreaHeight> => GetProperty ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , <"p"> )
#xtranslate FocusedWindow . <p:NoClose,NoCaption,NoMaximize,NoMinimize,NoSize,NoSysMenu,HScroll,VScroll,Enabled> => GetProperty ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , <"p"> )
#xtranslate FocusedWindow . <p:NoClose,NoCaption,NoMaximize,NoMinimize,NoSize,NoSysMenu,HScroll,VScroll,Enabled> := <arg> => SetProperty ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , <"p"> , <arg> )
#xtranslate FocusedWindow . <p:AlphaBlendTransparent,BackColorTransparent> := <arg> => SetProperty ( GetFormNameByIndex( _HMG_LastActiveFormIndex ) , <"p"> , <arg> )

Function Main

	DEFINE WINDOW Win_1 ;
		ROW 0 ;
		COL 0 ;
		WIDTH 350 ;
		HEIGHT 150 ;
		TITLE 'Win 1' ;
		WINDOWTYPE MAIN  
		 
		DEFINE BUTTON B_1
		ROW     10
		COL     10
		WIDTH   90
		HEIGHT  28
		CAPTION ""
		ACTION  Nil
		END BUTTON

		DEFINE STATUSBAR FONT 'Verdana' SIZE 7
		STATUSITEM "" 
		END STATUSBAR

		DEFINE TIMER Timer_1 ;
		INTERVAL 100 ;
		ACTION getFocusedForm() 

	END WINDOW

	DEFINE WINDOW Win_2 ;
		ROW 150 ;
		COL 150 ;
		WIDTH 350 ;
		HEIGHT 150 ;
		TITLE 'Win 2'  
	END WINDOW

	DEFINE WINDOW Win_3 ;
		ROW 300 ;
		COL 300 ;
		WIDTH 350 ;
		HEIGHT 150 ;
		TITLE 'Win 3'  
	END WINDOW

	DEFINE WINDOW Win_4 ;
		ROW 450 ;
		COL 450 ;
		WIDTH 350 ;
		HEIGHT 150 ;
		TITLE 'Win 4'  
	END WINDOW

	Activate Window Win_1, Win_2, Win_3, Win_4 

Return
***************************************************************************
Function getFocusedForm()

Win_1.StatusBar.Item(1) := "FocusedWindow.Name=" + FocusedWindow.Name + " , ThisWindow.Name=" + ThisWindow.Name
Win_1.B_1.Caption := FocusedWindow.Title

Return

Re: DEFINE WINDOW properties

Posted: Fri Nov 29, 2019 4:19 am
by bpd2000
Thank you Edward
Exactly what I needed
It will also useful to other user also