Non-Modal, resizeable, TXBrowse from a Resource file

Non-Modal, resizeable, TXBrowse from a Resource file

Postby PatrickWeisser » Mon Apr 02, 2007 7:54 am

Hello Everyone,

Sorry for all the TXBrowse() questions, but data grids are very central to the application I'm porting to FiveWin/Harbour, and from what I can see think TXBrowse() is the best way for me to go. Once I get past a few difficult things I'll be fine.

The Testxbrw.prg sample has one resource-based use of TXBrowse(), but it is modal, and can't be resized. I was wondering if anyone has or knows of an example using TXBrowse() with a resource-based non-modal dialog, which also allows for a TXBrowse() control combined with buttons, and which allows the TXBrowse() control to be automatically resized if the user changes the size of the dialog window. In the code for our current application we respond to the WM_SIZE message from Windows and directly change the size of the Browse control based on the new size of the dialog, allowing space for our dialog buttons on the left as we do so.

Maybe a picture is worth a thousands words. Here is a screen shot of the application I'm porting:

Image

The top data grid is browsing the main name/address table, and the two windows below it are browsing related records in other tables. As the user moves in the top data grid, the related data grids are updated to point to the related records in their tables. I got this synchronization part working (thanks Kleyber) with TXBrowse() using DEFINE WINDOW, and CreateFromCode(), but that was just for testing -- I now need to use my resource-based data grid dialogs which have buttons.

Thanks for any help anyone can offer!
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Postby Antonio Linares » Mon Apr 02, 2007 8:06 am

Patrick,

> I now need to use my resource-based data grid dialogs which have buttons.

Please provide a portion of your resource where you define the buttons and the grid, thanks
regards, saludos

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

Postby PatrickWeisser » Mon Apr 02, 2007 9:30 am

Hello Antonio,

Here is the resource definition for the first browse window you see in the screen shot I provided:

Code: Select all  Expand view
DE_HEADER_BROWSE DIALOG 42, 100, 297, 93
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
CAPTION "Main File Browse"
{
LISTBOX HEADER_BROWSE_HOST_CONTROL, 51, 1, 246, 67, LBS_NOTIFY | LBS_NOREDRAW | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Find", CID_FIND, 0, 1, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Add", CID_ADD, 0, 13, 23, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
DEFPUSHBUTTON "&Edit", CID_FORM2, 25, 13, 23, 10
PUSHBUTTON "&Mark", CID_MARK, 0, 24, 23, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Copy", CID_COPY, 25, 24, 23, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Delete", CID_DELETE, 0, 36, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "Con&solidate", CID_CONSOLIDATE, 0, 47, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&OK", IDOK, 0, 69, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
CTEXT "", CID_STATUS_DISPLAY, 52, 83, 226, 9
PUSHBUTTON "W&ord Notes", CID_WORD_NOTES, 0, 58, 48, 10
}


The browse window is hosted by a LISTBOX control named, HEADER_BROWSE_CONTROL. The code supporting resizing of the dialog at runtime is:

Code: Select all  Expand view
   Case( nMsg == WM_SIZE )

      If( nWparam != SIZE_MINIMIZED )

         aCRect  := GetClientRect( hDlgWnd )  // hDlgWnd is a handle to the dialog hosting the browse.

         aStatusRect := GetClientRect( GetDlgItem( hDlgWnd, CID_STATUS_DISPLAY ) )
         hStatusWnd  := GetDlgItem( hDlgWnd, CID_STATUS_DISPLAY )
         ShowWindow( hStatusWnd, SW_HIDE )
         MoveWindow( hStatusWnd, snButtonOffset + 10, aCRect[ W_BOTTOM ] - aStatusRect[ W_BOTTOM ], aCRect[ W_RIGHT ] - snButtonOffset - 10, aStatusRect[ W_BOTTOM ] )
         ShowWindow( hStatusWnd, SW_SHOW )

         hList := GetDlgItem( hDlgWnd, snBrowHostID )  // This is normally HEADER_BROWSE_HOST_CONTROL in the resource file.

         MoveWindow( hList, snButtonOffset, 0, aCRect[ W_RIGHT ] - snButtonOffset, aCRect[ W_BOTTOM ] - 25, .T.)

         SendMessage( hList, WM_PAINT, 0 , 0 )

         UpdateWindow( hList )


         aCRect  := GetClientRect( hList )

         MoveWindow( oB:hWnd, 0, 0, aCRect[ W_RIGHT ], aCRect[ W_BOTTOM ], .T.)

         SendMessage( oB:hWnd, WM_PAINT, 0 , 0 )

         UpdateWindow( oB:hWnd )

      EndIf



The variable snButtonOffset is how much space we have to save on the left for the buttons when resizing the list box control hosting the Browse.

Thanks Antonio!
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Postby Antonio Linares » Mon Apr 02, 2007 12:18 pm

Patrick,

This is a first working prototype:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   USE Customer

   DEFINE WINDOW oWnd TITLE "Test" MDI

   ACTIVATE WINDOW oWnd ;
      ON INIT BuildChild()

