Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDialog Updating Controls - Newbie 1

Status
Not open for further replies.

jhauic

Programmer
Joined
Jul 9, 2002
Messages
5
Location
US
Hi,
I haven't coded Visual C++ dialogs in aeons and am working off vague memories and can't find my solution in the reference books I've hunted through. Plus while I've trawled through MSDN I can't seem to find it there either. I am trying to understand the code below and why one of the controls does not update.

Basically, I thought that the following code associated the member variable m_sRefGrid with the variable sRefGridNumber.
Code:
CXXXDlg::CXXXDlg(CSetupDlg * pParent)
:CDialogNL(CXXXDlg::IDD,pParent),
m_pParent(pParent),
m_sxxx(pParent->GetTeachDataPtr()->GetSetupPtr()->sxxx),
m_sRefGrid(pParent->GetTeachDataPtr()->GetSetupPtr()->sRefGridNumber),
m_syyy(pParent->GetTeachDataPtr()->GetSetupPtr()->syyy),
m_bEnabled(true),
{
 Create(CXXXDlg::IDD,pParent);
 EnableAllControls(false);
 ShowWindow(SW_HIDE);
}

Plus, since I can't see any other connection between these variables and the SetupPr variables, this is where I was assuming they were connected. The sxxx and syyy variables update correctly when a certain button is pushed and the UpdateData function is run, however the m_sRefGrid variable is correctly set but has no effect on sRefGridNumber.

I already tried explicitly assigning the sRefGridNumber to the m_sRefGrid value when the radio button is selected. It compiles but has no effect.

Code:
// A Reference Grid radio button has been selected.
void CXXXDlg::OnRefGridSelected(UINT uiCmd)
{
	m_sRefGrid = (short) (uiCmd - IDC_WS_REFGRID_1);
	m_pParent->GetTeachDataPtr()->GetSetupPtr()->sRefGridNumber = m_sRefGrid; // My new code
	UpdateGridData();
}
Basically, I am not sure where to assign sRefGridNumber to the m_sRefGrid value. The m_sRefGrid value changes reasonably often depending on operator input, so I need to update the sRefGridNumber variable everytime it changes and keep it current.

Help! Even good code examples online / MSDN or reference texts would be welcome. I need a good book for Visual C++ programming that doesn't only give Wizard examples.

Jha
 
>> this is where I was assuming they were connected.

You can’t “assume” things in C++, you have to “know” what’s going on. Getting lucky is not an option if your going to code in C++, It may work in VB but it’s just not going to hold together in C++.

Your code does not look like standard MFC Dialog code. If it’s not then you don’t have DDX plugged and you will need your own code that transfers the string data to the window controls you want them displayed in. Something like:

Code:
GetDlgItem(ID_MYEDIT)->SetWindowText( m_somestring);

-pete
 
Hi Pete,
Thanks for the quick response,
Unfortunately a) it's not my code but it's now my problem and b) I'm not very experienced with dialogs. This example is beyond my usual tweaks when I just have to add controls.

The radio button that gives me the m_sRefGrid value is being selected correctly. The m_sRefGrid value is fine. I need to set the m_pParent->GetTeachDataPtr()->GetSetupPtr()->sRefGridNumber to the m_sRefGrid value.

I don't understand what the following code is doing...if anything.
CXXXDlg::CXXXDlg(CSetupDlg * pParent)
:CDialogNL(CXXXDlg::IDD,pParent),
m_sRefGrid(pParent->GetTeachDataPtr()->GetSetupPtr()->sRefGridNumber), // What does this line actually do?

Jha
 
>> What does this line actually do?

It is part of the initializer for the class CXXXDlg. The specific line you reference:

m_sRefGrid(pParent->GetTeachDataPtr()->GetSetupPtr()->sRefGridNumber)

results in a constructor for the object "m_sRefGrid" member variable being called with the value "sRefGridNumber" which is a member variable of pParent->GetTeachDatePtr()->GetSetupPtr() whatever that is.

None of it is Standard MFC and by the look of it the design is... well on a scale of 1 to 10 it might be around a "-5" or so.

Given the nature and scope of your problem i don't know how much help you will be able to get in a forum based support system.

-pete
 
Since it's not standard MFC, I suppose it isn't likely that a book would be able to help me either.

Thanks for trying,

Jha
 
A MFC book would help you see what is at the “base” of the code. Then you would have to follow it on through the hierarchy of classes in the project that were used to “extend” the MFC base classes. I use the term “extend” very loosely here.

So if you are interested in taking the trip from beginning to end it would in fact be a significant help. There is just not going to be a solution that does not come from gaining at least some understanding the originally authors code and inter-object communications, such as they are.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top