Visual studio 2017 flatten class hierarchy in watch - visual-studio-2017

Is there a way to indicate to Visual Studio 2017 that I want to view my objects in the Watch window like before: not flatten?
For an unknown reason, in a Watch if I drag and drop an object that inherits from a base object, all the properties and variables of the object and its base are represented on the same level.
Thanks.

Related

Changing button name MFC Visual Studio

I just started the GUI development, i had started on C++Builder but i switched to Visual Studio for differents reasons. But in Visual Studio, i've got a big problem :
In the GUI development interface (rc file) i can create buttons and place it, but i can't change there names. The name for all of MFC components i placed is initialize to a default name which i can't call and i can't change the property by the properties interface, i can change the Text, for change the Label of the Button, but not the name...
It's very incomfortable because by that i can't call my buttons for do anything, i have the same problem for Listboxs, so i can't modify my list because i can't call there
I just want to modify access my component by my c++ code for modifying this component
enter image description here
Thank for your help !
The MFC way of doing event handling is a bit more elaborate.
After the control is created on the form in the designer, an ID is generated ("IDC_BUTTON1" in the attached screenshot).
This is the ID that will be used for accessing this UI control from the code.
All this can be done via the designer also as shown in this article.
Basically, in the background this generated ID is put in a 'message map'
(more about message maps here).
In short 'message map' is used to specify what action needs to be performed when a certain type of action is done on the UI control by the user.
For, example if the button click is to be handled then in code:
the message map would look like:
BEGIN_MESSAGE_MAP(CSurface3DView, CView)
ON_BN_CLICKED(IDC_BUTTON1, CallMyFunction)
END_MESSAGE_MAP()
'ON_BN_CLICKED' is a predefined event macro.
The 'CallMyFunction()' function has to be declared with 'afx_msg' in the class. Besides please, have a look at data exchange mechanism as well. This know-how about data exchange will come in handy going forward.

How to adjust Intellisense in the Visual Studio 2022 to display specific class member in C++

If we look at default std::wstring, the Intellisense in VS 2022 displays the contents of a string if I mouse over it:
I've written my own class, but is there a way to tell Intellisense which member of that class to display in the Intellisense popup during a mouse-over for? Because otherwise it displays the info that is not very useful:
In this case I would like it to display a value (cast to PCWSTR) from a derived class. Is such possible?

Goto the class a method belong in Visual Studio

In Visual Studio, suppose already jump to a method in a very huge C++ class in a header file, how to know which class the method belong to? Now the method is scroll up until the class shows up, but sometimes you miss the class and get into another class's body.
At the top of the code panel in visual studio, it shows the details like currently which project you are accessing and at which class you are in and which method you are looking into. Refer the below image,
You can hover your cursor over the function declaration and a tooltip should show you the name of the class that this method belongs to. Alternatively there is a dropdown menu in the main toolbar that shows the name of the class:

C++ Windows Forms application -- where to implement OnInitDialog()?

I'm new to programming and I am experimenting with Windows Forms Applications on Visual Studio C++ 2012. I added a comboBox to the form and want to initialize with values determined at runtime. I did some research and found that I need to define the OnInitDialog() function. Where do I implement this (and how)? Visual Studio has created two source files: Form1.h and .cpp.
Thank you.
OnInitDialog() is for MFC dialogs, not Windows Forms -- you can initialize your controls either in each control's constructor or in the form's Load event (OnLoad overridable method) -- some more info in this SO answer.
OnInitDialog need to be part of a class which is derived from CDialog or CDialogEx.
If you used Visual Studio project creation wizard and selected MFC type application and then as Dialog based, you will have OnInitDialog function created by the wizard automatically.

How to get access to main dialog's element in MFC? Element was created in visual editor VS 2012

I have created in VS 2012, in a visual resource editor, few components on the main form of the application (one of them is CStatic text).
I want now to access it, so I have wrote somewhere in my MainFrm.cpp (the code executes after clicking one of the buttons, so after everything was constructed):
CStatic * temp = (CStatic *) GetDlgItem(IDC_OPERATION_INFO);
temp->SetWindowText(text);
And while executing second line of the code, I get error:
Debug Assertion Failed!
Program: C:\Windows\system32\mfc110ud.dll
File: f:\\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp
Line: 245
What I'm doing wrong?
The CStatic was created via visual editor, not in the code. Ofc I see it on the application.
The static control is probably on a CDialog or CFormView derived class, not CMainFrame. GetDlgItem only works for controls that are a child of the calling class.
A better way to access the control is to right click on it in the visual editor and select 'Add Variable'. It will let you add a CStatic variable (like m_opinfo) to the correct parent class. Then that class can call m_opinfo.SetWindowText(text).
You should also note that GetDlgItem can be unsafe to use since it returns a temporary pointer. The pointer is only valid for the scope of the code (method) that is executing. You should follow ScottMcP suggestion.