# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  [VB6] XP/Vista/Win7 Manifest Creator

## LaVolpe

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


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


```
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.

----------


## LaVolpe

*Sample Steps to Creating/Embedding Manifest Files*

Here is MSDN documentation on the proper formatting of an application manifest.

You may ask why you would want to include a security section in the manifest... Suggest reading this MSDN page.

You may ask why you would want to include a manifest for common controls (i.e., buttons, textboxes, MS common controls, etc). The answer is simply appearance. For operating systems that use themes, your compiled application will look like 98% of the other apps the user is used to. It won't appear out of place or "old". There are known incompatibilities between VB and themes. Don't use frames. Within your project, common controls v5 works with themes where common controls v6 don't. Using VB's Graphical Style property on command buttons, option buttons, checkboxes prevent theming for those specific controls. Some other "bugs" may crop up.  But these are just a minor annoyance vs. a major inconvenience, in my opinion.

Themes are applied to compiled applications ONLY. However, you can get a WYSIWYG version of it in IDE by having the IDE run themed. See post #54, page 2, for more information on theming the IDE

*Preface*: If you update a resource file that is being referenced in an open VB project, the changes made may not be visible when you open the resource file via VB's Resource Editor.  In that case, simply remove the resource file from the project and re-add it back to the project, or close & re-open your project.  The changes will be seen.  Not recommended to write to a resource file that you have modified with VB's Resource Editor and have not yet saved the changes; unexpected results may occur.

*If you do not already have an embedded manifest within your project's resource file*
1. Open the Manifest Creator
2. Create a resource file and add it to your project if no resource file exists yet
If you do not want controls themed, and only want one of the other manifest portions, skip steps 3 & 4 below
3. Create a module in your project, if needed
4. Click on the button "Sub Main To Clipboard" 
-- Paste text to your module. 
-- Ensure pasted API/Structure declarations are moved near top of the module. 
-- Add any additional ICC constants to the _.lngICC =_ line of code. See comments in that code.
-- In the Sub Main procedure, just prior to "FreeLibrary" call, add line of code to show your main form
-- Add any other custom start-up code needed
-- Save changes
5. In bottom combobox, select "Create from VB File" and select your project's .vbp file. Press "Go"
6. Adjust any settings/values in the Manifest Creator. If you want controls themed, ensure option to include Common Controls is checked.
7. In bottom combobox, select "Write Manifest", press "Go"
8. Select "Resource Files" in browse window's bottom combobox. Locate your project's .res file and click "Save"

How to start your project with Sub Main? This *must* be done if you chose to include common controls in your embedded manifest
a. You should have already completed steps 1-4 above.
b. Open your project's Properties window. IDE menu: Project | [project name] Properties
c. In the General tab, select "Sub Main" from the Startup Object combobox
d. Close the properties window and save changes.

*If you already have a manifest embedded in your project's resource file and you want to change it*
1. Open the Manifest Creator
2. Start with Step #5 above
The old manifest will be replaced with the new manifest. Note that if you chose to include the Common Controls in the manifest, you *must* start your app with Sub Main, initializing common controls. See Steps 3 & 4 in previous paragraph. 

*If you want to delete the embedded manifest from your project's resource file*
1. Open the Manifest Creator
2. In bottom combobox, select "Delete Manifest", press "Go"
3. Select "Resource Files" in browse window's bottom combobox. Locate your project's .res file and click "Open"
You may or may not want to remove the Sub Main from your project, if it exists.

----------


## Cunae

> Unzip the project and compile it, then run it. It should be themed and run just fine.


Hi, great project - maybe you should add which Components/References must be selected for the project to compile without errors?
/Cunae

----------


## LaVolpe

> Hi, great project - maybe you should add which Components/References must be selected for the project to compile without errors?
> /Cunae


Not sure I understand the suggestion. The checklist I posted in #2 above, if followed, does ensure compilation without errors. Because you have the option of including a Vista security and/or controls manifest, the options are fairly simple:
1. Vista manifest, no special handling needed
2. Controls manifest, include Sub Main with the code provided via the "Sub Main To Clipboard" button, and set your startup object to Sub Main.

If you are asking which references you should be adding to your project (i.e., ADO, Scripting, etc)? Not applicable to this project. VB does that for you anyway by popping up a window saying you are missing a reference.

----------


## Cunae

Ok, my intention was just to inform you my experience after I unzipped your Vista Manifest Creator project and then compiled it, compilation failed because of missing references/components ("_Unzip the project and compile it, then run it.._"). I did find out to select the necessary component and compile ok because as you say VB helps you by popping up a window, so I am happy and satisfied with your solution. I am seeing forward too to others testing it with Windows 7  :Thumb:

----------


## LaVolpe

Thanx. I'll have to look at the project again; maybe I left in some reference I didn't need?  Offhand I don't see it, do you recall what was missing? I'll unzip it to a new computer tomorrow and see if I can replicate a problem.

And please let us know if it works with Win7.  I don't have access to it for tests.

----------


## Jonney

1.It's a very good example of  using Unicode (W-Type) APIs to Read/Write file.
2.It's a very good example to understand Resource File Structure.
3.It's a very good example to know how to put/retrieve UDT in a file.

Thanks.

----------


## Jonney

```
ReadFile hFileFrom, dcbHeaderSize, 4&, resDataL, ByVal 0&
    If resDataL <> 4& Then Exit Function
```

If the last step is successful,resDataL will remain 4,so this checking will fail.

Supposed to reset (???):


```
resDataL=0&   'Reset
     ReadFile hFileFrom, dcbHeaderSize, 4&, resDataL, ByVal 0&
       If resDataL <> 4& Then Exit Function