return nil

function BuildChild()

   local oChild
   
   DEFINE WINDOW oChild TITLE "A Child Window" MDICHILD
   
   ACTIVATE WINDOW oChild ;
      ON INIT BuildDialog( oChild )
   
return nil   

function BuildDialog( oChild )

   local oDlg, oBrw

   DEFINE DIALOG oDlg RESOURCE "DE_HEADER_BROWSE" OF oChild
   
   oBrw = TXBrowse():New( oDlg )
   oBrw:CreateFromResource( 10 )
   oBrw:SetRDD()

   ACTIVATE DIALOG oDlg NOWAIT ;
      ON INIT oDlg:Move( 0, 0 ) ;
      VALID .F.
   
   oChild:bResized = { || oDlg:SetSize( oChild:nWidth, oChild:nHeight - 30 ),;
                                     oBrw:SetSize( oDlg:nWidth - 118, oDlg:nHeight - 10 ) }
   
return nil   

We have modified your RC this way:
Code: Select all  Expand view
DE_HEADER_BROWSE DIALOG 42, 100, 297, 93
STYLE WS_CHILD 
{
LISTBOX 10, 51, 1, 246, 67, LBS_NOTIFY | LBS_NOREDRAW | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Find", 20, 0, 1, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Add", 30, 0, 13, 23, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
DEFPUSHBUTTON "&Edit", 40, 25, 13, 23, 10
PUSHBUTTON "&Mark", 50, 0, 24, 23, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Copy", 60, 25, 24, 23, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&Delete", 70, 0, 36, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "Con&solidate", 80, 0, 47, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "&OK", 1, 0, 69, 48, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
CTEXT "", 90, 52, 83, 226, 9
PUSHBUTTON "W&ord Notes", 100, 0, 58, 48, 10
}

Here you have a screenshot:
Image
regards, saludos

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

Postby Enrico Maria Giordano » Mon Apr 02, 2007 12:53 pm

Is TXBrowse able to show more than one line of text on each row?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8600
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby demont frank » Mon Apr 02, 2007 1:27 pm

Yes,

oBrw:nHeaderLines := 2
oBrw:nDataLines := 2
oBrw:nFooterLines := 2

Frank
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Enrico Maria Giordano » Mon Apr 02, 2007 1:51 pm

Thank you!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8600
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Mon Apr 02, 2007 1:55 pm

This is a cleaner way to do it:
Code: Select all  Expand view
#include "FiveWin.ch"

#define COLOR_BTNFACE   15

function Main()

   local oWnd

   USE Customer

   DEFINE WINDOW oWnd TITLE "Test" MDI

   ACTIVATE WINDOW oWnd ;
      ON INIT BuildChild()

return nil

function BuildChild()

   local oChild
   
   DEFINE WINDOW oChild TITLE "A Child Window" MDICHILD ;
      COLOR 0, GetSysColor( COLOR_BTNFACE )
   
   ACTIVATE WINDOW oChild ;
      ON INIT BuildDialog( oChild )
   
return nil   

function BuildDialog( oChild )

   local oDlg, oBrw, oSay, cText := "Hello World!"

   DEFINE DIALOG oDlg RESOURCE "DE_HEADER_BROWSE" OF oChild
   
   oBrw = TXBrowse():New( oDlg )
   oBrw:CreateFromResource( 10 )
   oBrw:SetRDD()
   
   REDEFINE BUTTON ID 20 OF oDlg
   REDEFINE BUTTON ID 30 OF oDlg
   REDEFINE BUTTON ID 40 OF oDlg
   REDEFINE BUTTON ID 50 OF oDlg
   REDEFINE BUTTON ID 60 OF oDlg
   REDEFINE BUTTON ID 70 OF oDlg
   REDEFINE BUTTON ID 80 OF oDlg
   REDEFINE BUTTON ID 100 OF oDlg
   REDEFINE BUTTON ID   1 OF oDlg

   REDEFINE SAY oSay VAR cText ID 90 OF oDlg

   ACTIVATE DIALOG oDlg NOWAIT ;
      ON INIT ChangeParent( oDlg, oChild )
     
   oDlg:End()   
   oChild:bResized = { || oBrw:SetSize( oChild:nWidth - 117, oChild:nHeight - 60 ),;
                                     oSay:nTop := oChild:nHeight - 55, oSay:nLeft := ( oChild:nWidth / 2 ) - oSay:nWidth / 2 }
   oChild:SetSize( 800, 400 )
   
return nil   

function ChangeParent( oDlg, oChild )

   local n
   
   for n = 1 to Len( oDlg:aControls )
      SetParent( oDlg:aControls[ n ]:hWnd, oChild:hWnd )
      AAdd( oChild:aControls, oDlg:aControls[ n ] )
   next
   
return nil

Image
regards, saludos

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

Postby PatrickWeisser » Mon Apr 02, 2007 10:45 pm

Thanks so much Antonio, that looks fantastic!

-Patrick
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA


Return to FiveWin for Harbour/xHarbour

Who is online

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