# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  [VB6] Manifest Creator II

## LaVolpe

This is the second version of this application. The previous version will no longer be maintained.

If you landed here looking for information on SxS (side-by-side) manifests, recommend jumping to here as a start.

The project simply creates application-manifests that can be written to disk, clipboard, or VB resource files. The project includes a default/dummy manifest with all known options, as of this date. You would select whichever manifest options you want to include and modify those option values as needed. If you wish to view or replace an existing manifest file, you can import it into the project via the clipboard, disk, or VB resource file. The tool will attempt to parse VB vbp project files and create a new manifest, filling in the Identity element from that file.

The major reasons for revision are several 
- Previous version was create only. This version can also edit existing manifests.
- Use Microsoft XML in the background to create and modify the XML
- Use XML stylesheets to help transform the manifest based on export options
- More intuitive design and more modular to assist with future updates by you or me
- Will no longer ignore hand-jammed manifests within VB resource files, i.e., #24 custom entries
- Offers ability to update unrecognized (future) manifest entries imported from elsewhere

The manifest is designed to make use of XML qualified names, internally, and is the default mode. However, when exporting the manifest, you can opt to convert to traditional name spaces if you choose.

Caveat: Not 100% of the manifest options available have been fully tested. Some options can't be tested by me because I don't have the system(s) to perform the desired tests. However, all the options should be technically correct and in accordance with the Microsoft schema for application manifests.

Comments, bug reports, and suggested enhancements are always welcomed.





```
Update History
9 Apr 17: Realigned questionable elements to their correct namespace 
10 Apr 17: Fixed error noted in post #4 below
13 Apr 17: Fixed new-found error & added minor enhancement. See post #9 below
15 Apr 17: Optional update. See post #11 below
26 Apr 17: Added support to allow editing Assembly Manifests. See post #12 below
29 Apr 17: Optional update. See post #13
16 May 17: Padding bytes of Chr(0) prevented Win10 from applying manifest. See post #14 below
20 Jul 17: A few minor changes plus a couple minor enhancements. See post #21 below
24 Oct 17: Handles UTF8 BOM in imported manifests to prevent MSXML2 from rejecting manifest
25 Oct 17: Found bug when toggling TrustInfo name space. See post #41
2 Sep 19: Added forceFocusBasedMouseWheel option
7 Dec 19: Added activeCodePage & heapType options
          options having comma-delimited values can now have those values in specified order
          fixed 2 options that were defaulted to the wrong namespace
```

----------


## LaVolpe

*Compilation Errors*
Should you see an error like the following once your app is compiled...



> 


... There are two possible reasons for it:
1. Your embedded manifest file size is not a multiple of 4 bytes. This is a bug with VB6 that SP6 fixed. If you don't have SP6 applied, do so. That fixes a lot more than the problem just mentioned. This tool now ensures it writes dword-aligned manifests to resource files anyway. 
2. The manifest syntax/values may not be valid. You will need to view your Windows events log (from the control panel), look at the application log and find your application and the error shown above. In that error you'll see what line number and reason within the manifest (XML) that is causing the problem. 

Here is an example of such a windows event error. The "version" value in that line of the manifest is a 4-part format, i.e., 1.0.0.0, not the 2-part format used: 1.0



> Activation context generation failed for "C:\Program Files\...\CopyDatabaseWizard.exe". Error in manifest or policy file "C:\Program Files\...\CopyDatabaseWizard.exe" on line 8. The value "1.0" of attribute "version" in element "assemblyIdentity" is invalid.


*Note*: Adding a manifest with the Common Controls option allows your form's standard controls to be skinned using the current O/S theme. When adding this element, also start your project with the Sub Main located in a bas module, that routine is used to initialize the common controls. Do know that v5 of the common controls in your toolbox is skinnable, v6 in the toolbox is not. *Tip*: The Help menu can copy a typical Sub Main to the clipboard for pasting into that bas module. *Tip*: This option allows you to add alpha blended icons to buttons if desired. See post #10 below for an example.
Updated: On modern O/S, starting with Sub Main no longer seems to be required if using an embedded manifest. The manifest entry prompts the O/S to call the needed functions. However, on older O/S, there is a bug when using compiled OCXs created in VB that can cause a crash when the compiled application is closed. If that is happening, recommend using Sub Main. Even if not technically needed, does no harm. See this thread where that problem was discovered, jump to post #12 in that thread.

*Tip*: When exporting manifest to a RES file, the file does not need to exist. The tool will create the new RES file and then insert the manifest. However, don't export to a RES file belonging to a project that is currently open, write access will likely be denied. In this case, simply remove the res file from your open project, update it with this tool, then re-add the res file.

*Note*: Many options prevent modifying their values. This is simply because only one value is permitted and it is hard-coded. *Tip*: To show any attributes hidden in the tree view, edit values that are locked, or manually provide a value not in a displayed list of values, hold the shift key down while activating the context menu. Regardless, you cannot enter a blank value if the element/attribute has been flagged as its value cannot be blank.

*Tip*: Attributes cannot be selected/unselected. How to prevent optional ones from being exported? Set their value to empty/blank. In the "Output" window/form, choose option to not export empty attributes. Optional attributes have the context menu item "Erase". Several can have their values manually entered as a null string. Empty attributes that are exported will have a null value, i.e., <assemblyIdentity ... publicKeyToken=""/>. Optional is not always optional. For example, the publicKeyToken attribute is not optional if it applies. You, of course, are responsible for providing correct values for any item that can be manually entered.

*Note*: The Identity item cannot be unselected. It is the only required manifest XML element.

*Tip*: When displaying the Qualified Name context menu item, the base name and NameSpace submenus are FYI only. Since the treeview is designed to be human-friendly for the most part, the actual manifest element name and namespace are not necessarily displayed as they would be if reading the raw XML, if displayed at all. Those submenus give you that info.

*Tip*: VB is mostly DPI-aware. Adding the DPIAware option to your manifest will prevent your forms being stretched in higher DPI settings your users may be running your app in. However, VB6 is only mostly aware, and there are details that must be addressed. There is a tutorial of sorts on things to consider; here are a few:
- Use TrueType/OpenType fonts everywhere. First step: Assign the form a TrueType font as that is the font that is inherited by most controls added to the form afterwards, negating the need to individually set the font for most controls 
- Image controls should have its Stretch property set to True else manually scale as needed
- PictureBox controls should NOT have its AutoSize property set to True else manually scale as needed
- Metafiles are DPI-aware. All other image types are not & may need to be scaled by you
- Controls without Top/Left, Width/Height properties (i.e., Line controls, etc) can fail to position/size correctly unless its form is saved in ScaleMode other than pixels. Always leave the form in twips ScaleMode and only change its ScaleMode at run-time if desired, i.e., in Form_Load
- Always test your app in highest DPI setting available when using the DPIAware option. Minimally, test at 175% DPI. If you are going to see issues, it will be there since internally, VB is not running at the same exact DPI.

*Note*: For those of you that are familiar with SetProcessDPIAware & SetProcessDPIAwareness APIs, Win10 can prevent their usage with the dpiAwareness and dpiAware elements. May only apply if your app, no embedded manifest, calls those APIs and an external manifest is applied to prevent the API usage. In other words, manifest trumps API calls.

*Gotchas*: When manifesting VB projects back in the day (XP), frames treated many child controls badly when rendering. That has been fixed for the most part... Except frames within frames. Try it and you should see the problem with the inner frame's caption. The workaround is similar to those old days: place the inner frame in a picturebox & that picturebox in the outer frame. Resize picturebox, change backcolor as needed, and make it borderless. See post #58 for an option to do this at runtime vs. fixing complex projects in the IDE.

