Help writing "helper class" for UI Controls.
Posted on 2004-07-30
This question relates to accessing UI controls from a within a class that isn't derived from a prop sheet or dialog.
edit: Using VC++ 6.0
I've written a class CUIControlManager that has a method defined as:
UIToggleGroup(int* p_aID, BOOL a_bVISIBLE, BOOL a_bENABLE)
int iIndex = 0;
while (p_aID[iIndex] != -1)
CWnd* pControl = GetDlgItem(p_aID[iIndex]);
p_aID is a static array of control ID values. I basically want any property sheet classes throughout my app to be able to call this "helper" in order to facilitate all of my UI control operations. (my prop sheet classes have static arrays defined which basically model groups of controls. I can then pass a pointer to an array to this method to turn on/off enable/disable groups..
Anyway - this line:
CWnd* pControl = GetDlgItem(a_ControlID);
edit: the crash is an assertion failure:
I think this is because my CUIControlManager class perhaps isn't derived from an appropriate class? Do I have to derive it from a PropertySheet or CDialog? What if I don't want to do that, is there another paramater I can pass in or grab within the method in order to use the GetDlgItem(int nID, HWND *pHWnd) interface instead of GetDlgItem(int nID) ?
I think the problem is that this method has no idea what window to go to to find the specified control ID? I'm still very new to this, so I think I have the concept down, but the implementation is alluding me. I thought about adding a 4th paramater to UIToggleGroup that took the ID of the Dialog that contains the control, but if that's a viable approach, how would I turn the ID of the dialog into an HWND pointer for GetDlgItem() ?