Focus bug/problem with Window

Focus bug/problem with Window

Postby Patrick Mast » Mon Jan 14, 2008 4:00 pm

Hi,

I need some help :)

I have this small test application (See code below) where a MDI window calls 2 other windows.

Please follow these steps:
1) Start the test application.
2) Click "Menu", than "Open Window 1"
-> Standard window opens
3) Click "Menu", than "Open Window 2"
-> Second window opens, above Window1.
-> Window2 has focus now
4) Click on Window1
-> Window1 gets focus
5) Click in the GET field of Window2
-> Window2 SHOULD get focus, but it does not
6) Click anywhere IN Window2
-> Window2 SHOULD get focus, but it does not
7) Click on the title bar of Window2
-> Window2 gets focus

What should I change to get 5) and 6) working.
Meaning, I'd like Window2 to get focus when the GET is activated or when the user clicks somewhere IN window2. Now Window2 ONLY gets focus if you click on its title bar.

I have created a ZIP fie for you to download here:
http://upgrades.winfakt.com/TestFWH-FOCUS.zip


This is the source code for Test.prg:
Code: Select all  Expand view
#include "fivewin.ch"

STATIC oWndH,oWnd1,oWnd2

PROCEDURE Main

   LOCAL oMenu
   
   MENU oMenu
   
     MENUITEM "Menu"
      MENU
     
       MENUITEM "Open Window 1";
         ACTION OpenWindow1()
         
       MENUITEM "Open Window 2";
        ACTION OpenWindow2()
       
       SEPARATOR
       
       MENUITEM "Quit";
         ACTION __Quit()
         
      ENDMENU
     
   ENDMENU
   
   DEFINE WINDOW oWndH MDI ;
          MENU oMenu ;
          FROM 0,0 TO 30,70 ;
         
   ACTIVATE WINDOW oWndH

RETURN

//-------------------------------------------------------------//

PROCEDURE OpenWindow1()

   DEFINE WINDOW oWnd1;
          FROM 1,1 TO 20,40
         
   @ 1,1 SAY "Test"
   
   ACTIVATE WINDOW oWnd1
   
   SetParent( oWnd1:hWnd, oWndH:oWndClient:hWnd )
   Aadd(oWndH:oWndClient:aWnd,oWnd1)

RETURN


//-------------------------------------------------------------//

PROCEDURE OpenWindow2()

   LOCAL oDlg
   LOCAL oGet1,cGet1:=Space(30)
   LOCAL oGet2,cGet2:=Space(30)
   
   DEFINE WINDOW oWnd2 MDICHILD ;
          OF oWndH ;
          FROM 5,5 TO 15,55
     
     DEFINE DIALOG oDlg ;
            NAME "TEST" OF oWnd2
     
     REDEFINE GET oGet1 ;
              VAR cGet1 ;
              ID 100 OF oDlg
             
     REDEFINE GET oGet2 ;
              VAR cGet2 ;
              ID 101 OF oDlg

     ACTIVATE DIALOG oDlg;
              NOMODAL;
              VALID (.F.)
   
   ACTIVATE WINDOW oWnd2
           
RETURN

//-------------------------------------------------------------//


This is the code for test.rc:
Code: Select all  Expand view
TEST DIALOG 0, 0, 300, 300
STYLE WS_CHILD
FONT 8, "MS Sans Serif"
{
EDITTEXT 100, 30, 25, 200, 12
EDITTEXT 101, 30, 45, 200, 12
}


Thank you guys!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Re: Focus bug/problem with Window

Postby Patrick Mast » Mon Jan 14, 2008 4:01 pm

BTW, tested with latest FWH ;-)

Thanks!
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby nageswaragunupudi » Mon Jan 14, 2008 4:34 pm

If oWnd1 is created as mdichild of oWndH, but not as Standard Window and later set its parent, this works. We can switch focus between the two child windows by clicking anywhere in the windows ( but not on gets ).
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Mon Jan 14, 2008 7:54 pm

Patrick,

Try this:

oGet1:bLClicked = { || BringWindowToTop( oWnd2:hWnd ), oGet1:SetFocus() }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41404
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Tue Jan 15, 2008 7:51 am

Hello,

nageswaragunupudi wrote:If oWnd1 is created as mdichild of oWndH, but not as Standard Window and later set its parent, this works. We can switch focus between the two child windows by clicking anywhere in the windows ( but not on gets ).


Yes, I know, but that's not what we want. We want the MDI window created like this.

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Tue Jan 15, 2008 8:37 am

Patrick,

With the code that I have posted, you sample is working fine :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41404
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Tue Jan 15, 2008 10:57 am

Antonio,

Antonio Linares wrote:oGet1:bLClicked = { || BringWindowToTop( oWnd2:hWnd ), oGet1:SetFocus() }

Ok, this seems to works, thanks!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 17 guests