*IDE Gotchas*: If you manifest your IDE for theming, you will likely lose the popup palette to select property colors during design-time. The palette is simply erased, but still there. To fix the problem, I have an add-in that can be used. See that thread

----------


## LaVolpe

Pretty much external manifests are history. These manifests are external files with the same name as your application and appending a .manifest extension. The reason why they are becoming history is that any embedded manifest will take priority unless certain registry keys are changed.

To embed a manifest in VB6 project, you can use a tool like the one here or you can create an external manifest and add it to your resource file, in the CUSTOM section. Once added, double click on it and change the Type Field to: #24 and change the Id Field to: 1. Tip: Those can be manually extracted by opening the RES file in NotePad.

If you want your VB6.exe to use an external manifest, unless you plan on using some 3rd party software to embed one into the exe (and hope it doesn't corrupt it), some annoyances are expected. Simply adding an external manifest along side of VB6.exe doesn't guarantee it will be used. You may very well need to change a registry setting to make it happen. After you are sure your manifest is being recognized, you will likely want to go and restore the setting:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide
Value: PreferExternalManifest
Data: 1 = prefer, 0 = don't preferAfter making the change and manifest still appears to not take effect, reboot. It is getting harder and harder to use external manifests within Windows -- and that's probably not a bad thing.

In post #56, page 2, an example of using mt.exe is shown for editing your VB6.exe to insert a manifest.

Here is another way of manifesting the IDE without permanently modifying the VB6.exe file.
1. Create an external manifest. Make it perfect, exactly how you need it
2. Copy the manifest into your VB6.exe folder and name it VB6themed.exe.manifest
3. Now copy your VB6.exe and rename the copy: VB6themed.exe
Now run the new VB6themed.exe. The idea is that since the executable hasn't yet run, it should pick up the manifest the first time.

If that worked, and you later need to change the manifest, you still may have to jump through hoops. You could always repeat the above 3 steps using a different name. If playing with DPI awareness, you may want to create a couple different versions, where maybe one is system DPI aware, one is per-monitor DPI aware, etc.

----------


## pekko

```
1. Start program
2. Select "Application" => "Description"
3. Context menu => "Qualified Name" => "Base Name: description"

Run-time error '9':
Subscript out of range
```

----------


## Elroy

Say LaVolpe,

I'm not entirely sure when it was all fixed, but resources are correctly unpacked with the correct byte size (not rounded to 4-byte multiples) so long as they're smaller than 65520 bytes (which most .manifest files would certainly be smaller).  Once you go over 65520 bytes, they do start getting rounded up to the nearest 4-byte boundary.

Best Regards,
Elroy

EDIT1:  Also, great work on the above.

----------


## LaVolpe

Elroy... Correct. After testing it, it doesn't matter if the manifest manually inserted into the RES file is word-aligned or not. I know that when my code inserts the manifest, it must ensure the entry is word-aligned

Edited: removed some comments, regarding another project, where I may have been misinformed. No clarification will be provided

----------


## Elroy

Interesting about the alignment if you're doing it through code.  I suppose though, since you're also creating the manifest through code, it's easy enough to align/pad it.

(Removed my related comments as well.) Peace, to all.  :Smilie:  

All The Best,
Elroy

----------


## Shaggy Hiker

I have removed a few posts from this thread, including one of my own. It was taking the thread off topic, though it raised some points I feel are worth pursuing. I'll attempt to pursue them by other means.

----------


## LaVolpe

Uploaded modified project. The modifications include a bug fix and a minor enhancement:

Bug: Adding a new <file> element from the Miscellaneous menu could result in a duplicate key error. Fixed

Enhancement: Holding shift key down while activating the context menu (right click) unlocks any locked item and/or attributes
-- Any item with 'hidden' attributes displays a new menu item: Show Attributes
-- Any item where the Value or Text menu item is disabled, will be enabled
-- Any item where a new value must be selected from a finite list will have "New Value..." appended to the list, allowing manual entries

Some code changes, but a noticeable one should you already have modified the project is that the various cManifestEntryEx class methods that accepts an optional attribute index parameter did accept -1 meaning the method applies to the element vs. an attribute. That has been removed, -1 is no longer a valid index. The MenuActions_Timer event modified due to that change.

----------


## LaVolpe

Just a FYI item. Another benefit of adding manifests is the ability to add nice alpha-blended icons to your buttons. This method will NOT work if controls are not themed.

Updated: This method does not work for XP. It is possible to get an image on the button using this technique, but the button will lose its theme and you cannot get both button+text. Potential workaround is using BCM_SETIMAGELIST, something for you to research.


The button icon assignment in the screenshot above was accomplished...

1) Load your alpha-blended icon/bitmap via your favorite method. You will need to destroy the icon/bitmap at some point

2) Here is a generic routine. If button is not themed, then your result is either image or text, not both.


```
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function GetGdiObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long
Private Declare Function RedrawWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal lprcUpdate As Long, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long

Private Enum ButtonTextImageAlignment
    BS_NO_CHANGE = -1
    BS_DEFAULT = 0
    BS_LEFT = &H100&
    BS_RIGHT = &H200&
    BS_CENTER = &H300&
    BS_TOP = &H400&
    BS_BOTTOM = &H800&
    [_BS_MASKALIGN] = BS_CENTER Or BS_TOP Or BS_BOTTOM
End Enum

Private Function SetButtonImage(ByVal buttonHwnd As Long, ByVal imageHandle As Long, _
                                Optional ByVal Align As ButtonTextImageAlignment = BS_NO_CHANGE, _
                                Optional ByVal ShowCaption As Boolean = False) As Long
                                
    ' Return value is the previous image handle, if any.
    ' You are responsible for disposing of that handle if it was not from a .Picture property
                                
    ' pass zero for imageHandle to remove an existing image, else pass bitmap/icon handle only
                                
    ' how alignment works
    '   Horizontal alignment
    '       Unless BS_LEFT or BS_RIGHT is passed, alignment is centered
    '   Vertical alignment
    '       Unless BS_TOP or BS_BOTTOM is passed, alignment is centered
    '   If image is being shown, it is positioned first and text positioned afterwards
    '       when BS_BOTTOM then Image on bottom, then text on top of image
    '       when BS_LEFT or BS_CENTER then Image on Left, then text right of image

    Const BS_BITMAP As Long = &H80&
    Const BS_ICON As Long = &H40&
    Const GWL_STYLE As Long = -16&
    Const BM_SETIMAGE As Long = &HF7&
    Const IMAGE_ICON As Long = 1
    Dim dwStyle As Long, dwNewStyle As Long, imageType As Long

    If Align <> BS_NO_CHANGE Then
        dwStyle = Align And [_BS_MASKALIGN]
        If dwStyle <> Align Then Align = BS_NO_CHANGE
    End If
    
    dwStyle = GetWindowLong(buttonHwnd, GWL_STYLE)
    dwNewStyle = dwStyle And Not (BS_BITMAP Or BS_ICON)
    If Align <> BS_NO_CHANGE Then dwNewStyle = (dwNewStyle And Not [_BS_MASKALIGN]) Or Align
    
    If imageHandle <> 0 Then
        If GetGdiObject(imageHandle, 0&, ByVal 0&) < 24 Then
            imageType = IMAGE_ICON
            If ShowCaption = False Then dwNewStyle = dwNewStyle Or BS_ICON
        Else
            If ShowCaption = False Then dwNewStyle = dwNewStyle Or BS_BITMAP
        End If
    End If
    
    If dwNewStyle <> dwStyle Then SetWindowLong buttonHwnd, GWL_STYLE, dwNewStyle
    SetButtonImage = SendMessage(buttonHwnd, BM_SETIMAGE, imageType, ByVal imageHandle)
    RedrawWindow buttonHwnd, 0, 0, 1    ' optional if project is themed
    
End Function
```

