Underlining first letter of Label C++ (Underline doesn't show) - c++

Problem:
I wish to underline the first letter of certain static text controls (such as Login and Password). The letters become underlined when the ALT key is pressed.
What I have tried:
In C#, I was able to acheive this by using an ampersand. Such as "&Log in" or "&Password". I am trying to find a similar method in C++. The below picture shows an example in C#:
I am using MFC/C++ in Visual Studio 2010.
Edit:
Added information about the ALT key. Here is an example of what I am trying in Visual Studio 2010's properties box. I am adding an ampersand to the front of the "Caption"'s text.
When I run my program in the debugger, the first letter is not underlined (until ALT is pressed):

There's a fundamental difference between a menu and a static control.
To do this in a menu, you do it just like in C#. Here's a screen shot of editing a menu in a C++ project:
...and here's the result:
For a static control, you have to clear the SS_NOPREFIX style for the control to get the same behavior. However, it's been my observation that under some circumstances the underline doesn't show (but I haven't ever pinned down the precise circumstances under which the underline didn't show--I think when it happened, I fixed it by changing the font, but I don't remember for sure).

After help from the SO community, it seems that using the ampersand (&) symbol before the desired underlined letter is the correct way. There was a setting on my personal machine that would keep the underlined letters hidden until the ALT key was pressed.
According to the MSDN:
A user often has to press ALT in order to see access key designations. To ensure that you address them throughout the development process, set your computer to persistently display access keys.
In Windows 8: Open Control Panel -> Ease of Access Center -> Make the Keyboard easier to use.
At the bottom of the screen, check "Underline keyboard shortcuts and access keys".

Related

How to check if all of the many fields are filled? [C++, VS 2015, Windows Form]

I'm making Windows Form project in C++ using Visual Studio 2015 and I have to check if all the TextBoxes are filled in and RadioButtons checked before I let the user go to the next panel. The problem is that when the "Next" button is clicked, I need to check all these fields one by one (textbox->text=="" etc.) and that makes really long "if".
Is there any other easier (or just better looking) way?
It might be stupid question, but I'm still learning.
You can find many solution for this.
For example:
You can catch change in all the text boxes and use a numeric variable big enough to be used as bitmap with bit for each box, You start it when all bits are set. In the on_change, if the box is empty set the bit for the corresponding box, if not clear it.
Now you can enable the next button only if the bitmap variable is zero.

Paste selection in console based editor

I have written a windows console based text-editor with C & I'm gonna add copy/paste feature to it.
Editor is made up of a doubly-linked list that each structure just contains one letter. editor gets letters, arrow keys, backspace, ... with getch function (which is found in conio.h) & uses their ascii code to recognize them.
when a selection is made and CRTL+C is pressed, the selection is copied to memory but I don't know where to get that copied text.
Hope I cleared the problem,
Thanks.

Visual Studio go to bookmark only inside current file

Is it possible to go to the next/prev bookmark only inside the current file? I'm using VS 2010 and I find it extremly annoying that it jumps always across all files when I want to navigate inside the current file only.
Yes. Go to "customize" (right click on the toolbox area, choose customize) ->commands->keyboard, choose edit.NextBookmarkInDocument and associate it with a shortcut.
In addition, you can add it as a button in the text editor toolbar. Go to to text editor toolbar, press the little mark on the bottom-right,and choose the appropriate button to add.
Set bookmarks to stay in one file in Visual Studio 2019
In the Search box at the very top menu, put in ‘customize’ and hit Enter’.
A complex box comes up, but I simply clicked on a button at the bottom labelled ‘Keyboard’, which is where keyboard shortcuts can be set up.
That brings up another huge box. In the left hand pane is Environment and under that is Keyboard. I guess that the way I went in is why this was expanded and already selected, so there must be other ways to get to the same place.
In a right hand pane is now a huge list of commands that can have shortcuts attached!
The ones to scroll to (enlarge the box or the scroll bar is a joke. A slight move scrolls dozens of lines!) are Edit.NextBookmarkInDocument and Edit.PreviousBookmarkInDocument. (similar commands without ‘inDocument on the end are what f2/ shift f2 do by default and jumps between files rather than staying in the same document.)
When you select a command you can then just click on the field labelled ‘Press shortcut keys’ and then press the keys you want to be the shortcut for that command.
I assigned Edit.NextBookmarkInDocument to f2, which then replaces the old f2 that jumps from file to file, and shift f2 for Edit.PreviousBookmarkInDocument. You have to press the ‘Assign’ button to make VS remember the change. After this, bookmark jumps stay in the same file. I guess you could choose any shortcut you fancy, and it does at least show you if that shortcut is assigned and what it is assigned to.
There are some features which I have not explored, like when I use f2 it shows it is assigned to ‘Rename’ but it seems to not effect that function at all when you reassign and just takes it away from the jump between files command version. Maybe someone would like to delve deeper, but what I did worked without any side effects and renames outside of VS still worked with f2 so I have no idea what it was going on about.

When using Visual Studios 2012 for coding in C++, how do you autocomplete code selected in IntelliSense?

When using IntelliSense, it would usually show up functions, members, and etc. in the dialog box. Usually at the very top of the dialog box, IntelliSense would automatically select the most relevent C++ code that fits what the user typed.
I want the IntelliSense to help me autocomplete the word I was typing, but whenever I press Enter key, it would just insert a new line, and not autocomplete it for me.
The only workaround for me is to press Down key, and then press Enter, in order to achieve this. Are there any other methods of making this process easier? It's annoying for me not being able to autocomplete C++ codes when pressing Enter key.
In C++, press TAB key to autocomplete.

how to hide windows 7 switch user button in vc++ CredentialProvider sample

I have provided a screenshot of my
CredentialProvider window. In this
window everything is fine now but i
don't want to show Switch User
button to the user. How i can do
this. I am just editing Win-7 SDK
sample for CredentialProvider
(C++). Anyone can help me, or any
link for code help.
One more thing I want to ask is by default, the username text box displaying EditText in grey color. How i could change it to Username text. I can set text in SHStrDupW(L"", &_rgFieldStrings[SFI_EDIT_TEXT]); code but its not setting in background text. is there any hack for this.
Thanks SO members
You cannot directly prevent the Switch User button from appearing; if the conditions are present that cause it to appear, then it's going to appear. What you can do however: prevent the conditions that cause it to appear.
That button appears either when a tile is in the selected state and 1.) your credential provider is enumerating tiles other than the one that is selected, or 2.) other credential providers are enumerating tiles.
The first condition is easy to prevent: In GetCredentialCount(), always report that you will enumerate only one credential. (This means of course that you must structure the tile to handle all users.)
To prevent the second condition, you will have to implement a credential provider filter. (Search for the "ICredentialProviderFilter" interface if you don't know what that is.)
Good luck.
To answer question 2:
The username text box is displaying EditText in grey color. You can change it to Username text. You set text using
SHStrDupW(L"", &_rgFieldStrings[SFI_EDIT_TEXT]);
Have a look at common.h, there you'll find
CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR s_rgCredProvFieldDescriptors[] = { SFI_EDIT_TEXT, CPFT_EDIT_TEXT, L"Edit Text" }
If you change this Edit Text to UserName then it will show in your Text Box.