| |

VerySource

 Forgot password?
 Register
Search
View: 755|Reply: 8

How to get editcontrol content in dialog

[Copy link]

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-3-2 00:30:01
| Show all posts |Read mode
I created a dialog with an editcontrol and two buttons (ok, cancel). When I click the menu option, the dialog pops up, enter the content, click the ok button to get the content in editcontrol, and the dialog exits. But it's not always available. Why?

IDC_EDIT is the ID number of editcontrol, and dlgPara is the dialog that pops up when I click the menu.

if (dlgPara.DoModal ()! = IDOK)
{
return;
}


char str [3];

SendDlgItemMessage (IDC_EDIT, WM_GETTEXT, 3, (LPARAM) str);
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-13 01:00:01
| Show all posts
It seems that lz uses mfc
Then I think that the class that calls senddlgitemmessage is a dialog box containing idc-edit, I am afraid it is not the case, huh, huh
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Korea, Republic of

Post time: 2020-5-13 12:30:02
| Show all posts
The simple way is to bind a variable to the edit control, you can get it directly
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

 Author| Post time: 2020-5-17 07:45:01
| Show all posts
CString str;
dlgPara.GetDlgItemText (IDC_EDIT, str);

The program still reported an error. What should I do?
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-17 15:00:02
| Show all posts
Personally think this is the case. After you click ok, after the dialog box exits, Edit should no longer exist!
You look up its value again, it seems not work!
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-17 23:30:01
| Show all posts
Associate a variable editText for Edit, UpdateData () in ok,
then;
In the main program
CString str;
if (dlgPara.DoModal () = = IDOK)
{
str = dlgPara.editText;
}

Give it a try
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

 Author| Post time: 2020-5-18 09:30:02
| Show all posts
Associate a variable editText for Edit, UpdateData () in ok, how to do this.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-19 02:30:01
| Show all posts
When you click ok in your dialog, use GetDlgItemText (IDC_EDIT, str);

Then use the upstairs association method
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

 Author| Post time: 2020-5-22 21:30:01
| Show all posts
Well done, thank you.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list