4) Finally, as needed, destroy your icon/bitmap during form_unload, as needed


```
DestroyIcon hIcon ' or if bitmap
DeleteObject hBitmap
```

How did I use a 48x48 icon? Easy way: use your favorite icon editor/parser and single it out to its own file. 

If you are asking how to load an icon, suggest starting with LoadImage API

----------


## LaVolpe

Project uploaded to address undesirable effects when running in 200% DPI. This is an optional update since most will never be running this application in 200% DPI. Since I talk about manifesting for DPI-awareness and how VB is mostly DPI-aware, least I should do is make sure the app works well in high DPI.

Should you want to download the changes, here's what changed

- Form size is no longer fixed. At 200% DPI, the form was taller than the screen. So form is resizable, but to prevent resizing the width (which is not what I want), I subclassed the form. Subclassing is optional when in IDE via a message box confirming you will allow it. There is a specific line that can be rem'd out to prevent the message box from displaying (see modWork.SetSizeRestrictions). It will never display once the application is compiled. 

- The TreeView control would not scale properly in 200% DPI. Added tweak in Form_Resize event to address that.

- Since form can now be resized vertically, needed to add code to resize the treeview and reposition the textbox

By the way, app looks fine at 200% DPI  :Wink:

----------


## LaVolpe

Added moderate support for Assembly Manifests also. This required including nearly 10 new elements, along with ability to merge elements common between both Assembly & Application manifests.  This project does not auto-generate assembly manifests; however, you can now edit existing ones or create them from scratch. The Miscellaneous menu has been modified to allow insertion of any Assembly-Manifest related elements.

Other minor changes include defaulting to exclude prefixed element names during exporting of manifests. Can be toggled in the Output window. The "File" menu now has an option to select secondary manifests to be merged with the currently loaded manifest. Since many elements can only exist once in a manifest, any subsequently loaded manifest elements will not overwrite existing elements. For those elements that can exist multiple times, they will be appended. Recommend if using this option, always load the primary/base manifest first, then append other manifests if you want to import their special/custom elements.

----------


## LaVolpe

Updates applied, no need to update your previous version if these options are not desired:

1. Added support for optional assembly-manifest windowClass element.
2. Updated a few more help tips for assembly-manifest related elements
3. All manifest elements can be deleted that were appended via the menu: Manifest|Append/Merge Manifest
4. Any elements that offer a list of possible values now offer those values in a separate submenu
5. Added new form to make selection of comma-delimited element values easier vs. relying on the standard vb InputBox() function. See screenshot below. When the "New Value" menu item is clicked, it generates the displayed form with its multi-select listbox. This additional fluff currently applies only to 2 elements: 
- windowsSettings/2016/dpiAwareness 
- assembly/file/comClass/miscXXX attributes.

----------


## LaVolpe

Self-identified a bug. At least with Win10, using null char Chr(0) as padding to word-align manifest before writing to a resource file prevented the manifest from being applied. The fix was simple enough, use a space as padding instead. Patch uploaded in post #1.

Edited: An example of the Windows Event log showed this:



> Activation context generation failed for "C:\Users\LaVolpe\Desktop\..\some.exe". Error in manifest or policy file "C:\Users\LaVolpe\Desktop\..\some.exe" on line 29. *Invalid Xml syntax*.


There was no invalid XML syntax. Everything I have that could open/validate the XML proved that. So out of curiosity, thinking maybe Windows was interpreting null character as end of XML within the res file and bouncing that byte position relative to dWord alignment, determined invalid XML, not necessarily invalid format (generic error probably). The required padding changed to spaces, no modifications to the XML & Windows had no problems.

Edited: Though the above solution appears to work, not satisfied. I'll look at it again and see if the null characters are indeed the problem, which I find hard to believe. This is just a matter of better understanding the res file format more than anything else. There is very little documentation on how the typical 'data' portions of the resource file should look like for sections other than bitmaps, icons, cursors, and string tables.

Edited yet again. It is possible, depending on whether SP6 is installed and/or the size of the embedded manifest, VB will change the size of the resource. When changed, it will included padded null bytes which can generate that error. As of Oct 2017, the tool will now ensure the manifest is padded with spaces, as needed, to prevent any chance of VB padding with null characters. Just a sanity check. This logic applies only when writing to resource files.

----------


## CreativeDreamer

Forgive me if I'm asking a basic question, but can the manifest file be created on an XP Pro computer and then used with a compiled version of the chosen program on a Win10 computer? Or do you have to make the manifest file and compile the chosen program on the same computer that you want it to run on?  Sorry for asking what seems a basic question, but Ive always wondered about manifests, so now it's time for me to stay playing around with them.
BTW I love your slogan: Insomnia is just a byproduct of, "It can't be done" I tested out the Insomnia part with a late 3pm to 3am programming session, and found "It can be done" with a "bit of triple blended Coffee and dark chocolate".


Thanks for the info LaVolpe and  dilettante. Just editing this post,so as not to clog up this page with extra threads.

I still use XP Pro, Win8 as well as Win10 so I will experiment with manifests on these machines. 

In the past I had upload some source code to Planet VB and found that people had problems seeing the program in action, due to the different Operating Systems around. The main problem was that objects *turned Black*, so I tend to stick with original standard textboxes, shapes, labels and listboxes that came with VB6 Pro to avoid these problems. So I had to weight up whether to have a nice interface or have may program showing correct graphics. I tend to make little maths programs, as I am a teacher so my students need simple GUI's that show up correctly on the various OS's they use. I want to experiment with *"Quizzer"* (a Lan tester on this codebank site by  dilettante) so I need to make sure that all students see the same test on their various computers.

Many thanks for the extra information on manifests. I've always been curious about them, but had not experimented due to the many operating systems around. I had an idea, that one could create say 5 different manifests, and let the program automatically choose the manifest that is specific to the operating system run on that computer. Sort of like, the program runs and identifies Xp Pro as being used and then decides to use the XP Pro manifest, ignoring all other manifests.

----------


## LaVolpe

> ... and found "It can be done" with a "bit of triple blended Coffee and dark chocolate".


You know how that slogan came to be then.  When I was far younger, I'd program into the wee hours of the morning, more times than I can remember, trying to find a workaround for something that others said VB can't do. At my age now, doing so typically results in some form of regret -- physically, not mentally.

Regarding your question... Supposedly, the O/S will only look at the manifest parts relative to the O/S version. If newer O/S version items exist, they should be ignored completely. It won't matter which operating system you compile your app on since the manifest should be embedded into your resource file. That resource data doesn't change during compilation. 

Above being said, I wouldn't suggest adding newer O/S options to the manifest if you haven't tested it, unless you are doing so to pass off to a friend to do the testing for you.  Declaring your app Vista (or newer) compatible while only having access to XP would be a guess at best -- always test your app after applying a manifest, for at least two reasons: 

1) Make sure the manifest isn't preventing loading your app (results if manifest syntactically incorrect) . The manifest can prevent loading the app for other reasons, for example, requiring an assembly that does not exist. Example: GDI+ v1.1 is assembly included in the manifest and app runs on XP. GDI+ v1.1 typically not installed on XP; therefore, error & app fails to load.

2) make sure the manifest options you chose are not causing some unexpected results, i.e., making your app DPI aware and user loads your app in 175% DPI.

----------


## dilettante

You can also get burned by requesting an alternate assembly that doesn't exist on a downlevel machine.  For example GDI+ 1.1 requires Vista or later, or MSXML 4 on XP.