```

I attached a resource file which contain a manifest file but the function of *view External Manifest* fails.

----------


## LaVolpe

Jonney, what is in the resfile is not a manifest, not really.  A manifest file will have a RT_MANIFEST resource type. That text in the res file is a CUSTOM resource type. It might as well be an email or ini file. Even though it is a manifest, it will never effect a compiled application. One cannot just throw a manifest in a CUSTOM resource and have Windows recognize it as a true manifest.  To read CUSTOM resource file entries or any resource entries, really, one simply needs to process all the resource types. The project I wrote only messes with RT_MANIFEST resource types.

Try creating a test project, one command button, adding that resfile & appropriate Startup code to the project and compiling it.  The compiled project will not be themed if themes are active.  Now add a manifest via this project, recompile, & it will be themed; your updated resfile will have 2 manifests in it: 1 that is a true manifest and one that is simply a custom, text resource.

The bottom line is that the code is fine. If the ReadFile API fails, it should set resDataL to zero, else it will set it to how many bytes were read.  Anything <> 4, in this case, is considered failure.

----------


## Jonney

Thanks.
"CUSTOM" could be else than Manifest XML script."RT_MANIFEST" (24) is the signature of Manifest resource type.

----------


## MrSmith.

Just to note, Works with 32-bit Windows 7 Ultimate. Great work LaVolpe  :Smilie:

----------


## LaVolpe

Thank you MrSmith, I was curious.  Maybe I should now change the post title to include Win7  :Wink:

----------


## MrSmith.

Most definitely  :Smilie:  I will be using this very often, gives the application a refreshing look and is so easy to implement. Thank you.

----------


## 7edm

Hi,

When arriving to Step 5 and loading my project file it read the version as 6.2.35.0 while properties of my exe show 6.2.0.35 - is this correct? I know VB6 doesn't allow you to set one of the version parts, which should be 'build' as it has fileds for major, minor and revision and the MSDN docs (as linked above) refer to
the assembly version as 'major.minor.build.revision' so according to this MC have it wrong or?

----------


## LaVolpe

I have to fix that. The code inside is simply reversing the last two portions. Until I post the patch, simply recommend editing the version info in the textbox.  Sorry for the inconvenience.

----------


## 7edm

No problem, I mostly wanter to be sure about it but also it doesn'y seem to matter as at least the styles applies with both version strings. 

But there is another reason as well, I have an Add-In vbAdvance that let me set this "zero masked" digit but in its documentation it refer to it as the revision and what VB6 call revision as build. I think they got it wrong though as according to the MSDN docs the 3rd integer is the build number. 

Now that doesn't matter so much but what matter is that you may like to concider adding support for it rather then just hard code it to "0"?

They set this value as


```
RevisionVersion=n
```

I have done it in my downloaded copy as


```
sVersion = "M.m.B.R"
```

and in the For Loop


```
Case "revisionversion": sVersion = Replace$(sVersion, "B", Mid$(sLines(lLine), iPos + 1))
```

Then after the loop


```
If InStr(sVersion, "B") Then sVersion = Replace$(sVersion, "B", "0")
```

I don't know if there is any other tool offering this function but to cater fore that one could check for the [vbAdvance] ini section being present in vb project file.

By the way, vbAdvance was previously a commersial Add-in but is now offered as an unsupported Freeware at http://vb.mvps.org/tools/vbAdvance/

It has some really nice features and so far it seam to work fine even in Win7-64  :Thumb:

----------


## LaVolpe

7edm, not possible. I did fix the version info issue & updated project in post #1 above.  But a "Build" option is not available in a VBP file.  Looking at your post above, VB does not have RevisionVersion it has RevisionVer.  Trying to add RevisionVersion to a vbp file and opening in VB produces expected "invalid key" error.

Also note that what you may be looking at may not be a true VBP file, but rather a vbAdvanced file.  From browsing the net, the only way to set the build number for an app is to do it after the fact; after compiled. I have no plans on modifying this for vbAdvanced files; but feel free to do so for your needs.

----------


## 7edm

LV, vbAdvance create its own section in the VBP file, like this


```
[vbAdvance]
IsConsole=0
HasStubFile=0
GenerateMap=0
TSAware=0
XPManifest=0
ResBuildName=.\project.dll
ReplaceIcon=0
SendCommandArgs=0
SymbDbgPref=0
RevisionVersion=0
```

and so does the CodeSmart 2009 add-in which I also have, it's fully valid. Exactly how it then add that value to the exe file I don't know, but it does and it works. What I tried to explain above was that while VB and MSDN docs label that unaccessable value 'build', vbAccess refer to it as 'revision' and the other way around for the other. So the labels for the 2 positions are reversed.

But it's perfectly ok to keep it out of the project and anyone being in need of it (who uses vbAdvanced) can just patch with my code above, it works.

----------


## LaVolpe

I see. Yes, there is some inconsistency with what VB calls a revision and what .Net & others call revisions. The patch I put into place simply changed sVersion from "M.m.R.0" to "M.m.0.R".  Tweaking the code to look for the additional vbAdvance section would be simple enough for those that use vbAdvance. And if so, do recommend using "M.m.B.R" as you stated, defaulting to zero for B if no such build information exists in the vbp file.  Thanx for the vbAdvance lesson; never used that tool.

----------


## exgliderpilot

This seems such an excellent project - I just cant get it to work: VB6 SP6b - Vista home

1 download zip and exctect to c:\ \Manifest folder
2. open in VB6 (as admin)
3. complie to c:\ \Manifest
4. close
5. run c:\ \Manifest\ManifestCreator (as admin)
6. ex's name "ManifestCreator"
7. description "Manifest Creator"
8. tick include common controls
9. level as invoker
10 UI access = false
11. res language English (United kingdom)
12 sub main to clipboard
13. create from vbp file (select prjManefiests)
(fields created, resource file referenced)
14. write manifest - (first time it created a new resource file)
(Maniftest inserted)
15. close exe
16 open manifest proj
17 complie
18 run
19 - app looks escactly as it did before - ie. no xp/vist theme

20 open proj in vb - manfest with node 24 - ukenglish and nothing else?

21. read manifest:

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="1.1.0.0"
    processorArchitecture="X86"
    name="Manifest Creator"
    type="win32"
    />
  <description>Manifest Creation Application</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="X86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
             />
        </dependentAssembly>
    </dependency>
<!-- Identify the application security requirements: Vista and above -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
        <requestedPrivileges>
          <requestedExecutionLevel
            level="asInvoker"
            uiAccess="false"
            />
        </requestedPrivileges>
      </security>
  </trustInfo>
</assembly>

----------


## LaVolpe

Been away for a bit, but back now.  Couple questions for verification
1. Your resource file, with the manifest in it, is referenced in your project?
-- Open it from inside your project and ensure you have a resource section named: 24
2. Did you tell your project to start with Sub Main? << I suspect this is the problem
3. If so, do you have themes applied in Vista?
4. If so, you are saying that none of the buttons, textboxes are themed?  If they are, what exactly isn't themed?

----------


## exgliderpilot

1. I believe so - I'm doing my tests with the Manfiest Creator project as downloaded - seems to have this
2. I believe so - I'm doing my tests with the Manfiest Creator project as downloaded - seems to do this
3. Err... Well I have a customised desk top - (wall paper) other than that is the standard vista theme as I understand it
4. Non, no buttons, no text boxes, no check boxes -it looks exactly as it did when first downloaded.

I am puzzled, thanks for the reply so far.

Ian

----------


## LaVolpe

> 2. I believe so - I'm doing my tests with the Manfiest Creator project as downloaded - seems to do this
> 
> I am puzzled, thanks for the reply so far.
> 
> Ian


Manifest Creator doesn't do this, you have to do this with VB project properties. 
See post #2 above, the section that starts with: "How to start your project with Sub Main?"
Also, ensure you have a Sub Main in a module as described in Post #2 above. Recommend re-reading Post #2 and follow its instructions exactly. Do not deviate.

----------


## exgliderpilot

thanks - i'll look again i thought manefest creator did start with sub main...apologies if i'm wrong

----------


## LaVolpe

No apologies necessary. In order for the Manifest Creator to edit your project to force it to start with Sub Main, the creator would have to modify the .VBP file and/or create/modify a .BAS file.  I chose not to automate it to that level -- too much effort, room for problems, for such little gain.

----------


## exgliderpilot

Hi, Thanks for the reply - now I'm totaly confused...
here's what I see: http://creamteadiet.blogspot.com/201...confusion.html
and as i understand it that is the manifest creator project starting with sub main???
PS you may need to click on the image to get it full size...

----------


## LaVolpe

Oh good screenshot. I thought you were trying to apply a manifest to one of your projects, not the creator itself.  The creator should be themed once it is compiled.  Just so we are on the same page, recommend re-downloading the project from post #1 and just compile it; don't modify anything.  Then open the compiled exe and see if it is themed.  If not, we can discuss that.

To apply a manifest to one of your existing themes, use the steps in Post #2.

----------


## dilettante

For trivial manifests with little more than a CC6 selection assembly entry and a trustInfo entry you can edit them by hand using Notepad.  Just be sure you pad the file to a multiple of 4 bytes as measured after saving them in UTF-8 format.  Re-edit adding blank spaces to the end if required for padding.

Then you can add this as a Custom resource using VB6's Resource Editor, then edit the new resource's Properties to Type: #24 and Id: #1 as shown in the capture.

I was surprised this worked myself.

----------


## exgliderpilot

Hi LaVolpe, Did as you asked - compliled exe has theme. So now I'm going to repeat applying the exe to the (newly) downloaded project. It may take a day or two as customer is rattling my cage over something else at this very moment. PS thanks for the help so far.

----------


## LaVolpe

@exgliderpilot (post #29): Thought it would & should also work for your projects if you follow steps in post#2
@dilettante (post #28). Interesting indeed, will have to try this too.

----------


## NeedHelp!

Hello LaVolpe, thank very much for all your work!

I like the fact, that your tool also supports the admin rights thing.
But it is a little complicated to use.

Would it be possible for you, to make an IDE addin like one of these:
* XP Style (http://www.vb-zentrum.de/Tools.html or http://www.vbarchiv.net/download/dow...yle-addin.html)
* vbAdvance

First I did like vbAdvance more, because it is possible to use a res file (I guess vbAcvance adds the manifest to that resource file before each compilation) - XP Style does not work, if a resource file is already added to the project.
But in one project, vbAcvance did make my application to crash at start up, when "adding XP manifest resource" was activated.

I'll bet you are able to bring all advantages together.  :Big Grin: 
_______________________________________________

Something else:

If I add a manifest to my projects, which contain UserControls, they do all crash at program shut down, if I run them on other systems (Windows XP/Vista/7 wants to send an error report to Microsoft & executable cannot be deleted any more).
But it does not happen on my system (maybe because uxtheme.dll is patched... I have no clue  :Confused: ).

This already happens, if I start a new project with code to init common controls, add a resource file with included manifest and a new empty UserControl. Can you reproduce this behavior? Do you have any idea, how to solve this problem?  :Cry:

----------


## LaVolpe

I don't think it is hard to use. Just add a res file to your project and use this project or dilettante's method to insert a manifest into it.  You can modify the project as needed to work with vbAdvance .vbw files.  If vbAdvance can't remove an existing manifest from the res file, that is their shortcoming; you could use this project to remove the resfile though.  I don't use vbAdvance and don't want to install it just to work around its shortcomings. I think you can understand.  Take the time to modify the code and upload it here as a "vbAdvance-aware" version.

As for your other questions regarding the crashes & usercontrols, post that on the forum so more people can have opportunity to offer solutions from their experiences.

----------


## coolcurrent4u

Nice one LaVolpe

But am having a problem using the toolbar in v5sp2 of vb6. How do you make the regions of buttons in the tool bar control transparent. I am using magenta as the basckground color of my bitmap icon images. please check the attache. the issue occurs wjem you add manifest to project files

----------


## LaVolpe

coolcurrent4u.  I don't follow. What does it look like without a manifest? Please post this in the VB6 forum with more details so I & others might be able to help.

----------


## dilettante

Possible workaround.

Be sure to UseMaskColor in your ImageList, and make the call:


```
Private Const CLR_NONE As Long = &HFFFFFFFF
Private Declare Function ImageList_SetBkColor Lib "comctl32" ( _
    ByVal hIml As Long, _
    ByVal clrBk As Long) As Long

