First-time Windows programming
This is my first time programming Windows.
OK. So I know how to add text to dialog box editor. Right? Well, I've figured out about how I can add another dialog box.
What I did is, create a test application and named it as Test Dialog. What I did is after I chose MFC appwizard, I follow instructions.
Then I resize my dialog, move OK button, delete Cancel, name OK as Close, and for that process, I add a new button called a Test.
Then I add a function after I chose IDC_SENDNAME and BN_CLICKED (I name a Test button of IDC_SENDNAME).
Then I edit the code:
Code:
void CDialogTestDlg::OnSendName()
{
// TODO: Add your control handle nodification handle code here
MessageBox("This is the test.", "Hi!", MB_OK);
}
Well, that's it!
But... that may sound way to easy to code like that. And, when I visit some of the tutorials you've posted somewhere in the forum, I thought those tutors are hard and just because VC++ are very easy to add controls without adding a single line of code.
So, for example, unlike cout and cin, I thought there must be a way to copy the text from an edit box and send it to a new dialog box with just a press of a Test button. What I mean is Windows have to take over my text I've entered into, and be able to view text. For example: When I type in "Grayson" in the edit box, and hit "Test", that text string would then be carried over to a dialog box.
Any suggestions?
Please keep in mind that I had started to program Windows for the first time.
Win32 API (Please note that I'm Grayson_PEDDIE< SO i'm in a hotel.)
Where can I find that info of Win32 API out? Any suggestions?
Needed detailed information!
You didn't give me detailed information for what to put the code at...
Oh... I somewhat forgot something...
I have IDs and controls that I have in 2 dialogs:
IDD_OUTPUTTEST_DIALOG : Main dialog
IDC_QUESTION : Static text (What is your name?)
IDC_NAME : Edit box {This is where I type in and send a text to a
new dialog)
IDC_SENDNAME : This button should copy the text and send them to a new dialog {Button: (Send)}
IDOK : (Close) Acts as an OK button...
In MFC ClassWizard:
~Begin...~
Object ID: IDC_NAME
Messages: EN_CHANGE
Member Functions: OnChangeName ON_IDC_NAME EN_CHANGE
(Indicates the display is updated after text changes)
Object ID: IDC_SENDNAME
Messages: BN_CLICKED
Member Functions: OnSendname ON_IDC_SENDNAME BN_CLICKED
(Indicates the user clicked a {left mouse} button)
~End of information in ClassWizard...~
IDD_OUTPUT_TEXT_DLG : This is a dialog box where I get an output from an edit box I've inputted into a edit box and clicked Send
IDC_TEXT_PREFIX : (Hi )
IDC_OUTPUT_NAME : Border turned off; This is where I recieve text that I've typed from edit box in the previous main dialog
IDOK : Return
ClassWizard info I've implemented:
Object IDs: IDC_OUTPUT_NAME
Messages: EN_UPDATE
Member Functions: OnUpdateOutputName ON_IDC_OUTPUT_NAME EN_UPDATE
OK. I put the code in for those 2 files:
One is for outputtestDlg.cpp, though I included Windows.h...:
Code:
void COutputtestDlg::OnChangeName()
{
static char buffer[256];
GetDlgItemText(IDD_OUTPUTTEST_DIALOG,
IDC_NAME,
buffer,
255);
}
void COutputtestDlg::OnSendname()
{
}
Others for outputtextstring.cpp:
Code:
void Outputtextstring::OnUpdateOutputName()
{
extern char buffer;
SetDlgItemText(IDD_OUTPUT_TEXT_DLG,
IDC_NAME,
buffer
);
}
Now I got 2 errors here:
--------------------Configuration: outputtest - Win32 Debug--------------------
Compiling...
outputtestDlg.cpp
C:\Learn\VCPP\outputtest\outputtestDlg.cpp(102) : error C2661: 'GetDlgItemTextA' : no overloaded function takes 4 parameters
Outputtextstring.cpp
C:\Learn\VCPP\outputtest\Outputtextstring.cpp(49) : error C2660: 'SetDlgItemTextA' : function does not take 3 parameters
Generating Code...
Compiling...
outputtest.cpp
Generating Code...
Error executing cl.exe.
outputtest.exe - 2 error(s), 0 warning(s)