We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,594 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Windows Dialog Text Programming

I am working on a Windows application, and I have a Settings Dialog box with 5 text fields. I currently get the values of each text field with:

  GetDlgItemText(hDlg, IDC_EDIT_SIPADDRESS, sipAccount->sipAddress, 80);      
  GetDlgItemText(hDlg, IDC_EDIT_USERNAME, sipAccount->userName, 80);      
  GetDlgItemText(hDlg, IDC_EDIT_PASSWORD, sipAccount->password, 80);      
  GetDlgItemText(hDlg, IDC_EDIT_HOST, sipAccount->host, 80);
  GetDlgItemText(hDlg, IDC_EDIT_STUN, stun, 80);

And then set the appropriate Registry keys to save the values. But how do I check if a new value has been put into the text box? (e.g. I want to ensure that it is not trying to set a blank value)

if(!text_box_is_empty)
  GetDlgItemText(...);
else
  //do nothing - Registry Key will be set to current value

Also, when I initialize the dialog box, how can I get text to appear in the text fields? I want the current value of that characteristic to be in the box upon initialization. I currently set up the box like:

std::wstring wsSIPAddress = RegistryHelper::ReadRegKeyW(HKEY_CURRENT_USER, L"path", L"sipaddress");
if(wsSIPAddress.length() == 0)
    memset(sipAccount->sipAddress, 0, 80);
else
    memcpy(sipAccount->sipAddress, wsSIPAddress.c_str(), wsSIPAddress.length() + 1);
SetDlgItemText(dialogHandle, IDC_EDIT_SIPADDRESS, sipAccount->sipAddress);
1
Contributor
0
Replies
2
Views
iamthesgt
Junior Poster
119 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0580 seconds using 2.69MB