Public Sub SetImageListTransp(ByVal hImageList As Long)
    ImageList_SetBkColor hImageList, CLR_NONE
End Sub
```

... passing in the handle of the ImageList.

This should make the ImageList's background transparent, since we don't have a BackStyle property we can use.

----------


## coolcurrent4u

> Possible workaround.
> 
> Be sure to UseMaskColor in your ImageList, and make the call:
> 
> 
> ```
> Private Const CLR_NONE As Long = &HFFFFFFFF
> Private Declare Function ImageList_SetBkColor Lib "comctl32" ( _
>     ByVal hIml As Long, _
> ...


Your solution does not seem to work for me. I have openned a thread for this topic here
Here

----------


## duffann

Hi,

I could not understand how to add the resource file as said in step two :

"2. Create a resource file and add it to your project if no resource file exists yet"

Thanks

----------


## LaVolpe

Well, there are a few ways in this case

1) Non-traditional, simply select "Write Manifest" in the bottom combobox, after filling in the rest of the form. In the dialog box that pops up, select "Resource Files" in file type box, navigate to the folder of your project, provide a file name for the res file & click ok. The manifest creator creates the res file. You'll still need to add it to your project. See next step(s)

2) Add a resource file to your project using your menus: Project | Add New Resource File

3) Right click in your project explorer and select menus: Add | Resource File

