Page 2 of 3

Re: DEFINE WINDOW...ON INIT...

Posted: Mon Aug 02, 2010 8:37 pm
by mol
Hi Kalko. You can look at my sample in this topic:
viewtopic.php?f=5&t=1592
I'm creating there dynamically a lot of windows. There are modal windows, but I've tested to create standard windows and it works.
Try to read this one.

Re: DEFINE WINDOW...ON INIT...

Posted: Mon Aug 02, 2010 9:40 pm
by kajko
Hi Esgici

I'm sure I understand :)
Esgici wrote:
kajko wrote:That implies that before main loop invocation (using ACTIVATE) I still can change all preactivate events on the window, eg. ON INIT.
Not at all :(

Since you want change something before activation, what is meaning of make this out of definition?
Simple, is it easier this:
if( <something> )
DEFINE WINDOW wndKomit AT 0, 0 WIDTH w_width HEIGHT w_height ;
WINDOWTYPE CHILD ;
TITLE " Registar komitenata" ;
FONT "Bodoni" SIZE 9 ;
ON INIT func1()
else if( <something> )
DEFINE WINDOW wndKomit AT 0, 0 WIDTH w_width HEIGHT w_height ;
WINDOWTYPE CHILD ;
TITLE " Registar komitenata" ;
FONT "Bodoni" SIZE 9 ;
ON INIT func2()
else if( <something> )
DEFINE WINDOW wndKomit AT 0, 0 WIDTH w_width HEIGHT w_height ;
WINDOWTYPE CHILD ;
TITLE " Registar komitenata" ;
FONT "Bodoni" SIZE 9 ;
ON INIT func3()
etc...

or like this:
DEFINE WINDOW wndKomit AT 0, 0 WIDTH w_width HEIGHT w_height ;
WINDOWTYPE CHILD ;
TITLE " Registar komitenata" ;
FONT "Bodoni" SIZE 9

if( <something> )
wndKomit.OnInit := {|| func1() }
else if( <something> )
wndKomit.OnInit := {|| func2() }
else if( <something> )
wndKomit.OnInit := {|| func3() }
etc....

Esgici wrote:As said before, somethings are assignable, and somethings are not :(
Esgici wrote:"Some properties/events may or may not be defined in definition of windows" doesn't means "all of them may will be assign later" :( Again, somethings are assignable, and somethings are not ;)
Correct, but whole point of this discussion is to determine why are they not and how we can overcame this lack in interface. This is, I believe, just oversight in interface implementation, nothing more, especially if HMG is aiming to introduce 'proper' event driven development (eg. for Windows, Gnome, ...) into harbour.
And, as I can easy mix CLIPPER/XBASE and C/C++ code, I can replace even window message loop procedure, very handy for real-time processing (eg. reading com port data). That is not possible at the moment as there is no way to replace win proc in HMG.
Esgici wrote: Sorry, not correct. You can use macro substitution for name of window and can assign it at run time. for example :

Code: Select all

PROC ABC( cCountry )
      LOCAL cWinName := "frm" + cCountry + "Trans"
      DEFINE WINDOW &cWinName ...
(Notice & symbol before variable name)
Does that mean that &window.control.value := "something" will work ?
Esgici wrote: Moreover we have very handy "is" functions; such as : IsWindowDefined(), IsWindowActive() ... We can use them for warrant using an unique window name; for example :

Code: Select all

PROC ABC( cCountry )
      LOCAL cWinName := "frm" + cCountry + "Trans"
      IF !IsWindowDefined( cWinName ) 
           DEFINE WINDOW &cWinName ...
           ...
As I explain in my example in previous post, I do not need to know is there a window or not, either way i need to create it again with, maybe, different parameters.
Esgici wrote: Dear Kajko, I'm not a WinAPI expert, as a HMG user, it's sufficient for me knowing "if it's assignable or not" ;)
Eh...it is never sufficient, if it is not assignable I want to know WHY ? It can be and it does not break anything, just gives me more freedom to express my self and write more productive code.
I am sure Bjarne Stroustrup never imagined Boost when he was creating C++, but he was not building solid language on "if it's assignable or not".

And, yes, I am enjoying in this discussion with you as well.

Kajko

Re: DEFINE WINDOW...ON INIT...

Posted: Mon Aug 02, 2010 9:49 pm
by kajko
Hi, Marek

Thanks for reply, i did take a look at that post and I can see what and why you did.
I started this thread as i did not want to use potentially non compatible functions with future versions (eg. DoMethod or SetProperty).
I already wrote my self a window class that sorts my problems using those functions :), I was just trying to see if there is a 'legit' why of doing it.

Kajko

Re: DEFINE WINDOW...ON INIT...

Posted: Mon Aug 02, 2010 11:00 pm
by esgici
Hi Kajko
kajko wrote:That implies that before main loop invocation (using ACTIVATE) I still can change all preactivate events on the window, eg. ON INIT.
Yes, understood, but, my opinion is: you don't need this !
kajko wrote:Simple, is it easier this:...
Are you sure that we have only this two options ?

Code: Select all

DEFINE WINDOW wndKomit  AT 0, 0 WIDTH w_width HEIGHT w_height ;
      WINDOWTYPE CHILD ;
      ON INIT OnInitKomit() ;
      TITLE " Registar komitenata" ;
      FONT "Bodoni" SIZE 9

...

PROC OnInitKomit()
     if( <something> )
           func1() }
     else if( <something> )
           func2() 
     else if( <something> )
           func3() 
     etc....
