Results 1 to 40 of 98

Thread: [VB6] XP/Vista/Win7 Manifest Creator

Threaded View

  1. #1

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    [VB6] Manifest Creator for XP thru Win10

    RETIRED. No longer maintained. If still interested, look at its replacement here

    This project has a slight twist. See post #28 below for yet another easy option of inserting manifests into a resource file. And at this thread, Karim Wafi offers this code as a VB IDE add-in option, but as of this latest update, his project hasn't been updated to reflect latest changes herein.

    We know manifest files allow our forms to display with window themes. And we know there are 2 ways to make that happen.
    1) Including an external manifest file with our application
    2) Inserting that manifest file into a resource of our application

    Another plus to adding themes is that you can easily include alpha-blended icons to your buttons. See this post for an example

    This app allows both options above.

    But for option #2 above, it does not use rc.exe, no batch files, and is a bit customizable. And this is the best part.... This can be done before your exe is compiled so that the manifest is compiled with your exe. You don't have to go back later to insert the manifest using rc.exe & other techniques. How easy is that? And it can be undone too!
    Edited: Note, either manifest technique can cause crashes when compiled exe closes & it contained VB usercontrols. To rememdy this problem, the Sub Main created by the Manifest Creator now contains a LoadLibrary/FreeLibrary call. See the Change History below for a link that has information pertaining to this problem.

    Some quick notes.
    :: The attached project will create a manifest file and create a res file if needed. It can also overwrite an existing manifest file and insert into an existing res file. It can also delete embedded manifests from any VB resource file.
    :: See post #2 below for step-by-step procedure for embedding manifest files

    FAQ: "So, I want my app to be themed and don't want to include external manifest file(s) and I don't use a resource file. Does that mean I have to create a resource file just to embed the manifest file into my compiled application?"
    Answer: YES
    FAQ: "I copied sub main to the clipboard and pasted it into a module. I also changed my project to start with Sub Main vs. my main form. When I run the project, my main form does not show, the project simply starts & closes. Why?"
    Answer: You forgot to show your main form before exiting Sub Main.
    FAQ: "How do you get VB6 IDE to run using themed controls?
    Answer: Use a manifest file. See post #54 on page 2 for details

    You can see the differences below between unthemed controls & vista/xp themes
    Name:  manifestcreator.jpg
Views: 20931
Size:  50.8 KB

    P.S. Remember that including theme capability requires you to initialize the common controls before your app starts. This means adding a Sub Main to your project and having the project start with Sub Main. If you don't do this, your compiled app will not load & run if it contains a manifest file or embedded manifest.

    Comment update: The above comment regarding Sub Main no longer applies for modern O/S. This is because simply including a manifest has Windows initialize the common controls. Adding Sub Main for this purpose is safe regardless. However, whether or not to use the LoadLibrary tweak mentioned earlier is still a choice that should be considered.

    Edit History
    20 Dec 14
    :: Added Win10 compatibility & Win8.1+ Per-Monitor DPI Awareness items
    17 Nov 14
    :: Added few more sections, all are for systems > XP
    - O/S-app compatibility
    - autoElevate, disableTheming
    - printerDriverIsolation, disableWindowFiltering
    - highResolutionScrollingAware, ultraHighResolutionScrollingAware
    30 Dec 11
    :: Added options to include 2 new sections in the manifest (above screenshot not updated)
    - DPI-aware for Vista+
    - GDI+ v1.1 dependency. See post #53, page 2, for more info & a warning
    2 Oct 10
    :: Bonehead typo on my part. Declared function FreeLibraryA. There is no FreeLibraryA. Should be just FreeLibrary.
    2 Oct 10
    :: Added LoadLibrary/FreeLibrary calls to Sub Main code to help prevent crashes when themed & usercontrols exist in project. See this thread for some more info
    15 Jun 10
    :: Fixed version info read from a vbp file. See post 14 & 15 below
    :: Added more options/information for "Sub Main" when used
    10 Mar 10
    :: Added ability to delete manifest(s) from resource files
    :: Added ability to load key fields from vbp files
    :: Added ability to modify app version within the manifest (oversight on my part)
    :: Added ability to view external manifests
    :: Added ability to preview manifest

    Here is a complete, working example of a Sub Main procedure should you just want to copy & paste it to an existing project.
    Change Form1 in the sample code to your main form's name
    Code:
    Private Declare Function LoadLibraryA Lib "kernel32.dll" (ByVal lpLibFileName As String) As Long
    Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
    Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As InitCommonControlsExStruct) As Boolean
    Private Declare Sub InitCommonControls Lib "comctl32.dll"()
    Private Type InitCommonControlsExStruct
        lngSize As Long
        lngICC As Long
    End Type
    
    Private Sub Main()
        Dim iccex As InitCommonControlsExStruct, hMod As Long
        ' constant descriptions: http://msdn.microsoft.com/en-us/library/bb775507%28VS.85%29.aspx
        Const ICC_ANIMATE_CLASS As Long = &H80&
        Const ICC_BAR_CLASSES As Long = &H4&
        Const ICC_COOL_CLASSES As Long = &H400&
        Const ICC_DATE_CLASSES As Long = &H100&
        Const ICC_HOTKEY_CLASS As Long = &H40&
        Const ICC_INTERNET_CLASSES As Long = &H800&
        Const ICC_LINK_CLASS As Long = &H8000&
        Const ICC_LISTVIEW_CLASSES As Long = &H1&
        Const ICC_NATIVEFNTCTL_CLASS As Long = &H2000&
        Const ICC_PAGESCROLLER_CLASS As Long = &H1000&
        Const ICC_PROGRESS_CLASS As Long = &H20&
        Const ICC_TAB_CLASSES As Long = &H8&
        Const ICC_TREEVIEW_CLASSES As Long = &H2&
        Const ICC_UPDOWN_CLASS As Long = &H10&
        Const ICC_USEREX_CLASSES As Long = &H200&
        Const ICC_STANDARD_CLASSES As Long = &H4000&
        Const ICC_WIN95_CLASSES As Long = &HFF&
        Const ICC_ALL_CLASSES As Long = &HFDFF& ' combination of all values above
    
        With iccex
           .lngSize = LenB(iccex)
           .lngICC = ICC_STANDARD_CLASSES ' vb intrinsic controls (buttons, textbox, etc)
           ' if using Common Controls; add appropriate ICC_ constants for type of control you are using
           ' example if using CommonControls v5.0 Progress bar:
           ' .lngICC = ICC_STANDARD_CLASSES Or ICC_PROGRESS_CLASS
        End With
        On Error Resume Next ' error? InitCommonControlsEx requires IEv3 or above
        hMod = LoadLibraryA("shell32.dll") ' patch to prevent XP crashes when VB usercontrols present
        InitCommonControlsEx iccex
        If Err Then 
            InitCommonControls ' try Win9x version
            Err.Clear
        End If
        On Error GoTo 0
        '... show your main form next (i.e., Form1.Show)
        Form1.Show
        If hMod Then FreeLibrary hMod
    
    
    '** Tip 1: Avoid using VB Frames when applying XP/Vista themes
    '          In place of VB Frames, use pictureboxes instead.
    '          'bug' may no longer apply to Win7+
    '** Tip 2: Avoid using Graphical Style property of buttons, checkboxes and option buttons
    '          Doing so will prevent them from being themed.
    End Sub
    The zip file includes a resource file with just the manifest embedded into it. Unzip the project and compile it, then run it. It should be themed and run just fine.
    Attached Files Attached Files
    Last edited by LaVolpe; May 10th, 2020 at 10:40 AM. Reason: added new manifest sections
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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