XBrowse online editing

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

Post by nageswaragunupudi »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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 :

Code: Select all

   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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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

Post by Antonio Linares »

Nageswararao,

Fixed. In METHOD Edit( nKey ) CLASS TXBrwColumn make this change:

Code: Select all

   ::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

Code: Select all

HB_FUNC( GETWINDOWPROCESSID ) // hWnd --> nProcessId
{
   DWORD dwProcessId;
   
   GetWindowThreadProcessId( ( HWND ) hb_parnl( 1 ), &dwProcessId );
   
   hb_retnl( dwProcessId );
}   	
regards, saludos

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

Post by Antonio Linares »

We can use GetWindowThreadProcessId() instead of GetWindowProcessId():

Code: Select all

HB_FUNC( GETWINDOWTHREADPROCESSID ) // hWnd --> nThread
{
   _retnl( GetWindowThreadProcessId( ( HWND ) _parnl( 1 ), NULL ) );
}   	
regards, saludos

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

Post by Antonio Linares »

regards, saludos

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

Post by Antonio Linares »

This change cancels the editing before giving focus to another control in the application:

Code: Select all

METHOD Edit( nKey ) CLASS TXBrwColumn
...
   ::oEditGet:bLostFocus := { | oGet, hWndFocus | EditGetLostFocus( oGet, hWndFocus, ::oBrw, ::oEditGet ) }
...
new static function inside Class TXBrowse:

Code: Select all

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

Post by Antonio Linares »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

I have changed the function Valida in mallocra.prg as below

Code: Select all

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

Post by Antonio Linares »

Nageswararao,

Please add this line and try it again:

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

Antonio Linares
www.fivetechsoft.com
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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

Post by Antonio Linares »

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

Post by Antonio Linares »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
Post Reply