FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Folder header with bitmaps
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Folder header with bitmaps
Posted: Tue Sep 18, 2007 11:10 AM
Dear friends,

the sample Testfold.prg is not working, if I try to put bitmaps in the headers of the folder. The bitmaps are not shown.

//Testfold.prg

DEFINE DIALOG oDlg RESOURCE "Test"

   REDEFINE FOLDER oFld ID 110 OF oDlg ;
      PROMPT "CA-Cli&pper", "&and", "&Windows", "&Magic" ;
      DIALOGS "Sub1", "Sub2"

ACTIVATE DIALOG oDlg CENTERED ;
      VALID MsgYesNo( "Want to end ?" ) ;
       ON INIT SetImages( oDlg, oFld )

return nil

function SetImages( oDlg, oFld )

   local oImageList
   
   DEFINE IMAGELIST oImageList SIZE 16, 16
   
   oImageList:AddMasked( TBitmap():Define( "new",,    oDlg ), nRGB( 192, 192, 192 ) )    
   oImageList:AddMasked( TBitmap():Define( "open",,   oDlg ), nRGB( 192, 192, 192 ) )    
   oImageList:AddMasked( TBitmap():Define( "search",, oDlg ), nRGB( 192, 192, 192 ) )    
   oImageList:AddMasked( TBitmap():Define( "print",,  oDlg ), nRGB( 192, 192, 192 ) )    
   
   oFld:SetImageList( oImageList )
    //oFld:SetPadding( 2, 5 )
    //oFld:SetItemSize( 300, 18 )   
   
return nil


Why does it not work ?
kind regards

Stefan
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Folder header with bitmaps
Posted: Wed Sep 19, 2007 07:36 AM
Ok, I think first step is to change TabCtrlAdd () in Tabctrl.c to allow bitmaps

CLIPPER TABCTRLADD( PARAMS ) // cPrompt --> nil
{
   _bset( ( char * ) &item, 0, sizeof( item ) );

   item.mask       = TCIF_IMAGE | TCIF_TEXT | TCIF_STATE ; // allow bitmaps
   #ifndef UNICODE
      item.pszText = _parc( 2 );
   #else
      item.pszText = AnsiToWide( _parc( 2 ) );
   #endif
   item.dwState    = _parl( 3 );
   item.iImage     = _parni( 4 );  // index of Imagelist

   SendMessage( ( HWND ) _parni( 1 ), TCM_INSERTITEM, 0, ( LONG ) &item );
   #ifdef UNICODE
      hb_xfree( item.pszText );
   #endif
}


and then in folder.prg:

METHOD SetPrompts( aPrompts ) CLASS TFolder
...
...
  for n = Len( ::aPrompts ) to 1 step -1
     // 4. parameter is bitmap index of Imagelist
       TabCtrlAdd( ::hWnd, ::aPrompts[ n ], ::aEnable[ n ] , n)
   next
...
...


But it is still not working. :-)

Does anyone have an idea ?
kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Folder header with bitmaps
Posted: Wed Sep 19, 2007 08:14 AM
Stefan,

Your code is fine. Try samples\TestFold.prg adding this line:
   ACTIVATE DIALOG oDlg CENTERED ;
      VALID MsgYesNo( "Want to end ?" ) ;
      ON INIT SetImages( oDlg, oFld )


We may modify REDEFINE FOLDER syntax to easier it
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Folder header with bitmaps
Posted: Wed Sep 19, 2007 08:38 PM
Antonio,

I tried this, but it was not working. After a lot of unsuccessful tests my last idea was to change the header of the function TabCtrlAdd() and that did the trick.

HARBOUR HB_FUN_TABCTRLADD( PARAMS ) // cPrompt --> nil
{
   _bset( ( char * ) &item, 0, sizeof( item ) );

   item.mask       =  TCIF_TEXT | TCIF_STATE  | TCIF_IMAGE;
   #ifndef UNICODE
      item.pszText = _parc( 2 );
   #else
      item.pszText = AnsiToWide( _parc( 2 ) );
   #endif
   item.dwState    = _parl( 3 );
   item.iImage     = _parni( 4 );

   SendMessage( ( HWND ) _parni( 1 ), TCM_INSERTITEM, 0, ( LONG ) &item );
   #ifdef UNICODE
      hb_xfree( item.pszText );
   #endif
}


It seems that CLIPPER TABCTRLADD() was not correctly translated.
kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Folder header with bitmaps
Posted: Wed Sep 19, 2007 08:39 PM

Stefan,

Glad to know that you got it working :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion