Re: Does my object exist? So why its HWND doesn't exist? That's a question... (CMonthCalCtrl control)

From: Lt (zdolna.bestia_at_wp.pl)
Date: 07/25/04


Date: Sun, 25 Jul 2004 20:55:45 +0200

Philip wrote:
>GetDlgItem returns a HWND, which happens to be the first member inside
CMonthCalCtrl

CWindow::GetDlgItem (ATL) returns a HWND but I'm using CWnd::GetDlgItem
(MFC) that returns CWnd*

>Try:
>CMonthCalCtrl cal(GetDlgItem(IDC_MONTHCALENDAR2));
>int nCount = cal.GetMonthRange(...);

That dosen't work because the constructor CMonthCalCtrl::CMonthCalCtrl ()
doesn't take any parameters.

Lt



Relevant Pages

  • Re: MFC Custom Control in a MFC DLL
    ... GetDlgItem should not be used in MFC. ... const CWnd *pWndInsertAfter wouldn't cast from CStatic to const CWnd, ... but when I SetWindowPos with WndCStatic it appears the window without ...
    (microsoft.public.vc.mfc)
  • Re: Setting a radio button group property in code.
    ... While using GetDlgItemto get a CWnd* and call some CWnd method like EnableWindowis perhaps acceptable, the casting to a derived class is in fact a diabolical trick that only works because of the specific structure of MFC classes like CEdit, CButton, etc. ... Remember that the window on the template is created by Windows, which knows nothing about MFC (not even about CWnd, let ...
    (microsoft.public.vc.mfc)
  • Re: MFC Custom Control in a MFC DLL
    ... written for MFC or written by someone who had not figured out what you ... const CWnd *pWndInsertAfter wouldn't cast from CStatic to const CWnd, ... lines of code in the OnInitDialog so in the class I can have OnCreate ... have missed something in the OnCreate or I should fire different event ...
    (microsoft.public.vc.mfc)
  • Re: talking to CView from a thread?
    ... other senarios that would require the usage of FromHandle? ... >> OK, either pWnd or pParent must be the CWnd for CView, is that right? ... >> one of edit control which belongs to CMyView? ... > MFC uses a handle map to convert an HWND into a CWnd pointer. ...
    (microsoft.public.vc.mfc)
  • Re: Why does AfxGetMainWnd returns nulls?
    ... Ajay and Tom have been working on the assumption that your main .exe was created with MFC, but nowhere have you said that. ... Though I have seen the value in watch window, the changed value is reflected, incase you have those concerns. ... CWnd* pWnd = AfxGetMainWnd; ...
    (microsoft.public.vc.mfc)