Page 1 of 1

Folder header with bitmaps

Posted: Tue Sep 18, 2007 11:10 am
by StefanHaupt
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.

Code: Select all

//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 ?

Posted: Wed Sep 19, 2007 7:36 am
by StefanHaupt
Ok, I think first step is to change TabCtrlAdd () in Tabctrl.c to allow bitmaps

Code: Select all

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:

Code: Select all

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 ?

Posted: Wed Sep 19, 2007 8:14 am
by Antonio Linares
Stefan,

Your code is fine. Try samples\TestFold.prg adding this line:

Code: Select all

   ACTIVATE DIALOG oDlg CENTERED ;
      VALID MsgYesNo( "Want to end ?" ) ;
      ON INIT SetImages( oDlg, oFld )
Image
We may modify REDEFINE FOLDER syntax to easier it

Posted: Wed Sep 19, 2007 8:38 pm
by StefanHaupt
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.

Code: Select all

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.

Posted: Wed Sep 19, 2007 8:39 pm
by Antonio Linares
Stefan,

Glad to know that you got it working :-)