473,378 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Button Images Not Showing When Using XP Style Forms

Good Afternoon:
I was hoping if someone could share some light on a problem that I'm facing.
When I create a Visual Basic.Net program and I use the XP style for my Window
Forms and buttons; if I add images to my menu buttons they don't show when
the form is created. But, if I don't use the XP style the images show on my
buttons correctly. Can someone please explain to me what the problem is and
how to get around it? Here is how I'm calling my forms:
Public Sub Main()

Dim frmSplash As New fclsSplash
Dim mainForm As New fclsMain

System.Windows.Forms.Application.EnableVisualStyle s()
System.Windows.Forms.Application.Run(frmSplash)

Select Case vfClass.fdisplay
Case 0
System.Windows.Forms.Application.Run(SqlLogin)
Case 1
System.Windows.Forms.Application.Run(mainForm)
End Select

It's my mainForm that holds the menu buttons with the images. Do anyone
know what's going on? Thanks.
--
TC
Jul 21 '05 #1
9 3474
It's my mainForm that holds the menu buttons with the images. Do anyone
know what's going on?


Just like the documentation says, when you set the button's FlatStyle
property to System the Image isn't displayed.


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
What type of button is a MenuButton?

If it's a toolbar button then you need to add Application.DoEvents after
Application.EnableVisualStyles, or supply a manifest file instead of calling
Application.EnableVisualStyles.

If it's a standard Button, then System Buttons do not show an Image. I
modified the Button class to get around this and you will find the source
for this button on my site. Note that when set to Flatsyle.System the button
still wont show an Image, but Visual Styles will be applied to
Flatstyle.Standard buttons.
http://dotnetrix.co.uk/buttons.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Terrance" <Te******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Good Afternoon:
I was hoping if someone could share some light on a problem that I'm
facing.
When I create a Visual Basic.Net program and I use the XP style for my
Window
Forms and buttons; if I add images to my menu buttons they don't show when
the form is created. But, if I don't use the XP style the images show on
my
buttons correctly. Can someone please explain to me what the problem is
and
how to get around it? Here is how I'm calling my forms:
Public Sub Main()

Dim frmSplash As New fclsSplash
Dim mainForm As New fclsMain

System.Windows.Forms.Application.EnableVisualStyle s()
System.Windows.Forms.Application.Run(frmSplash)

Select Case vfClass.fdisplay
Case 0
System.Windows.Forms.Application.Run(SqlLogin)
Case 1
System.Windows.Forms.Application.Run(mainForm)
End Select

It's my mainForm that holds the menu buttons with the images. Do anyone
know what's going on? Thanks.
--
TC

Jul 21 '05 #3
Mick,

I have the same problem in VB.net. I can see the image in the design window
on the toolbar button. But, when I build and run the application the image
doesn't show up. I don't know where the Application.EnableVisualStyles
statement is.

Can you help?
Thanks.

Dave Green
dc*****@dcgreen.com

"Mick Doherty" wrote:
What type of button is a MenuButton?

If it's a toolbar button then you need to add Application.DoEvents after
Application.EnableVisualStyles, or supply a manifest file instead of calling
Application.EnableVisualStyles.

If it's a standard Button, then System Buttons do not show an Image. I
modified the Button class to get around this and you will find the source
for this button on my site. Note that when set to Flatsyle.System the button
still wont show an Image, but Visual Styles will be applied to
Flatstyle.Standard buttons.
http://dotnetrix.co.uk/buttons.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Terrance" <Te******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Good Afternoon:
I was hoping if someone could share some light on a problem that I'm
facing.
When I create a Visual Basic.Net program and I use the XP style for my
Window
Forms and buttons; if I add images to my menu buttons they don't show when
the form is created. But, if I don't use the XP style the images show on
my
buttons correctly. Can someone please explain to me what the problem is
and
how to get around it? Here is how I'm calling my forms:
Public Sub Main()

Dim frmSplash As New fclsSplash
Dim mainForm As New fclsMain

