"GetDlgItem" call Fails......
-
Hi Guys, Iam working on VisualStudio MFC & have run into a problem. I have a dialog & have placed on this Dialog command buttons,labels & componentone studio VsFlexGrid activex control at DesignTime(In ResourceEditor). I use the "GetDlgItem" method: HWND GetDlgItem( HWND hDlg, int nIDDlgItem); -->For getting the windowhandle of the specified control. For commandbuttons,Labels It gives me a valid handle back,but for the "VSFlexGrid" It gives me a NULL back. Is there any other alternative function other than "GetDlgItem" so that it gives me a valid handle for all my controls within the dialog. or Is there any other alternative way Any help is appreciated.... Thanks...
-
Hi Guys, Iam working on VisualStudio MFC & have run into a problem. I have a dialog & have placed on this Dialog command buttons,labels & componentone studio VsFlexGrid activex control at DesignTime(In ResourceEditor). I use the "GetDlgItem" method: HWND GetDlgItem( HWND hDlg, int nIDDlgItem); -->For getting the windowhandle of the specified control. For commandbuttons,Labels It gives me a valid handle back,but for the "VSFlexGrid" It gives me a NULL back. Is there any other alternative function other than "GetDlgItem" so that it gives me a valid handle for all my controls within the dialog. or Is there any other alternative way Any help is appreciated.... Thanks...
-
Hi Guys, Iam working on VisualStudio MFC & have run into a problem. I have a dialog & have placed on this Dialog command buttons,labels & componentone studio VsFlexGrid activex control at DesignTime(In ResourceEditor). I use the "GetDlgItem" method: HWND GetDlgItem( HWND hDlg, int nIDDlgItem); -->For getting the windowhandle of the specified control. For commandbuttons,Labels It gives me a valid handle back,but for the "VSFlexGrid" It gives me a NULL back. Is there any other alternative function other than "GetDlgItem" so that it gives me a valid handle for all my controls within the dialog. or Is there any other alternative way Any help is appreciated.... Thanks...
are you sure the dialog is
Create
d before you use GetDlgItem ? Are you sure the flexgrid is also created ? ) use CWnd::GetSafeHwnd() to check. )
Maximilien Lincourt Your Head A Splode - Strong Bad
-
Hi Guys, Iam working on VisualStudio MFC & have run into a problem. I have a dialog & have placed on this Dialog command buttons,labels & componentone studio VsFlexGrid activex control at DesignTime(In ResourceEditor). I use the "GetDlgItem" method: HWND GetDlgItem( HWND hDlg, int nIDDlgItem); -->For getting the windowhandle of the specified control. For commandbuttons,Labels It gives me a valid handle back,but for the "VSFlexGrid" It gives me a NULL back. Is there any other alternative function other than "GetDlgItem" so that it gives me a valid handle for all my controls within the dialog. or Is there any other alternative way Any help is appreciated.... Thanks...
The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE. You can enumerate the child windows of oyur dialog, see if the grid show up in the list. Use Spy++ to get window handle of grid while it is on screen. That can help you figure out what is wrong.
-
The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE. You can enumerate the child windows of oyur dialog, see if the grid show up in the list. Use Spy++ to get window handle of grid while it is on screen. That can help you figure out what is wrong.
-
The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE. You can enumerate the child windows of oyur dialog, see if the grid show up in the list. Use Spy++ to get window handle of grid while it is on screen. That can help you figure out what is wrong.
Hi, Iam new to MFC & I tried your "EnumChildWindows" function where I gotinto some trouble. I have a class "C_PropView" which is derived from CDialog. Under "BOOL C_PropView::OnInitDialog() " { //I called the functions RECT rcClient; GetClientRect(&rcClient); ::EnumChildWindows((HWND)this, EnumChildProc,(LPARAM) &rcClient); "EnumChildProc",I declared it as follows in my "C_PropView.h" file but outside the class,but this function is never getting called from the "onInitDialog", I have to declare "Extern C" declarations co's I got some calling convention errors. static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) { return TRUE; } Would be nice if you could help...
-
Hi, Iam new to MFC & I tried your "EnumChildWindows" function where I gotinto some trouble. I have a class "C_PropView" which is derived from CDialog. Under "BOOL C_PropView::OnInitDialog() " { //I called the functions RECT rcClient; GetClientRect(&rcClient); ::EnumChildWindows((HWND)this, EnumChildProc,(LPARAM) &rcClient); "EnumChildProc",I declared it as follows in my "C_PropView.h" file but outside the class,but this function is never getting called from the "onInitDialog", I have to declare "Extern C" declarations co's I got some calling convention errors. static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) { return TRUE; } Would be nice if you could help...
I think this will work. You need to add a public member function BOOL HandleChildEnum(HWND) to your view class. If this does not work, then you can not enumerate from within the OnInitDialog, and a message will have to be posted to yourself to cause the enumeration. // global function maps from global space to class space BOOL CALLBACK MyEnumChildProc( HWND hwndChild, LPARAM lParam ){ // lParam was apointer to 'this' a C_PropView C_PropView* pMyView = (C_PropView*)lParam; // now call function within context of the class data return pMyView->HandleChildEnum(hwndChild); } // now you have access to all your member variables and are within t he // context of your class BOOL C_PropView::HandleChildEnum( HWND hWindowChild ){ return TRUE; } // call the child window enumerator // make sure BOOL C_PropView::OnInitDialog() { // make sure to call base class // first, so all the MFC crap is initialized CDialog::OnInitDialog(); // enumerate child windows // passing in our window, the local function, and a point to 'this' ::EnumChildWindows(m_hWnd, MyEnumChildProc, (LPARAM)this); }