HMG4: start, quit, resource, localized

Moderator: Rathinagiri

User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: HMG4: start, quit, resource, localized

Post by concentra » Mon Jul 04, 2011 5:45 pm

l3whmg wrote:Hi to everyone.
MrDuck it's right.
On the other hand, I have write in my post: we have to options: 1) use of HMGAPP():Quit() when main window is closed (via connected event) or 2) programmaticaly inside program. In this moment, I prefer to respect HMG3 style.

Remember: for HMG3 it's mandatory to have a WND_MAIN form open and active.

With HMG4 we have a new future: modal or child(???) can be opened witho main form.
Is it possible to open multiple no-modal windows in HMG3 ?
If so, what happen when the main one is closed while the others are still opened ?
[[]] Mauricio Ventura Faria

User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Post by concentra » Mon Jul 04, 2011 5:53 pm

l3whmg wrote:Hi Mauricio.
About check VALTYPE I'm in agrrement with if we have now a valid errorsys. There are a lot of errors to check, but IMHO we must have an usable HMG4.
So it´s probably better not change the way its coded now, not checking.
A type error will rise by Harbour when needed.
[[]] Mauricio Ventura Faria

Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Post by Rossine » Mon Jul 04, 2011 6:58 pm

Hello all,

In my sample I tried to solve the problem when the user needs a confirmation before the window is closed. Could you implement this in the current version of HMG.4 ?

OBS: In minigui I use well:

DEFINE WINDOW Form_X ... ON INTERACTIVECLOSE msgsyesno( "Exit ?" )

In HMG.4 maybe:

DEFINE WINDOW Form_X ... ON RELEASE msgsyesno( "Exit ?" )

Best Regards,

Rossine.

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Post by l3whmg » Tue Jul 05, 2011 4:51 pm

Hi Mauricio.
No, only one modal window can open.
What I mean is that HMG3 (but also QT) want a main window open and active always, then you can open a lot of child and/or a modal window. You can't close main window when a modal window is open, obviously, but you can close main window when child (standard) window are open: all these form are close. But this "system" require a different way to write your program.

About code error. I would like to avoid error messages when, in fact, it is a misuse. At least during the development phase. About errore handlig I notice within misc.prg the same code of errorsys.prg, but errorsys.prg (at this moment) it's not used. Who write error handling within misc.prg?

Rossine: I believe that we should use "ONRELEASE" when you've already decided to close the form. On the other hand OnRelease mean this: during release of the object. I don't use your method with HMG3 and for this reason I ask you: if your answer is NO (I don't want close) what happen? Please tell me

Best regards
Luigi from Italy
www.L3W.it

User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Post by concentra » Tue Jul 05, 2011 5:37 pm

Hi Luigi.
l3whmg wrote:What I mean is that HMG3 (but also QT) want a main window open and active always, then you can open a lot of child and/or a modal window. You can't close main window when a modal window is open, obviously, but you can close main window when child (standard) window are open: all these form are close. But this "system" require a different way to write your program.
Ok, but in HMG4 all windows are main...
And because of these, it is possible to close the first opened window ( main ) and still have other windows running.
To me this is a plus !
But we need to manage these open/close windows correctly.
I have an idea on how to manage this, if you all are ok I can code.
About code error. I would like to avoid error messages when, in fact, it is a misuse. At least during the development phase. About errore handlig I notice within misc.prg the same code of errorsys.prg, but errorsys.prg (at this moment) it's not used.
The main thought I have when coding the lib´s behavior is:
What Clipper do ? Do the same !
And in this case I think we can left to Harbour to do the dirty job, emitting an error message when an improper var type is used.
[[]] Mauricio Ventura Faria

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Post by l3whmg » Tue Jul 05, 2011 7:16 pm

Hi Mauricio.
About main window I'm in agreement with you.
Little brief: we use QMainWindow because has a lot of "future"; instead can be used QDialog, but I don't know property. I think: for this reason, when HMG4 was started, Roberto (it's my opinion) choose this type of window.

So we don't mix QMainWindow (type of QT) with WND_MAIN (type of HMG4). We can have a lot of QmainWindow but only one WND_MAIN; the other HMG4 window must be: WND_STANDARD, WND_CHILD, WND_PANEL, WND_SPLITCHILD or WND_MODAL

About opened window or what is the sequence....
Please take this example: I need a Login form before to access the application (main window). If I can open a form (WND_MODAL, but...) only when a WND_MAIN it's still opened, we have a problem. Why?
Because I have try to use this code:
WITH OBJECT MainForm....
:OnInit := ExecuteLogin
.....
within ExecuteLogin I show a Modal form and my code is like this "IF LoginFailed MainForm:Release()".
But this instruction is inside the "MainForm OnInit" and this wan't work today: so, I can't shutdown the project.
Solution? I need to open a modal BEFORE the MainForm.
I don't know very well QT, but on internet I find same problems. On the other hand there is this Qt command: QApplicatioN:CloseAllWindows(), but like Qt docs say (if I understand): there is'nt a predefined sequence, windows are close random. I think mainwindow is the last one

