MFC Handling Controls

closed account (o1vk4iN6)
I am having some difficulty understanding just how MFC works. I am trying to dynamically create controls on the fly but I'm not sure how to specify a function for it to go to when say a button is pressed.

1
2
3
BEGIN_MESSAGE_MAP(CMFCtestApp, CWinApp)
	ON_COMMAND(ID_APP_ABOUT, &CMFCtestApp::OnAppAbout)
END_MESSAGE_MAP()


Looking at the generated code, from visual studio, I'm guessing that how it defines it when the "about" button is pressed from the menu. I may have 100s of controls being generated and I'm not sure how to handle them.
I have used the following 'simple cheat' method in a dialog box when I wanted to create a small number of controls at run-time.

I created the controls on the dialog box at compile time - and then used the class wizard to generate the
required handler functions for the control (for example the onClick function for a button).

I then deleted the controls from the dialog box - this deletes the control but MFC does not delete the handler functions (it also does not delete the ID such as IDC_EDIT1 from the resource.h file)

Then at runtime when I needed to create one of the crontrols, I simply created it remembering to give the control the same ID
closed account (o1vk4iN6)
Not exactly what I was looking for but neat little way to do that, thanks.
Topic archived. No new replies allowed.