Of course those are both dead OSs now, but there are other less commonly used DLLs with SxS alternatives as well.

----------


## LaVolpe

> You can also get burned by requesting an alternate assembly that doesn't exist on a downlevel machine.  For example GDI+ 1.1 requires Vista or later, or MSXML 4 on XP.


Thanx for the reminder. In the past, I've always warned about that with XP-destined apps. Kinda let that slip a bit since XP is no longer supported by Microsoft. But, since people still use XP ... an apt reminder. I'll need to include that in this app's help strings on next update. Updated my comments in my previous post should they be viewed by others.

Edited: Possible workarounds in such cases...

1. Build different deployment versions of your app where each are targeted for a specific range of O/S and manifest adjusted for the O/S

2. With the GDI+ v1.1 example and other like-scenarios... Build your app with the GDI+ v1.1 option in the embedded manifest. Deploy the app along with another external manifest file _excluding_ the GDI+ v1.1 requirement. If the targeted O/S is XP, place that external manifest alongside your app. If Vista or better, don't include the external manifest. XP, by default, uses external manifests and Vista or better, by default, use embedded manifests over external ones. However, I don't recall which O/S actually stopped recognizing external manifests, without registry edits, even when an embedded manifest does not exist.

3. Use external manifests only. But this can be be problematic, because on newer O/S, they are ignored by default. And making them apply requires registry edits and other annoyances. Those registry edits apply to the entire system, not just your app. This should always be a user-choice, not an app deployment choice.

----------


## dilettante

Vista switched to giving embedded manifests priority.  It was meant to help stave off malware infestations based on an external manifest that substituted a hacked DLL for a system DLL used by a victim application.  Manifests can do DLL redirection for standard DLLs (overriding DLL Search) separately from the SxS Assembly and reg-free COM features.

----------


## C++Novice

I downloaded and used this today and despite not being too sure what I was at, it worked! 
It's really spruced things up.
Thanks very much for providing this, LaVolpe!

----------


## LaVolpe

Made several changes, none really major. And added a couple of enhancements.

*Changes*: 

- Made final choice on which name space the <trustInfo> element will be assigned to: urn:schemas-microsoft-com:asm.v3. Even though I can find Microsoft sites that use asm.v2 and others that use asm.v3, I have reviewed several Vista Windows exes and those I've reviewed all use asm.v3. Vista was the first O/S to use <trustInfo>. However, the Miscellaneous menu in the app allows you to override and toggle name space version if the need ever arises. Do note that it is possible that both versions will be displayed in the app's treeview if you are loading a manifest that uses asm.v2. In that case, unselect whichever you do not want, before exporting/saving the manifest.

Edited: I'll look at tweaking the above scenario a bit. Auto-unselecting one of them if both exist in the tree. Regardless, if the menu option to toggle the name space version is used, the 1st <trustInfo> item, if two are present, is toggled.

- Reworked the extraction and insertion routines. Major change was to allow you to select a specific manifest type: 1) standard, 2) isolation, 3) isolation without static imports or 4) first manifest found. This was needed for one of the enhancements mentioned later

*Enhancements*:

- Offered option to specify which manifest type (see above) should be used when saving manifest to a res file. This option is offered in the output window. Previously, one would need to go into the VB resource editor and change that value as needed.

- Offered option to extract manifests from executables (exes). This could be useful if you want to review the manifest within your own executables or within others. Though it is possible manifests can exist in ocx and dll files, the open dialog window only offers exes in its filter. If desired, simply change the file name field in the dialog, i.e., *.dll or *.ocx, for example.

- The main form's Manifest menu was changed up a bit. It does offer a way to specify which manifest type (see above) to be extracted from executables or resource files.

- When viewing the name space, via right click, of element attributes, typically you'd see: {none specified}. That has changed. No manifest attributes currently have their own name spaces. If in the future they do, it will be displayed in that pop-up menu. If  any don't, then the parent's name space is displayed instead with a "[Parent]" suffix. Just prevents you having to select the parent element to see the name space.

- The output window has an option to export the entire manifest to a preview window. And the preview window was tweaked a bit to force smaller tab stops. Looks better.

----------


## anderci

Thank you very much for this forum's content and all that went it.

I guess I am a VB6 has been and a reg-free novice.  Has anyone, as yet, put together some instructions to guide a novice through the use of Manifest Creator II?

I have succeeded in creating the .res file and building one of my tiny apps and putting it in the install folder with 'dependency' manifest files and putting the dependency files in a Dependency sub folder and it WORKS!

I guess to do it all of the way, I must incorporate all of the 'dependency' manifest files into the .res file before building.

Would that make it complete: with the app.exe in the install folder and the dependency files in its Dependency sub folder?

Am I getting the drift? ...  I guess that maybe I am: I did succeed in building my tiny test app with embedded manifest files.  I did need to add to the assemblyIdentity the value:  processorArchitecture="x86"  for each of the dependency manifest files.

If I can remember how to repeat those steps, I can do the embedded reg-free build for Win7 and Win10.

However I believe there is something else wrong with my manifest files for MSCOMCT2.OCX, threed32.ocx and RICHTX32.OCX .

Can Manifest Creator II  create manifest files for the individual dependency files?

----------


## Elroy

Hi anderci,

My primary application is entirely registration free (aka, portable).  It's also all distributed as a single executable, although quite large (189 meg at latest compile).  I've got several OCX files, a handful of ActiveX DLL files, a great many Word and Excel templates, a blank Access Database, the SMPlayer movie player program, and a C3D viewer program all bundled into the application's resources.  I just "unpack" those things when I need them.

Before I go on, let me say that my program always runs in somewhat unique environments (i.e., hospital settings).  As such, there's no possibility of any theme-ing.  Also, I insist on 100% DPI (although this drives dilettante nuts).  (But the new Win10 virtualization solves this problem.)  Therefore, I don't use my internal manifest file for anything other than Side-by-Side (SxS) running of my OCX files.  (I use another approach to run my ActiveX DLLs without needing to register them.)

