473,888 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Toolbar's, ImageLists, and Manifest Resources

I have encountered a problem (most certainly a .NET bug), that, for the
life of me, I cannot figure out how to work around.

Using Visual Studio 2003, with enabled XP Visual Styles.

There are two possible scenarios here, the first one works properly,
while the 2nd one doesn't.

Scenario 1
----------
* Application opens with a notifyicon instead of a form window.

* User double clicks the notifyicon to show the main form window

* The main form window properly displays the toolbar buttons with
their respective images from the assigned ImageList. The ImageList is
populated from calls to
Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream("n s.file.ext")
-----------

Scenario 2
----------
Everything is the same as in Scenario 1, except for the following:

* Application opens with a notifyicon, same as above.

* A Timer event triggers the opening of another form window, and the
user has *not* double clicked the notifyicon to open the "main" window.
* When double clicking the notifyicon and opening the main form window,
the buttons on the toolbar do not display their images. They are
blank. This is the problem.
-----------

Also, If there is a timer tick that triggers the secondary window AFTER
the user has already opened and closed the main window, and the user
procedes to open the main window again, everything still displays as it
should.

Other than forcing the main window to open (which I do not want to do),
I absolutely cannot find a workaround for this problem. I have been
trying absolutely everything that I can think of for hours to no avail.
Any insight would be appreciated.

Nov 16 '05 #1
5 3251
How are you starting the App with a NotifyIcon?
When are you loading the ImageList?
Are visual styles actually Enabled?

I just built a quick test project starting my app with an
ApplicationCont ext.
I fill the ImageList in the Forms load method.
I showed the form by DoubleClicking on the NotifyIcon and all was well.

I restarted the App and allowed a Timer to show the Form.
Visual Styles were not Enabled, but the Images showed up on the Toolbar
Buttons.

I then removed the EnableVisualSty les and DoEvents calls and added a
Manifest Resource to the project.
Visual Styles are now enabled and the Icons display just fine in the toolbar
whether the form is loaded by doubleClick or timer.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
<an***********@ gmail.com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
I have encountered a problem (most certainly a .NET bug), that, for the
life of me, I cannot figure out how to work around.

Using Visual Studio 2003, with enabled XP Visual Styles.

There are two possible scenarios here, the first one works properly,
while the 2nd one doesn't.

Scenario 1
----------
* Application opens with a notifyicon instead of a form window.

* User double clicks the notifyicon to show the main form window

* The main form window properly displays the toolbar buttons with
their respective images from the assigned ImageList. The ImageList is
populated from calls to
Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream("n s.file.ext")
-----------

Scenario 2
----------
Everything is the same as in Scenario 1, except for the following:

* Application opens with a notifyicon, same as above.

* A Timer event triggers the opening of another form window, and the
user has *not* double clicked the notifyicon to open the "main" window.
* When double clicking the notifyicon and opening the main form window,
the buttons on the toolbar do not display their images. They are
blank. This is the problem.
-----------

Also, If there is a timer tick that triggers the secondary window AFTER
the user has already opened and closed the main window, and the user
procedes to open the main window again, everything still displays as it
should.

Other than forcing the main window to open (which I do not want to do),
I absolutely cannot find a workaround for this problem. I have been
trying absolutely everything that I can think of for hours to no avail.
Any insight would be appreciated.

Nov 16 '05 #2
This is my main() method:

static void Main()
{
System.Windows. Forms.Applicati on.EnableVisual Styles();
System.Windows. Forms.Applicati on.DoEvents();
Loader load = new Loader();
System.Windows. Forms.Applicati on.Run();
}

Loader() then loads the notifyicon in its constructor and sets up its
click events and menu. The main form is also instantiated in the
Loader() constructor.

The ticker is a variable in the Loader() class, and is initialized on
declaration in the class header.

The main form loads the toolbar buttons from the manifest resource
stream in its OnLoad event. I have also tried arranging this to load
up the toolbar button images in the forms instantiation, but that does
not work, either.

Note that I have created a PictureBox and used the manifest resource
stream to grab one of the icons and display it in the picture box
successfully - in the same OnLoad() method, while it didn't display in
the toolbar button.

If I'm being unclear in anything, the full source code and application
can be obtained on source forge - http://sf.net/projects/ontime

Nov 16 '05 #3
Looks like Application.Ena bleVisualStyles is doing nothing when your app
loads a form via the timer, as can be seen by looking at the radio buttons
and checkboxes on your config form.

Remove the calls to EnableVisualSty les and DoEvents from your main() method.
Rebuild your app.
Open OnTime.Exe with Visual Studio.
Import a *.manifest file into the resource table (Resource Type =
RT_MANIFEST)
Change the Id from 101 to 1.

The downside to this method is that you must add the manifest resource every
time you rebuild the app, but visual styles will work and your Icons will
show in the toolbar.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
<an***********@ gmail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
This is my main() method:

static void Main()
{
System.Windows. Forms.Applicati on.EnableVisual Styles();
System.Windows. Forms.Applicati on.DoEvents();
Loader load = new Loader();
System.Windows. Forms.Applicati on.Run();
}

