• 0

C# and XP Themes


Question

20 answers to this question

Recommended Posts

  • 0

For text boxes and buttons and some other controls you need to change the FlatStyle property, lol waiti forgot what the property name is... but yeah

and inside the constructor after the initialize component call, you add

Application.EnableVisualStyles();

however, there has been random issues in the past with this method call, causing conflicts with third party controls etc, so it might be better to just include a .manifest file.

Link to comment
Share on other sites

  • 0

if you are using .net 1.1 then set the flat style property to system.

then add Application.EnableVisualStyles(); before you call Application.Run();

this is basically what Winston said, but i thought that I should clarify a bit.

STV

Link to comment
Share on other sites

  • 0

Right at the very top ;)

#Region " Windows Form Designer generated code "

	Public Sub New()
 ?MyBase.New()
 ?Application.EnableVisualStyles()
 ?Application.DoEvents()
 ?'This call is required by the Windows Form Designer.
 ?InitializeComponent()

 ?'Add any initialization after the InitializeComponent() call

	End Sub

edit: This isn't "application.run", but I guess this was what u're looking for... or am I wrong??

Link to comment
Share on other sites

  • 0
Hmmmm funny fix, btw out of curiosity where exactly is the call for Application.Run(); inside a normal VB form? :s

584794234[/snapback]

This is all you have to have. Make sure you set the FlatStyle property of your controls (like buttons, checkboxes, etc.) to System instead of Standard on your form.

[STAThread]
static void Main() 
{
	Application.EnableVisualStyles();
	Application.DoEvents();
	Application.Run(new frmMain());
}

Link to comment
Share on other sites

  • 0
Right at the very top ;)

#Region " Windows Form Designer generated code "

	Public Sub New()
 ?MyBase.New()
 ?Application.EnableVisualStyles()
 ?Application.DoEvents()
 ?'This call is required by the Windows Form Designer.
 ?InitializeComponent()

 ?'Add any initialization after the InitializeComponent() call

	End Sub

edit: This isn't "application.run", but I guess this was what u're looking for... or am I wrong??

584794259[/snapback]

not what i was looking for, i wanted to see where the Application.run call was made inside the form.

Link to comment
Share on other sites

  • 0
not what i was looking for, i wanted to see where the Application.run call was made inside the form.

584795032[/snapback]

Look at my post 2 posts above this one.

Link to comment
Share on other sites

  • 0
Look at my post 2 posts above this one.

584795065[/snapback]

lol look at my original question, thanks anyways, your one is in c#, i'm just asking a question about vb

Link to comment
Share on other sites

  • 0
Hmmmm funny fix, btw out of curiosity where exactly is the call for Application.Run(); inside a normal VB form? :s

584794234[/snapback]

Set your startup object to Sub Main, and create your own Main. Inside there, add the call to Application.Run (Y)

Link to comment
Share on other sites

  • 0
Set your startup object to Sub Main, and create your own Main. Inside there, add the call to Application.Run (Y)

584795220[/snapback]

lol arggh that still doesn't answer my question, i know how to do that, but where is the Application.Run call when the startup object is set to a form.

Link to comment
Share on other sites

  • 0

It doesn't exist, it's created by the VB compiler and ends up somewhere in the IL. Or in other words, I don't know and I don't think you can access it with VB code :p

Link to comment
Share on other sites

  • 0
lol arggh that still doesn't answer my question, i know how to do that, but where is the Application.Run call when the startup object is set to a form.

584795565[/snapback]

It isn't defined by default, but you can add it manually. Just add this to your startup form.

   <STAThread()> _
    Public Shared Sub Main()
        Dim myForm As New Form1
        Application.EnableVisualStyles()
        Application.DoEvents()
        Application.Run(myForm)
    End Sub

Link to comment
Share on other sites

  • 0
It isn't defined by default, but you can add it manually. Just add this to your startup form.

? ?<STAThread()> _
 ? ?Public Shared Sub Main()
 ? ? ? ?Dim myForm As New Form1
 ? ? ? ?Application.EnableVisualStyles()
 ? ? ? ?Application.DoEvents()
 ? ? ? ?Application.Run(myForm)
 ? ?End Sub

584795892[/snapback]

mmmm but since Application.Run is mysteriously invoked apparently, then wouldnt this second call, cause you to make another form?

One more thing, what's &lt:sTAThread()> for? :s does it do anything, i never understand what items inclosed in relational signs i.e. <,> mean, aren't they the way to comment code so that you can generate XML Documentation?

Link to comment
Share on other sites

  • 0
mmmm but since Application.Run is mysteriously invoked apparently, then wouldnt this second call, cause you to make another form?

One more thing, what's <STAThread()> for? :s does it do anything, i never understand what items inclosed in relational signs i.e. <,> mean, aren't they the way to comment code so that you can generate XML Documentation?

584796067[/snapback]

No, I just tested adding my own sub main to a VB.NET Windows application. It worked fine and did the visual styles correctly.

STAThread is an attribute that tells whomever asks that the app is compatible with single threaded apartments. It's a COM thing. You could probably safely remove the attribute. You use attributes to allow more robust queries through reflection. I could query this assembly for it's attributes and find that it is STAThread safe. Attributes are metadata for both the compiler and for anyone that needs to know things about a given assembly. It's quite handy. My company uses attributes for an object repository framework.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.