I am quite new to Microsoft Visual Studio. I am using VS Community 2019. I want to enable all suggestions in intellisense all the time, how can I do that?
For example, I have a vector variable v2qPenLine which is a QVector<QVector<QPen>>. The vector variable is named in such a way so that I have easy access to it through intellisense. When I try to use it inside setPen() method (which is expecting a QPen but not a vector of QPen I guess) the intellisense does not suggest this vector:
To have it suggested, I need to click on the + button at the bottom and then it suggests the correct variable immediately:
This behaviour is not convenient at all. How can I change this behaviour of the intellisense so that it suggests only based on the name and do it all the time so that I don't have to click the + button at the bottom of the suggestion list? I think there should be a setting for this and so I tried to look up the settings of intellisense but I was unable to change this behaviour. I also couldn't find any reference to this on the internet.
I think it is a problem of your VS IDE Intellisense. And you can see that the Intellisense of your environment does have any info about variables, functions, classes ....on the first time. It should show all types on the first time. In your side, it only has the type of methods, quite strange.
Try the following suggestions:
1) disable any third party extensions under Extensions--> Manage Extensions-->Installed to check if there is an extension which caused that.
2) close VS, delete all files under C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\16.0_xxx\ComponentModelCache
3) reset all vs settings under Tools-->Import and Export Settings-->Reset all settings
4) close Vs, delete .vs hidden folder under the solution folder and then restart your project to test again.
5) repair vs or update it if there is a new release version
Related
I am facing a very consistent and persistent problem with Visual Studio 2022 Community Edition.
In an MFC project I open the Resource File and add a new Dialog. Then I place some standard controls and rename the dialog resource from its default name to a new ID.
Then I save and try to assign a Class to the dialog by right-clicking on the dialog and choosing 'Add Class'. Then the 'Add MFC Class' window appears, I enter the Class Name and click [OK].
It appears it creates the class on the File System and then VS2022 crashes completely!
I have disabled all addins in case an addin could be causing the problem but it happens every (almost) every time even without plugins. The only time I manage to get it to work is if I save, close all code editors, exit VS2022, restart it and immediately try to add the class. Another piece of information is that I have changed the MFC dialog template with a different one but it does not seem to bother it when I get it to work. Also intelliSense is completely disabled.
How can I debug this and identify the root cause of this crash?
There's a fair chance that you can't do anything in an effective fashion. VS2022 isn't an open source project, where you can easily pinpoint a crash to a specific line of code and fix it yourself.
But the good thing is that you don't need to. Just use the feedback channel VS2022 provides:
Usually a Microsoft employee will reply within a few days and maybe a fix will be included in the next preview version. Only now and then it can take some month to get a bug resolved.
I am using Visual Studio Community 2017 and am frequently switching between several class files. The way I am having to do this is by pressing Ctrl+Tab (or Ctrl+Shift+Tab) repeatedly until I reach the desired tab.
It would be more convenient if there was a way to switch between tabs by pressing Ctrl+(tab's index) similar to how browser tabs are navigated. e.g. pressing Ctrl+1 opens the first/leftmost tab on your browser, Ctrl+2 opens the second one, etc.
Looking in Tools > Options > Environment > Keyboard, there are commands that use View.NavigateBackward and View.NavigateForward (The Ctrl+Tab and Ctrl+Shift+Tab functionality) that can be re-mapped - however nothing for the functionality I described above.
There are threads solving this issue for Visual Studio Code, however (and I'm really surprised/must be really dumb that) there are no threads that I could find for just Visual Studio.
Threads for Visual Studio Code:
Is there a quick change tabs function in Visual Studio Code?
https://github.com/Microsoft/vscode/issues/24753
You can switch to a specific tab with a keyboard shortcut with my Tabs Studio extension:
And you can additionally enable the Show tab numbers option to simplify usage of NavigateToTabXX commands:
So... After doing a more sensible search on StackOverflow instead of Google, I've found this thread;
https://stackoverflow.com/search?q=CTRL+Number+Visual+Studio
Which suggested to download a Visual Studio tool called "Hot Tabs". I have done so and it's working well for my purposes at the moment.
Hot Tabs
I am trying to change the $(RootNamespace) of a WP8 runtime component to solve the same problem that this question is trying to solve: Changing namespace name of C++ component in Windows Phone causes exception
However, the location of the RootNamespace macro definition appears to have moved in VS 2012.
When I press alt-enter after selecting my C++ project, I see this:
Which is the same window that you see when you right click > properties and as I understand, this shouldn't be the case. Either they changed the location of this mysterious property in VS 2012 or something is wrong with me.
I've bashed my head against this for some time now, so I would really appreciate any help you guys can give me.
Thanks in advance
I was in the same boat as you, trying to follow the same instructions from the thread you referenced. That thread refers to the Properties Window (Ctrl+W,P), not the Property Pages (Shift+F4). Commonly confused. In the Properties Window you can set the value for Root Namespace.
When I start the program, I get the dialog and everything. But it closes by itself after some 10 seconds. How do I disable that?
EDIT: This happens when I run "Debug -> Start Without Debugging". This is the only way I know how to run the program.
EDIT2: My dialog is inheriting from CDialogEx.
If your dialog is not modal, i.e. you are not firing it up using the DoModal() member function, it is possible that it is being created with the constructor, and deleted with the destructor as it goes out of scope. You see this type of behaviour with some implementations of splash screens. To figure out what is happening, put a breakpoint on your dialogs destructor, and look at the call stack that is leading to it. It is also worth turning on all exceptions in the debugger, as you could be getting hit with an uncaught exception that is terminating your app.
As others have already said, this is not normal behaviour for an MFC app.
Usually dialogs do not behave that way.
But in default, they close on OnOk (CDialog::OnOk) which is "Enter Key Pressed"
and OnCancel (CDialog::OnCancel()) which is "Esc Key Pressed"
Try overloading those two in your Dialog, to see if those get called and to handle
the behaviour there as you like it.
Perhaps the Close event should also be handled or watched.
here are lots of examples of what can be done with a Dialog (especially OnOk, OnCancel and Close) CDialog Examples
I was facing the same issue with Visual Studio 2013:
I was creating the most basic MFC application with the Visual Studio wizard (either dialog-based, Single/Multiple document based), and just recompiling the generated code. No modification to the code at all.
I just found out that the "restart" does not occur when I turn off my Anti-virus. :-)
This is not a bug in Visual Studio, it is an environment problem.
My anti-virus is Avast.
The solution for Avast is to turn-off the Deepscreen feature.
There, go to Settings / Active Protection / Deepscreen - and disable that.
More details could be found about this approach to the solution on Avast's forums, from this discussion:
https://forum.avast.com/index.php?topic=139935.0
Confirmed, this happens with Visual Studio 2010, and doesn't happen with Visual Studio 2008. That means all the negative votes were completely unnecessary. It's a default of Visual Studio 2010, I didn't change anything. Nor did I make any bug, because I explicitly said that I created a new application without changing anything.
Thanks for all the negative votes.
Just for the record, I tried this using Visual Studio 2010. I picked Dialog-based application and left all the other options at their default settings. Compiled both Debug and Release configurations, for x86 and x64. When launched using Start without Debugging none of the four executables terminated by themselves.
If this is happening for you I would assume you have some application running (in the background) that interferes with the expected behavior. Try setting up a virtual machine, install a clean Visual Studio and perform the same procedure again.
I am trying to create a COM component using ATL, and I'd like to raise events for my VB client. I've found numerous tutorials, all of which seem to vary in details, and none of them appear to generate a working solution. Here is what I am doing:
(Using Visual Studio 2008):
Create a new ATL DLL Project. I've called it ATLEventTest.
Class View: Right clicked on ATLEventTest, Added a new ATL Simple Object class.
I called this MyObject, which generated CMyObject, IMyObject, etc...
This object was created with:
a) Apartment Threading
b) Aggregation
c) Dual Interface
d) ISupportErrorInfo
e) Connection points
Right clicked on CProxy_IMyObjectEvents<T>, clicked 'Add Function'
Function is of void return type, named someEvent, and takes an int testParam.
Rebuild.
(At this point, I should be able to see an 'Implement Connection Point' somewhere. I do not...)
Right clicked on CMyObject. 'Add Connection Point'
Moved '_IMyObjectEvents' over into the list.
Did a code search in my solution. Can't find someEvent anywhere!
Added the someEvent function again. Now, it is found in ATLEventTest_i.h
Should be able to call fire_someEvent(...) in my code, but can't.
This has been driving me insane trying to get this to work. If anyone can see what I'm doing wrong, I'd appreciate any corrections, tips, hacks, etc.
At this point, I'm tempted to say screw the wizards, and just try to modify the c++ and idl directly, but I've got a feeling that might not fair much better :(
Try using the method outlined at this location:
Adding an Event (ATL) # MSDN
With the example names you have given above, in your MyObject.idl file, you should see a declaration for your outbound even under the section for dispinterface _IMyObjectEvents. Since you right clicked on CProxy_IMyObjectEvents<T> and not on _IMyObjectEvents under the library, your IDL is probably missing the definition. The auto-generated file _IMyObjectEvents_CP.h file should be present in your project header files and should contain the Fire_someEvent() method as a result of adding the method correctly. If not, you may find that it just created a method named someEvent() instead.
Here is an outline you can try in a test project.
Create a new ATL DLL Project. I've called it ATLEventTest1.
Build Project.
Class View: Right clicked on ATLEventTest1, Add a new ATL Simple Object class. Call it MyObject.
Create the definition with a) Apartment Threading b) Dual Interface c) Connection points and whatever else you need.
Rebuild Project.
Class View: Locate the ATLEventTest1Lib library, right click on _MyObjectEvents, and "Add Method".
Method is of void return type, named someEvent, and takes an int testParam with parameter attribute [in].
You should see "[in] int testParam" as a result of adding the parameter.
On the IDL Attributes tab, change the id if necessary. Click Finish.
Class View: Right click on CMyObject, go to Add... , go to Implement Connection Point.
Select _IMyObjectEvents and click ">" to move it to the implemented connection points list. Click Finish.
Rebuild.
Now, in your CMyObject class, you should be able to call Fire_someEvent(). You will see a new method in your ATLEventTest1.idl file under the dispinterface _IMyObjectEvents; the header file _IMyObjectEvents_CP.h file will be created and will create the broadcast code for Fire_someEvent().
Does you class have an implementation of IProvideClassInfo/IProvideClassInfo2? If I recall for non-control objects, VB requires this to locate the event source interface.
Try this:
public IProvideClassInfo2Impl<&CLSID_MyClass NULL, &LIBID_ATLEventTest, 1, 0>,
and then in the interface map
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
Maybe you have a problem with apartment threading.
Do you write console application on VB?
It requires a classic message pump to work properly (for example classic windows application).
Try different apartment mode on your COM object (MTA).
Ok. So after a new system rebuild, I have installed both Visual Studio 2005 and Visual Studio 2008. I can get this working in 2005 perfectly. Still can't get the thing working in 2008. Looks like I'm just going to have to work on VS2005 for my ATL stuff...
Thanks again to all who helped.
I was having the same issue. Kept reading the MSDN documents and searched online. Finally, I figured it out.
The main thing that the wizard isn't doing is putting the declaration in the IDL file. I manually added it, and in my class, theres a "Fire_".
Hope this helps you.
I was able to fix similar issue by deleting all _I***Events references from control's .h file