visual-c++

How to disable auto document/view creation when MFC application first starts

扶醉桌前 提交于 2020-01-24 23:03:59
问题 I have a regular MFC application which uses Doc/View architecture. When the application starts it automatically creates a view of an empty document. I want to disable this automatic view on startup and show a view only when the user clicks on "New Document" from the File menu. Is there any way to do so? CMultiDocTemplate* template = new CMultiDocTemplate(IDR_DorlionTYPE, RUNTIME_CLASS(CDocument), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CView)); if (!CView) return

how can i create an excel file using Interop on c++

*爱你&永不变心* 提交于 2020-01-24 21:31:48
问题 I've searched a lot of info, about the easiest way to create and edit excel files to save some login and passwords of my program. I've seen lots of C# methods and I don't understand it a lot. I've added a reference to Visual Studio 2010 Microsoft.Office.Interop.Excel (I'm using Office 2010). I don't know how to take this further, however; what headers should I add, what else should I do? I can't find any tutorial of C++ using this on their projects. I just want something simple. EDIT: I will

Unexplainable error “Please use the /MD switch for _AFXDLL builds”

别等时光非礼了梦想. 提交于 2020-01-24 21:13:29
问题 I use VisualStudio2010 and CMake 2.8.12.1. I created a CMakeLists.txt for a MFC project. MFC capability was done by following lines in the CMake file: add_definitions(-D_AFXDLL) #enables MFC set(CMAKE_MFC_FLAG 2) #use shared MFC library Furthermore the project will be build with MD as runtime library (default). But now I want my project to be build as MT (which also requires to specify static MFC library). So I replaced the lines above with: add_definitions(-D_AFXDLL) #enables MFC set(CMAKE

QPainter painter object outside paintevent

自作多情 提交于 2020-01-24 20:57:25
问题 I am trying to draw a simple two dimensional figure in a QWidget window. There is a paintEvent defined and a painter object of the QPainter class is also defined. My drawing contains elements which I need to draw more than once at various locations, such as lines, text etc. For this purpose, I am using functions to draw these lines with varying positions. Similarly for text. In order to make the program shorter, also modular. The paintEvent function is calling functions which are used to

Return local character array from a function [duplicate]

感情迁移 提交于 2020-01-24 20:13:25
问题 This question already has answers here : Can a local variable's memory be accessed outside its scope? (20 answers) Closed 6 years ago . How to return a local character array from one function char* testfunction() { char array[] = "Hello World"; return array; } char main() { char* array = testfunction(); printf(" %s -> string", array); return 0; } THis code results unknown error �@$�@<��Ʉ؅�;���Y@��� -> string 回答1: You should not return the address of the stack variable directly as it is

How to wrap a win32 WndProc into a C++ class?

匆匆过客 提交于 2020-01-24 15:42:51
问题 Is this even possible? For example, let's say I have the following: class Window { private: WNDCLASSEX wc; public: inline WNDCLASSEX getWindowClass() { return wc; } Window(); LRESULT CALLBACK WndProc(HWND hwnd, UINT message, LPARAM lParam, WPARAM wParam); } void RegisterWindow(Window win) { WNDCLASSEX* wc = win.getWindowClass(); RegisterClassEx(wc); } Now, somewhere there is going to be a section (probably in the constructor of the Window class, where it's necessary to assign the WNDCLASSEX a

Error : Class A uses Class B, which is being defined

末鹿安然 提交于 2020-01-24 13:43:21
问题 I have a C++ project that I've successfully wrapped with .NET classes using C++/CLI. I'm defining the wrapper classes in a .h file. I'm currently getting Error C2460: Mixer uses Track, which is being defined . As you can see in the code below, Mixer uses Track in the var MainTrack and Track also uses Mixer in the var Parent . How do I get these 2 classes linked to each other and compile successfully? #ifndef CPP_MIXER_NET_H #define CPP_MIXER_NET_H #pragma managed // Mixer class public ref

Error : Class A uses Class B, which is being defined

…衆ロ難τιáo~ 提交于 2020-01-24 13:42:09
问题 I have a C++ project that I've successfully wrapped with .NET classes using C++/CLI. I'm defining the wrapper classes in a .h file. I'm currently getting Error C2460: Mixer uses Track, which is being defined . As you can see in the code below, Mixer uses Track in the var MainTrack and Track also uses Mixer in the var Parent . How do I get these 2 classes linked to each other and compile successfully? #ifndef CPP_MIXER_NET_H #define CPP_MIXER_NET_H #pragma managed // Mixer class public ref

What's the reason for this no-op while-loop used for assert macro?

孤街浪徒 提交于 2020-01-24 12:18:28
问题 I'm reviewing a codebase where assert macro is expanded like this in non-debug configurations: #define assert( what ) while( 0 )( ( void )1 ) which I don't quite get. Obviously the goal is to have a no-op. Then why not expand into an empty string? #define assert( what ) What's the reason for this no-op loop? 回答1: Most likely to avoid compiler warnings. Check whether this code provokes a warning about an empty statement: if (foo); If it does, then do you want the same warning in release mode

how check is .NET framework installed or not

岁酱吖の 提交于 2020-01-24 11:43:28
问题 I want to develop a .NET application in c# but first i need to check that the .NET framework is installed , because i don't want user see any error. so is there any vc++ code that only use MFC in a static Library to check if .NET framework is installed ? 回答1: You can use the registry to check about .net framework and it's version, Either you you use VC++ or some other language that can handle registry.. Check Micrsoft Knowledge Base Article - How to determine which versions and service pack