Using #defined values in Visual Studio dialog resource scripts? - windows

I'm trying to create an About box for my Windows C++ application. In Visual Studio 2008, I'm using the dialog editor to design the dialog. I want the About box to display the application's version in a static label.
I can hardcode the version into the dialog, stored in a .rc file, but then I'll have to remember to update the version in multiple places.
My application version is #defined in version.h as APPLICATION_VERSION. The resource editor can be convinced to put
#include "version.h"
at the top of the .rc file, so I have access to the APPLICATION_VERSION symbol.
However, I cannot use this symbol from the dialog editor. I can edit the .rc file by hand, replacing the hardcoded version string by the symbol APPLICATION_VERSION. That works fine until I edit the dialog in the dialog editor again: upon saving the .rc from the dialog editor, the symbol gets overwritten with its current value.
Of course, I can set the version label to some dummy text, overriding that text when I receive WM_INITDIALOG, but that feels very clunky and unnecessary. Is there any other workaround that allows me to keep the application version in a single place?

The way I do this is to put the resource in a separate file with a .rc2 extension, and #include that into the .rc file (like you're doing with your version.h). I then edit the .rc2 files with a normal text editor, not the Visual Studio resource editor.
That system's not too bad for VERSIONINFO resources, which is what I use it for, but I can see it would be more of a pain for dialog resources. I'd love to hear of a better way, but I don't know of one.

Related

How can I open the Visual Studio EditorConfig Designer after changing the default editor for the .editorconfig file type?

Does anyone know how to either add back in the EditorConfig Designer as a program to open files with or how to reset the default editors for file types?
After changing the default editor for .editorconfig files to be something other than the EditorConfig Designer the option to set the default editor back to the designer or to open with the designer is now gone.
I know I can probably delete my appdata folder or something like that and reset it that way, I'm looking for a way to do it that doesn't take doing that. I did a quick search in some of the xml files visual studio uses but realized it would take some time to figure out exactly what to do to add it back in myself, thus I'm asking with hopes someone has experience doing this.
One work around I have found is to set the files to open with a text editor with text encoding then hit cancel when it asks which encoding to use. It then opens the designer but it still won't show up as an option to set as the default or in the open with items, which is what I want.

MFC EditBrowse control does not display the folder icon at runtime

I have a dialog type application that includes a MFC EditBrowse Control. This control includes a folder/magnifier icon on the right side where the user is supposed to click to bring up a folder browser pop-up.
That folder/magnifier icon displays properly in the dialog editor within Visual Studio, but at runtime it displays as a plain flat button. It behaves properly otherwise - that is, the browser pop-up pops up and the selected folder is displayed when the user clicks OK.
When run with the debugger a message is displayed in the VS Output Window saying "Can't load bitmap: 4299". That message is displayed after the CDialogEx::OnInitDialog() line within my OnInitDialog().
I've written test programs and they display the icon properly. I've also added additional EditBrowse controls in my original program, but they experience the same problem and just add another line of "can't load bitmap". I've also added other MFC controls and some of them also do not display their icons (or other stuff).
I've managed to affect the problem slightly by making calls to EnableBrowseButton() and EnableFolderBrowswButton() from my OnInitDialog. If I do that, I get an icon that looks like 3 horizontal dots:
which is better, but I'd prefer the folder/magnifier icon.
It's a complicated enough application I'd rather not re-write it from the beginning and furthermore I'd like to understand what is going on. I'm fairly certain this is a result of adding/deleting controls as the app was developed, but don't have a good idea on where to begin tracking down where things went awry.
Thoughts on how to debug this? BTW, this is VS 2010.
CMFCEditBrowseCtrl uses the Visual Manager to load the bitmap from MFC resources.
This resource is loaded in "afxribbon.rc"
Make sure the following these lines are included in the main *.rc file (this is how VS Wizard creates the *.rc file)
#if !defined(_AFXDLL)
#include "afxribbon.rc" // MFC ribbon and control bar resources
#endif
(I guess you can omit the #if/end statement, but it's probably there for a reason)
Alternatively, CMFCEditBrowseCtrl::SetBrowseButtonImage can be used to assign user icon.

VS2010 - HLSL Intellisense?

Are there any free components out there that will give highlighting and/or intellisense for HLSL?
I've seen mentions of something called "InteliSense.Net," but the author's site is down and I can't find a download anywhere.
Not a direct answer to your question, but this is what I do to solve the same problem:
I set Visual Studio to open *.fx files in Notepad++. (Right click the file, Open With, Add Notepad++, Set Default). Of course, you can use any editor you like.
I use a HLSL syntax highlighting file for Notepad++ that I found on Google. I think it's this one.
And finally, I keep this MSDN page open in my browser: Intrinsic Functions (DirectX HLSL). Because HLSL is so simple - with no way to mess around defining classes and such - and the programs are usually quite small and self-contained, I find that this is sufficient.
Try NShader that is a VS2012/2010/2008 extension for HLSL/CG/GLSL syntax highlighting.
With a little effort you can configure manually MSVC2010 IDE in a way it will highlight HLSL files and will do partial auto-completion/intelisense:
Part 1)
In 'Tools' menu click 'Options'
In the 'Options' dialog box expand to 'Text Editor' node and select 'File Extension'
Now on the right side you can add extensions and configure editor for them
Add extensions: hlsl and fx with 'Editor' field set to 'Microsoft Visual C++'
Check 'Map extensions files to' and set it to 'Microsoft Visual C++'
Part 2)
Create 'usertype.dat' text file beside VCExpress.exe or devenv.exe (typically located "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\"). Populate 'usertype.dat' file with hlsl keywords you want highlighted i.e:
float2
float3
float4
float4x4
matrix
cbuffer
tbuffer
Part 3) Restart MSVC
Part 4) In VC Open 'Tools'\'Options' dialog box again and navigate to 'Environment'\'Fonts and Colors' and configure it to your liking. Color of user keywords added via 'usertype.dat' is controlled through 'C/C++ User Keywords' display item (Personally I matched it with 'Keyword' settings).
Part 4a) In VC 'Tools'\'Options'\'Text Editor'\'C/C++'\'Advanced' on the right side you might want to consider setting field 'Disable Squiggles' to true (since hlsl is not a valid C++ code VC would normally underline C++ compile errors in your shader code)
ShaderSense project seems to solve syntax highlighting and some kind of intellisense for HLSL files
HLSL Tools for Visual Studio brings IntelliSense to HLSL in Visual Studio. It includes statement completion, signature help, live errors, quick info, and more.
Disclaimer - I'm the author of HLSL Tools.

