Pelles C forum

C language => Beginner questions => Topic started by: avcaballero on August 24, 2015, 08:25:10 AM

Title: XML Manifest
Post by: avcaballero on August 24, 2015, 08:25:10 AM
Hello. I have created a PellesC project with the Win32 wizard. At this point everything is ok, compiles and executes right, but when I add a xml manifest, compiles ok, but fails when try to execute it.

Any help, please?
Thank you
Title: Re: XML Manifest
Post by: Stefan Pendl on August 24, 2015, 11:48:30 AM
You can't comment out an attribute of a node as you did with the processor architecture.
Remove the entire attribute of the AMD64 architecture and you are good to go.

Very bad
Code: [Select]
<assemblyIdentity
    type="win32"
    name="MyOrganization.MyDivision.MyApp"
    version="1.0.0.0"
    <!-- processorArchitecture="amd64" -->
    processorArchitecture="X86"
/>

Good
Code: [Select]
<assemblyIdentity
    type="win32"
    name="MyOrganization.MyDivision.MyApp"
    version="1.0.0.0"
    processorArchitecture="X86"
/>
Title: Re: XML Manifest
Post by: avcaballero on August 24, 2015, 12:51:03 PM
Thank you Stefan, now it works fine. Just one thing, I didn't do anything, this is how it comes by default.

Thank you again  :).
Title: Re: XML Manifest
Post by: avcaballero on August 24, 2015, 01:21:24 PM
Hello again. The main reason to adding the xml manifest file is to creating an ico/bmp button with text. However, it doesn't show anything and, if I try to create a debug point in line 86, the application break up on debug-running. Any idea? Thank you.
Title: Re: XML Manifest
Post by: TimoVJL on August 24, 2015, 05:01:35 PM
Use button style BS_BITMAP
Title: Re: XML Manifest
Post by: avcaballero on August 25, 2015, 08:38:12 AM
No, it has to be BS_TEXT, ie 0 by default. So we can paint ico/bmp and text in the same button. For example, the same project in FASM.

Code: [Select]
        invoke    CreateWindowEx,WS_EX_LEFT, \
                          szClaseBoton, \
                          szBut01, \
                          WS_CHILD + WS_VISIBLE + BS_TEXT, \
                          cdXCol1,cdYCol+cdYAlto*0,cdXAncho1,cdYAlto, \
                          [hWnd],cdIdBoton+0, \
                          [wc.hInstance],NULL
        mov       [hBtn1], eax
        invoke    CreateWindowEx,WS_EX_LEFT, \
                          szClaseBoton, \
                          szBut02, \
                          WS_CHILD + WS_VISIBLE + BS_TEXT, \
                          cdXCol1,cdYCol+cdYAlto*1,cdXAncho1,cdYAlto, \
                          [hWnd],cdIdBoton+1, \
                          [wc.hInstance],NULL
        mov       [hBtn2], eax

Regards.
Title: Re: XML Manifest
Post by: TimoVJL on August 25, 2015, 07:35:30 PM
OK. Give that string in that CreateWindowEx call.
Title: Re: XML Manifest
Post by: avcaballero on August 26, 2015, 08:35:01 AM
Wow, what oversight, thank you very much.
Title: Re: XML Manifest
Post by: jj2007 on August 27, 2015, 10:50:45 AM
Code: [Select]
WS_CHILD + WS_VISIBLE + BS_TEXT
better:
Code: [Select]
WS_CHILD | WS_VISIBLE | BS_TEXT
No problem in 99% of all cases, and no problem here, but occasionally the Windows API plays foul.

