FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse online editing
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Mon Dec 24, 2007 02:01 PM

Trying with your Exe:
Let us take 4th line first column.
Enter 9 and press enter key. ( in your exe valid msg is shown only once).
and get retians focus and shows 9
click on some other program window outiside. Get still has focus.
Now come back to browse and click on any other cell.
9 is written and also wrongly justified ( as if painted by get object)
Please release your next exe with colored gets.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Mon Dec 24, 2007 02:10 PM
In the above case:

9 seems to be in Get still. We can not navigate to the cell by left clicking on the cell. But if we block the 9 with mouse and press enter :
   Path and name: C:\TESTS\Bin\mallorca1.exe (32 bits)
   Size: 1,223,168 bytes
   Time from start: 0 hours 0 mins 32 secs 
   Error occurred at: 12/24/07, 19:48:17
   Error description: Error BASE/1005  No exported variable: NLASTKEY
   Args:
     [   1] = U   
     [   2] = N   13

Stack Calls
===========
   Called from:  => _NLASTKEY(0)
   Called from: .\source\classes\XBROWSE.PRG => EDITGETKEYDOWN(0)
   Called from:  => (b)EDIT(0)
   Called from:  => TGET:KEYDOWN(0)
   Called from:  => TWINDOW:HANDLEEVENT(0)
   Called from:  => TCONTROL:HANDLEEVENT(0)
   Called from:  => TGET:HANDLEEVENT(0)
   Called from: .\source\classes\WINDOW.PRG => _FWH(0)
   Called from:  => WINRUN(0)
   Called from:  => TWINDOW:ACTIVATE(0)
   Called from: D:\FiveWin.20\samples\mallorca.prg => MAIN(34)
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Mon Dec 24, 2007 02:40 PM
Mr Antonio

There seem to some difference in the behavior between your exe and what I compile here.

I have made the changes in a derived class so that the changes are very clear. The zip file of the changes is here

XBROWED.zip (3.40 KB)

Can you kindly go through and advise me if there are any more modifications I need to make?
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Mon Dec 24, 2007 02:40 PM
Nageswararao,

Fixed. In METHOD Edit( nKey ) CLASS TXBrwColumn make this change:
   ::oEditGet:bLostFocus := { | oGet, hWndFocus | If( GetWindowProcessId( hWndFocus ) != GetWindowProcessId( ::oBrw:hWnd ), ::oBrw:CancelEdit(), If( ::oEditGet != nil .and. ! ::oEditGet:lValidating, ::PostEdit(),) ) }

and add this function to source\winapi\getwnd.c
HB_FUNC( GETWINDOWPROCESSID ) // hWnd --> nProcessId
{
   DWORD dwProcessId;
   
   GetWindowThreadProcessId( ( HWND ) hb_parnl( 1 ), &dwProcessId );
   
   hb_retnl( dwProcessId );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Mon Dec 24, 2007 02:47 PM
We can use GetWindowThreadProcessId() instead of GetWindowProcessId():
HB_FUNC( GETWINDOWTHREADPROCESSID ) // hWnd --> nThread
{
   _retnl( GetWindowThreadProcessId( ( HWND ) _parnl( 1 ), NULL ) );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Mon Dec 24, 2007 02:50 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Tue Dec 25, 2007 11:35 AM
This change cancels the editing before giving focus to another control in the application:
METHOD Edit( nKey ) CLASS TXBrwColumn
...
   ::oEditGet:bLostFocus := { | oGet, hWndFocus | EditGetLostFocus( oGet, hWndFocus, ::oBrw, ::oEditGet ) }
...

new static function inside Class TXBrowse:
static function EditGetLostFocus( oGet, hWndFocus, oBrw, oEditGet )

   // focus goes to another control in the same application
   if oWndFromHwnd( hWndFocus ) != nil
      oBrw:CancelEdit()               
      return nil
   endif   

   // focus goes to another application
   if GetWindowThreadProcessId( hWndFocus ) != GetWindowThreadProcessId( oBrw:hWnd )
      oBrw:CancelEdit()
      return nil
   endif   
      
   if oEditGet != nil .and. ! oEditGet:lValidating
      oBrw:PostEdit()
   endif   

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Tue Dec 25, 2007 11:38 AM

A new mallorca.exe build:

http://www.hotshare.net/file/25841-7828226dca.html

Please try to break it, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Tue Dec 25, 2007 12:19 PM

I have tested the exe provided by you. I have also rebuilt the samples adopting your changes.

Both are now working fine. I continue my tests.

Only one thing I dont understand. In the exe provided by you the valid block is executed only once, but with the exe i built it is executed twice. I am trying to figure out the reason.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Tue Dec 25, 2007 01:01 PM
I have changed the function Valida in mallocra.prg as below
STATIC FUNCTION Valida( oGet )

   local nnew  := 0

    IF oGet:Value() > 6
       MsgAlert( "Must be lower than 7" )
       if msgget('NEW VALUE','Enter number between 1 and 6',@nnew)
          if nnew > 0 .and. nnew < 7
             oGet:varput( nnew )
             oget:refresh()
             return .t.
          else
             return .f.
          endif
       endif
       return .F.
    ENDIF

RETURN .T.

If i enter a valid value, ( example 6 ) it is not getting assigned.
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Tue Dec 25, 2007 03:40 PM
Nageswararao,

Please add this line and try it again:

oGet:varput( nnew )
oGet:refresh()
MsgInfo( oGet:VarGet() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Tue Dec 25, 2007 03:49 PM

msginfo( oget:varget() ) shows the entered value of 6. Also at that moment I see 6 in the edit cell in the browse also ( we refreshed the get just before).

But after the valid function returns, the cell in xbrowse is repainted with orginal value.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Tue Dec 25, 2007 04:16 PM

Nageswararao,

That behavior is fine because the real assignment is done from here:

oBrw:aCols[1]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,1] := xVal,) }

The VALID should not try to modify the edited value. It just jave to return .T. or .F., and a warning for the user, if needed

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Tue Dec 25, 2007 04:18 PM

In case that you need to do the assignment from the VALID, then you could try:

oBrw:aCols[1]:bOnPostEdit := { || nil }

But thats not the recommended use

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Tue Dec 25, 2007 04:27 PM

More Important problem. After using EditGetLostFocus function, even entering valid values are not getting assigned. The problem is there.

Regards



G. N. Rao.

Hyderabad, India