TOOLBAR is loosing images

TOOLBAR is loosing images

Postby codemaker » Sun Feb 05, 2012 5:43 pm

Finally I decided to switch to some nicer windows of my app.
I decided to use the OUTLOOK style which I like and also In such window I want to add a TOOLBAR

Testing the TOOLBAR all looks nice but I have a problem:
When I start the app, the nice window show and on top there is a TOOLBAR with images shown for each "button", also very nice.
But when I move the mouse over any toolbar image, the image dissapears! :(

It looks like this
Image

Here is the code that I use for testing:
Code: Select all  Expand view

function TEST_TOOLBAR1()
*-----------------------
   local oWnd, oImageList
   local oMenu

   MENU oMenu
      MENUITEM "&Project"
      MENU
         MENUITEM "&New..." ACTION MsgInfo( "New" ) MESSAGE "New"
         MENUITEM "&Open..." ACTION MsgInfo( "Open" ) MESSAGE "Open"
         SEPARATOR
         MENUITEM "&Exit..." ACTION MsgInfo( "End" ) MESSAGE "Exit"
      ENDMENU

      MENUITEM "&Edit"
      MENU
         MENUITEM "&Search..." ACTION MsgInfo( "Search" )
         MENUITEM "&Print..." ACTION MsgInfo( "Print" )
      ENDMENU

      MENUITEM "&Utilities"
      MENU
         MENUITEM "&Disable button..." ACTION oToolBar:EnableButton( 3, .f. )
         MENUITEM "&Enable button..." ACTION oToolBar:EnableButton( 3, .t. )
      ENDMENU
   ENDMENU
   
   DEFINE WINDOW oWnd TITLE "FWH - Testing Win32 Toolbars" ;
      MENU oMenu

   // First we build an ImageList with all the bitmaps
   DEFINE IMAGELIST oImageList SIZE 32, 32

   DEFINE IMGBITMAP OF oImageList NAME "newt1"      COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "opent1"     COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "checkt1"    COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "searcht1"   COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "printt1"    COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "internett1" COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "keyst1"     COLOR nRGB( 255, 0, 255 )
   DEFINE IMGBITMAP OF oImageList NAME "quitt1"     COLOR nRGB( 255, 0, 255 )

   // Now we create the toolbar and add the buttons
   
   DEFINE TOOLBAR oToolBar OF oWnd SIZE 50, 58 ; // 50, 50 ;
      IMAGELIST oImageList BALLOON // tooltips balloon style
   
   oToolBar:SetTextRows( 2 )
   
   DEFINE TBBUTTON OF oToolBar ;
      ACTION  oToolbar:SetText( 1, "Hello" ) ; // Modify first button text
      TOOLTIP "New" ;
      PROMPT  "&New project"
   
   DEFINE TBBUTTON OF oToolBar ;
      ACTION  oToolBar:SetChecked( 2, .t. ) ; // Set pressed the second button
      TOOLTIP "Open" ;
      PROMPT  "Open project" ;
     
   DEFINE TBSEPARATOR OF oToolBar
   
   DEFINE TBMENU OF oToolBar ;
      ACTION  MsgInfo( "Menu" ) ;
      TOOLTIP "Menu" ;
      PROMPT  "Menu" ;
      MENU    BuildPopup()
   
   DEFINE TBBUTTON OF oToolBar ;
      ACTION  oToolBar:SetChecked( 2, .f. ) ; // MsgInfo( "Search" ) ;
      TOOLTIP "Search" ;
      PROMPT  "Search"

   DEFINE TBBUTTON OF oToolBar ;
      ACTION  MsgInfo( "Print" ) ;
      TOOLTIP "Print a report" ;
      PROMPT  "Print a report"

   DEFINE TBSEPARATOR OF oToolBar
     
   DEFINE TBBUTTON OF oToolBar ;
      ACTION  MsgInfo( "Upgrade" ) ;
      TOOLTIP "Search for new versions" ;
      PROMPT  "Upgrade"
     
   DEFINE TBBUTTON OF oToolBar ;
      ACTION MsgInfo( "Users" ) ;
      TOOLTIP "Users management" ;
      PROMPT "Users"  

   DEFINE TBSEPARATOR OF oToolBar

   DEFINE TBBUTTON OF oToolBar ;
      ACTION  oWnd:End() ;
      TOOLTIP "End Application" ;
      PROMPT  "Exit"

   DEFINE STATUSBAR OF oWnd PROMPT "Toolbars test"

   ACTIVATE WINDOW oWnd MAXIMIZED
   
   oImageList:End()

return nil

function BuildPopup()
*----------------------
   local oMenu
   
   MENU oMenu POPUP
      MENUITEM "One"   ACTION MsgInfo( "One" )
      MENUITEM "Two"   ACTION MsgInfo( "Two" )
      MENUITEM "Three" ACTION MsgInfo( "Three" )
   ENDMENU
return oMenu      
 


I thought I will start using the new look today but spent all day with this problem.
I hope somebody has the help for me.

I am using FWH where the FIVEHMX.LIB is dated 29.01.2010
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TOOLBAR is loosing images

Postby codemaker » Sun Feb 05, 2012 7:24 pm

I hope I found the solution.
At the end of the function, just before exit, there was
oImageList:End()
I remarked this and now all images are on place all the time!
Code: Select all  Expand view

ACTIVATE WINDOW oWnd MAXIMIZED
   
   //oImageList:End()

return nil
 


Is this the solution which is ok, or I am doing something I shouldn't?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TOOLBAR is loosing images

Postby Antonio Linares » Mon Feb 06, 2012 9:49 am

Boris,

Yes, thats the right solution as you can not destroy the ImageList object as it is the images container for a standard toolbar
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42086
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 75 guests