----------


## LaVolpe

Project updated to help prevent crashes when themed exe containing VB usercontrols closes. See project history and comments in post #1 for more info. This update was in response to post #31 above.

----------


## dee-u

> 8. Select "Resource Files" in browse window's bottom combobox. Locate your project's .res file and click "Save"


I cannot understand the above instruction, I cannot find "Resource Files" in the combobox?

----------


## LaVolpe

> I cannot understand the above instruction, I cannot find "Resource Files" in the combobox?


When you click the GO button, you should be presented with a browser window. Select "Resource Files" in browse window's bottom combobox

----------


## PinoyAko

This works very well on setting the UAC permissions on vista  :Smilie:  Thank you

----------


## rojaldearintok

It works perfectly on my app, I have the admin rights now elevated, but when I drag and drop a picture on a picture box it does not work, what is the problem? please tell me.

----------


## LaVolpe

> It works perfectly on my app, I have the admin rights now elevated, but when I drag and drop a picture on a picture box it does not work, what is the problem? please tell me.


Ummm, what does your drag/drop problem have to do with this manifest creator? You are making an assumption, right or wrong, that permissions are involved with your problem. Post your question along with some code snippets in the appropriate portion of the forums. 

Please use this thread to only post questions/information relevant to the project I provided. Otherwise, the CodeBank section is not the place to post non-related questions. Thank you.

----------


## rojaldearintok

sorry

----------


## bh626

Nice project LaVolpe.  I  wonder if the version or appname make any difference.  For example, I created a resource using your tool called VisualStyles.res ver 1.0.0.0.  I have several vb projects so I simply add this res file to each VB6 project and modify the SubMain.

I can't see that the version or name make any difference.  Are they important?

----------


## LaVolpe

Talking about which app name and version you place inside the applications section of the manifest?

Per the links in post #2, it should, or could, make a difference. The version & app name in the manifest should be unique, per Microsoft.

----------


## bh626

Yes, the application section.  I have not seen any issues relating to uniqueness, but it may be there.  I'm also finding that just placing a manifest file in a dir doesn't work anymore for one of our non VB apps on Win 7.

----------


## LaVolpe

> I'm also finding that just placing a manifest file in a dir doesn't work anymore for one of our non VB apps on Win 7.


Not sure what to tell you. As we all know, what used to work before may not work on newer systems. When in doubt, I always side with the creator's advice (Microsoft in this case). And this is the reason why the option to provide that information exists in this project. Will changing that info in your manifest fix it? Easy enough to test & rule out for your situation. I'd also verify the manifest is in line with the link(s) in post #2 to rule out improper format/content.

----------


## Grasmere

Thanks for providing this creator. Looks much better than plain VB6.
Please note the following:
1) Option buttons in Frames look fine in Win 7 and Vista. Only get blacked out in XP.
2) Adding the security section seems to cause problems in Win 7 (and I expect Vista). It stopped my app from creating a file correctly in the users document folder (standard user with no special admin rights under Win7). It also wouldn't remember (save) the Armadillo security key entered. It would forget the key each time the app was restarted. These problems disappear if I don't use the security feature (invoker).

----------


## LaVolpe

