LoadImage unexpected size LR_DEFAULTSIZE
If I am reading the documentation correctly then the following call should return a bitmap of dimensions cx,cy. However it does not. Am I doing something wrong? The IDB_BITMAP1 is 16x16 pixels.
HBITMAP hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE); ::GetObject(hBmp, sizeof(BITMAP), &bmp); int cx = GetSystemMetrics(SM_CXICON); int cy = GetSystemMetrics(SM_CYICON);
results: cx=32, cy=32, bmp.Width=16, bmp.Height=16
See also questions close to this topic
Can we generate CPP files out of WINRT/header files?
I see that we've a bunch of header files and references(winmd) ,in windows 10 SDK. Is there any way I can generate cpp files as well out of these so that I can compile all of them together and create a library out of this ?
Basically, what I want is : I do not want to include the publicly available WINRT header files inside my app directly. Instead, I want to create a WINRT library with all the WINRT definitions which can be referred/linked to in my app. I'll expose the required definitions via some subset of header files.
Let me know if this is possible.
Thanks in advance.
Generically adding object file to Link task in MSBuild in addition to existing linked files
I'm trying to add an additional object file to the automatic linking process using MSBuild.
The reason why is best explained with some background information (WARNING: wall of text looming).
We develop applications based on the Qt5 Framework. A part of the process is to embed translation (.qm) files into a resource dll using the Qt resource manager. This has worked great for many years, but recently we bumped into the (apparently wellknown and dreaded) "C1060: Compiler is out of heap space" error.
This happens because Qt's resource compiler (RCC) creates an increasingly large .cpp file containing the embedded resources. At some point that file is too large for the compiler to handle (we hit the limit at approx. 60 MB).
Googling the issue usually results in recommendations to use "CONFIG += resources_big" (undocumented by the way) in the project's .pro file. The problem for us is, we do not use .pro files, but Visual Studio's MSBuild.
Some further googling shows what "CONFIG += resources_big" actually does.
Instead of generating a (huge) .cpp file using the usual syntax
rcc.exe my_resources.qrc -o qrc_my_resources.cpp
a three-stage approach is applied using the (equally undocumented) RCC parameters -pass 1 and -pass 2.
First you create a special .cpp file which allocates the necessary space
rcc.exe my_resources.qrc -pass 1 -o qrc_my_resources.cpp
Then you explicitly call the compiler on this particular .cpp file
cl.exe /c /Zl qrc_my_resources.cpp -Foqrc_my_resources.tmp
This creates an object file padded mainly with zeros. Parameter /c causes that no linking occurs and /Zl makes sure no default library calls are embedded (otherwise you'd get linker errors later).
The third and final stage is to call RCC again and have it fill the empty space in the object file with the actual binary data.
rcc.exe my_resources.qrc -pass 2 -temp qrc_my_resources.tmp -o qrc_my_resources.obj
Now we have our final object file containing all the resources without causing the dreaded C1060 error. However, we now also have a problem because we need to tell the linker to use our object file in addition to the automatically generated list of object files provided by cl.exe for all the files that weren't compiled with /c.
Further complications arise, since an ex-employee created a very intricate MSBuild solution. Specifically to deal with automatically RCC'ing Qt resource files he created the following properties (the TemporaryFileName and ObjectFileName elements are my addition).
<PropertyGroup> <QtToolsIntermediateDir>$(IntermediateOutputPath)GeneratedFiles</QtToolsIntermediateDir> </PropertyGroup> <ItemDefinitionGroup> <QtRCC> <OutputFileName>$(QtToolsIntermediateDir)\qrc_%(FileName).cpp</OutputFileName> <TemporaryFileName>$(IntermediateOutputPath)\qrc_%(FileName).tmp</TemporaryFileName> <ObjectFileName>$(IntermediateOutputPath)\qrc_%(FileName).obj</ObjectFileName> </QtRCC> </ItemDefinitionGroup>
In a special .targets file he defined the automatic resource compilation like this
<Target Name="QtRCC" BeforeTargets="CustomBuild" DependsOnTargets="QtToolsEnsureOutputDir" Inputs="%(QtRCC.Dependencies)" Outputs="%(QtRCC.OutputFileName)"> <Message Text="RCC'ing @(QtRCC)..."/> <Exec Command="$(MSBuildThisFileDirectory)tools\rcc.exe -name %22%(QtRCC.FileName)%22 -no-compress %22%(FullPath)%22 -o %(QtRCC.OutputFileName)"/> </Target>
which results in the "normal" compilation process (the one resulting in a huge .cpp file).
I exchanged that for the three-stage approach described above
<Exec Command="$(MSBuildThisFileDirectory)tools\rcc.exe -name %22%(QtRCC.FileName)%22 -no-compress %22%(FullPath)%22 -pass 1 -o %(QtRCC.OutputFileName)"/> <Exec Command="cl.exe -c -Zl %(QtRCC.OutputFileName) -Fo%(QtRCC.TemporaryFileName)"/> <Exec Command="$(MSBuildThisFileDirectory)tools\rcc.exe -name %22%(QtRCC.FileName)%22 -no-compress %22%(FullPath)%22 -pass 2 -temp %(QtRCC.TemporaryFileName) -o %(QtRCC.ObjectFileName)"/>
This works exactly as intended but again has the same problem also stated above. Namely, that I now have an object file which I need the linker to link in addition to all the automatically generated link targets.
I have found one solution, but it's one I really want to avoid. This solution is to manually add the object file containing the resources in the AdditionalDependencies section of the Link task of every project file that may use a Qt resource file.
<Link> <AdditionalDependencies>$(IntermediateOutputPath)\qrc_my_resources.obj;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5PrintSupport.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link>
I would very much like to have this in a generic place like the aforementioned .targets or .props files. Is that possible? And if so, how?
How to convert c++ .dll to c#?
I had two .dll files in c++, I need to use them both in c#. So I compiled both in c# independently.
In c++ project they called both .dll in separate menu button as volume mesh and background mesh(name of a button). When I tried to call the compiled .dll in c# using button click I am not able to see nothing.
How I called my code is like, using a process I called the compiled .dll in button click.
Please provide me with some example to solve my problem.