Results 1 to 29 of 29

Thread: Xp visual style on a vb.net application?

  1. #1

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    Xp visual style on a vb.net application?

    Hi,

    I have just been trying to get the XP Visual style in my application (like the buttons and stuff) But how can I do it?

    I did
    VB Code:
    1. Public Sub New()
    2.         MyBase.New()
    3.  
    4.         'This call is required by the Windows Form Designer.
    5.         InitializeComponent()
    6.         Application.EnableVisualStyles()
    7.  
    8.         'Add any initialization after the InitializeComponent() call
    9.  
    10.     End Sub

    And set the button I want on its property of FlatStyle = System but it doesn't work...

    Is there something that I have to do first or something should be?

    Thanks,

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    It should be working. Maybe you need to re-build the project.

  3. #3
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    So long as you are running your application from Windows XP with the styles enabled, then this should work. However, you will see no difference on Win98/NT/2000 machines. The EnableStyles option only works for XP (it basically creates the manifest file for you).

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this
    http://www.developer.com/net/asp/article.php/3101831

    though , I've tried it with no errors and no XP Visual style . It sucks . Meaning , if you have XP without all effects on then it won't work .
    Last edited by Pirate; Dec 9th, 2003 at 12:55 PM.

  5. #5

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    hi again

    i do have xp so thats not a problem, i am wanting the styles to view properly on windows xp based systems.

    pirate - i tryed that manifest file, but i could not find (anywhere) where the 'Add Resource' thing is...

    Can you help? thanks

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ok , click File---> Open ----->File ---> then look at the image below you'll find Add Resource item when you right click on the Icon item.
    Attached Images Attached Images  

  7. #7
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304

    The answer to your problem

    you will not believe this, it hasbeen posted here before:##this is what you need to do:

    create a module caled sub main and use the application.run to get the application started,

    the use doevents an example follows:

    Sub Main()
    Application.EnableVisualStyles()
    Application.DoEvents()
    Dim f1 As New Hub
    Application.Run(f1)
    Application.Exit()

  8. #8

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    thanks, ill try that!

    I didnt realise it asked to open the exe, i thoguht it meant the project!

    if the manifest file doesnt work, or i decide to use a different method, ill use yours. thanks richard

    cya

  9. #9

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    the manifest file worked, but I don't like the idea much that I have to keep adding it to my exe after it has been buit - with the ammount of compiles i do, ill have to keep doing that proceedure so many times, and I don't want to have to just do the manifest at the last build i do, because I am constantly updating it.
    But thanks, i think ill have to use it anyway.

    Richard, your method didnt work for me
    First of all, my main program runs through SubMain(), that is where almost all the code is. So adding this will just mess the app up.
    Second, Hub wasn't defined so I could'nt add the entire code.

    Any ideas? Don't worry if you don't, Ill stick with the manifest, even if it is a bit strenuous - and like Pirate said, it sucks.

    Thanks

  10. #10
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Manifest

    Hi.

    You can still use the manifest file, without adding it as a resource.
    Just put the manifest file in the same directory as the EXE file.

    Then you won't have to go through those annoying steps everytime you rebuild.

    This way, you can have visual styles while developing, without doing any work at all.

    When the project is completely finished, you can add it as a resource, and remove the file from the directory.

    You propably allready know this, but I'll put it in anyway:
    EnableVisualStyles() is for Ver. 2003 only...
    So if you have Ver. 2002 then it won't work.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  11. #11
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    By way of clarification, 'Hub' is simply the name of the first form I display and I simply cut and pasted exisitng working code as an example.

    The solution proposed is not my idea from memory it was DevGrp a consistent poster who pointed me in this direction.

    As an additional benefit Toolbar button images now display correctly.

    My solution is for VS2003 and for VS22002 you still need to use the manifest approach

    This is a regonised bug by Microsoft although they classify it as low prioirity.

    Yes I know we all thought we had left DoEvents behind in VB3, apparently it is still with us and I did note your comments about having a complex Startup module but you still have to run the application and show the first form.

  12. #12
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Will it...

    If I create a project on Windows 2000 and do what you have suggested above about calling the Windows XP styles, will someone running my app on a Windows XP machine be able to see my app with the XP styles? Will those running my app on other operating systems have any problems?

  13. #13
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    Yes you will, for a start you will have to if you use crystal reports instal a dll call DbgHelp.dll into windows system32, you wil lalso need to installt he correct version of the Jet Database engine and the correct level of DMAC,it real needs 2.7 or above

  14. #14
    Registered User
    Join Date
    Jul 2001
    Posts
    283

    manifest file not working

    are you saying that i just add this file to my /bin directory (named something.manifest) and then change the flatstyle property of all my controls to system? and i don't have to redo anything after i recompile?
    what do i have to put in for all the bold values (or anything else that needs to be changed?, considering that the version number changes every time i recompile?

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
    manifestVersion="1.0">
    <assemblyIdentity
    version="Insert Your Exact Version Number Here"
    processorArchitecture="X86"
    name="Name of Application"
    type="win32"
    />
    <description>Description of Application</description>
    <dependency>
    <dependentAssembly>
    <assemblyIdentity
    type="win32"
    name="Microsoft.Windows.Common-Controls"
    version="6.0.0.0"
    processorArchitecture="X86"
    publicKeyToken="6595b64144ccf1df"
    language="*"
    />
    </dependentAssembly>
    </dependency>
    </assembly>

  15. #15
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    from Karl E. Peterson....


  16. #16
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    You can still use the manifest file, without adding it as a resource.
    Just put the manifest file in the same directory as the EXE file.

    Then you won't have to go through those annoying steps everytime you rebuild.

    This way, you can have visual styles while developing, without doing any work at all.
    now reread my last post.

    the manifest file in you link requires the version number, which changes every time you compile!

  17. #17
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Anybody have tried this yet and got it to work ?
    http://msdn.microsoft.com/library/?u...hemeaddin_.asp

  18. #18
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    or this?



    http://msdn.microsoft.com/library/de...ndowsForms.asp

    [URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchUsingWindowsXPVisualStylesWithControlsOnWindowsForms.asp]

  19. #19
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    No need for af version.

    Hi.

    The version is not important.

    I use this file all the time, and the only thing I do is rename to MyExeName.exe.manifest.
    Attached Files Attached Files
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  20. #20
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    finally something that#s simple to implement and actually works. thanks pax.

  21. #21
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    except for progress bars have a really weird look.
    any ideas how to fix that?

  22. #22
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    I've posted this answer before:


    If you have VS2003, you do not need a manifest file.

    Simply ensure you start you application with a sub main

    in that module do as follows:


    as an example

    Module ProLet21 ' The name of My prjoect
    Sub Main()
    Application.EnableVisualStyles()
    Application.DoEvents()
    Dim f1 As New Hub ' The name of my first form
    Application.Run(f1)
    Application.Exit()
    End Sub
    End Module

    This solves problems with both progess bars and toolbars and is the way that MS have decided to implement OS independent form displays.

    The DoEvents is required as without the toolbars don't show icons and yes it is recognised as a bug that enablestyles does not work properly without the Doevents

    The above solution has been posted before by both myself and from memory DevGrp another contributor and it does work and hey presto no need for a manifest file and it works on Win98, Win200 and WinXP never tried it on Win95

  23. #23
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    i know you've posted that before, but I don't have vs2003, so the enable visual styles function dosn't do the trick. Using a manifest file, how do I fix the awkward display of the progress bar?

  24. #24
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    sory we are msdn subscribers so get all updates. Always hated using the manifest file, every time you thought you got it right something else tripped you up.
    No wonder MS make so much moeny from upgrades!

  25. #25
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    yeah, no worries. i wish i got free upgrades.
    anyways, i still need some suggestions on fixing this ugly progressbar...

  26. #26
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Progressbar

    Hi MarvinKlein.

    Sorry, I can't help you with the progressbar.

    I have no problem with the progressbars.
    See picture.
    Attached Images Attached Images  
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  27. #27
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252
    Hi RichardAtherton,

    If you place the following bolded lines under InitializeComponent(), then you do not need a module. One of my projects didn't like the startup object being the module.
    VB Code:
    1. Public Sub New()
    2.         MyBase.New()
    3.         'This call is required by the Windows Form Designer.
    4.         InitializeComponent()
    5.         [b]Application.EnableVisualStyles()[/b]
    6.         [b]Application.DoEvents()[/b]
    7.         'Add any initialization after the InitializeComponent() call
    8.     End Sub
    Cheers,
    McoreD

    Edit: Oh, now I see LITHIA has had the same problem as me. Unbelievable how he didn't get any method to work except for the manifest file method.

    Edit2: I rechecked just now. Having the above code in the Form and setting Start up object as Sub Main, still gives me XP Style.
    Last edited by ~*McoreD*~; Feb 21st, 2004 at 05:22 AM.

  28. #28
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    .enableVisualStyles() only works for vs 2003.

  29. #29
    New Member
    Join Date
    Jun 2004
    Posts
    2
    Does anyone know if the xp visual styles can be enabled for a UserControl? I'm working on a add-in for Outlook 2003 and I'd like the custom property page (on the Options tab) to have the same visual style as the other Outlook option tabs. I've tried both the Application.EnableVisualStyles and the manifest methods, neither seem to work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width