Thanx for the feedback. Regarding manifest causing issues in Win7, suggest reading the related links in post #2 to see if it sheds any light

----------


## dilettante

> 2) Adding the security section seems to cause problems in Win 7 (and I expect Vista). It stopped my app from creating a file correctly in the users document folder (standard user with no special admin rights under Win7). It also wouldn't remember (save) the Armadillo security key entered. It would forget the key each time the app was restarted. These problems disappear if I don't use the security feature (invoker).


Almost certainly due to the program working properly (with the trustInfo) instead of with filesystem and registry virtualization.

Of course "properly" here means following the rules which restrict where programs can write to.  If your programs are not Vista-aware then they need the virtualization appcompat shims, and so cannot have a trustInfo section.  The presence of trustInfo (no matter the requestedExecutionLevel setting) is an explicit declaration to Windows that you are Vista-aware.  Legacy programs need to omit this section.

A user's Documents folder is not a restricted location.  Perhaps your program is using an old-format hard coded path?

Beyond virtualization there are other shims like CorrectFilePaths involved.  Also note Profile Changes in Windows Vista and Windows Server 2008 and beyond for some details.

----------


## LaVolpe

The project updated to include two new manifest sections for Vista and above.

1) DPI aware declaration. By including this in the manifest, your app will not be subject to DPI virtualization. See this MSDN page for more information

2) GDI+ v1.1 dependency. GDI+ v1.1 is available on Vista and above, VB will not use it by default without a .Local file or by requiring it in a manifest. There is a big caveat here. *Including this in a manifest where the app will also be deployed on XP will prevent the app from loading* when installed on XP. This is because GDI+ v1.1 is  not available on XP. There is one exception. One known version of GDI+ v1.1 does work on XP, but the odds that it exists on every machine you want to deploy your app is extremely remote. Also, v1.1 is not redistributable.

With the above GDI+ v1.1 warning supplied, there is a workaround where your app can use a manifest and load GDI+ v1.1 on Vista and above, but not try to load it on XP. Here's that workaround:

- Create a manifest that *includes* the v1.1 dependency. Embed this manifest into a resource file so it is compiled with your application
- Create a second, identical manifest that *excludes* the v1.1 dependency. Save it to file named exactly the same as your application but adding a .manifest extension. 

Now when you build your deployment package (i.e., setup.exe), you will include that manifest file too. When installing on XP, you must deploy that manifest file to the same folder as your application. When installing on Vista and above, you do not want to include that manifest file

This is how the workaround works. On XP, external manifests override embedded manifests. On Vista and above it is the opposite behavior. However, there is a registry setting that can force the behavior to be same as XP. So, since the manifest file is deployed in XP and that file does NOT include the v1.1 dependency, your XP app will work just fine because the embedded manifest is overridden by the file. And by not deploying the file on Vista and above, you do not need to be concerned with it overriding the embedded manifest which does include the v1.1 dependency. On Vista and above, this concern only applies if that registry setting is set; otherwise external manifests do not override embedded manifests

----------


## LaVolpe

Applying the info in the previous reply, here is how you can run VB6 IDE using some manifest options

The manifest below will tell Vista & above, that VB6 is DPI-aware, to use themed controls, and to use GDI+ v1.1, all of which, are optional and can be removed from the manifest. By placing a copy of this manifest in the same folder as VB6.exe, it will be used when VB6 is run. To stop it from being used, simply rename the manifest file to something else.
FYI: Why care if v1.1 of GDI+ gets loaded instead of v1.0? Simply, you may be using custom controls that offer extra stuff if v1.1 is loaded. You may want to use v1.1 functions when on Vista+

*For XP*: You will need to change the GDI+ version from 1.1.0.0 to 1.0.0.0 otherwise VB will not load if GDI+ v1.1 does not exist on the XP machine. The other sections and entries are fine.

*For Vista & above*. I have noticed that when disabling the manifest by renaming it & then naming it back so it could be used, it seems to be ignored from time to time. There is some system caching going on and this is one way around it.

a) Close any instances of VB6
b) Right click on VB6.exe & select Properties
c) Toggle the Compatibility option's checkbox
d) Click the Apply button
e) Toggle that Compatibility option's checkbox again
f) Click the Ok button
g) Re-start VB6, the manifest should now be effective once again

This can be copied and pasted into a text document, then renamed to vb6.exe.manifest


```
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="6.00.9782.0"
    processorArchitecture="X86"
    name="Visual Basic"
    type="win32"
    />
  <description>Microsoft Corporation VB6</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="X86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
             />
        </dependentAssembly>
    </dependency>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.GdiPlus"
                version="1.1.0.0"
                processorArchitecture="X86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
             />
        </dependentAssembly>
    </dependency>
<!-- Identify the application as DPI-aware: Vista and above -->
  <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
      <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
        <dpiAware>true</dpiAware>
      </asmv3:windowsSettings>
  </asmv3:application>
</assembly>
```

----------


## dilettante

I'm a little confused.

I understand why you'd want to select the newer GDI+ assembly for programs written for Vista or later.  But I assume that's because you want to use that version's newer capabilities.

Since it doesn't exist in most cases in XP though, how can you just use the older assembly?  Your calls wil fail?

Or are you additionally expecting the program to be written to use error trapping around a "test call" to some 1.1 function to set a flag causing the program to skip using 1.1 calls from then on?


Also, if some program is found fiddling with an important global registry setting like that one you mentioned I'd consider it malware.  This isn't the reputation you want any of your software getting.

As far as I can tell, the proper way to handle this sort of thing would be to avoid selecting this assembly via the manifest.  Instead you could use the SxS calls after testing the version of Gdiplus.dll or the OS version.


