:SetFocus problem with WHEN clause in Gets and Pushbuttons

:SetFocus problem with WHEN clause in Gets and Pushbuttons

Postby RAMESHBABU » Fri Nov 10, 2006 11:45 am

I have a problem with :SetFocus()

In the following code I have three gets and three pushbuttons.

By default the Gets are disabled and when the "Create" button
is pressed, the gets should be enabled and the focus should be
placed on the 1st get. The "Create" and "Save" functions of my
code below is working Ok enabling and disabling the gets.

But the oGet1:SetFocus() in Create() function and oBtn1:SetFocus()
in Save() function are not working at all.

I tried with oDlg:Update() and oDlg:Refresh() also in both Create()
and Save() functions without sucess.

Can anybody look into the code and suggest me where I am going
wrong?

I am using FWH 2.8 (September Build) + xHarbour 0.99.61 (Simplex)

Thanks

- Ramesh Babu P


Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION main()

LOCAL oDlg, oGet1, oGet2, oGet3, oBtn1, oBtn2, oBtn3, cGet1, cGet2, cGet3
LOCAL lCreate := .T., lSave := .F., lGo := .F.

STORE SPACE(30) TO cGet1, cGet2, cGet3

DEFINE DIALOG oDlg RESOURCE "TESTFOCUS"

REDEFINE GET oGet1 VAR cGet1 ID 101 OF oDlg UPDATE WHEN lGo
REDEFINE GET oGet2 VAR cGet2 ID 102 OF oDlg UPDATE WHEN lGo
REDEFINE GET oGet3 VAR cGet3 ID 103 OF oDlg UPDATE WHEN lGo

REDEFINE BUTTON oBtn1 ID 104 OF oDlg WHEN lCreate ;
         UPDATE ACTION Create(@lCreate,@lSave,@lGo,@oGet1)

REDEFINE BUTTON oBtn2 ID 105 OF oDlg WHEN lSave   ;
         UPDATE ACTION Save(@lCreate,@lSave,@lGo,@oBtn1)

REDEFINE BUTTON oBtn3 ID 106 OF oDlg ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED ON INIT oBtn1:SetFocus()

RETURN nil

**********

FUNCTION Create(lCreate, lSave, lGo, oGet1)

lSave   := .T.
lCreate := .F.
lGo     := .T.

oGet1:SetFocus()

RETURN nil

**********

FUNCTION Save(lCreate, lSave, lGo, oBtn1)

lSave   := .F.
lCreate := .T.
lGo     := .F.

oBtn1:SetFocus()

RETURN nil

**********

/****************************************************************************
get.rc
produced by Borland Resource Workshop
*****************************************************************************/

TESTFOCUS DIALOG 6, 15, 207, 113
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Testing Focus"
FONT 8, "MS Sans Serif"
{
GROUPBOX "", 301, 8, 3, 192, 82, BS_GROUPBOX
LTEXT "Get - 1", -1, 20, 23, 30, 8
EDITTEXT 101, 58, 20, 132, 13
LTEXT "Get - 2", -1, 19, 44, 30, 8
EDITTEXT 102, 58, 41, 132, 13
LTEXT "Get - 3", -1, 19, 65, 30, 8
EDITTEXT 103, 58, 62, 132, 13
PUSHBUTTON "&Create", 104, 74, 92, 40, 15
PUSHBUTTON "&Save", 105, 117, 92, 40, 15
PUSHBUTTON "&Ok", 106, 160, 92, 40, 15
}

User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Antonio Linares » Fri Nov 10, 2006 12:00 pm

Ramesh,

Try this:

oGet1:PostMsg( WM_SETFOCUS ) instead of oGet1:SetFocus()
regards, saludos

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

Postby RAMESHBABU » Fri Nov 10, 2006 12:17 pm

Mr.Antonio

Amazing to get a solution in 5 minues time.

It is working now Ok.

Thank you very much.

BTW, why :SetFocus() is not working!

Regards to you

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby RAMESHBABU » Fri Nov 10, 2006 1:51 pm

Hi Mr.Antonio

Once the focus is passed on to a get with oGet1:PostMsg(EM_SETFOCUS)
and when I click on any other controls or press tab, the blinking cursor is
still showing on old control (oGet1) and bLostFocus is also not working
properly.

Just add the following lines to the above code after redefinition of GETS,
implement the oGet1:SetFocus(WM_SETFOCUS) in place of
oGet1:SetFocus(), oBtn1:SetFocus(WM_SETFOCUS) in place of
oBtn1:SetFocus() and test it. You will find the anomaly.

Code: Select all  Expand view
oGet1:bGotFocus  := {||oGet1:SetColor(nRGB(0,0,0), nRGB(193,193,255))}
oGet1:bLostFocus := {||oGet1:SetColor(nRGB(0,0,0), nRGB(255,255,255))}


Thanks to you

- Ramesh Babu P
Last edited by RAMESHBABU on Fri Nov 10, 2006 1:56 pm, edited 1 time in total.
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Antonio Linares » Fri Nov 10, 2006 1:55 pm

Ramesh,

Try this:

oGet1:PostMsg( WM_SETFOCUS )
oBtn1:oJump = oGet1
regards, saludos

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

Postby Antonio Linares » Fri Nov 10, 2006 1:59 pm

Ramesh,

> BTW, why :SetFocus() is not working

Because Windows returns the focus to the button, after processing the ACTION of the button, so we can not interrupt that process.
regards, saludos

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

Postby RAMESHBABU » Fri Nov 10, 2006 2:07 pm

Hello Mr.Antonio

Thanks again for immediate attention.

oBtn1:oJump = oGet1


If we do not know in advance that the user will jump to oGet1 from oBtn1?

Thanks

Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Antonio Linares » Fri Nov 10, 2006 2:10 pm

Ramesh,

> If we do not know in advance that the user will jump to oGet1 from oBtn1?

You set it from the Create() function where you know where it will go.
regards, saludos

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

Postby RAMESHBABU » Fri Nov 10, 2006 2:21 pm

Mr.Antonio

Kindly test the above code with the changes you have suggested
and give me the suitable solution please.

I tried with the all your suggestions with fail.

Regards to you

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Antonio Linares » Mon Nov 13, 2006 9:28 am

Ramesh,
Code: Select all  Expand view
FUNCTION Create(lCreate, lSave, lGo, oGet1 )

lSave   := .T.
lCreate := .F.
lGo     := .T.

oGet1:PostMsg( WM_LBUTTONDOWN )
oGet1:PostMsg( WM_LBUTTONUP )

RETURN nil
regards, saludos

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

Postby RAMESHBABU » Tue Nov 14, 2006 2:16 am

Mr.Antonio

Thank you very much for your reply.

After spending some time on this, I could get the
required effect with the following statement.

oGet1:PostMsg( WM_RBUTTONDOWN )


Regards to you

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests