I have upgraded from Visual Studio 2010 to Visual Studio 2013.
I have also installed the Multibyte MFC Library for Visual Studio 2013.
Since upgrading, the visual styles no longer apply to the controls created in the MFC dialogs.
I will point out that Visual Studio previews (renders) it semi correctly (wrong background but generally the correct controls), it's only at runtime (Debug or Release etc) does this strange change happen.
I have added a new MFC application to my current solution. When I debug this MFC app it renders with Visual Styles.
Edit
I have followed the advice found in How to enable visual styles without a manifest
This means, in the MFC project I have a stdafx.h. Since I'm using a version later than VS2005 (and since there is no manifest file), I have added the following to stdafx.h
#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
Edit
If it matters, this project's default Character Set is set to Use Multi-Byte Character Set
Edit
There is no manifest file for this project. It is embedded.
Edit
Comparing the .exe file (opened with notepad) of the VS2010 build and VS2013 build shows the same manifest file with 1 exception
VS2010
<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</ms_windowsSettings:dpiAware>
VS2013
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
However, I don't see how the DPI would affect this.
Edit
I've just realised there is another project in this solution which also uses MFC dialogs. The same issue persists to that as well.
Update
I have ensured the project settings are as identical between a new MFC project and my C++ projects (with the difference being MFC exports to an Application where as I export my project to a .dll)
I have ensured the stafx.h in my project is the same as a new MFC project (with the difference that my C++ project requires ActiveX Control includes)
Please note, the manifest is embedded, and was created via the properties pane. There was no manually configured xml file.
Very hard to guess what could possibly have gone wrong in the project conversion. Or for that matter how you ensured in VS2010 that the proper manifest was generated for the program. You really need to address that detail in your question.
Noodling a bit about it, pretty crucial these days to ensure that an EXE file has a good manifest. Not just important to enable Visual Styles, it also declares the program compatible with UAC. That manifest should always be embedded as a resource, not deployed as a separate file. Done by the linker. The #pragmas you added can only work when the linker embeds the manifest.
You can double-check that this manifest is embedded properly with File > Open > File > select the EXE from your build directory. Try this with c:\windows\notepad.exe for comparison. You should see the RT_MANIFEST node, open it to see resource ID #1. You can double-click it to see the content, but that gives a hex-dump that is hard to read. Alternative is to right-click it > Export > save to a file with a .txt extension and open it in your text editor.
And you'll want to check your project's build options to ensure that manifest generation is enabled. Best to do so by starting VS again and creating a new MFC project with the wizard, allowing you to compare known-good settings with your project's settings. The ones you want to compare are located in Linker > Manifest File and Manifest Tool > all settings.
Related
I'm debugging some code from within the Unity editor that starts with #if UNITY_EDITOR, but UNITY_EDITOR isn't getting defined though I'm running Visual Studio through the Unity editor. I've tried
Ensuring that I've got Visual Studio set in Debug mode (vs. Release)
The Scripting Define Symbols settings, and msc and csc solutions from here: http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html?_ga=2.148389495.1394951635.1638832224-1796620461.1636419298
I've also tried to just add a #define to the project sheets that Unity is generating, which doesn't work because there's no project files that these files are being opened & debugged through. And, I've regenerated solution files. What am I missing? Thank you!
Edit:
Some additional important information: this behavior isn't happening in all files within the Visual Studio instance, just files that are NOT included inside of any of the the .csproj's in the solution I have open. So, my workspace is .csproj's that do have UNITY_EDITOR defined, but the file I'm opening is from outside of that project. In this case, the .cs file I'm trying to debug into is from a package that is running, so the debugger will drop into it, but no .csproj is generated for this package.
It seems to me that there should be different behavior here, but I'm not sure what it is. Should Unity create a .csproj for packages whose .cs files you can debug into so that you can view them correctly in Visual Studio?
So, finally: in the context of the existing .csproj's that I have open, if I add a line <Compile Include="Full\Path\To\File.cs" />, it works as desired. Kludgy, but it works for my purposes.
In one of the existing .csproj's that I have open, if I add a line , it works as desired. Kludgy, but it works for my purposes.
I have a legacy project that used to be build in Visual C++ 2005 Express, and it depends on a certain third party DLL. As far as I can tell it doesn't come with a lib or header file.
The project compiles fine in Visual C++ 2005, here is a screenshot showing the DLL visible and browsable in the object explorer. The code can also use it without #include or anything like that, which is pretty weird.
Importing the project into Visual Studio 2019 works as well, the code can still use the DLL and it is listed under both the dependencies and the references:
I now want to achieve the same thing in a new project, but I cannot figure out how to register the DLL as a dependency. Things I found online and tried:
"Just include the header or lib file" doesn't work, I don't have one
LoadLibrary() and GetProcAddress() are awfully contrived and don't seem necessary because it's clearly possible without.
Create your own lib file doesn't work either, dumpbin doesn't show any symbols for my DLL: image
How do I register the DLL as a dependency? And where does Visual C++ 2005 get the list of methods in the DLL from is the first place?
I just installed Visual Studio 2012 express for Desktop. I can't see any place to create a GUI application with C++ ! Where is this "Windows Form Application" used to exists in Visual C++ 2010 ? Where are these drag and drop controls? I installed this because I got details telling this supports GUI intellisense (Visual C++: Unable to invoke method from another class)
It is an unsubtle hint that they want you to stop creating C++/CLI Winforms applications. The plumbing is still in place however, at least for VS2012 and VS2013. This might not be the case in a future one.
You can turn a CLR console application into a Winforms application with these steps:
Start with File + New + Project, CLR node, CLR Console Application
Project + Add New Item, UI node, Windows Form
Project + Properties, Linker, System, SubSystem = Windows
Project + Properties, Linker, Advanced, Entry Point = main
Change the pre-generated .cpp file to look like this:
#include "stdafx.h"
#include "MyForm.h"
namespace ConsoleApplication45 { // Change this!!
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew MyForm());
return 0;
}
}
Note that you'll need to change the namespace name to your project name. Press F5 to test. You can design the form as normal once everything checks out.
NOTE, Visual Studio 2015 has a nasty static initialization order bug in the CRT that can cause the app to crash instantly with an AVE at startup if the project contains any native C++ code. As yet an unfixed bug, the somewhat inevitable hazard of having these project templates removed. A possible workaround is to change the Entry Point (4th bullet).
For a project that targets x86, copy paste this string:
?mainCRTStartupStrArray##$$FYMHP$01AP$AAVString#System###Z
For a project that targets x64, copy paste:
?mainCRTStartupStrArray##$$FYMHP$01EAPE$AAVString#System###Z
Somewhere around VS2017 the designer fails to open a new form with a cryptic error message. Workaround is to build the project first, use Build > Build.
Remove the #include "stdafx.h" and this works well for VS 2022. The form must be hand coded since the Form Designer support was removed starting with VS 2012.
I have an application that uses windows.h but I am tasked with removing the calls to Windows functions.
I am using Visual Studio Express 2010 and when I delete the #include "windows.h" line the code is still able to compile and I can right click and "Go To Definition" for all the variables associate with the windows include file.
I removed $(WindowsSdkDir)include; from the VC++ Directories in the Configuration Properties page but that didn't seem to make a difference. I believed that could be the case because windows.h can be found at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windows.h on my computer.
How do I completely break this link so Visual Studio can give me errors for all calls to that library?
Use the /showIncludes command switch to search for indirect includes of windows.h
http://msdn.microsoft.com/en-us/library/hdkef6tk.aspx
Any suggestions on how one could go about setting up a build system that would compile one or two libraries against a couple of different platforms/targets.
The main project is in Visual Studio.
For example, I have a library:
nav.lib
It compiles on Windows and Linux with a few tweaks.
The executable that uses the library, win_nav.lib, only compiles on Windows at the moment with OpenGL.
I'm porting this code to the iPhone. Although I know I can't compile and link the entire library on windows I would like to try to compile the graphics code with OpenGL includes and OpenGLES includes. (Perhaps I can test out my opengles code on the windows machine as well?)
I plan to change my graphics file to include based on preprocessor flags:
#ifdef USE_OPEN_GL_FULL
#include <opengl/gl.h>
#else
#include <opengles/gl.h>
#endif
So, how would you go about doing this?
Using a couple of different scripts or different projects in Visual Studio?
This is what "Solution Configurations" are for. By default Visual Studio creates Release and Debug configurations, but you can add your own custom configurations too. The Project options are different for each configuration, so just set your #define in the configuration that needs it.
When you are running your automated build you just set the /build parameter to the name of the configuration you want to compile with.
Within VS you can use the Configuration Manager to target different builds and use different libraries within your code.