LaVolpe may correct me, but I don't believe his manifest creator is for explicitly setting up the SxS running of OCX files.  I don't have to mess with this very often (as my OCX files don't change very often), but I always use a combination of MT.exe and RegSvr42.exe to dig the information out of OCX files for placing in my manifest.  There are several threads around these forums that discuss this.

And I also feel a bit like I'm hijacking LaVolpe's thread by discussing it here.

If you want a variety of opinions about SxS operations (with OCX files), maybe you'd let me recommend starting a new thread over in the main "Visual Basic 6" Q&A section.

Good Luck,
Elroy

----------


## LaVolpe

Elroy, correct. This project does not automate building SxS manifests. It is designed for automating application manifests. Though one could use this project to create a SxS manifest but that would be difficult because one would need to fill out all the XML attribute values manually, knowing which ones to add to the manifest. This project was not designed for automating SxS manifests and don't ever expect it will be. The closest it comes is its ability to load an existing SxS manifest, edit it, and export it.

I think there should be a FAQ page or Tutorial on ways to create SxS manifests correctly and completely. That FAQ/Tutorial could include custom tools others have designed and/or usage of existing APIs and/or Windows apps.

----------


## anderci

Thank you both for responding.  So, I should use RegSvr42.exe to build the .OCX manifest files and then use Manifest Creator II to package them all as well as the dependency (.ocx, .dll, ...) files into my VB6 build .exe ?

----------


## LaVolpe

SxS manifests can be quite complex. Application manifests basically have elements that are entered once, though there are some that can have multiple entries. With SxS there can be several that have multiple entries and do not apply to application manifests. I wouldn't recommend using this project for creating a SxS manifest from scratch. It could be used that way if the user is very comfortable with all the XML elements that are needed and how each should be filled out. This project has very minimal support for SxS manifests -- basically useful for quickie edits of existing SxS manifests.

I started a thread in the classic VB section of the forum asking if anyone was willing to take on a SxS manifest tutorial. But even if someone jumps on it right away, it will take time to create.

Regarding any other questions about SxS manifests, suggest you start a thread in that classic VB section. You won't get the help you need in this thread. And honestly, I'd appreciate this thread not be used for that purpose.

----------


## anderci

In Manifest Creator, after using Create from Project File (vbp), I tried:
The Manifest > Append/Merge Manifest > From File and got the following messages:

No Action Taken
Failed to load the selected file. 
Invalid at the top level of the document.
		[ OK ]

No Action Taken
Failed to extract any manifest from the selected file
		[ OK ]
What usually causes this rejection?

----------


## LaVolpe

> No Action Taken
> Failed to load the selected file. 
> Invalid at the top level of the document.


That error is typically a result of the XML not being syntactically correct in the 1st couple lines. Would have to post your XML to know for sure. That error is passed by the Microsoft XML parser, not due to my code.




> No Action Taken
> Failed to extract any manifest from the selected file


Now this error is my code triggered by the previous error.

Edited: If a UTF8 BOM is present at the first 3 bytes of the XML, the above error occurs. The Microsoft XML library used doesn't appear to like BOMs. The tool has been modified to look for a BOM if parsing failed, remove it, then resubmit the adjusted XML. Therefore, a BOM will no longer be the source of such an error.

----------


## anderci

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentity
    processorArchitecture="x86" type="win32"
    name="ThreeD32.ocx"
    version="1.0.0.0" />

<file name="Dependencies\ThreeD32.ocx">

    <comClass
        description="Threed Frame Control"
        clsid="{0BA686AF-F7D3-101A-993E-0000C0EF6F5E}" />

    <comClass
        description="Threed Checkbox Control"
        clsid="{0BA686AA-F7D3-101A-993E-0000C0EF6F5E}" />

    <comClass
        description="Threed Option Button Control"
        clsid="{0BA686AF-F7D3-101A-993E-0000C0EF6F5E}" />

    <comClass
        description="Threed Checkbox Property Page"
        clsid="{0BA686AA-F7D3-101A-993E-0000C0EF6F5E}" />

    <comClass
        description="Threed Group Push Button Control"
        clsid="{0BA686AF-F7D3-101A-993E-0000C0EF6F5E}" />

    <typelib tlbid="{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}"
        version="win32"
        helpdir="" />

</file>   

</assembly>

----------


## LaVolpe

If you run the project, copy and paste what you posted above into the Manifest Creator II, using menus: The Manifest > From Clipboard.

My gut feeling is that, as a file, there may be a BOM or some other marker on the manifest? That's just a guess. I've seen the Microsoft XML parser fail for reasons I don't understand, like a leading carriage return at top of file, for example. But when I pasted your XML into the project -- no problems. Sorry don't have an answer why it failed when you tried to upload it from file.

Edited: See post #28 comments.

----------


## VbNetMatrix

Hi Lavolpe, 

thanks for this great contribution...

I was wondering

1.  How do you make a .res from a .manifest ?  (just the big lines)
2. in Output option Windows, you got a typo:
>>Manifest Type for Resoruce Files Only

ressource I guess...

3. why is indent not recommended for .res file ?
if it's mandated (not too) why not simply uncheck it if user select .res as output ?


thanks

----------


## anderci

Yes, 'From clipboard' works smoothly. 
OK, it is very critical that your VB6 project is open during all of your steps in Manifest Creator:
The Manifest
 - Create from Project File (vbp)
 - Append/Merge Manifest
 - Export Manifest

I fell astray and was using Manifest Creator with the VB6 project closed. And then, an adventure... (details upon request)

----------


## LaVolpe

> 1.  How do you make a .res from a .manifest ?  (just the big lines)


A res file is a specifically formatted file. Knowing the format is required. If no res file exists, a 32 byte header is created and the manifest is then inserted. The manifest also uses a specific 32 byte header, followed by the XML data. Its placement in the res file doesn't matter as long as it comes after the initial 32 byte header.




> 2. in Output option Windows, you got a typo:
> >>Manifest Type for Resoruce Files Only


Yepper, should be Resource




> 3. why is indent not recommended for .res file ?
> if it's mandated (not too) why not simply uncheck it if user select .res as output ?


Not recommend due to extra bytes added to res file that doesn't need to be there. Extra bytes are added to exe when compiled. That's only reason. As for auto-checking/unchecking. Don't want to go there. If user unselects res as output, should I re-check the box? What if user doesn't realize/see the auto-checking/unchecking? Those questions are rhetorical only.

----------


## VbNetMatrix

> A res file is a specifically formatted file...


My bad I think I didn't explain my thought properly... I meant "how" ?
are you using an API or did you coded yourself the subroutine to export in .res ?
although I loved the information you provided, thanks




> Extra bytes are added to exe when compiled That's only reason.


got that now, thanks, but would it really slow down the reading since it's only a few bytes ?!




> As for auto-checking/unchecking. Don't want to go there. If user unselects res as output, should I re-check the box?


you're right... you got the proper way.  didn't thought of it that way




> Those questions are rhetorical only.


not sure what you meant... did I offended you ?  I apologize if I did, I'm only trying to understand more.

thanks for all your help, much apreciated.

----------


## LaVolpe

No offense taken in any of your replies. Rhetorical simply means no reply is necessary.

Regarding the writing/reading of the res file. It is like most other "chunk" related files. Each "chunk" describes how many bytes, read/write the chunk header then read/write the chunk data. Chunks can contain wildly different data from other chunks in the file. Each chunk has documentation on how it should be written/read. That is why I said "knowing the format is required". 

The res file can be written/read with standard VB functions or APIs. Nothing special there other than preference to write/read in binary mode. The code I wrote myself, no APIs used other than ReadFile/WriteFile. The Microsoft executable rc.exe can create resource files. You have to provide a script for that tool and the scripting language is not too complex but can take some time to become proficient with it. I felt the res file format was easy enough to be able to read/write without use of an additional tool.




> got that now, thanks, but would it really slow down the reading since it's only a few bytes ?!


Regarding indentation of the manifest... I'm old-school: don't bloat the application if not needed and if the extra stuff adds nothing to the project.

----------


## VbNetMatrix

Hi Lavolpe, 

thanks for all the provided information, very instructive.  As yourself, I like to program myself export function in binary output.
well.. you already saw that in my failed attempt to change VB6 main font source code.




> Regarding indentation of the manifest... I'm old-school: don't bloat the application if not needed and if the extra stuff adds nothing to the project.


I feel you man.  I used to count every bytes of everything, compress my .html and .js files, etc, etc...
in database, I even used a way to "compress" date in 3 bytes without losing the first 2 digit of the year.
I don't feel that same urge today because of how fast computer have became and how annoying hard drive size are.

you're a real inspiration to me Lavolpe.  Keep up the good work, hope you got some time someday to finish some of your long awaited project (AIC version 3)   :Smilie:

----------


## LittleTyke

Previously I have used MMM (Make My Manifest). I've just come across Manifest Creator II for the first time, have downloaded it, and am now looking at the main form (running). With MC I've found how to open a .vbp file, but from then on I'm stuck. How do I get the references to the OCX files in my VB6 program into MC? Let's just take one example from the manifest I built with MMM, RICHTX32.OCX. How do I make this dependency known to MC?

----------


## LaVolpe

> How do I get the references to the OCX files in my VB6 program into MC? Let's just take one example from the manifest I built with MMM, RICHTX32.OCX. How do I make this dependency known to MC?


This project can automate application manifests. You are describing a SxS/deployment manifest. This project does not automate those as explained in previous posts. See this tutorial for possible solutions.

----------


## LittleTyke

> See this tutorial for possible solutions.


Thanks. That tutorial has given me a great deal more information about how SxS manifests are constructed.

----------


## LaVolpe

FYI: Project modified to handle a byte-order-mark (BOM) when it exists in a manifest (file, embedded in resource, clipboard). MSXML2 DLL is used to parse manifest XML, but that library does not seem to accept the BOM. Therefore, when importing a manifest fails, the project will now look to see if a UTF8 BOM (3 bytes) precedes the XML data. If it does, it is stripped to allow MSXML2 to parse the data. However, if it is important, and it shouldn't be, the BOM is never written when the project exports a manifest.

----------


## LaVolpe

Bug found when toggling TrustInfo between namespaces v2 and v3. Fixed.

Additionally. As mentioned in post #21. It is possible to get two TrustInfo entries if merging multiple manifests, one using v2 and one using v3, depending if v2 exists in the selected manifest. Also mentioned in that post, you can simply unselect the one you don't want. When selecting the menu to toggle the namespace and 2 or more TrustInfo elements exist, the first element is the one that gets toggled. At that time, the others will be flagged so you can delete them via the tree node's context menu (right click)

----------


## VbNetMatrix

thanks for the update  :Smilie: 

EDIT:
I noticed in your .vbp, you're using COMCTL32.OCX v1.3
is that version bound to OS ? I got 1.4 on Win7

----------


## ColinE66

Thanks for your great work on this, LaVolpe  :Smilie:

----------


## LaVolpe

> I noticed in your .vbp, you're using COMCTL32.OCX v1.3
> is that version bound to OS ? I got 1.4 on Win7


Yep, chose the v5 common controls so it would be themed. Theoretically, your version should take effect due to the option to update ActiveX automatically...



> The Upgrade ActiveX Controls project property automatically updates any ActiveX controls if you have installed a newer version of them on your machine since the last time you opened the project.

----------


## VbNetMatrix

if I get it correctly, in order for a project to be themed, I need to use the v1.3 ?

----------


## LaVolpe

> if I get it correctly, in order for a project to be themed, I need to use the v1.3 ?


Ensure version 5 vs. version 6 of the common controls. Note that the comctl32 (v5), the version is retrieved from the dll (comctl32.dll), not the ocx. In your VB components (Ctrl+T), look for entry: Microsoft Windows Common Controls 5.0. The v6 (components entry: Microsoft Windows Common Controls 6.0) is a usercontrol that can't be themed via a manifest.

FYI: My version number from the DLL is 5.82 xxxxxxx

Where the 1.3 or 1.4 comes from, I don't know. Here is a somewhat interesting link regarding the revisions of that dll.

Edited: Theming does not occur in the IDE unless VB6.exe has a manifest (external or embedded)

*Follow-up*. I went to Microsoft's site and re-downloaded SP6. After reinstalling, I now have v1.4. I had a cached version of SP6 previously, that I used whenever I reinstalled VB6. Obviously SP6 was upgraded a bit sometime afterwards.

----------


## VbNetMatrix

> Ensure version 5 vs. version 6 of the common controls. Note that the comctl32 (v5), the version is retrieved from the dll (comctl32.dll), not the ocx. In your VB components (Ctrl+T), look for entry: Microsoft Windows Common Controls 5.0. The v6 (components entry: Microsoft Windows Common Controls 6.0) is a usercontrol that can't be themed via a manifest.
> 
> FYI: My version number from the DLL is 5.82 xxxxxxx
> 
> Where the 1.3 or 1.4 comes from, I don't know. Here is a somewhat interesting link regarding the revisions of that dll.
> 
> Edited: Theming does not occur in the IDE unless VB6.exe has a manifest (external or embedded)


yes thanks, now I understand...  I was aware about the v5 (themable dll) and v6 (static ocx)
as for the vb6.exe, I don't use manifest on it because it cause too many problem in the IDE (the main one being the accessing the color)

I also got 5.82, the next 4 number is the version of the OS (in my case 7601 mean Win7sp1) and the 5 other digit is the revision model, wich should be the same for everyone using the most recent version of the 5.82. I got 18837, do you have a most recent version ?  just asking in case I missed a MS patch.

btw, off topic, but is there a way so the forum when it send me email for new post doesn'T always send me to post #23 of page #1 of this thread ???  it seem to be keeping track of last comment I did instead of where I read.

thanks for the link I'm reading it.

----------


## vbLewis

using 64 bit architecture it specifies 'ia64' this should be amd64 ? also a valid value is '*' for all.

----------


## LaVolpe

> using 64 bit architecture it specifies 'ia64' this should be amd64 ? also a valid value is '*' for all.


I err on the side of official documentation. Per MSDN (Application Manifests)...



> Specifies the processor. The valid values are x86 for 32-bit Windows and ia64 for 64-bit Windows. Optional.


However, here is another quote I found on a page describing how to enable visual themes. Note that this deals specifically with the common controls dependency. Based on the following, I am considering offering amd64 & * for the common controls entry.



> Set the processorArchitecture entry to "X86" if your application targets the 32 bit Windows platform, or to "amd64" if your application targets the 64 bit Windows platform. You can also specify "*", which ensures that all platforms are targeted.


Note: You can override this by holding the shift key and right clicking on the item. Then select "Value" from the context menu, you'll see a "New Value" submenu... that provides the option to override. On the GDI+ and Common Controls entry, holding the shift key offers the "Show Attributes" option. Once that is selected, now you can override via the "New Value" submenu.

In the meantime, anyone can update the project to offer the other options:
1. Find this line in cManifestEx class, pvValidateAttributes routine


```
.AddAttributeValueList "processorArchitecture", attr_HasValueList Or attr_CanBeBlank, "x86", "32 Bit", "ia64", "64 Bit"
```

2. Suggested change


```
.AddAttributeValueList "processorArchitecture", attr_HasValueList Or attr_CanBeBlank, "x86", "32 Bit", "ia64", "64 Bit (Itanium)", "amd64", "64 Bit (AMD)", "*", "All Platforms"
```

For VB applications (original intent of this project), 64-bit won't be in play. However, nice to know some may be using this for their non-VB projects.

----------


## LaVolpe

Minor update. Had an itch I had to scratch.

There is an undocumented 2014 WindowsSettings option: forceFocusBasedMouseWheel. This is undocumented and I only know about it because it exists in the registry. After some trial and error, I have added that option; hence the update

What that option does is revert to pre-Win10 mousewheel behavior where the mousewheel only affects the window with the keyboard focus. As of Win10, per Raymond Chen, Windows broke this and allowed the wheel to affect any window under the mouse, regardless whether it had the focus or not. The newly added option prevents that for the thread only. So if you had 2 listboxes that have scrollbars, this option will only allow the mouse to scroll the one that has the focus, even if the mouse is over the other listbox.

----------


## MountainMan

Your release on 25 Oct 2017 shows version 2.0.4. So does your new version on 2 Sep 2019. Shouldn't it be incremented to at least 2.0.5?

----------


## LaVolpe

> Shouldn't it be incremented to at least 2.0.5?


Feel free to change it to whatever you want. I often get lazy on incrementing when only minor updates are applied.

----------


## Caine

Thanks for creating this invaluable tool. I've been using it for quite some time now and it has always come in handy!

I recently stumbled over an incorrect configuration when trying to use the printerDriverIsolation windowsSetting. You've put this into the wrong namespace (2013). According to the docs it should belong into the "http://schemas.microsoft.com/SMI/2011/WindowsSettings" namespace. As soon as I corrected your base XML in the resource file the error went away.

----------


## LaVolpe

@ Caine, thanx for the bug report. I'll be sure to fix it. After reviewing MSDN, yepper 2011 vs 2013

FYI: Two new settings showed up on MSDN lately which I'll include in the next update: 
- for 2019: <activeCodePage>
- for 2020: <heapType>

----------


## LaVolpe

Project updated to address bug report in post 53 by Cain.

In addition to aligning printerDriverIsolation to the correct namespace, also needed to do this with: highResolutionScrollingAware

Following enhancements made:
- added activeCodePage and heapType elements, using 2019 and 2020 namespaces respectively
- for any elements that can have comma-delimited values, those values can now be placed in user-defined order. This is important for the dpiAwareness element because first-recognized, first-used is the rule of thumb for that element's values. Example


```
<dpiAwareness>permonitorv2, permonitor, system</dpiAwareness>
```

----------


## VanGoghGaming

> If you want your VB6.exe to use an external manifest, unless you plan on using some 3rd party software to embed one into the exe (and hope it doesn't corrupt it), some annoyances are expected. Simply adding an external manifest along side of VB6.exe doesn't guarantee it will be used. You may very well need to change a registry setting to make it happen. After you are sure your manifest is being recognized, you will likely want to go and restore the setting:
> Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide
> Value: PreferExternalManifest
> Data: 1 = prefer, 0 = don't preferAfter making the change and manifest still appears to not take effect, reboot. It is getting harder and harder to use external manifests within Windows -- and that's probably not a bad thing.


I have been using resource files and manifests in my apps for quite some time but I've stumbled upon this thread while searching for how to update the user interface to reflect modern standards. Applying visual themes via the manifest file seems to be just the thing I was looking for. Your posts have helped me numerous times throughout the years, LaVolpe!

Since you mentioned that it's possible to update the theme of the VB6 IDE itself, I definitely wanted to try that and I experienced the following outcomes:

In both Windows 7 and Windows 10 the external manifest doesn't work unless you set "PreferExternalManifest=1" as you suggested. Setting it back to zero will ignore the external manifest again!

If you set "PreferExternalManifest=1" there is an unexpected behavior in Windows 7. The "Network" icon will disappear from the taskbar (lower right corner, near the clock). Also clicking the clock will no longer display the calendar (nothing happens). These are fixed by setting PreferExternalManifest back to zero (requires reboot). In Windows 10 everything works correctly.

I have found a way to embed the external manifest inside the VB6.EXE file by using the manifest tool (mt.exe) that comes with the Microsoft Windows SDK. If you don't have the SDK you can download just the mt.exe tool from: https://github.com/eladkarako/mt



```
mt.exe -manifest VB6.EXE.manifest -outputresource:VB6.EXE;1
```

After running the command above, the new VB6.EXE will contain the manifest file embedded inside itself while somehow retaining the same file size as before and you will have the added benefit of the visual themes inside the IDE! Hope this helps.

----------


## LaVolpe

FYI. Something I don't think I've used in over a decade was reported as an issue when project is manifested: frames inside frames

In the old days of XP, some controls would not render correctly when placed in a frame, the option button was the biggest issue. The easy workaround then was to place those controls inside a picturebox, then put the picturebox inside the frame. After resizing, repositioning the picturebox and changing its backcolor as needed, you simply made it borderless. The controls that would not render properly in the frame would render properly in the picturebox inside the frame.

Well, that problem can still arise when a frame is placed in another frame. The frame's caption won't render correctly. You can test this in a manifested IDE or compiled test project. The easy workaround is the same as was used back in the XP days ... place the frame inside a picturebox and that picturebox inside the other frame.

I've added a note about this in post #2 (Tips, notes, etc)

----------


## VanGoghGaming

It so happens that my project which needed a visual styles facelift also used several smaller frames inside one big frame so I was confronted with this bug right away. It seems that frames need to be hosted inside a container that has a DC (device context) and frame themselves don't have one, hence the need for the PictureBox.

I wasn't going to add PictureBoxes at design time so I figured I could create temporary PictureBoxes at run time! For some reason this didn't work inside the Form_Load event so I had to use Form_Activate and also needed to make sure the Activate event didn't fire more than once:



```
Private Sub Form_Activate()
Dim xControl As Control, PicContainer As PictureBox, i As Long
Static bActivate as Boolean
    If bActivate Then Exit Sub
    bActivate = True
    i = 1
    For Each xControl In Me.Controls
        If TypeOf xControl Is Frame Then
            If TypeOf xControl.Container Is Frame Then
                Set PicContainer = Me.Controls.Add("VB.PictureBox", "PictureBox" & i, xControl.Container)
                i = i + 1 
                With PicContainer
                    .BorderStyle = 0
                    .BackColor = xControl.Container.BackColor
                    .TabStop = False
                    .Visible = xControl.Visible
                End With
                With xControl
                    PicContainer.Move .Left, .Top, .Width, .Height
                    Set .Container = PicContainer
                    .Move 0, 0
                End With
            End If
        End If
    Next xControl
End Sub
```

This code runs very nicely and provides a PictureBox container for each frame hosted inside a bigger frame. Hope this helps!

Edited. Thanks for the tip LaVolpe, you rock as usual!

----------


## LaVolpe

> This code runs very nicely and provides a PictureBox container for each frame hosted inside a bigger frame. Hope this helps!


Nice touch, could help others. Just to nit pick a tiny bit... You could test the frame's container type instead of testing for Me, i.e., test for Frame specifically. If the container is a frame, then apply the dynamically loaded picturebox workaround, else don't. Worse case scenario otherwise is loading up unneeded picturebox controls, i.e., frame is in a picturebox already or frame added to some other ocx/control for example. Would be a small tweak and still remain generic.

The only potential flaw I can see, and it would be on per-user scenarios, is ZOrder when it must matter to the user. I think that in majority of scenarios, your code should work just fine.

Edited. If you want to tweak your code a bit, just update the above post vs. adding it again. Either way, I'm going to point people to your posting as an option for that specific problem.

----------


## KenHorse

I notice that if I disable a frame (or label), it doesn't "gray out" anymore. Is there a workaround?

----------


## LaVolpe

Well, if you are theming the controls, and don't like the way the theme is applied to some controls, not sure what anyone can say. The options seem to be just a couple: a) don't theme or b) subclass and draw the control yourself, c) use a custom control. You might be able to apply your own theme? In any case, that is a question that should be asked in the general VB forum section.

