Toolbar buttons and WM 2003SE

  • Thread starter Thread starter John Atkins
  • Start date Start date
J

John Atkins

I have a Windows Mobile 2003 application (Pocket PC) that works fine in
WM2003 but in Second Edition, the buttons do not show on the toolbar. This
happens with a real device (Dell X30) and in the WWE PPC 2003 SE - SDK
Emulator.

To try to find where the problem is, I created a VERY simple test
application and that shows the same problem.

I created a PPC Smart Device application, dropped on a menu and created just
a File menu with Exit on it.
I dropped on a TooBar and an ImageList.
I added two simple 16x16 Bitmap images to the ImageList. Bitmaps were
created with VS.Net
I set the ImageList for the Toolbar to this ImageList.
I add two buttons to the Toolbar and set their Image Indexes to 0 and 1.
The two buttons show up correctly next to the menu at design time.

When I run the program in the emulator, neither button appears on the
toolbar. I see a grey area next to the menu and if I click in the grey area
where the buttons should be, I see a while square where the buttons should
be.

Does anyone know what is wrong and how I can solve it?

John.
 
This is a bug with .netCF on WM2003SE.

To get around it, try this -- you cannot assign the ImageList for the
Toolbar and ImageIndex for the Toolbar Buttons in VS - you must assign them
at run-time:

toolBar.ImageList = toolBarImageList;
toolBar.Buttons[0].ImageIndex = 0;
...

Note, you may also be able to get Icons working with a transparent color in
your toolbar if you create the ImageList at run-time (this means your .ico
files must be available at run-time, or you must have them as embedded
resources in your .exe).
 
Thank you very much Bob, that did indeed solved it.

John.

Bob Prochnow said:
This is a bug with .netCF on WM2003SE.

To get around it, try this -- you cannot assign the ImageList for the
Toolbar and ImageIndex for the Toolbar Buttons in VS - you must assign them
at run-time:

toolBar.ImageList = toolBarImageList;
toolBar.Buttons[0].ImageIndex = 0;
...

Note, you may also be able to get Icons working with a transparent color in
your toolbar if you create the ImageList at run-time (this means your .ico
files must be available at run-time, or you must have them as embedded
resources in your .exe).

John Atkins said:
I have a Windows Mobile 2003 application (Pocket PC) that works fine in
WM2003 but in Second Edition, the buttons do not show on the toolbar. This
happens with a real device (Dell X30) and in the WWE PPC 2003 SE - SDK
Emulator.

To try to find where the problem is, I created a VERY simple test
application and that shows the same problem.

I created a PPC Smart Device application, dropped on a menu and created just
a File menu with Exit on it.
I dropped on a TooBar and an ImageList.
I added two simple 16x16 Bitmap images to the ImageList. Bitmaps were
created with VS.Net
I set the ImageList for the Toolbar to this ImageList.
I add two buttons to the Toolbar and set their Image Indexes to 0 and 1.
The two buttons show up correctly next to the menu at design time.

When I run the program in the emulator, neither button appears on the
toolbar. I see a grey area next to the menu and if I click in the grey area
where the buttons should be, I see a while square where the buttons should
be.

Does anyone know what is wrong and how I can solve it?

John.
 
Hi,

I have exactly the same problem as described. However, the suggested fix
does not work for me. I tried all thinkable orderings of ImageList and
ToolBar initialization in my InitializeComponent method, but none works. I
never see an Image on PPC 2003 SE, however it works flawlessly on PPC 2002
and PPC 2003.

Could you please post or mail (to a.selle_at_subsembly.com) your complete
working ToolBar and associated ImageList initialization.

Cheers,

Andreas Selle

John Atkins said:
Thank you very much Bob, that did indeed solved it.

John.

Bob Prochnow said:
This is a bug with .netCF on WM2003SE.

To get around it, try this -- you cannot assign the ImageList for the
Toolbar and ImageIndex for the Toolbar Buttons in VS - you must assign them
at run-time:

toolBar.ImageList = toolBarImageList;
toolBar.Buttons[0].ImageIndex = 0;
...

Note, you may also be able to get Icons working with a transparent color in
your toolbar if you create the ImageList at run-time (this means your ..ico
files must be available at run-time, or you must have them as embedded
resources in your .exe).

John Atkins said:
I have a Windows Mobile 2003 application (Pocket PC) that works fine in
WM2003 but in Second Edition, the buttons do not show on the toolbar. This
happens with a real device (Dell X30) and in the WWE PPC 2003 SE - SDK
Emulator.

To try to find where the problem is, I created a VERY simple test
application and that shows the same problem.

