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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subclassing problem

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US
I'm trying to subclass two edit boxes from a dialog box that is not the main dialog box.

Code:
CEditCode::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
 CScan_SN_DLG* scanCode;  // dialog with two text boxes
 CAppDlg* AppVar;         // main app dialog
 
 // need to get variables from main program
 AppVar = (CAppDlg*)AfxGetMainWnd();

 // need to get variables from this class
 // this is a dialog box with two text boxes
 scanCode = (CScan_SN_DLG*)GetDlgItem(IDD_DIALOG_SCAN_SN);

 // this is one of the text boxes to get the focus
 CEdit* SN2;
 SN2 = (CEdit*) GetDlgItem(IDC_SCAN_2);

 .
 .
 .
 .
}

AppVar returns a good handle. But scanCode and SN2 do not. I can get to the variables of AppVar, but not for scanCode or SN2. What am I missing?
Thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Doesn't GetDlgItem() require 2 arguments, the dialog handle and the item ID? e.g.

Code:
HWND hDlgItem = GetDlgItem( hDlg, nIDDlgItem );
 
There are two forms for the GetDlgItem(). One has one argument and the other has two. But I need the handle of a dialog box first. That is the scanCode handle. Then I could use this to get the handle of the text box control, possibly. But I can't seem to figure out how to get the handle of the other dialog box. Remember, I'm sitting in the subclass trying to use variables from the main app and the other dialog box, besides the text box controls on the second, not the main, dialog box.

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top