In my project i have 2 radio button "File" and "not File" and i also hav a textbox called "width"..
I need to disable the text box when i click on "not file" radio button and once i click "file" radio button it should enable the textbox..
Can u tell me the function in Windows programming in visual c++
EDIT : "Add variable" is disabled when i right click on the textbox
Attach a CTextBox member variable to your text box. Say m_tbWidth. You can do this by right clicking on the textbox in the dialog designer and selecting "Add variable..."
In the handler for File, enter the line m_tbWidth.EnableWindow( TRUE );
And in the handler for NotFile, enter the line m_tbWidth.EnableWindow( FALSE );
Related
How can I set "Start without debugging " in the top-bar of the Visual Studio 2019 IDE, instead of "Local Windows Debugger". I find it annoying that every single time I need to press CTRL + F5 to start without debugging.
I looked through settings but I didn't see anything. Maybe I missed something.
You can add virtually any command to the VS-2019 IDE's toolbars. At the right-hand side of the tooolbar where you want your command to go, click the small down-arrow and select the "Add or Remove Buttons" command from the pop-up:
Then, if the command you want is not shown in the list of 'available' buttons, select the "Customize" command (near the bottom). Then, in the pop-up box, click the "Add Command" button:
In the next pop-up, for the "Start Without Debugging" command, you have to (odd though it may seem) select the "Debug" category from the left-hand list and scroll down (some way) in the right-hand list to find it:
Once selected, click "OK" ad "Close" the first pop-up. The command button will now appear (probably at the extreme left-hand side) on the toolbar.
Right click on the toolbar, pick Customize from the drop down menu
Click the Commands tab in the dialog that appears
Click the Toolbar radio button
Pick the 'Standard' option from the drop down menu to the right of the Toolbar button
Click the Add Command button
Click the Debug category on the left
Scroll down to list on the right to find the 'Start without Debugging' command and select it.
Click OK
etc. etc.
I am trying to build an MFC application Dialog based application. It runs ok. But I need to insert another Dialog. So how can I for example, pressing on a button from the first dialog to open the new added dialog?.
I am using Microsoft Visual Studio 2015.
I right clicked on the resources folder and insert a dialog.
It is inserted, but how to create it?.
Thank you.
The easiest way is: I consider you are creating a Dialog based application so you get a main Dialog box and an About Dialog box when Selecting menu->About.
To add Another Dialog to your application:
1- Right click on the solution explorer on the resources files and select Add->Resource->Dialog->New
You get a new Dialog right front of you. Right click on this Dialog and select Add Class. give it for example a name like "MyDlg2" and click ok.
You'll see two files added: MyDlg2.h and MyDlg2.cpp.
Now How to Popup this second dialog (MyDlg2)? Let's create a button on the main Dialog:
Drag a button onto Main Dialog.
Give it a caption "Gong to Dialog2..."
Double-click this button to add a handler for it.
In this handler enter:
MyDlg2 dlg;
dlg.DoModal();
Scroll to the top of this file and add:
#include "MyDlg2.h"
This is important so that main Dialog knows How to create dialog 2.
Build and run.
You need to derive a class from CDialog.
For more information check this MSDN example.
The title isn't very explicit but here is my problem :
I have a MFC-based application with a dialog that has :
1 Text input;
1 Ok button;
1 cancel button;
1 button with an arrow to type in the next value
When the text box has the focus, pushing enter triggers the OK button. Why ? The text box has the focus, not the OK button so why would it do that ?
What i need ito to redirect the enter key to the arrow button instead of the ok button so that pushing enter doesn't close the dialog but goes to the next input.
Why can i do that please ? If i use SetFocus on the arrow button, the text box loses the focus, as expected, and this is not what i want.
You must set the Multiline and the Want Return properties of your edit control to True.
If an edit control does not have the style ES_WANTRETURN pressing ENTER has the same effect as pushing the dialog's default button. However, this style has no effect on single line controls, so you must also set the ES_MULTILINE style for the control.
Is it possible to have enabled radio buttons though the user cannot change the value?
It is possible. If you create your radio buttons with the BS_RADIOBUTTON style instead of BS_AUTORADIOBUTTON then Windows will not automatically change the selection when the user clicks a radio button. (In the dialog editor in Visual Studio, right click the radio button and set the Auto property to False.)
Read the "Using Radio Buttons" section of this page in MSDN for more information.
either you can setchek it to BST_CHECKED and the EnableWindow to FALSE
or..
on every other selection of radio button make the radio button that you need selected
i have dialogbox as a singleton class and on that dialog box i hv 2 radio button on and off which are grouped.when i make on group true in resource and add variable then if i clicked on off radio button and then if i open again that dialog box its focus is on "off" radio button which is right. but when i make "off" button group true i.e. initially its on "off" raio button then if i cliked on "on" button and closed an reopen the dialog focus is neither on "off" nor on "on".i hv used setfocus also but nothing working
You can use SetCheck to select the proper radio button when the dialog opens and GetCheck on each radio button to see which is selected. The easier option is to use DDX_Radio to automatically associate an index with the selection of a radio button.
If I am not wrong with you description, when you close the dialog box you call the destructor. If the dialog is in a 'greater' executable - the dialog is called by another dialog in the same .exe - you can declare the variable as global instead of member (as I suppose is declared).
Otherwise you send data to your .exe by using shared data.
Got the answer:)
suppose i have made two radio button Radio1 and Radio2 under group box then we hv to make group true for first radio button i.e. Radio1 then add varible integer on Radio1 button.If we want focus on Radio2 initially or by default then in constructor of dialogbox on which these radio button exist make variable value as 1 (as index start from 0).