I have a C++ Visual Studio project, in which I wish to locate one particular constant throughout the whole project. That is, I want to locate that particular variable in every single file in my project, including all .cpp and .h.
A previous question seems to be relevant, but it is only able to locate the variable within ONE file.
How may I do it?
You can use Quick Find available on the Edit ► Find and Replace ► Quick Find menu. With my key bindings it is bound to Ctrl-F.
The Quick Find dialog box is shown in the upper right corner of the editor window. You can change where to search from the drop down. Normally you search in Current Document but you can change it to Entire Solution.
If you want to search .h files that are not part of your solution you can use Find in Files available on the Edit ► Find and Replace ► Find in Files menu. Here you can specify a scope that also includes files of a specific type in a folder.
Related
Is there a file somewhere that I can use to do massive changes to the context menu in an easier fashion?
The GUI:
gives me no way to move a command from one menu to another, nor does it let me see what the command actually is (in order to add that same exact command to another menu), thus I don't have much to work with.
And thus I am seeking a file (or a gigantic registry key? ugh.) that I can edit somewhere else where I have more powerful tools. (my VS version is Enterprise 2017 if that matters)
You can find the defaults at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Profiles, with a general settings and some language-specific overrides. There's an additional override in IDE\VC\Profiles as well.
In my case, I wanted to move 'Start new instance" on a Project into the top-level context menu. So I:
Made a copy of CurrentSettings.vssettings
Added a new command where I wanted it (via the Tools > Customize... GUI)
Found the command I wanted to clone and moved it up one
Closed VS (it saves on exit)
Compared the two files to find the diffs (use your favorite tool.) You'll find them under Category[#name="Environment_CommandBars"]\CommandBars\UserCustomizations as add remove and modify entries
Took the Cmd attribute from the moved entry and pasted it over the added one (it was Cmd="{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}:00000164" for me, to save interested parties a few steps)
Undid the move to retain only the added entry
I wasn't able to find a command entry for this anywhere in the defaults, so had to figure it out the hard way.
I have been able to open a Windows 8 shsxs.dll file in Visual Studio 2010.
But it's write protected.
Now, while in Visual Studio, I want to know how to modify an existing image or add a new image in
png format to shsxs.dll.
Also, I have been a to unpack/extract it too using 7-zip.
Thus, how can I repack the unpacked .dll file back to a .dll file?
PS: I'm new to Visual Studio, so question or tag may seem irrelevant. Please correct me & help me out asap.
Preface: I haven't got a chance to work with Windows 8 yet, so the information in this answer might be slightly off. Or completely useless.
I think by write protected you mean read-only. That's easily corrected. Locate your shsxs.dll and right-click on it. Select Properties and uncheck the Read-Only checkbox in the Attributes section, if it is checked. Then go to the Security tab, and click edit. Select your username (or the user Everyone if it's there) and tick the Full access checkbox in the Allow column. Click OK. Click OK again.
Next you want to know how to modify an existing image or add a new image in png format. These are two different things.
Let's tackle the modifying first.
You can't do that with 7-Zip. You can only use it to look at the DLL's content, but you can't modify it. You need a specialized tool for the job, I recommend the XN Resource Editor, which is basically a better Resource Hacker, which used to be the program to edit already compiled resources. I'm not sure whether they work with Windows 8 modules, though. If they don't, please link to an alternative which can in the comments, or edit this answer if you can.
After you install the XN Resource Editor, start it, and open your shsxs.dll. On the left side you have the resource tree. Expand the Bitmap subtree. You should see a bunch of numbers, each one represents one resource in the DLL. Expand each subtree until you find the desired image.
Once you find your image, you can modify it inline using XN Resource Editor's built-in picture editor. You can also remember the resource's number, right-click on the Image and select Delete Resource, then go to the Resource menu and select Import Image Resource, find your desired image. Then right-click on the newly imported image in XN Resource Editor, select Properties and enter the old resource's number (you remembered it, right?) and press OK.
Adding a new Image is not that different.
It's easy, simply go to the Resource menu and select Import Image Resource, find your desired image and click OK. DONE.
Edit: Since the file came from System32, I added instructions on how to grant the user full access to the file, additionally to removing the read-only flag.
XCode2 had this beautiful feature: you put the cursor on a line with a #include <file> and execute the open-quickly command (command-shift-D) and it would open the file. I can't get it to work for me in XCode3.
I have something like this
#include <folder/subfolder/HeaderFile.hh>
and when I put the cursor on this line, and open the open-quickly dialog, it automatically fills the search window with
folder/subfolder/HeaderFile.hh
but doesn't find anything. If I then remove "folder/subfolder/" then the dialog will identify HeaderFile.hh and I can open it up. But this extra deleting is so much slower just the three-key command-shift-D opening I was used to with XCode2.
If I give it the full path to this file in the search window, then it finds it:
/Users/andrew/myproject/src/folder/subfolder/HeaderFile.hh
this path will find the file. Again, I don't want to spend all my time typing out the full path.
I created this project as an external build system, and I think that's related to the problem; the xcode project lives in
/Users/andrew/myproject/xcp_dir/
and I want it to search in the "../src/" directory so that the partial path I give it (which is already present in the #include) will match the file I want to open. In XCode3, I had to create the project in the xcp_dir directory; in XCode2, I could create the project directly into the existing myproject/ directory -- maybe that's why the search is failing?
I read on a previous thread (which never answered the question) that I should set the HEADER_SEARCH_PATHS option. I tried this (setting the option to /Users/andrew/myproject/src) but it did not work.
I don't have any sense of what other options (like the HEADER_SEARCH_PATHS option) are availalbe, so if you know which one I have to set, I'd love to hear it.
Since this is an old question I'll answer it for Xcode 4 instead of 3.
As far as I know Open Quickly doesn't use anything like a search path. It seems to have use the project's codesense index and will show results from that. Querying the database doesn't have an notion of file paths, so the workflow you describe just won't work anymore.
However that's okay, because there's a better solution: Just ⌘+click on the include line and the appropriate file will be found using the same rules as the compiler uses, and opened. If you want to open the file up in an assistant, another tab or window, you can use ⇧⌘+click instead, and you'll get a little UI for easily selecting where you want the file opened.
You can also use these shortcuts to go to definitions for any identifier.
If you don't want to use the mouse you can use the command "Jump to Definition" which has the shortcut ⌃⌘J, or ⌥⌃⌘J to open the definition in the assistant editor. This also works for both normal identifiers and #included files.
More specifically my problem is if I include a pdf in my project and set its build action to content so it gets copied to the server when I publish, is there a way to exclude it from visual studios search and replace feature. Would a post build action be a solution to this? I just don't want anybody to do a global search and replace in my project and mess up the pdfs...
I know I just said a mouth full so let me know if you need clarification. Thanks!!!
If you look in the section headed "Find options" in the find dialog, there is an option titled "Look at these file types". If you qualify the type as *.cs, it will only look in files with that extension. You can also enter multiple file extensions. As long as you don't include pdf files in that filter, it will not apply to them. An alternative is to define a folder set to search in by clicking the ... next to the folder combo. Put your PDF files into a sub-directory of your project and exclude that folder from the folder set.
Additionally, as you have said, not including them in the project and using a post-build event to copy them to the output would also work.
I would qualify though that you are trying to solve a problem that shouldn't really be a problem. The onus is on the developer doing a find and replace to take care in doing so, and to not replace the contents of files they don't intend to change in the first place. Find an replace can be a dangerous tool.
I never use "Add existing item..." feature in Visual Studio's Solution Explorer because it is confusing:
it seems to me the way it should work is that if you have a Customer.cs file in Models directory, that you could choose "Add existing item", it would then show you which items exist in that directory an allow you to choose one. Instead, it opens a file dialogue to some seemingly random directory on your hard drive, and I'm not sure if it is going to make a copy of that file, or use it outside the solution, etc.
instead, if I want to "add an existimg item", I go into windows explorer, click file, CTRL-C, click folder in solution explorer, ctrl-v, and it is clear
Do others do it differently? Am I missing something about how "add existing item" in solution explorer is supposed to work?
The folder opens where-ever you last left it...
As for using this feature; by default (Add) it does IMO the least useful thing; copy the file. But if you notice, the add button is actually a drop-down; hit the down arrow and you can add a link to the file - i.e. leave it where it is and reference it by location (Add As Link).
The quick and easy way to do what you are trying to do (add an existing file that already exists within the folder in your project) is:
At the top of the Solution Explorer window is an icon/button for "Show All Files", enable it (if it is already enabled and the file you are looking for is not shown, click "Refresh"). Note that this setting is enabled on a per project basis.
Right click on the file that you want to include and select "Include in Project".
Add Existing file adds the file to the project. Keeping it in the project directory is something different and making it a part of the project is something different. By making it a part of the project, its entry is made in .csproj/.vcproj/etc and then further properties can be set of this file such as specifying a custom build step etc.
And No, it doesn't create a copy of the file in your current project's directory in case of a Visual C++ project. In case of a CSharp Project, it does create a copy.
e.g., I use this when I need to add a bitmap/png file in my project which I have gotten from an external source. I just copy the file to my project directory and then use Add Existing File to add this to the project.
I'm using it. I even didn't know it's possible to ctrl+c ctrl+v in solution explorer.
It's particulary handy, if you want to add something 'as link'.
I do use it but often I just add file as a link. That make it easier to maintain some common classes if you do not want to make full assembly out of them.
As far as my experience goes using this function, it does the same copy and paste that you are describing.