System.Windows.Forms.Application.EnableVisualStyle s()
System.Windows.Forms.Application.Run(frmSplash)

Select Case vfClass.fdisplay
Case 0
System.Windows.Forms.Application.Run(SqlLogin)
Case 1
System.Windows.Forms.Application.Run(mainForm)
End Select

It's my mainForm that holds the menu buttons with the images. Do anyone
know what's going on? Thanks.
--
TC


Jul 21 '05 #4
I'm sorry I no longer have the reference to an article on MSDN a few weeks ago that states there is a bug using image buttons in
VS.NET due to the serialization order of code.

The fix, if I remember correctly, was to go into the hidden area of code that the designer serializes and move any code that adjusts
the buttons bounds or location to appear before the image property is set.

The problem with this "quick fix" is that designer changes may revert back to the error-producing code. At this time I don't
believe there is a fix for the latest version of NET. Maybe 2005 will have fixed that issue.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Dave Green" <Dave Gr***@discussions.microsoft.com> wrote in message news:A6**********************************@microsof t.com...
Mick,

I have the same problem in VB.net. I can see the image in the design window
on the toolbar button. But, when I build and run the application the image
doesn't show up. I don't know where the Application.EnableVisualStyles
statement is.

Can you help?
Thanks.

Dave Green
dc*****@dcgreen.com

"Mick Doherty" wrote:
What type of button is a MenuButton?

If it's a toolbar button then you need to add Application.DoEvents after
Application.EnableVisualStyles, or supply a manifest file instead of calling
Application.EnableVisualStyles.

If it's a standard Button, then System Buttons do not show an Image. I
modified the Button class to get around this and you will find the source
for this button on my site. Note that when set to Flatsyle.System the button
still wont show an Image, but Visual Styles will be applied to
Flatstyle.Standard buttons.
http://dotnetrix.co.uk/buttons.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Terrance" <Te******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
> Good Afternoon:
> I was hoping if someone could share some light on a problem that I'm
> facing.
> When I create a Visual Basic.Net program and I use the XP style for my
> Window
> Forms and buttons; if I add images to my menu buttons they don't show when
> the form is created. But, if I don't use the XP style the images show on
> my
> buttons correctly. Can someone please explain to me what the problem is
> and
> how to get around it? Here is how I'm calling my forms:
> Public Sub Main()
>
> Dim frmSplash As New fclsSplash
> Dim mainForm As New fclsMain
>
> System.Windows.Forms.Application.EnableVisualStyle s()
> System.Windows.Forms.Application.Run(frmSplash)
>
> Select Case vfClass.fdisplay
> Case 0
> System.Windows.Forms.Application.Run(SqlLogin)
> Case 1
> System.Windows.Forms.Application.Run(mainForm)
> End Select
>
> It's my mainForm that holds the menu buttons with the images. Do anyone
> know what's going on? Thanks.
> --
> TC


Jul 21 '05 #5
Assuming your startup form is called Form1 add the following code to the
form.

Shared Sub main()
Application.EnableVisualStyles
Application.DoEvents
Application.Run(New Form1)
End Sub

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Dave Green" <Dave Gr***@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Mick,

I have the same problem in VB.net. I can see the image in the design
window
on the toolbar button. But, when I build and run the application the image
doesn't show up. I don't know where the Application.EnableVisualStyles
statement is.

Can you help?
Thanks.

Dave Green
dc*****@dcgreen.com

"Mick Doherty" wrote:
What type of button is a MenuButton?

If it's a toolbar button then you need to add Application.DoEvents after
Application.EnableVisualStyles, or supply a manifest file instead of
calling
Application.EnableVisualStyles.