But I'm no GDI+ expert, and certainly not 1.0 vs. 1.1 literate.  Not trying to drag this off topic, but I see:



> *Note*  If you are redistributing GDI+ to a downlevel platform or a platform that does not ship with that version of GDI+ natively, install Gdiplus.dll in your application directory.


I also see: http://www.microsoft.com/download/en...ng=en&id=18909

But maybe that's just the 1.0 version of the library?

I wouldn't put it in the application directory (bad, bad advice there with nasty potential consequences for VB6 programs) nor use a .local file (completely obsolete).  But one can easily put it into a subdirectory of the application's directory to isolate it, and then have the manifest for the application redirect to it there.

You use the _loadFrom_ attribute of the _<file>_ tag to do this, the value of this attribute is a relative or absolute path to the redirected, isolated library.

----------


## dilettante

Sorry to crud up the thread.

It does look like the redist Gdiplus.dll is a 1.0 "edition" (hate to call it "version" since the versioning is different from this) meant to go onto Win2K and such.  There also seems to be an unrelated "1.1" that some versions of Office install into XP, but it isn't supposed to be generally usable.

I had no beef with your last post until it started talking about hacking global registry settings.  I still think there is a preferable way to do this, but I concede that they won't be of any help for the VB6 IDE.  You have to use a manifest there, and for Vista+ programs that's a fine solution anyway.

Things only start getting dicey if you want a program to use 1.1 after XP but still run in crippled (1.0) mode on XP.

----------


## LaVolpe

@ dilettante

- Hacking registry. I wasn't supporting that at all, you misread my intentions. I wanted those interested to know that users (read pc owners) can override default behavior in Vista+. This information is useful to know if you expect your embedded manifest to always be used. Knowing this would also be helpful for troubleshooting 

- v1.1 of GDI+. In stuff I build, it is easy enough to test for the version. So I set a global flag. If the flag is set, other options are enabled in the software. If not, they are disabled. I have no knowledge of any function/method corrections between the two dlls, but if there were & there probably are, this would be another reason to want the newer version.
   -- update this last point. v1.1 on Vista, Win7/8 do have corrections to v1.0 functions. GDI+ LoadImagexxx functions in later O/S version of v1.1 fixed some bugs that existed in earlier v1.1 & v1.0

----------


## dilettante

I see what you mean.  I've definately had people do this and break applications by substituting a bad file manifest.  Lots of frustration trying to figure out what went wrong.

As far as GDI+ 1.1 goes, as far as I can tell the main changes were moving a few operations out of GDI+ itself and into the DWM.  Beyond that I've seen little.

GDI was enhanced in Win7 to use hardware acceleration for a few things like blitting, while GDI+ has been left behind.  The "way forward" is supposed to be Direct2D now.  But not being a graphics guy I haven't messed with any of it in a meaningful way.

It's all a rat's nest to me.  I just hate wasting time debugging something caused by a registry tweak.

----------


## LaVolpe

Didn't think I'd mess with this again, but appears to have quite a few references on several other sites, not just this one. So, wanted to add O/S compatibility options to manifests for those that still use & abuse this project. Update includes that and more. See the change history in the 1st post, where you would download the project from.

Note: Not yet fully tested with Win8/8.1 so if others that play with this can post any issues, I can see what I might be able to do about it.

Edited: found what appears to be a valid Win10 compatibility GUID. Will add that to the manifest creator after a bit more research.


```
<!-- Windows 10 -->
 <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
```

Another modification would be for win8.1 that has a 'per monitor' DPI-awareness flag


```
<dpiAware>True/PM</dpiAware>
```

----------


## dilettante

As far as I can determine those <supportedOS /> entries just turn off some appcompat shims and turn on other things (like correct version reporting).

So it seems as if most people won't need them, though some certainly will if they want and need accurate version reporting.

Vista ignores the "Vista" value.  Win7 may pay attention to it (though this doesn't seem clear), hard to say beyond that.  I think each post-Vista OS version only looks for its own, assuming you have a <trustInfo /> node.

So far I can't find a list of things for each OS that the compatibility entry turns on or off.  About all I've seen that even attempts to discuss the topic is Manifesting for Compatibility on Windows 7 but I haven't been keeping up with SDKs anymore either.

----------


## LaVolpe

Yep, from what I can gather, it may effect quite a bit...



> The Compatibility section allows Windows to provide new behavior to new developer-created software while maintaining the compatibility for existing software. This section also helps Windows deliver greater compatibility in future versions of Windows as well. For example, an application declaring support only for Windows 7 in the Compatibility section will continue to receive Windows 7 behavior in future version of Windows.
> 
> Applications without a Compatibility section in their manifest will receive Windows Vista behavior by default on Windows 7 and future Windows versions. Note that Windows XP and Windows Vista ignore this manifest section and it has no impact on them.


There was more on this page and on this page too & probably more to come as Win10 comes on board.

I don't have anything higher than Win7 to play on, but maybe including/excluding this section may affect theme style?

----------


## dilettante

Thanks.  Those items listed are a good start.

----------


## LaVolpe

Updated to include 2 new items mentioned in post #59 above.

----------


## 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.

The button icon assignment in the screenshot below was accomplished with a couple lines of code
1) Load your alpha-blended icon via your favorite method. You will need to destroy the icon at some point

2) Here are the APIs


```
Private Const BM_SETIMAGE As Long = &HF7&
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 DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long
```

3) Here's the simple assignment after you've loaded your icon


```
SendMessage Command1.hwnd, BM_SETIMAGE, 1&, ByVal hIcon
```

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


```
DestroyIcon hIcon
```

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

----------


## NeedSomeAnswers

Hi LaVolpe, i know this is an old tool but good work by the way.

