HMG4 icon disappear

Moderator: Rathinagiri

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

HMG4 icon disappear

Post by l3whmg » Wed Jul 20, 2011 1:36 pm

Hi friends, I need your help because I can't find solution.
The problem is: when I close the first window I can't see the windowicon on the second.
If I have only one form it's work fine. The problem seem to be related with ::s_lQtStarted shared var that is .F. when I fired on the second form. I have placed

Code: Select all

   IF ::s_lQtStarted == .F.
      msgstop( cName + " ::" + hb_valtoexp( ::s_lQtStarted ) )
      HMGAPP():Start()
   ENDIF
within the New method of window class. I receive message when the second form is fired on.
Please take a look to this little source (note remember to change the resource file and the icons name to show the problem)

Code: Select all

FUNCTION Main

   HbQt_ErrorSys()

   HMGAPP():Resources := "stdicon"
   HMGAPP():Start()

   LoginSim()

   ShowMain()


RETURN NIL

STATIC FUNCTION ShowMain()

   LOCAL MainForm
   
   WITH OBJECT MainForm := Window():New( "MainForm" )
      :Row     := 10
      :Col     := 10
      :Width   := 600
      :Height  := 600
      :Title   := "MainForm title"
      :Type    := WND_MAIN
      :OnInit  := { || MainFrmOnInit() }
      :Icon    := ":L3W_ICO"
   END WITH

   MainForm:Activate()

RETURN NIL

STATIC FUNCTION MainFrmOnInit()

   THISWINDOW:Center()

RETURN NIL

STATIC FUNCTION LoginSim()

   LOCAL LoginForm
   
   WITH OBJECT LoginForm := Window():New( "LoginForm" )
      :Row     := 10
      :Col     := 10
      :Width   := 200
      :Height  := 200
      :Title   := "LoginForm title"
      :Type    := WND_MODAL
      :OnInit  := { || LoginFrmOnInit() }
      :Icon    := ":L3W_ICO"
   END WITH

   LoginForm:Activate()

RETURN NIL

STATIC FUNCTION LoginFrmOnInit()

   THISWINDOW:Center()

RETURN NIL
Best regards

p.s. I'm using Harbour compiler 3.x.x
Luigi from Italy
www.L3W.it

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

Post by l3whmg » Wed Jul 20, 2011 1:59 pm

It's not related with Harbour 3.x.x use. I'm sure.
Cheers
Luigi from Italy
www.L3W.it

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

Post by mrduck » Wed Jul 20, 2011 3:28 pm

l3whmg wrote: LOCAL LoginForm
Can it be that when LoginForm goes out of focus you release the resources ? just an idea, not seen the code....

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

Post by l3whmg » Wed Jul 20, 2011 4:14 pm

Hi MrDuck.
No, I don't do any release (the source it's very simple as you can see).
On the other hand, I think the problem is more complex. The shared var ::s_lQtStarted, that is enabled when we use HMGAPP():Start(), after closing the first window is .F. but must be .T. (and this mean to me: more complex).
This status var mean: QApplication and other Qt functions are fired on or not. Within window class (but I hope everywere) we test this value and: if it's .F. we call HMGAPP():Start() else it's already running. Why this test: to have HMG3 compatibility else we can call HMGAPP():Start() in top of our program. I don't remember this problem with HMG4.
I have explored all sources to find "::s_lQtStarted := .F." in a wrong place: nothing.
The only idea that I have is: when I open a new window I have a new shared var: like a new application starting.

I don't know.....
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 » Wed Jul 20, 2011 4:24 pm

Luigi, could you post the resource file and icon in order to me to test ?
[[]] Mauricio Ventura Faria

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

Post by l3whmg » Wed Jul 20, 2011 4:38 pm

Hi Mauricio. Sure but I think this it's not the problem.
If you run the program with only one form (Main or Modal) work fine!
Cheers
p.s. you must change path for icon file withi resource file
Attachments
XMauricio.zip
icon file and resource file
(4.71 KiB) Downloaded 61 times
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 » Wed Jul 20, 2011 6:42 pm

Luigi, I think this was me again... :oops:

Remember some time ago we discussed about Window class and window types, main, modal, etc.
So, at that time, to avoid multiple main type windows I coded that the first window would be forced main and any others other types.

Your first window, the one you defined as modal, was forced to be main type and, when closed, it calls HMGAPP():Quit() that was defined at QEvent_Close and Quit() restarts all shared vars...

I revised the window class code and now your sample runs Ok.

But this whole issue about window types must be deeply revised.
[[]] Mauricio Ventura Faria

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

Post by l3whmg » Wed Jul 20, 2011 7:25 pm

Hi Mauricio, great man
I remember your question and my answer now. Forget HMG3 for a moment; IMHO these rules must be respected:
1) a project can start with a WND_MODAL or a WND_MAIN form
2) a project can have only one WND_MAIN
3) when WND_MAIN will be close, HMG4 call HMGAPP():Quit() method. I THINK THIS IS WRONG we must use HMGAPP():Quit() within project, anyway...

Rule number 1) because at this moment we can't use QT single-shot (MrDuck know about this). The problem was: if I need a loginform to access?
With HMG3 I open: WND_MAIN and then WND_MODAL (it's a way) but I can close WND_MAIN if login fails
With HMG4 I can't do the same, I must: open WND_MODAL and if granted WND_MAIN. There is problem when we close a form within an OnInit event.

Thanks Mauricio.
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 » Thu Jul 21, 2011 10:46 am

Hi Luigi.
l3whmg wrote:we must use HMGAPP():Quit() within project.
Why not simply end the application ?
l3whmg wrote:if I need a loginform to access?
I started working on a "dialog" class which is a simpler window, with its own loop. I will return to this asap.
[[]] Mauricio Ventura Faria

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

Post by l3whmg » Thu Jul 21, 2011 12:27 pm

Hi Mauricio
concentra wrote:Hi Luigi.
l3whmg wrote:
we must use HMGAPP():Quit() within project.
Why not simply end the application ?
IMHO, because:
- HMGAPP():Start() fired on QApplication, register resource and... (I have introduce a StartUp procedure if you need)
- HMGAPP():Quit() shutdown QApplication, unregister resource and... (I have introduce a ShutDown procedure if you need)

I think it's always a good thing to fired on and fired off a process: QApplication. Perhaps, QT has this ability by itself: very good! Any way I prefer do.
On the other hand, but I don't have a good knowledge, in a MT program? What happen if you shutdown QApplication within the close method of a MainWindow?

In a while, a give my opinion about release topic viewtopic.php?f=32&t=2027&p=17207#p17207

Best regards
Luigi from Italy
www.L3W.it

Post Reply