If it's a standard Button, then System Buttons do not show an Image. I
modified the Button class to get around this and you will find the source
for this button on my site. Note that when set to Flatsyle.System the
button
still wont show an Image, but Visual Styles will be applied to
Flatstyle.Standard buttons.
http://dotnetrix.co.uk/buttons.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Terrance" <Te******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
> Good Afternoon:
> I was hoping if someone could share some light on a problem that I'm
> facing.
> When I create a Visual Basic.Net program and I use the XP style for my
> Window
> Forms and buttons; if I add images to my menu buttons they don't show
> when
> the form is created. But, if I don't use the XP style the images show
> on
> my
> buttons correctly. Can someone please explain to me what the problem is
> and
> how to get around it? Here is how I'm calling my forms:
> Public Sub Main()
>
> Dim frmSplash As New fclsSplash
> Dim mainForm As New fclsMain
>
> System.Windows.Forms.Application.EnableVisualStyle s()
> System.Windows.Forms.Application.Run(frmSplash)
>
> Select Case vfClass.fdisplay
> Case 0
> System.Windows.Forms.Application.Run(SqlLogin)
> Case 1
> System.Windows.Forms.Application.Run(mainForm)
> End Select
>
> It's my mainForm that holds the menu buttons with the images. Do anyone
> know what's going on? Thanks.
> --
> TC


Jul 21 '05 #6
Thanks Mick. Unfortunately, this form is not the startup form. I'm not sure
if that is why it doesn't work. Should that make a difference?
Dave

"Mick Doherty" wrote:
Assuming your startup form is called Form1 add the following code to the
form.

Shared Sub main()
Application.EnableVisualStyles
Application.DoEvents
Application.Run(New Form1)
End Sub

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Dave Green" <Dave Gr***@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Mick,

I have the same problem in VB.net. I can see the image in the design
window
on the toolbar button. But, when I build and run the application the image
doesn't show up. I don't know where the Application.EnableVisualStyles
statement is.

Can you help?
Thanks.

Dave Green
dc*****@dcgreen.com

"Mick Doherty" wrote:
What type of button is a MenuButton?

If it's a toolbar button then you need to add Application.DoEvents after
Application.EnableVisualStyles, or supply a manifest file instead of
calling
Application.EnableVisualStyles.

If it's a standard Button, then System Buttons do not show an Image. I
modified the Button class to get around this and you will find the source
for this button on my site. Note that when set to Flatsyle.System the
button
still wont show an Image, but Visual Styles will be applied to
Flatstyle.Standard buttons.
http://dotnetrix.co.uk/buttons.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Terrance" <Te******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
> Good Afternoon:
> I was hoping if someone could share some light on a problem that I'm
> facing.
> When I create a Visual Basic.Net program and I use the XP style for my
> Window
> Forms and buttons; if I add images to my menu buttons they don't show
> when
> the form is created. But, if I don't use the XP style the images show
> on
> my
> buttons correctly. Can someone please explain to me what the problem is
> and
> how to get around it? Here is how I'm calling my forms:
> Public Sub Main()
>
> Dim frmSplash As New fclsSplash
> Dim mainForm As New fclsMain
>
> System.Windows.Forms.Application.EnableVisualStyle s()
> System.Windows.Forms.Application.Run(frmSplash)
>
> Select Case vfClass.fdisplay
> Case 0
> System.Windows.Forms.Application.Run(SqlLogin)
> Case 1
> System.Windows.Forms.Application.Run(mainForm)
> End Select
>
> It's my mainForm that holds the menu buttons with the images. Do anyone
> know what's going on? Thanks.
> --
> TC


Jul 21 '05 #7
Actually, I'm not entirely sure what the cause of your problem is, I
answered a bit too quickly earlier.
Since you didn't know where EnableVisualStyles was called I should assume
that this is not a WinXP issue.

I've seen several variations of this problem and the most difficult to sort
out, was in an app that started without a GUI, but displayed a dialog box
with a toolbar at specified events. I've never seen this issue on a non
Visual Styles Enabled app, but that does not mean it doesn't happen.

Can you recreate the problem in a small project, or give the steps required
to reproduce it?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"dave green" <dave gr***@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
Thanks Mick. Unfortunately, this form is not the startup form. I'm not
sure
if that is why it doesn't work. Should that make a difference?
Dave

