<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Giorgio Brausi's Weblog</title>
	<atom:link href="http://brausi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://brausi.wordpress.com</link>
	<description>Visual Basic .NET programmer</description>
	<lastBuildDate>Thu, 21 Feb 2008 00:55:34 +0000</lastBuildDate>
	<language>it</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='brausi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Giorgio Brausi's Weblog</title>
		<link>http://brausi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://brausi.wordpress.com/osd.xml" title="Giorgio Brausi&#039;s Weblog" />
	<atom:link rel='hub' href='http://brausi.wordpress.com/?pushpress=hub'/>
		<item>
		<title>[VB6] Toolbar: impostare immagini in maniera flessibile</title>
		<link>http://brausi.wordpress.com/2008/02/20/toolbar-impostare-immagini-in-maniera-flessibile/</link>
		<comments>http://brausi.wordpress.com/2008/02/20/toolbar-impostare-immagini-in-maniera-flessibile/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 22:52:24 +0000</pubDate>
		<dc:creator>giorgiobrausi</dc:creator>
				<category><![CDATA[VB6]]></category>
		<category><![CDATA[imagelist]]></category>
		<category><![CDATA[immagini]]></category>
		<category><![CDATA[toolbar]]></category>

		<guid isPermaLink="false">http://brausi.wordpress.com/?p=3</guid>
		<description><![CDATA[Premessa Una delle questioni più fastidiose relative al controllo Toolbar riguarda l&#8217;impostazione delle immagini nei pulsanti; è noto infatti che l&#8217;assegnazione di un immagine ad un pulsante richiede preventivamente l&#8217;associazione ad un ImageList in fase di progettazione in cui ovviamente dobbiamo già aver inserito tutte le immagini da utilizzare. Ciò, di per sé, non presenta problemi; semmai è noioso [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=brausi.wordpress.com&amp;blog=2927689&amp;post=3&amp;subd=brausi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><font color="#000000">Premessa</font></strong><br />
Una delle questioni più fastidiose relative al controllo Toolbar riguarda l&#8217;impostazione delle immagini nei pulsanti; è noto infatti che l&#8217;assegnazione di un immagine ad un pulsante richiede preventivamente l&#8217;associazione ad un ImageList in fase di progettazione in cui ovviamente dobbiamo già aver inserito tutte le immagini da utilizzare.<br />
Ciò, di per sé, non presenta problemi; semmai è noioso dovere impostare l&#8217;immagine per ogni singolo pulsante, soprattutto se i pulsanti sono molti.</p>
<p>Ma i problemi sorgono in seguito, cioè quando si rende necessaria l&#8217;aggiunta di una nuova immagine nell&#8217;ImageList! Eh sì, perchè tale operazione è possibile solo se prima si &#8216;scollega&#8217; l&#8217;ImageList dal controllo Toolbar, altrimenti VB6 risponde picche!<br />
Oltretutto, questo provoca nel Toolbar il completo azzeramento di tutti i riferimenti alle immagini che avevamo assegnato ad ogni singolo pulsante, e dopo aver aggiunto la nuova immagine saremo costretti a ripristinarli di nuovo, uno per uno.<br />
A lungo andare, tutto questo può innervosire (e come se innervosisce!).</p>
<p>Non so voi, ma io che uso un Toolbar praticamente in ogni form (in sostituzione dei CommandButton) e questo problema per me divenne un incubo molto presto!</p>
<p>Così ho studiato un piccolo stratagemma che mi permette la massima libertà di azione e mi evita qualche imprecazione di troppo&#8230;</p>
<p><strong><font color="#000000">Soluzione</font></strong><br />
Il modo più semplice che ho trovato per risolvere questo problema è quello di assegnare le immagini in fase di esecuzione, anzichè in fase di progettazione, creando una semplice routine che si incarica di svolgere tutto il lavoro per me.</p>
<p>Esiste però una condizione, peraltro assai semplice:<br />
la proprietà <strong>Key</strong> del pulsante nel <strong>Toolbar </strong>deve essere uguale alla proprietà <strong>Key</strong> dell&#8217;immagine presente nell&#8217;<strong>ImageList</strong> che vogliamo assegnargli.<br />
In pratica, se al pulsante <font color="#0000ff">Salva</font> impostiamo <font color="#0000ff">Key=save</font>, anche l&#8217;immagine che raffigura tale operazione (es. <font color="#0000ff">floppy disk</font>) dovrà avere la proprietà <font color="#0000ff">Key=save</font>.</p>
<p>Vediamo il codice della routine</p>
<pre>Public Sub ImpostaToolBar(ByRef myTB As MSComctlLib.Toolbar, _
  Optional ByRef myIml As MSComctlLib.ImageList, _
  Optional ByRef myHotIml As MSComctlLib.ImageList, _
  Optional ByVal bMostraCaption As Boolean = False, _
  Optional ByVal bFlat As Boolean = True, _
  Optional ByVal bBorder As Boolean = False)
 <font color="#ff0000"> Rem NOTA: questa routine non è completa,
  Rem il codice serve solo come esempio.</font><font color="#ff0000">
  Rem Vedi in calce il link per scaricare
  Rem il progetto di esempio.</font>
  <font color="#008000">Rem Per ogni pulsante del controllo Toolbar,
  Rem prendo il valore di Key e cerco
  Rem l'immagine corrispondente nell'ImageList.  
  Rem Se la trovo la abbino al pulsante:</font>  
  For i = 1 To myTB.Buttons.Count
    If myTB.Buttons(i).Style &lt;&gt; tbrSeparator Then
      myTB.Buttons(i).Image = _
         myIml.ListImages(myTB.Buttons(i).Key).Index
      sToolTip = myIml.ListImages(myTB.Buttons(i).Key).Tag
      <font color="#008000">Rem uso la proprietà Tag per impostare il tooltip
</font>      If sToolTip &lt;&gt; "" Then
        myTB.Buttons(i).ToolTipText = sToolTip
      End If
      <font color="#008000">Rem Se si sceglie di mostrare la Caption</font>
      If bMostraCaption Then
        myTB.Buttons(i).Caption = myTB.Buttons(i).ToolTipText
      End If
    End If
  Next i
End Sub</pre>
<p>Osservando i parametri presenti nella firma di questa routine è facile intuire che in realtà essa permette di impostare molte altre proprietà, ad esempio l&#8217;imagelist da usare come effetto Hot. Nella sezione <strong>VB Projects</strong> del mio sito <a target="_blank" href="http://www.vbcorner.net">VBCorner</a> potete scaricare il progetto di esempio completo.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/brausi.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/brausi.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brausi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brausi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brausi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brausi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brausi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brausi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brausi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brausi.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=brausi.wordpress.com&amp;blog=2927689&amp;post=3&amp;subd=brausi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://brausi.wordpress.com/2008/02/20/toolbar-impostare-immagini-in-maniera-flessibile/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37ce999a4fa15407f9437e512a7a0f0c?s=96&#38;d=identicon" medium="image">
			<media:title type="html">giorgiobrausi</media:title>
		</media:content>
	</item>
		<item>
		<title>Salve!</title>
		<link>http://brausi.wordpress.com/2008/02/20/ciao-mondo/</link>
		<comments>http://brausi.wordpress.com/2008/02/20/ciao-mondo/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 18:25:08 +0000</pubDate>
		<dc:creator>giorgiobrausi</dc:creator>
				<category><![CDATA[Programmazione]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Benvenuto sul mio nuovo blog.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=brausi.wordpress.com&amp;blog=2927689&amp;post=1&amp;subd=brausi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Benvenuto sul mio nuovo blog.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/brausi.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/brausi.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brausi.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brausi.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brausi.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brausi.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brausi.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brausi.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brausi.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brausi.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=brausi.wordpress.com&amp;blog=2927689&amp;post=1&amp;subd=brausi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://brausi.wordpress.com/2008/02/20/ciao-mondo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37ce999a4fa15407f9437e512a7a0f0c?s=96&#38;d=identicon" medium="image">
			<media:title type="html">giorgiobrausi</media:title>
		</media:content>
	</item>
	</channel>
</rss>
