Folder header with bitmaps

Folder header with bitmaps

Postby StefanHaupt » 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.

Code: Select all  Expand view  RUN
//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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby StefanHaupt » Wed Sep 19, 2007 7:36 am

Ok, I think first step is to change TabCtrlAdd () in Tabctrl.c to allow bitmaps

Code: Select all  Expand view  RUN
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  Expand view  RUN
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Antonio Linares » Wed Sep 19, 2007 8:14 am

Stefan,

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

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

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

Postby StefanHaupt » Wed Sep 19, 2007 8: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.

Code: Select all  Expand view  RUN
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Antonio Linares » Wed Sep 19, 2007 8:39 pm

Stefan,

Glad to know that you got it working :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests