xBrowse on a Dlg OF oWnd MDI does not respond

xBrowse on a Dlg OF oWnd MDI does not respond

Postby reinaldocrespo » Fri Feb 13, 2015 12:04 am

Hi everyone.

I need help finding out what I'm doing wrong with this xbrowse. It is housed on a dialog built from resources. The app is an MDI app. I have been able to reproduce the problem on a reduced self-contained sample as shown below. When you execute the app you must resize the window in order to view the xbrowse. That is not the problem I'm looking to solve. The problem I need help with is that once the xbrowse is visible it responds to keyboard input but not to mouse clicks. Can someone please help?

Thank you,

First the .rc file needed:

Code: Select all  Expand view  RUN

GRID_DLG DIALOG 113, 70, 105, 0
STYLE DS_3DLOOK |DS_SETFONT |WS_CHILD |WS_SYSMENU
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "",100,"Txbrowse",WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,2,0,269,207
END
 


And now the actual .prg that reproduces the problem.


Code: Select all  Expand view  RUN

#include "fivewin.ch"
#include "xbrowse.ch"
#include "ads.ch"

STATIC cAlias

FUNCTION Main()
   LOCAL oTest
   
   rddRegister( "ADS", 1 )
   rddSetDefault( "ADS" )
   adsSetServerType( ADS_LOCAL_SERVER )
   AdsLocking( .t. ) //NON-compatible locking mode

   oTest := Test():New()
   
RETURN NIL


//------------------------------------------------
procedure RddInit()

   REQUEST HB_LANG_EN
   REQUEST DBFCDX, DBFFPT
   REQUEST OrdKeyCount, OrdKeyNo, OrdKeyGoto
   REQUEST ADSKeyNo, ADSKeyCount
   REQUEST ADS

RETURN




//------------------------------------------------
CLASS Test

   DATA oGridViewDlg
   DATA oGrid
   DATA oDbf
   DATA oWnd, oWndChild
   
   METHOD New()
   METHOD End()

   METHOD OpenDlg()
   
   METHOD SetSize( nType, nW, nH )

   METHOD CreateTables()
   
END CLASS


//------------------------------------------------
METHOD New() CLASS Test
   LOCAL oSelf := SELF
   LOCAL oMenu

   ::CreateTables()
   
   MENU oMenu
      MenuItem "hide dlg" action ::oGridViewDlg:hide()
      MenuItem "show dlg" action ::oGridViewDlg:show()
   ENDMENU  

   
   DEFINE WINDOW ::oWnd MDI MENU oMenu

   ACTIVATE WINDOW ::oWnd ;
           ON INIT oSelf:OpenDlg() ;
         ON RESIZE oSelf:SetSize( nSizeType, nWidth, nHeight ) ;
             VALID oSelf:End()


RETURN SELF



//------------------------------------------------
METHOD End() CLASS Test

   (cAlias)->( dbCloseArea() )
   
RETURN .T.



//------------------------------------------------
METHOD OpenDlg() CLASS Test
   LOCAL oSelf := SELF


//   DEFINE WINDOW ::oWndChild MDICHILD OF ::oWnd FROM 5,5 TO 6,6 COLOR "N/W" BORDER NONE NOMAXIMIZE NOMINIMIZE

   DEFINE DIALOG ::oGridViewDlg RESOURCE "Grid_Dlg" TRANSPARENT COLOR RGB( 240, 240, 255 ), RGB( 240, 240, 255 )  //OF ::oWndChild

   REDEFINE XBROWSE ::oGrid ID 100 OF ::oGridViewDlg ALIAS cAlias ;
            COLUMNS 'mrec', 'guid', 'Subject', 'Last_Name', 'First_Name', ;
                     'schedule', 'insurance' ;
             HEADER 'MedRecord', 'guid', 'SubjectLine', 'LastName', 'FirstName', 'Schedule', "Insurance" ;
              SIZES 70, 120, 150, 100, 100, 100, 150


   WITH OBJECT ::oGrid

    :lAllowRowSizing     := .T.
    :lAllowColSwapping   := .T.
      :nStretchCol         := 2
    :nMarqueeStyle       := MARQSTYLE_HIGHLROW
    :lRecordSelector     := .F.
    :nHeaderHeight       := 25

      :MedRecord:bLClickHeader := {|nR, nC, nF, o| SelectOrder( o , "mrec" ) }
      :guid:bLClickHeader := {|nR, nC, nF, o| SelectOrder( o , "guid" ) }
      :LastName:bLClickHeader := {|nR, nC, nF, o| SelectOrder( o , "Last_Name" ) }

      :bPastEof := { || (cAlias)->( dbAppend() ) }
     
   END

   SelectOrder( ::oGrid:MedRecord, "mrec" )

   ::oGridViewDlg:oClient    := ::oGrid
   ::oGridViewDlg:bGotFocus := { || ::oGrid:SetFocus() }

   ACTIVATE DIALOG ::oGridViewDlg NOWAIT VALID (.F.) ;
          ON INIT ( oSelf:oGridViewDlg:move( oSelf:oWnd:nBottom - oSelf:oGridViewDlg:nheight, ;
                                             oSelf:oWnd:nRight - oSelf:oGridViewDlg:nWidth ) )

   //::oWndChild:nWidth := ::oGridViewDlg:nWidth+7
   //::oWndChild:nHeight := ::oGridViewDlg:nHeight+32

   //ACTIVATE WINDOW ::oWndchild ON INIT ::oWnd:Paint()