Edited: The frame is probably a button-like control behind the scenes. It uses a window-style that includes the value 7 which is also the value for BS_GROUPBOX. Based on that and the description of a group-box, sounds a lot like a frame. And if actually a 'button' behind the scenes, that would explain why the theme is taking precedence.

----------


## LaVolpe

When manifesting the IDE to have it themed, that popup palette for color selection doesn't display correctly. The listbox of system colors works, but the palette is blank/erased. I have a remedy in an add-in that you can use. See this thread

----------


## BobbyAxelrod112

Hi, I am a bit of a VB6 beginner and I am trying to get this to work start to finish. I can't seem to find a step-by-step guide from the beginning to setting this up and get this running with themes in my projects. The instructions seem to be spread out over multiple threads and I can't seem to put all the pieces together. I would very much appreciate if someone put together a step-by-step process or a video. Thanks for this wonderful resource, and would appreciate any help.

----------


## thomasaj05

> Hi, I am a bit of a VB6 beginner and I am trying to get this to work start to finish. I can't seem to find a step-by-step guide from the beginning to setting this up and get this running with themes in my projects. The instructions seem to be spread out over multiple threads and I can't seem to put all the pieces together. I would very much appreciate if someone put together a step-by-step process or a video. Thanks for this wonderful resource, and would appreciate any help.