Jul 21 '05 #8
Did you attempt to try the fix I posted previously on this thread?

Locate the designer-serialized code in your code-behind. It will probably be in a #region block named, "Windows Form Designer
generated code".

In the region, find the method named, "InitializeComponent".

In the method there will be a declartion for your control. Find the area of the method that sets the properties on your control
(The appropriate section should be marked with a comment).

Cut and Paste the line of code that sets the image of the button as the last line of the section.

See if that does it.

Like I said, the article states that this is a bug. No sense driving yourself crazy over this if you can identify the problem as a
bug early on.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Mick Doherty" <EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
Actually, I'm not entirely sure what the cause of your problem is, I answered a bit too quickly earlier.
Since you didn't know where EnableVisualStyles was called I should assume that this is not a WinXP issue.

I've seen several variations of this problem and the most difficult to sort out, was in an app that started without a GUI, but
displayed a dialog box with a toolbar at specified events. I've never seen this issue on a non Visual Styles Enabled app, but that
does not mean it doesn't happen.

Can you recreate the problem in a small project, or give the steps required to reproduce it?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"dave green" <dave gr***@discussions.microsoft.com> wrote in message news:88**********************************@microsof t.com...
Thanks Mick. Unfortunately, this form is not the startup form. I'm not sure
if that is why it doesn't work. Should that make a difference?
Dave


Jul 21 '05 #9
If that is the problem, then the code could be cut from the
InitializeComponent() method and pasted to Sub New() after the
InitializeComponent() call. That way the designer is not going to mess with
it every time you rebuild the project.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
Did you attempt to try the fix I posted previously on this thread?

Locate the designer-serialized code in your code-behind. It will probably
be in a #region block named, "Windows Form Designer generated code".

In the region, find the method named, "InitializeComponent".

In the method there will be a declartion for your control. Find the area
of the method that sets the properties on your control (The appropriate
section should be marked with a comment).

Cut and Paste the line of code that sets the image of the button as the
last line of the section.

See if that does it.

Like I said, the article states that this is a bug. No sense driving
yourself crazy over this if you can identify the problem as a bug early
on.

--
Dave Sexton
dave@www..jwaonline..com

Jul 21 '05 #10

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

Similar topics

6
by: Marek Mänd | last post by:
Can the <button><img></button> mutated via CSS so, that the inner image of <BUTTON> would entirely visually become the button itsself - I mean without the outer elements borders and so... ...
10
by: IkBenHet | last post by:
Hello, I am creating a toolbar for an richtext editor. I already managed to make the images act as buttons (hovering,...) But now I want to be able to keep a button selected (down) when clicking...
6
by: meltedown | last post by:
Oh ye Gods of Style, I have been having fun making buttons with CSS: <div class='cssnav2'> <a href='#' onClick="document.location.href='/catalog/index.php?brand=94'"> <img...
5
by: martinjeffreys | last post by:
Anyone know of a good source of additional pictures for buttons in Access? Ta Martin --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com)....
9
by: Terrance | last post by:
Good Afternoon: I was hoping if someone could share some light on a problem that I'm facing. When I create a Visual Basic.Net program and I use the XP style for my Window Forms and buttons; if I...
2
by: dominic.martin | last post by:
Hi, I'm no javascript programmer but I found a really good piece of javascript at http://www.isdntek.com/tagbot/zipzoom.htm that magnifies areas of an image. It's just what I want but their...
1
by: Phil_Cam | last post by:
Hello All On a webpage I have a standard paypal image button for purchases. I am trying to set it up so that it only shows up or is endabled when text is entered into a textbox and a button is...
7
by: arupfrancis | last post by:
Hi, I am trying to create a colored box using background images. I am able to do it easily using tables but doing it in divs is proving to be an issue. Moreover IE and Mozilla also seems to be...
1
by: Peted | last post by:
im using radio button array with button appearence. Im just wondering if there is a easy way programtically to enhance the button look with such things a gradient color fills and effects and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.