I created a PPC Smart Device application, dropped on a menu and
created
just
a File menu with Exit on it.
I dropped on a TooBar and an ImageList.
I added two simple 16x16 Bitmap images to the ImageList. Bitmaps were
created with VS.Net
I set the ImageList for the Toolbar to this ImageList.
I add two buttons to the Toolbar and set their Image Indexes to 0 and 1.
The two buttons show up correctly next to the menu at design time.

When I run the program in the emulator, neither button appears on the
toolbar. I see a grey area next to the menu and if I click in the grey area
where the buttons should be, I see a while square where the buttons should
be.

Does anyone know what is wrong and how I can solve it?

John.
 
Hi,

somehow I managed to get it working. Starting from that accidental success,
I examined what is happening and why it didn't work before. So here is what
I found out:

1) The ImageIndex property must always be set after setting the ImageList of
the ToolBar. This is known and is in the NETCF FAQ.

2) Setting the same ImageList multiple times has NO effect. One can add the
line

toolBar.ImageList = toolBarImageList;

100 times in many places all over the code and it simply doesn't change
anything! I even experimented with

toolBar.ImageList = null;
toolBar.ImageList = toolBarImageList;

and it didn't change anything. One must ensure that the timing of setting
the ImageList property is done properly when it is set for the very first
time. There is no point in resetting that property with the same ImageList -
it is simply ignored.

BTW: This was the reason why the suggested problem solution didn't work for
me.

3) Da BUG: Adding the ToolBar Control to the Form or setting certain Form
properties will kick out any ImageList attached to the ToolBar!!! Add to
that observation number 2, and you see that there is no recovery after the
ImageList got kicked out. No matter how often one tries to reapply the same
ImageList you will never again see any ToolBar button (unless you waste
resources and create an all new ImageList every time you set the ImageList
property of the ToolBar)

By experimenting I found that changing the following Form properties kicks
out the ToolBar ImageList: MinimizeBox, ControlBox, and FormBorderStyle. I
didn't try all, so there may be more.

4) The real solution. Setting the ImageList property of the ToolBar should
be done only once, after adding the ToolBar to the form and after setting
the Form properties. It can be done at the end of the InitializeComponent
method (no need to put it into Form_Load). It is probably best to never
change the ImageList after it was set once and for all. The ImageIndex
property of the ToolBarButton must be set after setting the ImageList. This
can also be done at the very end of InitializeComponent. The ImageIndex can
also be changed whenever needed.


I hope that this helps...

--
Andreas Selle
http://subsembly.com/




Andreas Selle said:
Hi,

I have exactly the same problem as described. However, the suggested fix
does not work for me. I tried all thinkable orderings of ImageList and
ToolBar initialization in my InitializeComponent method, but none works. I
never see an Image on PPC 2003 SE, however it works flawlessly on PPC 2002
and PPC 2003.

Could you please post or mail (to a.selle_at_subsembly.com) your complete
working ToolBar and associated ImageList initialization.

Cheers,

Andreas Selle

John Atkins said:
Thank you very much Bob, that did indeed solved it.

John.

Bob Prochnow said:
This is a bug with .netCF on WM2003SE.

To get around it, try this -- you cannot assign the ImageList for the
Toolbar and ImageIndex for the Toolbar Buttons in VS - you must assign them
at run-time:

toolBar.ImageList = toolBarImageList;
toolBar.Buttons[0].ImageIndex = 0;
...

Note, you may also be able to get Icons working with a transparent
color
in
your toolbar if you create the ImageList at run-time (this means your .ico
files must be available at run-time, or you must have them as embedded
resources in your .exe).

I have a Windows Mobile 2003 application (Pocket PC) that works fine in
WM2003 but in Second Edition, the buttons do not show on the
toolbar.
This
happens with a real device (Dell X30) and in the WWE PPC 2003 SE - SDK
Emulator.

To try to find where the problem is, I created a VERY simple test
application and that shows the same problem.

I created a PPC Smart Device application, dropped on a menu and created
just
a File menu with Exit on it.
I dropped on a TooBar and an ImageList.
I added two simple 16x16 Bitmap images to the ImageList. Bitmaps were
created with VS.Net
I set the ImageList for the Toolbar to this ImageList.
I add two buttons to the Toolbar and set their Image Indexes to 0
and
 
I found this solution and posted here the last Thu, 24 Jun 2004 11:34:51
-0400.
Look for a post subject Re: Toolbar images invisible in WM2003SE

;)
 