Hi BobbyAxelrod112

I'm new to VBFORUMS and especially this topic but I am not new to forums in general.

I could be wrong but I don't think you will receive what you asked for unless the question is asked similar to...

"These is what I have done/tried/understand but I cannot figure out the next step."

This narrows down the answer to something manageable for the replier.

----------


## LaVolpe

@BobbyAxelrod112. Not really sure what the question is. The steps are fairly straightforward
1. Create a valid manifest file
2. Add that manifest to a resource file and rename the resource item, if necessary: Type of 24 and ID of 1
3. Compile your project

The Manifest Creator can do steps 1 & 2 for you. Manifests apply to compiled applications, not when uncompiled within the IDE. The exception of course is if the IDE is manifested -- two ways of doing that.

----------


## thomasaj05

> It so happens that my project which needed a visual styles facelift also used several smaller frames inside one big frame so I was confronted with this bug right away. It seems that frames need to be hosted inside a container that has a DC (device context) and frame themselves don't have one, hence the need for the PictureBox.
> 
> I wasn't going to add PictureBoxes at design time so I figured I could create temporary PictureBoxes at run time! For some reason this didn't work inside the Form_Load event so I had to use Form_Activate and also needed to make sure the Activate event didn't fire more than once:
> 
> 
> 
> ```
> Private Sub Form_Activate()
> Dim xControl As Control, PicContainer As PictureBox, i As Long
> ...


Maybe it's just my setup but I had to add '.Visible = True' line of code otherwise nothing showed.

If the author agrees then maybe just change the original code a few posts back and delete mine to reduce clutter or please enlighten me otherwise ):

----------


## thebalans

Hi,
I've downloaded your Manifest Creator II and, when I tested it, I get the following:

I'm using Win 10.
Thank you

----------


## Davor Geci

Hello,
can we use the manifest file to change the scrollbars of a controls?
For example when we are creating a dark theme of our app to apply the dark theme for the scrollbars?
Maybe if we change the theme of windows and to reflect this to the scrollbars?

----------


## Eduardo-

> Hello,
> can we use the manifest file to change the scrollbars of a controls?
> For example when we are creating a dark theme of our app to apply the dark theme for the scrollbars?
> Maybe if we change the theme of windows and to reflect this to the scrollbars?


You can manifest the program to use Windows themes, also called Visual styles, and the controls that support visual styles will render with the visual style set on Windows (the theme).
But you cannot change its colors or the controls parts individually, because that is set by the windows theme.

Dark theme? Yes, set Windows to dark theme.

If you otherwise want to apply a different theme only to your program, Windows does not support that but there is a third party library that does (it is not free): https://codejock.com/products/skinfr.../?2yn6s14z=p1z

----------


## NeedHelp!

Hello LaVolpe, are you still active on VB6?

I used that language for a small updating tool, but recently Windows Defender made some trouble with false alarms (but not on my own system). Therefore I wanted to try adding a manifest and see, if that helps...

I downloaded one from the web, changed the values by hand and used it side by side. To test it, I put the value "requireAdministrator" in it. I thought, if it is working, it will prompt the UAC dialog. - But this did not happen.
That is, why I tried your tool, but I am having some difficulties with it.

Ich am getting the error, which you posted above (just not in English), when compiling and running your tool:



> *Compilation Errors*
> Should you see an error like the following once your app is compiled...
> 
> ... There are two possible reasons for it:
> 1. Your embedded manifest file size is not a multiple of 4 bytes. This is a bug with VB6 that SP6 fixed. If you don't have SP6 applied, do so. That fixes a lot more than the problem just mentioned. This tool now ensures it writes dword-aligned manifests to resource files anyway.


I installed SP6, but the about dialog of VB6 does not show it. - Is this normal? (I am having VS6)

Because of the exception, which I mentioned above, I did start your project by running it in the VBE. But its main window did not show any entries (just some checkboxes without a caption).

----------


## VanGoghGaming

If you want to use the "requireAdministrator" flag then your EXE file needs to be digitally signed with a certificate. You can either purchase such a certificate from a recognized certification authority like DigiCert, Comodo, etc (costs a fair chunk of cash and requires submitting a lot of personally identifying paperwork) OR you can generate your own certificate (with the "makecert" utility) but that won't be recognized as valid by the operating system.

You could make your certificate recognizable as valid by making yourself a "Certification Authority" (also with the "makecert" utility) and adding it to the Root certificates repository with the "certutil" utility (certutil -user -addstore Root yourcertificateauhority.cer). The problem with this approach is that you need to run that command on every computer where you want to use your application. It's ok if your customers trust you with your application though.

----------


## VanGoghGaming

> Maybe it's just my setup but I had to add '.Visible = True' line of code otherwise nothing showed.
> 
> If the author agrees then maybe just change the original code a few posts back and delete mine to reduce clutter or please enlighten me otherwise ):


You are correct, I have checked my code and indeed it needs the line:


```
.Visible = xControl.Visible
```

I have added it in the above post as well!

----------


## KenHorse

Any plans to adapt this for Windows 11?

----------


## Elroy

> Any plans to adapt this for Windows 11?


Ken, LaVolpe has left us.  He got another job that wasn't VB6 related and said sayonara to us, so I believe you're on your own.

----------


## KenHorse

> Ken, LaVolpe has left us.  He got another job that wasn't VB6 related and said sayonara to us, so I believe you're on your own.



Ok thanks. I'm slowly getting VB6 IDE going under Win11 on an VM on my Win10 computer and have many things worked out (including the serial comm now). I just noticed that the manifest additions don't seem to be working, at least not yet  :Smilie:

----------


## VanGoghGaming

> Ken, LaVolpe has left us.  He got another job that wasn't VB6 related and said sayonara to us, so I believe you're on your own.


VB6 is like "Hotel California", you can always check out but you can never leave!  :Wink: 

You don't need this program to create manifests, they work just fine edited in Notepad...

----------


## KenHorse

That's the beauty of LaVolpe's Creator. You don't really need to know what you're doing  :EEK!:

----------


## Caine

For what it's worth, according to the docs the value of the <supportedOS> tag is the same for Windows 10, Windows 11, Windows Server 2016, Windows Server 2019 and Windows Server 2022. Unless there are other changes, there's nothing to worry about.

A cursory glance shows only this change: the <activeCodePage> tag isn't limited to UTF-8 anymore with Windows 11. I might be wrong, though.

----------


## Taro

Oh, sad to hear this.

LaVolpe is the most valuable person in our VB classic world. Hope he comes back to see us soon.

----------


## LittleTyke

*PLEASE IGNORE THIS POST! I NOW REALISE I MADE A SIMILAR POST 5 YEARS AGO.* My excuse? I'm getting old...

Having used Make My Manifest in the past, with complete success, I now get problems with running VB6 programs on Windows 10 using external manifest files. To be fair, several of my programs work fine on W10 "out of the box", so to speak. I just copy the main folder from XP to Windows 10 and the program runs. But there's one particular program which is fairly straightforward that will not run on W10 and throws all kinds of errors.

So I started researching SxS in more depth and found Manifest Creator II v2.03, but I just cannot get started with it. I cannot find any instructions on how to use it. I also tried Manifest Creator I, the first version, and that is slightly more intuitive, but II just leaves me floundering. There's a long list of checkboxes with little explanation on how to proceed.

Has anyone produced a detailed guide to using this tool, which is obviously capable, given the number of comments I see.

Right now, I'm building a new manifest the hard way by using mt.exe to extract dependencies, following the very excellent tutorial by Elroy "Using OCX Files with SxS Technology".

----------

