When i create multiple instances of a form resource, strange things happen..
Do i have to create one instance for each(similar) form?
The form comtains comfiguration settings, and has the same fields in all instances, only different data..
When i create multiple instances of a form resource, strange things happen..
Do i have to create one instance for each(similar) form?
The form comtains comfiguration settings, and has the same fields in all instances, only different data..
>>strange things happen<<
That tells us a lot.
>>Do i have to create one instance for each(similar) form?<<
Probably not. If you maintain the form data within some sort of struct/class then you only need determine which is active and interface that data set to/from your dialog.
If that seems utterly irrelevant or too ambiguous then you'll really have to elaborate on strange things happen. (unless CodePlug or anonytmouse or a few others are around as they're quite often psychic and may be along shortly with useful prognostications ).
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
Okay:
I have a parent dialog.
In this dialog i create X number of instances of a child form.
These chilkd forms are created by the same function, below is a short example:
It seems that only the last created dialog responds to messages??Code:// Creation of child windows static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static void InitForm(); static HWND hwThis; int frmSetup(HWND hWnd, ThData *data, void *tr){ return((int)CreateDialog(GetModuleHandle(0), MAKEINTRESOURCE(FRM_SETUP), hWnd, DialogProc)); }
I handle the WM_CTLCOLORSTATIC message to draw colored background on some labels. This only happens on the last instance of the form resource.
Does this have anything to do with the fact that DialogProc/hwThis is declared as static?
As i've understood this, the static keyword only means that the variable can't be referenced from other files when it's in the global scope of the file..?
For the dialog procedure, probably not. If you are using that static dialog handle in your message loop in IsDialogMessage or GetMessage then that will be problematic.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.