I came across this thread by accident really and i have a question for you?

I tried your Manifest creator on an old VB6 progam we have at my work which we don't really wont to upgrade just yet and while it updates the look and feel of buttons and text boxes it does nothing to the Listviews & Toolbars. 

Is this expected? should they skin or not?

----------


## LaVolpe

> Hi LaVolpe, i know this is an old tool but good work by the way.
> 
> I came across this thread by accident really and i have a question for you?
> 
> I tried your Manifest creator on an old VB6 progam we have at my work which we don't really wont to upgrade just yet and while it updates the look and feel of buttons and text boxes it does nothing to the Listviews & Toolbars. 
> 
> Is this expected? should they skin or not?


Depends on which version of the common controls you are using. v5 is 'skinnable' v6 is not

----------


## NeedSomeAnswers

> Depends on which version of the common controls you are using. v5 is 'skinnable' v6 is not


Ah that makes things clear and explains why those specific controls were not skinning, thanks !!!

----------


## DEXWERX

I didn't see mentioned in this thread the alternative (UMMM) Unattended Make My Manifest, which can be used for strictly command line builds.
Although personally I usually hand edit UMMM output, and then add the file as a custom resource named 1, with resource type "#24"

Registration-Free COM is a godsend for distribution.

----------


## LaVolpe

> I didn't see mentioned in this thread the alternative (UMMM)....


Believe that was developed after this. Usually we here don't advertise our projects on other people's codebank submissions which is why you didn't see it mentioned

----------


## DEXWERX

> Believe that was developed after this. Usually we here don't advertise our projects on other people's codebank submissions which is why you didn't see it mentioned


my bad! just to clarify - i definitely can't take credit for wqweto/Vlad's project since 2009.

----------


## LaVolpe

> my bad! just to clarify - i definitely can't take credit for wqweto/Vlad's project since 2009.


No, I know who developed UMMM.  Just trying to make a point regarding codebank submissions. Now, in the general help portion of the forum, totally difference scenario. I may, for example, reference this project as an option to solve a particular problem. It is completely understandable and expected to see other posts that reference other projects/solutions

----------


## DEXWERX

> No, I know who developed UMMM.  Just trying to make a point regarding codebank submissions.


 Understood, I can see my comment is completely rude on a codebank post.
This project does a great job of making Manifests simple. Thanks for a great app!

----------


## Davor Geci

Hello,
I've search and didn't find a sollution how to use manifest (theming) within an vb6 ActiveX ocx control. Can this be done?

----------


## LaVolpe

I played with the idea and found a partial solution, but decided against it for one specific reason... If the OCX can render itself themed and the rest of the controls on the form are not themed, I'd think the user would not be happy. The OCX would not appear similar to other controls it is hosted with.

If interested, here is the thread I started on that same topic. You can take it from there if you want. I abandoned the idea.
http://www.vbforums.com/showthread.p...-is-manifested

----------


## Davor Geci

Thanks LaVolpe.

----------


## pantalone

Please could you tell why we need to add all this (below) to the Project?
I tried without it and everything works fine, buttons and controls looks good.


```
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
```

----------


## dilettante

> Please could you tell why we need to add all this (below) to the Project?
> I tried without it and everything works fine, buttons and controls looks good.


You don't need to call InitCommonControlsEx at all, so almost all of that is pointless overhead.  ActiveX containers and controls already take care of everything it might theoretically accomplish (i.e. they call it themselves).


What needs to happen for things to work and not crash is to first load shell32.dll and then load comctl32.dll (in that order) before the first VB Form or Control is loaded.  While you can skip one or both steps and get away with it sometimes, in other situations your program will just fail.  It seems to vary by program, controls used, Windows version, and some "secret sauce" we haven't uncovered yet.

The call to InitCommonControlsEx causes comctl32.dll to be loaded into your process' address space.  Nothing else that it does matters.  You can also just use the simpler InitCommonControls call and accomplish just as much.  Or you could explicitly call LoadLibrary on comctl32.dll instead.  Same result.

However if you didn't cause shell32.dll to load first you are still at risk of "mysterious aborts."  These seem to occur less frequently than if you failed to load comctl32.dll at all before loading a Form or Control, but they still occur.

Once again, you could use LoadLibrary on it, or just call some innocuous entrypoint in the library.  I like to use IsUserAnAdmin:



```
Private Declare Function IsUserAnAdmin Lib "shell32" () As Long
```

It's short and sweet, works every time.  You can call it as a subroutine since you don't care about its return value.  Just call it before calling InitCommonControls.

----------


## pantalone

Thank you.
Do I need to use all this code when I use external manifest file next to exe file?

----------


## dilettante

External manifests are deprecated and should not be used.  But ignoring that, nothing changes.

As I already said  in post #77, you don't need "all this code" anyway and just something like this is plenty:



```
Option Explicit

Private Declare Function InitCommonControls Lib "comctl32" () As Long
   
Private Declare Function IsUserAnAdmin Lib "shell32" () As Long

Private Sub InitCommonControlsVB()
    'Reliably cause these libraries to be loaded in the correct order
    'so that a Common Controls 6.0 manifest doesn't cause a crash.
    
    On Error Resume Next
    IsUserAnAdmin
    InitCommonControls
End Sub

Private Sub Main()
    InitCommonControlsVB
    Form1.Show
End Sub
```

----------


## putu.oka

Hello, It seem not working good in windows XP 32bit. The original text turn black see the picture below

----------


## Arnoutdv

If I remember correctly you have to put the Option controls in a PictureBox control, otherwise you get those black backgrounds.
It's not a bug in the manifest or the manifest creator.

----------


## putu.oka