Any idea why compiling this code produces two linker errors (with #include <windows.h>)?
Code: [Select]
POLINK: error: Unresolved external symbol '__imp__CreateSolidBrush@4'.
POLINK: error: Unresolved external symbol '__imp__DeleteObject@4'.

P.S.: Solved with #pragma comment(linker, "gdi32.lib")
Title: Re: XML Manifest
Post by: avcaballero on August 27, 2015, 12:33:39 PM
Hello, jj.

As long as I know, it's the same using '+' than '|' because all of these constants are designed to be binary independent, ie

0  = 000
2  = 010
3  = 011 <-- This one wouldn't exists because overlap 2 in the second bit
4  = 100

That's because there wouldn't be 3, for example. So 2+4 = 2|4. Maybe there're some constants that are not compatible with others because they are not binary independent for the same propose.

This is in this way for you can get the style of a window and tell if any property is activated isolating it with an "&"

Any one has any other info regarding this subject?


Do you have any compiler failure with this code? I compile and execute it without problems...
Title: Re: XML Manifest
Post by: jj2007 on August 27, 2015, 10:23:34 PM
As long as I know, it's the same using '+' than '|' because all of these constants are designed to be binary independent

Indeed, but 'occasionally the Windows API plays foul' ;-)

Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
  Init
  mov eax, WS_EX_OVERLAPPEDWINDOW+WS_EX_CLIENTEDGE+WS_EX_WINDOWEDGE
  mov ebx, WS_EX_OVERLAPPEDWINDOW or WS_EX_CLIENTEDGE or WS_EX_WINDOWEDGE
  deb 4, "Windows plays foul", b:eax, b:ebx
  Exit
end start

Output:
Windows plays foul
b:eax           00000000000000000000011000000000
b:ebx           00000000000000000000001100000000
Title: Re: XML Manifest
Post by: avcaballero on August 28, 2015, 11:28:28 AM
Hello.

WS_EX_OVERLAPPEDWINDOW (https://msdn.microsoft.com/es-es/library/windows/desktop/ff700543(v=vs.85).aspx) = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
The window is an overlapped window.
Code: [Select]
#define WS_EX_WINDOWEDGE   0x00000100L  = 0100000000b
#define WS_EX_CLIENTEDGE   0x00000200L  = 1000000000b
So, WS_EX_OVERLAPPEDWINDOW              = 1100000000b
Thus, if you do WS_EX_OVERLAPPEDWINDOW | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE, you ensure that WS_EX_OVERLAPPEDWINDOW = WS_EX_OVERLAPPEDWINDOW = 1100000000b

On the contrary, if you do WS_EX_OVERLAPPEDWINDOW + WS_EX_WINDOWEDGE + WS_EX_CLIENTEDGE, in fact you are doing WS_EX_OVERLAPPEDWINDOW + WS_EX_OVERLAPPEDWINDOW  :o

Regards
Title: Re: XML Manifest
Post by: jj2007 on August 28, 2015, 02:12:47 PM
Exactly. And since you can hardly control, every time you see a Windows constant, if it's "pure" or "combined" (there aren't many, but they do exist), it's generally a good idea to always use the or operator "|" instead of the "+".
Title: Re: XML Manifest
Post by: Grincheux on February 12, 2016, 07:57:53 PM
Here is the manifest I use. Pelle's manifests are wrong. It is compatible from Vista to Windows 10 :

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

<assemblyIdentity
    type="win32"
    name="MyOrganization.MyDivision.MyApp"
    version="1.0.0.0"
    processorArchitecture="amd64"
/>

<description>Verbal description of MyApp.</description>

<dependency>
  <dependentAssembly>
    <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="amd64"
        publicKeyToken="6595b64144ccf1df"
        language="*"
    />
  </dependentAssembly>
</dependency>

   <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
       <application>
           <!-- Windows Vista -->
           <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
           <!-- Windows 7 -->
           <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
           <!-- Windows 8 -->
           <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
           <!-- Windows 8.1 -->
           <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
           <!-- Windows 10 -->
           <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
       </application>
   </compatibility>
</assembly>

And if you call GetVersion you have the correct windows version.

http://www.phrio.biz/mediawiki/Windows_Manifest (http://www.phrio.biz/mediawiki/Windows_Manifest)