RETURN NIL



//------------------------------------------------
METHOD SetSize( nType, nWidth, nHeight ) CLASS Test
LOCAL aClient := GetClientRect ( ::oWnd:hWnd ), i

   IF ::oGridViewDlg == NIL  ;RETURN NIL  ; ENDIF

   //::oWndchild:SetSize( ::oWnd:nWidth, ::oWnd:nHeight, .T. )
   //::oWndchild:Move( 0, 0, ::oWnd:nWidth, ::oWnd:nHeight )
   ::oGridViewDlg:Move( 0, 0 , ::oWnd:nWidth, nHeight )
         
   ::oGridViewDlg:SetSize( aClient[4] - 1, nHeight, .T. )
   ::oGridViewDlg:Move( aClient[ 1 ], 0 )

   IF ::oGrid == NIL    ;RETURN NIL       ;ENDIF

   ::oGrid:Move( 0, 0 )
   ::oGrid:SetSize( aClient[4], ::oGridViewDlg:nHeight , .T. )
   ::oGrid:SetFocus()

RETURN NIL


//------------------------------------------------
METHOD CreateTables() CLASS Test
   LOCAL cTable := "EvntColl"
   LOCAL aStruc := { { "GUID"              ,"C", 24, 0 },;
                  { "mrec"         ,"C", 15, 0 },;            //key
                  { "Subject"       ,"C", 50, 0 },;           //key
                  { "Last_Name"     ,"C", 24, 0 },;           //key
                  { "First_Name"    ,"C", 15, 0 },;           //key
                  { "eMail"         ,"C", 50, 0 },;          
                  { "Tel"           ,"C", 13, 0 },;          
                  { "More_Info"     ,"M", 10, 0 },;
                  { "Event"         ,"C", 15, 0 },;   //FK into events.adt (predifined events)
                  { "Schedule"      ,"C", 15, 0 },;   //FK into Schedules.adt
                  { "Label"         ,"C", 15, 0 },;   //FK into schdl_lbls
                  { "isEmail"       ,"L", 01, 0 },;
                  { "isReminder"    ,"L", 01, 0 },;
                  { "Reminder"      ,"N", 09, 0 },;      //in minutes
                  { "isNoShow"      ,"L", 01, 0 },;
                  { "Insurance"     ,"C", 20, 0 },;
                  { "Contract"      ,"C", 20, 0 },;
               { "Group"         ,"C", 20, 0 } }

   AdsSetFileType( ADS_ADT )
   cAlias := "MyAlias"
   
   IF !FILE( cTable )
   
      dbCreate( cTable, aStruc,, .T., cAlias )

      ( cAlias )->( OrdCreate( cTable, "guid", "guid" ) )
      ( cAlias )-> (OrdCreate( cTable, "mrec", "mrec" ) )
      ( cAlias )->( OrdCreate( cTable, "Last_Name", "Last_Name" ) )

      ( cAlias )->( dbAppend() )
   
      IF ( cAlias )->( rLock() )
         ( cAlias )->Guid := "1234567890"
         ( cAlias )->mRec := "00000001"
         ( cAlias )->Subject := "Test subject"
         ( cAlias )->Last_Name := "Doe"
         ( cAlias )->First_Name := "John"
       
      ENDIF
     
      ( cAlias )->( dbUnlock() )

      ( cAlias )->( dbAppend() )
   
      IF ( cAlias )->( rLock() )
         ( cAlias )->Guid := "4567890123"
         ( cAlias )->mRec := "00000002"
         ( cAlias )->Subject := "Test subject 2"
         ( cAlias )->Last_Name := "Doe"
         ( cAlias )->First_Name := "Joann"
       
      ENDIF
     
      ( cAlias )->( dbUnlock() )

   ELSE
   
      Dbusearea( .T., "ADSADT", cTable , cAlias , .T. , .F. )
     
   ENDIF
   
RETURN NIL



//------------------------------------------------------------------------------
FUNCTION selectOrder( oCol, cOrd )

   AEVAL( oCol:oBrw:aCols, {|o| o:bClrHeader := {|| { CLR_BLUE, } } } )
   oCol:bClrHeader      := {|| {CLR_HRED, } }
   (oCol:oBrw:cAlias) -> ( OrdSetFocus( cOrd ) )

   oCol:oBrw:refresh()

RETURN( NIL )

 


Notice how the xbrowse does responde to keyboard input but not to mouse clicks.

Can someone shed some light?

Thank you,

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xBrowse on a Dlg OF oWnd MDI does not respond

Postby reinaldocrespo » Fri Feb 13, 2015 12:32 am

Well, never mind. I was able to figure out the solution. I will be glad to share if anyone is interested.

I'm sure someone would've helped so thank you anyway.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xBrowse on a Dlg OF oWnd MDI does not respond

Postby James Bott » Fri Feb 13, 2015 5:16 am

I gave up on MDI designs a long time ago, and with it all the associated problems. I think single document interfaces (SDI) are much better UI's anyway.

Glad you solved your problem though.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse on a Dlg OF oWnd MDI does not respond

Postby reinaldocrespo » Fri Feb 13, 2015 2:49 pm

James;

Totally with you here. I try to avoid them all the time. AMOF, I imitate MDI using SDI + modeless dialogs and keep better control of the GUI and -IMHO -provide a better enduser experience.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 13 guests