Image editing in resources of visual studio 2008

I want to be able to edit an image (png file) from the resources folder of one of my projects in VS2008. But the resource editor in VS will only allow me to zoom in and out. As the images are 32 bit, VS also will not allow me to use the image editor toolbar to change this. I would like to know if anyone knows how i can edit the image via VS or an associated plugin that is safe to use with source control?!
Thanks in advance guys!
I'm unsure if VS has any built in image editing applications that meet your needs. However, for editing our image resources I've set it up so that the default application launched when selecting certain filetypes is Photoshop (or a different editor depending on the change required).
Changing the default opened program for a filetype can be done using the following steps:
http://msdn.microsoft.com/en-us/library/hy2sthf1.aspx
As for source control safety, I use AccuRev with the AccuBridge plug in for VS. So anytime any of the files under source control are modified it is noted as such. Then these files can be committed as required either through VS AccuBridge plug in or through the regular source control client.
I don't think the VS resource editor supports editing PNG files (see this related question).
I'm not sure what you mean by "safe to use with source control" -- any image editor should fit the bill. Check out the file, locking it if necessary, then edit it with your favorite image editor, such as GIMP. When you're done, check in.

Visual Studio 2005: Please stop opening my CS files in "Design Mode"!

I think it's associating my Web Service's CS files with the related ASMX files. But whatever's happening, I can't double-click to open the CS files - I have to "view Code" or it opens in the designer.
Anyone know how to turn off this automatic behavior? I just want to edit the code!
Try right-clicking, select "Open with...", mark "CSharp Editor" and select "Set as Default".
That works for avoiding the WinForms Designer.
I found this question when trying to deal with a similar problem. I had a C# class in a file and whenever I double clicked on the file it would try to open in design mode but design mode was meaningless for this class. I just want to see the code.
I found that adding the [System.ComponentModel.DesignerCategory("")] attribute to my class fixed this.
In the Solution Explorer view, click the "Show All Files" icon. This will put "+" symbol next to each of your files. Click the + and it will expand to show the .CS file which holds the ASMX's code. At this point, double click that file instead.
For some reason VS2005 seems to have this a bit backwards when it comes to webservices. To open a webservice in code view, double-click the .asmx file, not the .asmx.cs file.
I guess it makes a bit of sense, as there's nothing to "design" when it comes to a webservice, but it's counterintuitive if you've been working with .aspx files.
In my experience, if you find that the wrote editor, that is the non-default editor, is opening when double-clicking on a file within the Solution Explorer then something is wrong with the underlying project's User Options file (.user) or the solution's User Options file (.suo). (I am not sure which, but I suspect the settings are stored in the .suo file.) Deleting the the .suo and all project .user files solved the problem.
I personally, set the Form Editor as my default editor for forms at the beginning of a project. After the forms are stable and require less user-interface design changes, I switch the default editor.

Resources