> If I remember correctly you have to put the Option controls in a PictureBox control, otherwise you get those black backgrounds.
> It's not a bug in the manifest or the manifest creator.


Hi, i have explore this furthermore today that my option control button turn black if it put above frame control. besides that all is normal. in form, sstab,ect normal option button appear but when it put with frame control it's turn black. Any idea how to solved?

----------


## Arnoutdv

Yes, in the frame put a borderless picturebox control which is sized to inner width of the frame.
Then place the option control(s) in the picturebox.

----------


## Magic Ink

You may also find that Command buttons are shown with black rectangular borders in similar circumstances; treat them in the same manner as advised by Arno for the Option buttons.
Neither problem happens under Windows Vista and later.

----------


## Krool

> You may also find that Command buttons are shown with black rectangular borders in similar circumstances; treat them in the same manner as advised by Arno for the Option buttons.
> Neither problem happens under Windows Vista and later.


For Frame controls, which cause this, is a "fix" possible w/o the PictureBox workaround.

http://www.vbforums.com/showthread.p...es)&highlight=

Though this is actually a XP only bug, as you mentioned.

----------


## lmstearn

Much appreciated! Worked perfectly in XP 32bit Sp2.
Actually got the same manifest from other sources, but modifying it with PFE and XP notepad barfed the UTF8, or inserted wrong characters in somewhere.
Thank you for this fine project!

----------


## Urgentbody

Hi,
   (1) Created a manifest to my application making a textfile with .manifest extension and Res file as mentioned at #3. And got a shield at the App right bottom corner. 

Which helped to pass UAC. 
When i created a Res file using MC2 
The Manifest > Export Manifest (After Selecting the Required Check Boxes)
 and created .res file
Then attached the .res to the App (Saved a copy of App before  linking the Res file as in (1))
but after building the compilation file no shield this time to the bottom right corner of .exe file.
and upon run giving the following error message.

May be i have created the .res file wrongly.
Please suggest how to build .res file that will pas UAC and also support 32 bit .ico files.

----------


## LaVolpe

When that error occurs, the manifest is not technically correct. You'll need to look at your window events to see what portion of the file is triggering the error.

On Win10:
Open "Event Viewer" from your taskbar Windows button (RUN > eventvwr.msc /s)
Open the Windows Log section to view the Application events
Find the entry for your app.

Here's an example of one I found that applies to a Microsoft assembly



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


The last sentence should help narrow it down. In that case, the version format is a 4 part value: #.#.#.# (i.e., 1.0.0.0) not the two part one used: 1.0

Edited and a follow up. The above was resolved in another part of the forum. It appeared that the manifest was not dword-aligned when placed in the resource file. This is typically not an issue unless SP6 was not applied to VB. Prior to SP6, VB padded resources with null char bytes to ensure dword-aligned. Char 0 is an invalid character in XML/HTML and likely the reason for the error.

----------


## KenHorse

I know I'm late to the party but I only recently stumbled across this wonderful thread. 
I'm running into a few issues with using Creator II. Well...the issues are probably due to my misunderstandings as I've never dealt with manifests before this.

1) The theme changes don't seem to work if running within the IDE but do work if I compile and then run the executable (maybe this is normal, I don't know)

2) I only selected to use the Win 10 theme and I notice if I have a frame within another frame, the one inside, its title is bolded and a much larger font size than the 'container' frame. Is there a way around this?

3) My progress bars still look like VB6 ones not Win 10 ones

Screenshot attached

"Start" and "End" should be same font size (and non-bolded) as the "Daylight Savings" title of the parent frame. Notice the 'Start' and 'End' are also truncated.

----------


## LaVolpe

Lots of things to address:

1. Don't use this version, I am no longer supporting it. If you look at the 1st sentence in post #1, you'll see the link to the current version. Once there, I gave a bit of a summary why the new version was done.

2. Manifesting for common controls. You can get your IDE to work manifested with very little effort. I won't be addressing many questions on this thread as I am not supporting it any longer. In that other thread, there is a technique described for manifesting the IDE. If it doesn't seem to work, post a question there, I've since discovered a potentially easier method.

3. Fonts. Always use True-Type fonts, not the default font VB gives you. Simplest habit for new projects: before you add a single control to a new form, change the form's font immediately. Most controls later added to the form, inherit that font's properties.

----------


## KenHorse

I am using the new version (as my OP stated, I'm using Creator II).

I will move to the new thread, thanks.

----------


## LaVolpe

FYI for others. The problem is a bug that still isn't fixed when controls are added to frames and project is manifested. This frame in a frame solution is the same as how we got past it in the XP days --- add inner frame to picturebox, add picturebox to outer frame, change picturebox size/position/backcolor to taste, make it borderless

Edited: But don't use this version of the project anyway. Use the newer version linked to in the 1st posting. I've added comments to that thread regarding this problem.

----------


## mememe2

not sure if PMs work (tried sending one, and nothing happened), so posting here...

Hi! Came across your post here:
http://www.vbforums.com/showthread.p...57#post4810657

But I don't "get" how to use the loadimage function to get an icon applied to xp themed controls (I've searched but can't figure it out)...
if you have a moment, could you please just .zip up a project containing sample code with the icon in order to do that?

thanks very much!

----------


## LaVolpe

> But I don't "get" how to use the loadimage function to get an icon applied to xp themed controls (I've searched but can't figure it out)...
> if you have a moment, could you please just .zip up a project containing sample code with the icon in order to do that?


Recommend posting the question in the general VB forums section. Your question is not difficult to answer, but can result in multiple posts. I don't want this thread being used for other topics other than manifesting & I don't want this thread being resurrected with updated information. 

This thread is no longer being supported as noted at top of the 1st post.

----------