Loader() then loads the notifyicon in its constructor and sets up its
click events and menu. The main form is also instantiated in the
Loader() constructor.

The ticker is a variable in the Loader() class, and is initialized on
declaration in the class header.

The main form loads the toolbar buttons from the manifest resource
stream in its OnLoad event. I have also tried arranging this to load
up the toolbar button images in the forms instantiation, but that does
not work, either.

Note that I have created a PictureBox and used the manifest resource
stream to grab one of the icons and display it in the picture box
successfully - in the same OnLoad() method, while it didn't display in
the toolbar button.

If I'm being unclear in anything, the full source code and application
can be obtained on source forge - http://sf.net/projects/ontime

Nov 16 '05 #4
Mick,
That only happens when the timer event is the first thing to show a
form window. In my personal code, I overcame that by initializing
frmMain() in Loader's constructor, instead of when it was first being
shown. The EnableVisualSty les() also seems to be affected by this
whole weird form issue in this regard. I was able to work around that,
but I still haven't been able to work around the button images....

Nov 16 '05 #5
Adding a Manifest Resource only takes seconds and will fix it.

If you don't want to do that, then you'll have to make your ImageList a
global variable, instead of local to the form, and then assign the imagelist
to the toolbar in the load event.
In your Main() method you need to Initialize a new FrmMain, Initialize and
fill the imagelist, then show and hide/dispose the FrmMain.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
<an***********@ gmail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Mick,
That only happens when the timer event is the first thing to show a
form window. In my personal code, I overcame that by initializing
frmMain() in Loader's constructor, instead of when it was first being
shown. The EnableVisualSty les() also seems to be affected by this
whole weird form issue in this regard. I was able to work around that,
but I still haven't been able to work around the button images....

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1641
by: desa | last post by:
If I call EnableVisualStyles none the images in my ImageLists show up in my controls anymore. Is this a known issue? How do I fix this? I'm using VS.NET 2003.
3
3239
by: Jonathan Payne | last post by:
Hi, I am interested in adding a manifest file to the resources for a MFC application. When I create an AppWizard MFC app with a manifest file it adds the following lines to the .rc file: #ifdef _UNICODE IDR_MANIFEST RT_MANIFEST "res\\TestManifest4.manifest"
3
2588
by: Tom wilson | last post by:
Resources 'Beneficiary.aspx.resx' and 'OveraAge.aspx.resx' have the same manifest resource name 'Enroll.Beneficiary.resources'. Umm... what's this mean? The first two are aspx page resource files. I don't know what Enroll.Beneficiary.resources is, I don't have a page by that name. The entire project is called Enroll. What's VS talking about? Thanks!
2
1473
by: Jean-Francois Cantin | last post by:
I used a toolbar with an imagelist. When my devenv.exe file had an associated manifest file, disabled images in this toolbar was shown with grayscale colors. I'm trying to remove the manifest file ( I have some problems with Windows 98 ), but when I recreate the imagelist control, the toolbar doesn't show grayscale colors buttons anymore. How can I resolve it ? Thank's
3
2479
by: Al | last post by:
Hi All, I am trying to get a 24x24 "Windows XP" icon to display correctly on a button in my toolbar. My icon has 8 layers (16x16, 16x16, 24x24, 24x24, 32x32, 32x32, 48x48, 48x48) with each size having a 256 and windows xp colored image. When my application runs, the icon with 256 colors appears rather than the xp icon. I have tried using a manifest as well as Application.EnableVisualStyles. No luck. I have seen numerous articles...
9
1220
by: Bill English | last post by:
I have a problem with my toolbar images. I seem to have set them up correctly, because they show up perfectly in the designer, but when I run it the images do not appear. Here is a picture of the designer: http://68.34.190.119/images/VS%20Problem.bmp
9
1804
by: Hugh | last post by:
after I changed the image size. I tried different combinations of images sizes and button sizes. I have tried both botton and the image in the same sizes or button size was larger than that of image. The images were still invisible. What is the trick? I asked this question a while ago. Thanks.
1
1013
by: Mitchell Vincent | last post by:
I've had this problem for a week, and it's just now getting to where I can't work on a project because of it. Every single project I load up in VS.NET 2003 that has an imagelist in it gives me a compile error "'System.Reflection.TargetInvocationException' occurred in mscorlib.dl" on lines like "Me.imgAppointments.ImageStream = CType(resources.GetObject("imgAppointments.ImageStream"), System.Windows.Forms.ImageListStreamer)"
14
5925
by: _iycrd | last post by:
After several frustrating attempts to wrap a native DLL w a C++/CLI DLL, I finally got an assembly to compile, only to find a *runtime* error. The app comes up fine. Test dialog displays. Clicking on the button that creates the wrapper class causes an exception, not in the button's event handler, but in Application.Run() within Main(). The error: ! System.IO.FileNotFoundException was unhandled Message="The specified module could not...
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10777
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10882
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4243
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3251
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.