RETU // OnInitKomit()
Does this case is acceptable for you ?
kajko wrote:... whole point of this discussion is to determine why are they not and how we can overcame this lack in interface.
My opinion is : this isn't a lack.

Eventually, lack or not; HMG is open source project and ALL source code is open. As we all know, "open source" doesn't meas only "everyone can use any way that like"; it means also "everyone can examine, criticize, even participate the code". So, you haven't any difficulty writing and sending necessary code that will eliminate this "lack". Anyway the last decision is to owner of project; after his approval your code will be a reality.
kajko wrote:This is, I believe, just oversight in interface implementation, nothing more, especially if HMG is aiming to introduce 'proper' event driven development (eg. for Windows, Gnome, ...) into harbour.
As I said earlier, I'm not a Win32 expert, so I'm unable to understand what is 'proper event driven development'. In my opinion, HMG is most successful interface between WinAPI and us. And please consider that this opinion consisted after struggles with some other interfaces for dozen of years.
kajko wrote:... That is not possible at the moment as there is no way to replace win proc in HMG.
Why "no way" ? As I said above, write your code, make your test; when satisfied send to forum. That's all.
kajko wrote:Does that mean that &window.control.value := "something" will work ?
:) No ! Macro substitution is a Harbour feature, not HMG; and window.control.value is a HMG (semi OOP) notation, no Harbour.
kajko wrote:As I explain in my example in previous post, I do not need to know is there a window or not, either way i need to create it again with, maybe, different parameters.
May be... But knowing the window is defined or not will protect you from "BOOM" ;)
kajko wrote:... if it is not assignable I want to know WHY ? It can be and it does not break anything, just gives me more freedom to express my self and write more productive code.
I can't protest this point of view, moreover I have to appreciate. A programmer must be always investigative, even inquisitive. But have know their limits too. This is reason of my point of view by saying "it's sufficient for me knowing "if it's assignable or not".
kajko wrote:I am sure Bjarne Stroustrup never imagined Boost when he was creating C++, but he was not building solid language on "if it's assignable or not".
Does that mean that in C++ there isn't "assignable" and "not assignable" concepts ?

Regards

--

Esgici

Re: DEFINE WINDOW...ON INIT...

Posted: Tue Aug 03, 2010 5:47 am
by mol
Hi Kajko!
Maybe try to redesign your project to use with HMG or select differen tool to create it.

I have the impression, you've started to write your application without any knowledge of HMG.
When I was producing my first app. based on HMG, I had similar problems.
Now, I know philosophy of HMG (a little of course :D) and many thinks come to me more quick and easy.

Best regards, Marek

PS. Forgive me my hard words...

Re: DEFINE WINDOW...ON INIT...

Posted: Sun Dec 27, 2020 4:08 am
by MICROVOLUTION
minha dúvida é a seguinte:
estou carregando um formulário da seguinte forma:

Code: Select all

	LOAD WINDOW TELA_PADRAO_HMG AS F_BAIXAR
      // ON INIT TELA_ENTRADA() // esta linha não funciona
      // F_BAIXAR.OnInit TELA_ENTRADA() // esta também não funciona.
      // F_BAIXAR.OnInit := TELA_ENTRADA() // e esta também não funciona.
Como faço para incluir o ON INIT?

Re: DEFINE WINDOW...ON INIT...

Posted: Sun Dec 27, 2020 8:37 am
by mol
You should use TELA_ENTRADA() function in definition of TELA_PADRAO_HMG form

Re: DEFINE WINDOW...ON INIT...

Posted: Sun Dec 27, 2020 11:23 am
by MICROVOLUTION
Mas, nem sempre a ON INIT TELA_ENTRADA será a mesma em todos os formulários herdados... Cada um tem a sua tela diferente.

Isso significa que terei que fazer um formulário novo para cada tela?

Re: DEFINE WINDOW...ON INIT...

Posted: Sun Dec 27, 2020 6:04 pm
by franco
Hello Kajko,
I use something like Esgici suggests. I do not know if this is right but it works for me.
I use mostly modal windows as I have certain records locked in some tables of the form and want the user to finish what they are doing
before leaving. In any programs or procedures or functions if they need data entry I create a new form and then release it at return.
On my order entry screen I have a label with the customers name and beside it I have a button for changing the name if wanted.
On my browse windows for inventory or customer lookup I have a button for adding new if not there.

Code: Select all

DEFINE WINDOW wndKomit  AT 0, 0 WIDTH w_width HEIGHT w_height ;
      WINDOWTYPE MODAL ;                                      //ON INIT OnInitKomit() ;
      TITLE " Registar komitenata" ;
      FONT "Bodoni" SIZE 9

...
OPEN WINDOW wndKomit 

ON KEY F1 OF wndKomit ACTION ......

   if( <something> )
           func1() }
     else if( <something> )
           func2() 
     else if( <something> )
           func3() 
     etc....
ACTIVATE WINDOW  wndKomit 


Re: DEFINE WINDOW...ON INIT...

Posted: Mon Dec 28, 2020 1:39 am
by MICROVOLUTION
MICROVOLUTION wrote: Sun Dec 27, 2020 11:23 am Mas, nem sempre a ON INIT TELA_ENTRADA será a mesma em todos os formulários herdados... Cada um tem a sua tela diferente.

Isso significa que terei que fazer um formulário novo para cada tela?
parece então, que terei que me adaptar ao padrão da LIB HMG...
vamos rever nossos conceitos então.