MFC using pointers to change Dlg items

Mar 16, 2013 at 2:36am
Hey guys i'm working on a MFC project for school, and i have to have to be able to access a picture control and a text box using pointers from inside another .cpp file. I'm pretty sure that I did exactly what my teacher told me to do, but it is flagging the the ID's that I put in for the DLG items. I am sure that the ID's are correct, so the problem must lie somewhere else. Here is the code for the function that does the modifying.
1
2
3
4
5
6
7
8
bool Location::runEvent (Player& p, CDialog* window)
{
	visited=true;
	CEdit* txtPtr = (CEdit*)window->GetDlgItem(TEXTBOX);
	CStatic* picChange = (CStatic*)window->GetDlgItem(PICTURE);

	return true;
}

Like i said, my compiler is flagging TEXTBOX and PICTURE. Oh, and when i call this function from inside one of my handlers, i am using "this" for the CDialog* window parameter. Any help would be greatly appreciated, thanks!
Last edited on Mar 16, 2013 at 5:38am
Mar 16, 2013 at 2:38am
Your ID's are usually defined in resources.h. Do they exist in there? Also is that h-file included in your c++ file?
Last edited on Mar 16, 2013 at 2:39am
Mar 16, 2013 at 2:49am
Hey, all the id's were in the resource.h, but I didn't include it in my c++ file, and that was the problem. Thanks a lot!
Mar 16, 2013 at 3:14am
Now I am having a similiar problem while attempting to change the .bmp picture. My compiler is flagging the id of a .bmp that I am trying to using in a static picture control. I know i am using the right id.
1
2
3
4
5
6
7
8
9
bool Location::runEvent (Player& p, CDialog* window)
{
	visited=true;
	CEdit* txtPtr = (CEdit*)window->GetDlgItem(TEXTBOX);
	CStatic* picChange = (CStatic*)window->GetDlgItem(PICTURE);
	picChange->SetBitmap(LOCATION);

	return true;
}


It is flagging "LOCATION", and i can't figure out why...
Mar 16, 2013 at 3:16am
the error is, "argument of type int is incompatible with parameter of type HBITMAP"

any thoughts?
Mar 16, 2013 at 4:34am
this project is due pretty soon, so if anyone has knowledge of MFC I could really use some help.
Mar 16, 2013 at 7:31am
nvm, figured it out...
Topic archived. No new replies allowed.