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

how to use GetDlgCtrlID

Status
Not open for further replies.

ugly

Programmer
Jul 5, 2002
70
GB
my app consists of a single dialog, the dialog contains a number of edit boxes.Each time a edit box is clicked i would like to obtain its resource id. I am not quite sure how to acheive this i know it involves use of GetDlgCtrlID
I have tried this but "hold" always seems to take the value zero.


void MyDialog::OnSetfocusEdit1()
{
// TODO: Add your control notification handler code here
int hold = this->GetDlgCtrlID();


}

grateful of any help martin
 
instead of "this" u should have a pointer to the edit itself
in your code you are asking GetDlgCtrlID to return the id of your dialog and not that of the edit
 
thank you dima that does make sense. I tried this and it works just fine but my problem is i have a large number of edit controls is there a alternative way to obtaining a pointer other than by stating its resource ID each time
int hold = GetDlgItem(IDC_EDIT1)->GetDlgCtrlID();
 
why would you want to have the id of the control?
there might be another way to achieve your goal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top