when ever am adding MFC SysLink Control to my application , it forces the application to close , am using VC++ 11 , and am just dragging a syslink control tool to my dialog box, any clue why it forces the app to close?
I had similar problem. SysLink requires Common Control 6.0 defined in the manifest. I solved it by adding the following line in the project
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
You must set Generate manifest=yes in the properties-linker-manifest files.
Related
I have a simple project setup for an OpenGL-project for University.
An API project where every library I want to use (GLEW, GLFW, GLM) is linked statically. These libraries should be combined with my own API code into one single DLL file.
The other project should only have one dependency, the DLL. Throw that DLL it should get access to the API code and all libraries linked inside the API.
My problem is that inside the API I have access to all functions of all libraries I linked. But inside the actual project which has the API as a dependency, I can call the functions and the compiler throws out no error (of cause) because the function declaration is in the linked header files but the linker does not find the function definition inside the DLL, which mean the build of the API does not export the linked libraries into the DLL.
In the API project, I also defined the necessary preprocessor definitions:
I defined _GLFW_BUILD_DLL:
from "glfw3.h" l. 233-245
/* GLFWAPI is used to declare public API functions for export
* from the DLL / shared library / dynamic library.
*/
#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
/* We are building GLFW as a Win32 DLL */
#define GLFWAPI __declspec(dllexport) <----- this one is active
#elif defined(_WIN32) && defined(GLFW_DLL)
/* We are calling GLFW as a Win32 DLL */
#define GLFWAPI __declspec(dllimport)
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
/* We are building GLFW as a shared / dynamic library */
#define GLFWAPI __attribute__((visibility("default")))
#else
/* We are building or calling GLFW as a static library */
#define GLFWAPI
#endif
I defined GLEW_BUILD:
from "glew.h" l. 200-208
#ifdef GLEW_STATIC
#define GLEWAPI extern
#else
#ifdef GLEW_BUILD
#define GLEWAPI extern __declspec(dllexport) <---- this one is active
#else
#define GLEWAPI extern __declspec(dllimport)
#endif
#endif
Any help?
EDIT:
The linker options:
/OUT:"D:\Programmierung\C++-Projekte\CG-Project\CGAPI\bin\Debug\Win32\CGAPI.dll" /MANIFEST /NXCOMPAT /PDB:"D:\Programmierung\C++-Projekte\CG-Project\CGAPI\bin\Debug\Win32\CGAPI.pdb" /DYNAMICBASE "glew32s.lib" "glfw3.lib" "opengl32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"D:\Programmierung\C++-Projekte\CG-Project\CGAPI\bin\Debug\Win32\CGAPI.lib" /DEBUG /DLL /MACHINE:X86 /INCREMENTAL /PGD:"D:\Programmierung\C++-Projekte\CG-Project\CGAPI\bin\Debug\Win32\CGAPI.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:NO /ManifestFile:"D:\Programmierung\C++-Projekte\CG-Project\CGAPI\bin-int\Debug\Win32\CGAPI.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"D:\Programmierung\C++-Projekte\CG-Project\Dependencies\GLFW\Win32\lib-vc2019\" /LIBPATH:"D:\Programmierung\C++-Projekte\CG-Project\Dependencies\GLEW\lib\Release\Win32\" /TLBID:1
The one I added:
/WHOLEARCHIVE:glew32s.lib
/WHOLEARCHIVE:glfw3.lib
/WHOLEARCHIVE:opengl32.lib
EDIT 2:
So I had to download the source code from glew and build it myself and also I had to remove the .res file inside the option of my own glew build. Now the API builds successfully but the methods aren't part of the DLL. So nothing changed.
I don't fully understand your motivation for doing things this way. The common approach (that I'd also use) is shipping the OpenGL .dlls (I'm not aware of the licensing implications) along with yours.
However, even if this looks like an XY Problem, in order to achieve your goal, you could pass [MS.Docs]: /WHOLEARCHIVE (Include All Library Object Files) to the linker. In order to differentiate which .libs to include and which not, specify the flag once per each target library: /wholearchive:glew32.lib /wholearchive:glfw3.lib /wholearchive:glm.lib.
Check [SO]: Exporting symbols in static library that is linked to dynamic library (#CristiFati's answer) for more details.
As a note: the .libs must have been built with exportable symbols. If not, you'll have to export them "manually", using one of the other choices:
/EXPORT linker option
Module definition (.def) files
or rebuild the .lib as static but with exportable symbols. However, there's high chance it won't work OOTB (you'l probably need to modify a file or 2 or manually pass a compile flag), as it's not a normal way (most of the people would agree that's a NO-NO, especially for someone without a fairly deep know-how) of doing things.
This question already has answers here:
An XP style combobox in a DLL
(2 answers)
Closed 6 years ago.
I need to use Windows Common Controls v6.0 to see new style UIs.
I know I can do it by a manifest dependency but when I haven't access to the manifest (or source code... it's not my app but I have a DLL which will be attached to the process and every CommCtrls I need will be called from that DLL) what should I do to specify Windows Common Controls version for that process? Is there any API or someway to do it?
[By the way, I'm using C++ & VS2015]
Try this in your DLL:
#if defined(_M_IX86)
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined(_M_X64)
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
I have a ListCtrl in one of the dialog of a mfc application. I want to change the column name style and the button style to look more like win7 themed. this is the old dialog with the listCtrl in right.
what I want to change the top row of the table and the buttons to something like this ,
can this be done by changing any style by doing m_ElementListCtrl.SetExtendedStyle(..) ? or chaning some of its properties ?
Hi If your app is Unicode(otherwise there is some problems) you need to use Common controls 6.
In your stdafx.h file you probably could see this kind of code , if no , just add it in the end of file, if you change your app to UNICODE you will see controls with new style.
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32'name='Microsoft.Windows.Common-Controls' version='6.0.0.0'processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
Also check Project Properties -> linker-> Manifest File-> Generate Manifest should be set on Yes (/MANIFEST)
I tried using something like this to set the tool tip of a CMenu item (as described here) but it is just being displayed in a single line and the line break is not visible.
// read control id
UINT id = menu->GetMenuItemID(1235);
// modify caption and add tooltip?
menu->ModifyMenu( id, MF_BYCOMMAND, id, "Click here\nThis is the tooltip for the menu item ...");
I also tried to set the caption directly in the visual studio resource designer of the menu item with the same effect.
Can you give me any hints on whats wrong? I am using VS2008 on windows 7.
Any help is appreciated!
Perhaps you have not added the windows xp common controls to your application.
Try adding the common controls to your stdafx.h:
#ifdef UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
Looks like an duplicate
Mainly you should use \r\n instead of \n because this is what mfc expects.
I am writing several C++ libraries inside of visual studio. I know I can use the Version Resource to assign DLL's a version, product name, and so on but is there a way that I can swap out different Resource scripts depending on my configuration settings. For instance, say I am compiling for x86 I want the product name to be x86, likewise for x64 I want the product name to be x64.
You can use #ifdefs in resource files. But using #ifdefs directly in he resource files, can sometimes screw with the IDE's resource editor (it has happened for me in Visual Studio 2008). I would therefore create two resource files (e.g. resource-x86.rc and resource-x64.rc) and include them in the main rc file like this:
#ifdef X86
#include "resource-x86.rc"
#elif X64
#include "resource-x64.rc"
#else
#error Unsupported platform!
#endif
copied from here
--
Open your project in Visual Studio
Right click on resource script file (e.g. app.rc) and select "Properties"
At the top of the property page, select one platform like "Win32" or "x64".
In the left menu bar, select [Configuration Properties] / [Resources] / [General].
In the "Preprocessor Definitions" field, add "WIN32" for "Win32" platform and "WIN64" for "x64" platform. The field value will become "WINXX;_UNICODE;UNICODE". (XX will be 32 or 64)
Click OK to close the window.
Right click on resource script file (e.g. app.rc) and select "View Code".
In the code editor, add #ifdef and #elif to conditionally include resources when compiling. Use "WIN32" and "WIN64" preprocessor definitions that we defined just now.
Here is a sample code:
--------------------------------
#ifdef WIN32
IDB_BITMAP1 BITMAP "bitmap1.bmp"
IDB_BITMAP2 BITMAP "bitmap2.bmp"
#elif WIN64
IDR_TOOLBAR1 BITMAP "toolbar1.bmp"
IDI_ICON1 ICON "icon1.ico"
#endif
--------------------------------
Save the resource script file and compile the project in different platforms.