c++ - MFC import Dialog from DLL -
i have 2 projects: 1 mfc .exe , mfc .dll. have mfc dialog defined in dll. has resource associated , has class ctoolboxdiag
derived cdialog
.
the dialog has simple button shows message dialog when clicked.
void ctoolboxdiag::onbnclickedbutton() { messagebox(_t("test"), _t("t")); }
i can export resource dll code, , create standard cdialog
correct appearance using following code:
cdialog *diag = new cdialog; hinstance hclientresources = afxgetresourcehandle(); //tell client use .dll's resources afxsetresourcehandle(dll); // resource_id resource_id in dll diag->create(resource_id, null); //restore client application resource handle afxsetresourcehandle(hclientresources);
but results in dialog showing controls (i.e. button) performs no action when clicked, doesn't have linkage ctoolboxdiag
definition in .exe.
i wanted export dialog (with button code) without having export class definition .exe. in other words, want export functional dialog, including buttons actions, without having ctoolboxdialog
definition on .exe, can modular. how this?
this can't work in way. resource template has no direct connection code in dll. code created "empty" cdialog class has no handlers hat all, expect default handlers (onok, onclose...)
so need create object ctoolboxdiag , has happen wehere dialog code located. inside dll.
the easiest way export function creates dialog inside dll , returns cdialog* application.
be aware allowed , work without problems when using dll shared version of mfc.
Comments
Post a Comment