Focus bug/problem with Window

Post Reply
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Focus bug/problem with Window

Post by Patrick Mast »

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

#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

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: 244
Joined: Sat Mar 03, 2007 8:42 pm

Re: Focus bug/problem with Window

Post by Patrick Mast »

BTW, tested with latest FWH ;-)

Thanks!
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Patrick,

Try this:

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

Antonio Linares
www.fivetechsoft.com
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Patrick,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Antonio,
Antonio Linares wrote:oGet1:bLClicked = { || BringWindowToTop( oWnd2:hWnd ), oGet1:SetFocus() }
Ok, this seems to works, thanks!

Patrick
Post Reply