Dynamically resize dialog
-
Hello :), I have a dialog based application. On a menu command I need to hide sone controls (edit box and buttons) and I can do it (setting as not visible) Now I need to resize the main dialog, since there is an empty area. I tried with this (IDD_TEST_GUI_DIALOG is the ID of the main dialog window): CWnd* pWnd = GetDlgItem(IDD_TEST_GUI_DIALOG); RECT rc; pWnd->GetWindowRect(&rc); rc.right -= 100; ScreenToClient(&rc); pWnd->MoveWindow(&rc); but I get an error. If, instead of IDD_TEST_GUI_DIALOG, I put the ID of any other child element the function works. What did I do wrong? In debugging I find that, after GetDlgItem pWnd is 00000 Thanks in advance :) Marco.
-
Hello :), I have a dialog based application. On a menu command I need to hide sone controls (edit box and buttons) and I can do it (setting as not visible) Now I need to resize the main dialog, since there is an empty area. I tried with this (IDD_TEST_GUI_DIALOG is the ID of the main dialog window): CWnd* pWnd = GetDlgItem(IDD_TEST_GUI_DIALOG); RECT rc; pWnd->GetWindowRect(&rc); rc.right -= 100; ScreenToClient(&rc); pWnd->MoveWindow(&rc); but I get an error. If, instead of IDD_TEST_GUI_DIALOG, I put the ID of any other child element the function works. What did I do wrong? In debugging I find that, after GetDlgItem pWnd is 00000 Thanks in advance :) Marco.
for some reason it's not possible to do a GetDlgItem on a dialog (IDD_...) You can however, resize and shift your controls in your dialog. Maybe that's a solution? Their is a way to resize your dialog, but I have no idea on how. Is there no article about this? "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
-
Hello :), I have a dialog based application. On a menu command I need to hide sone controls (edit box and buttons) and I can do it (setting as not visible) Now I need to resize the main dialog, since there is an empty area. I tried with this (IDD_TEST_GUI_DIALOG is the ID of the main dialog window): CWnd* pWnd = GetDlgItem(IDD_TEST_GUI_DIALOG); RECT rc; pWnd->GetWindowRect(&rc); rc.right -= 100; ScreenToClient(&rc); pWnd->MoveWindow(&rc); but I get an error. If, instead of IDD_TEST_GUI_DIALOG, I put the ID of any other child element the function works. What did I do wrong? In debugging I find that, after GetDlgItem pWnd is 00000 Thanks in advance :) Marco.
Why do you try to get a pointer to your own class? Try this code: GetWindowRect(&rc); rc.right -= 100; ScreenToClient(&rc); MoveWindow(&rc);