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
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
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.
:: Not fully tested yet in all scenarios. Not tested on Win7. Could use some feedback from those of you with access to that system.
-- Update: MrSmith, post #11 below, mentioned it worked with Win7
:: 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?"
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 & themed controls
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.
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
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.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 Public 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. '** Tip 2: Avoid using Graphical Style property of buttons, checkboxes and option buttons ' Doing so will prevent them from being themed. End Sub