News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Bizarre

Started by Grincheux, February 26, 2016, 08:27:23 PM

Previous topic - Next topic

TimoVJL

I like that simple macro that John prefers.
without rect pointer that macro is useless?
warning #2130: Result of comparison is constant.
May the source be with you

frankie

#16
Sorry John, I don't understand what's wrong.
Please try this code:

#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#undef SNDMSG
#define SNDMSG myfunc
BOOL myfunc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PRECT prc = (PRECT)lParam;
printf("hwnd=%p, msg=%u, prc=%p, left=%d, wParam=%d\n", hwnd, msg, prc, prc ? prc->left : 0, wParam);
return TRUE;
}

void foo(PRECT prc)
{
//Here we don't get 'comparison constant' because prc is defined outside
ListView_GetItemRect(NULL, 10, prc,  20);
}

int main(int argn, char **args)
{
RECT rc;
//Here we got a 'comparison constant' because rc is defined here
ListView_GetItemRect(NULL, 10, &rc,  20);
ListView_GetItemRect(NULL, 10, NULL, 20);
foo(&rc);
        return 0;
}

This is a simple test for the list view macros, and as I can see it works.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

frankie

#17
Timo, see my updated sample that shows that the macro is correct.
The scope of the test is to avoid an exception when the user pass a null pointer. Because inside SendMessage no exception is generated, and the function simply fails, to let have an exception in the macro is to like to modify the standard behavior of SendMessage.
For these reasons the macro is correct IMHO.
About the
Quotewarning #2130: Result of comparison is constant.
message it is correct. See my code in previous post, it is generated only in the main where it is known to the compiler that rc exists. In this case the comparison is always true and the dead code, for comparison, is removed (this is the sense of the warning).
This is confirmed in the function foo where the warning is not generated because the pointer is defined outside and the camparison result is unknown at compile time.

P.S. To be noted that even on the line where we pass a NULL for rectangle pointer the compiler doesn't generate the warning. Maybe this conditional is resolved at preprocessor level?
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

Thank you for your research. :D

Grincheux

The problem comes from the manifest file. It is created by MSVC and set in ressources for Pelles. If I use the Pelle's manifest the result is the same.

frankie

Great!  :)
No bugs then  ;)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

I try to get the manifest created by MSVC and to import it into a ressoucre for Pelle and say to MSVC that it must use the rc manifest!
Thank for your help

Grincheux

#22
Here is the manifest found in ImageViewer.exe (Version MSVC)

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

And here is what I put in Pelle's version :

Quote<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity processorArchitecture="amd64" version="1.0.0.0" name="MyOrganization.MyDivision.MyApp" type="win32"/>
<description>Verbal description of MyApp.</description>
-<dependency>
-<dependentAssembly>
<assemblyIdentity language="*" processorArchitecture="amd64" version="6.0.0.0" name="Microsoft.Windows.Common-Controls" type="win32" publicKeyToken="6595b64144ccf1df"/>
</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>

Extracted with Ressources Hacker.

TimoVJL

#23
In Visual Studio 2008:
Project option -> Manifest Tool -> Input and Output -> Additional Manifest Files
May the source be with you

Grincheux

That's what I already made.
But the outline color must be drawn only when I click on a image, not always.
If there is no manisfest I get my result.
Thanks

Philippe

Grincheux

#25
That's what I already made.
But the outline color must be drawn only when I click on a image, not always.
If there is no manisfest I get my result.

QuoteLVS_EX_BORDERSELECT Version 4.71 and later. Changes border color when an item is selected, instead of highlighting the item.


QuoteSendMessage(hListView,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_BORDERSELECT|LVS_EX_DOUBLEBUFFER|LVS_EX_AUTOAUTOARRANGE,LVS_EX_BORDERSELECT|LVS_EX_DOUBLEBUFFER|LVS_EX_AUTOAUTOARRANGE) ;
Thanks

Philippe

Grincheux

You know ImageViewer than I!

I replaced the value in ImageViewer.ini and re-set the manifest for both MSVC and Pelle, all is OK.

Thank you for people who helped me without you I had not the answer to my problem.

I made a site for ImageViewer but members of this forum can access source files here.

I put the software in donationware.

Grincheux

The program that I wrote is not extraordinary , but it makes things that other
they do not do.
I tried to minimize the dialog boxes, there are only two , because I do not like them.
Perhaps that this software will help someone and whether he can bring me a few euros , why not.
Finally, I did not do it for the money but for the fun of programming .
I wish I have no gift for graphics, the interface would surely have been more beautiful.
I will continue to evolve , now a crazy idea is outstanding gestation ,
but I gladly accept your ideas.

Thank you , Frankie , Timo & John .

Philippe