IMHO, we must have these rules:
1) we can have only one WND_MAIN
2) we can open WND_MODAL without have WND_MAIN opened
3) we must have a WND_MAIN open and active to open other "child"
4) future: we can handle a sequencer: from 1 to N are open, from N to 1 can be closed...

About coding: ok for everyone? Yes, so good for me. I think the same. A simple workaround can be a simple error handling like this:

Code: Select all

IF PCOUNT() == 0
RETURN ...
ELSEIFVALTYPE( aValue ) == "A"
....
ELSE
 hMgerror( cError )
ENDIF
.....
and

Code: Select all

FUNCTION HmgError( cError )
MsgStop( cError )
HMGAPP():QUIT()
QUIT
RETURN NIL
In this way, at this moment, we can have a simple handler and in the future find every HmgError and rewrite, in a proper way, the error handling. But it's a simple opinion.

Cheers
Luigi from Italy
www.L3W.it

mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Post by mrduck » Tue Jul 05, 2011 8:55 pm

l3whmg wrote: Please take this example: I need a Login form before to access the application (main window). If I can open a form (WND_MODAL, but...) only when a WND_MAIN it's still opened, we have a problem. Why?
Because I have try to use this code:
WITH OBJECT MainForm....
:OnInit := ExecuteLogin
.....
Luigi, please have a look at
void QTimer::singleShot ( int msec, QObject * receiver, const char * member )

If you set msec = 0 the timer is run the first time the event loop is entered: when the form is ready to handle events: when the window is shown and ready. I saw this used in several Qt c++ code.

Unfortunately its implementation in hbQt is... WRONG...

Anyway, there should be some other way to have what I'd call ON READY in a DEFINE WINDOW, and we must find a solution for this.

ON INIT is run in tha Activate() method and it is too early, the event loop isn't started yet... perhaps we may "pump" a "uesr defined event" in the event queue...

Can you please create a SMALL sample of this ?

Code: Select all

FUNCTION HmgError( cError )
MsgStop( cError )
HMGAPP():QUIT()
QUIT
RETURN NIL
In this way, at this moment, we can have a simple handler and in the future find every HmgError and rewrite, in a proper way, the error handling. But it's a simple opinion.
We should invoke the harbour error handler so that we get correct error handling - hbqt_errorsys() puts a messagebox and each one may expand the error handler with log files, sending mails etc...

User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Post by concentra » Wed Jul 06, 2011 12:06 pm

Hi Luigi.
l3whmg wrote:Please take this example: I need a Login form before to access the application (main window).
Some time ago I read something about executing dialogs before QApplication::exec() and returned to search.
See this: http://doc.qt.nokia.com/latest/qapplication.html#exec
QApplication::exec ()
Enters the main event loop and waits until exit() is called, then returns the value that was set to exit() (which is 0 if exit() is called via quit()).
It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.
Generally, no user interaction can take place before calling exec(). As a special case, modal widgets like QMessageBox can be used before calling exec(), because modal widgets call exec() to start a local event loop.
So we have to implement a simple dialog to this cases and other where what is inside is so simple that a window is not needed.
I started this some time ago but stopped, will return to that.
[[]] Mauricio Ventura Faria

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Post by l3whmg » Wed Jul 06, 2011 12:29 pm

Hi Mauricio.
I think the best way is to use QTimer, but -as MrDuck write - in this moment HbQt has problem.
From the same Qt docs page:
To make your application perform idle processing, i.e., executing a special function whenever there are no pending events, use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().
IMHO, with your solution we must add "a special case"; but this can work fine for me but not for the other or later we must add something, etc. On the other hand, with QTimer we can have a lot of possibility: for example we can better handle the ONINIT().

Cheers.
Luigi from Italy
www.L3W.it

mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Post by mrduck » Wed Jul 06, 2011 12:30 pm

Mauricio,
Luigi actually wants to run the login page when the main window is already shown. This may happen only when the exec() is already called. So he was looking for a way to call a function that is called at that time, and this is not possible in this moment.

I have seen the "trick" to use the one-shot timer but it has not been adapted for hbQt...


If in the meanwhile Luigi changed his mind to show the login form before the main window I think he can use a modal dialog with its own eventloop and setting public vars from it and deciding what to do after closing (or hiding) the login form.
If hmg4 for whatever reason forbids to do this, we should review that part of the code...


This is one of "business-cases" we should start to test and write code for... for example, we shouldwrite code for combobox/listbox populated from dbf fields, auto-completation etc etc

Post Reply