This happens because of a bug in the native toolbar control. The bug was
introduced in Windows Mobile 2003 SE. What happens here is that when a
toolbar is removed from a form, the imagelist that was assigned to the
toolbar is deleted from the toolbar or destroyed. To workaround this
problem, you could try to add the toolbar to a form at the end of
constructor.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Date: Mon, 28 Jun 2004 14:45:43 -0400
| Subject: Re: Explained: Toolbar buttons and WM 2003SE
| References: <#[email protected]>
<[email protected]>
<[email protected]>
<u#[email protected]>
<[email protected]>
| From: Ctitanic <[email protected]>
| Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
| MIME-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Message-ID: <[email protected]>
| User-Agent: Opera M2/7.50 (Win32, build 3778)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 67.105.13.210.ptr.us.xo.net 67.105.13.210
| Lines: 1
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
..phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:56168
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I found this solution and posted here the last Thu, 24 Jun 2004 11:34:51
| -0400.
| Look for a post subject Re: Toolbar images invisible in WM2003SE
|
| ;)
|
|
| >
| > 4) The real solution. Setting the ImageList property of the ToolBar
| > should
| > be done only once, after adding the ToolBar to the form and after
setting
| > the Form properties. It can be done at the end of the
InitializeComponent
| > method (no need to put it into Form_Load). It is probably best to never
| > change the ImageList after it was set once and for all. The ImageIndex
| > property of the ToolBarButton must be set after setting the ImageList.
| > This
| > can also be done at the very end of InitializeComponent. The ImageIndex

| > can
| > also be changed whenever needed.
| >
| >
|
 
4) The real solution. Setting the ImageList property of the ToolBar should
be done only once, after adding the ToolBar to the form and after setting
the Form properties. It can be done at the end of the InitializeComponent
method (no need to put it into Form_Load). It is probably best to never
change the ImageList after it was set once and for all. The ImageIndex
property of the ToolBarButton must be set after setting the ImageList. This
can also be done at the very end of InitializeComponent. The ImageIndex can
also be changed whenever needed.


This all works great until one wants to "hide" the toolbar from view. The
only way I have ever been successful at hiding the toolbar was to set its
"Parent" to "Nothing" [i.e. Me.ToolBarMain.Parent = Nothing], then show it
by adding it back into the forms control set {i.e.
Me.Controls.Add(ToolBarMain)]. *BUT*, if you do this, then the toolbar
images are gone irreparably once again! Does anyone know another way to
"hide/show" the toolbar, or another work-around for this scenario?

Man I hate these types of bugs . . .
 
Hi.

In addtion to this thread I hope some of you can help me with the following problem. Trying to fix the same problem you have with invisible buttons on toolbar.

this.imageList1.Images.Add("loadede bitmap from embedded resources");
This line creates an error in system.windows.forms dll

thanks in advance
Peter
 
Rick - I have the same situation. We manipulate the toolbar at runtime. I was finally able to get icons to display in toolbar at initial load, but then they go away when we change the toolbar. This is a painful bug!



Rick said:
4) The real solution. Setting the ImageList property of the ToolBar should
be done only once, after adding the ToolBar to the form and after setting
the Form properties. It can be done at the end of the InitializeComponent
method (no need to put it into Form_Load). It is probably best to never
change the ImageList after it was set once and for all. The ImageIndex
property of the ToolBarButton must be set after setting the ImageList. This
can also be done at the very end of InitializeComponent. The ImageIndex can
also be changed whenever needed.


This all works great until one wants to "hide" the toolbar from view. The
only way I have ever been successful at hiding the toolbar was to set its
"Parent" to "Nothing" [i.e. Me.ToolBarMain.Parent = Nothing], then show it
by adding it back into the forms control set {i.e.
Me.Controls.Add(ToolBarMain)]. *BUT*, if you do this, then the toolbar
images are gone irreparably once again! Does anyone know another way to
"hide/show" the toolbar, or another work-around for this scenario?

Man I hate these types of bugs . . .
 
Hi,

it seems that the only possibility to change the toolbar appearance at
runtime is changing the ImageIndex of the ToolBarButtons. Anything else
simply kills the entire ImageList. :-(

Andreas
 
Try setting the ToolBar.ImageList property to null before removing the
toolbar from the form and then, when you add the toolbar back to the form,
set the ImageList to the original value.

Hope this helps.
Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Andreas Selle" <[email protected]>
| References: <#[email protected]>
<[email protected]>
<[email protected]>
<u#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Explained: Toolbar buttons and WM 2003SE
| Date: Thu, 8 Jul 2004 07:59:23 +0200
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: pD9EB6330.dip0.t-ipconnect.de 217.235.99.48
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXS01.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:56873
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| it seems that the only possibility to change the toolbar appearance at
| runtime is changing the ImageIndex of the ToolBarButtons. Anything else
| simply kills the entire ImageList. :-(
|
| Andreas
|
|
|
|
 
Back
Top