domehead100 | 4 Aug 2009 18:01
Picon

Bug in CMemDlgTemplate?

I am creating a dialog in memory by deriving my dialog class from CIndirectDialogImpl.

My dialog has a single child control, a CRichEditCtrl subclass.  (This is a messagebox class that uses the
rich edit for displaying the message in RTF).

My problem is with the ControlID for the rich edit control.  I set the ID to IDC_RICHEDIT which is 101 in my
resources, but when I subsequently try to subclass the control in OnInitDialog using that control id, I
get a null HWND.

I've determined that the real control ID, as reported by Spy++, is a DWORD with the low word being my control
id but the upper word being something else, either 0xCCCC, 0xC080, etc.

I'm overriding DoInitControls.  Originally I was doing this using BEGIN_CONTROLS_MAP, but in an attempt
to troubleshoot my issue, I switched to just a direct override without using the macros:

void DoInitControls()
{
m_Template.AddControl(CRichEditCtrl::GetWndClassName(), (WORD)IDC_RICHEDIT, 0, 0, 100, 16,
WS_CHILD|WS_VISIBLE, 0, _T(""), NULL, 0);
}

I tracked the problem down to CMemDlgTemplate.AddControl in atldlgs.h to line 3129 in my distribution:

DLGITEMTEMPLATEEX item = {dwHelpID, ATL::CControlWinTraits::GetWndExStyle(0) | dwExStyle,
ATL::CControlWinTraits::GetWndStyle(0) | dwStyle, nX, nY, nWidth, nHeight, wId};

This statement initializes the DLGITEMTEMPLATEEX structure directly using struct/array-style
initialization.  The problem seems to be that while the .id member of DLGITEMTEMPLATEX is properly
initialized as a WORD value, in actuality due to padding in memory it is a DWORD, and the high word is not
initialized via the statement above and contains whatever garbage existed in that memory previously.
(Continue reading)

Alain Rist | 4 Aug 2009 23:03

Re: Bug in CMemDlgTemplate?

Hi Mike,

For _ATL_VER < 0x800 (pre VC2008) WTL 8.0 incorrectly defines DLGITEMTEMPLATEEX::id as WORD instead of
DWORD. Changing WORD to DWORD in atldlgs.h #2972 (WTL 8.0 MS distribution) will fix it.
This bug (
http://sourceforge.net/tracker/?func=detail&aid=1858494&group_id=109071&atid=652372 ) is
fixed in current SVN.

cheers,
AR

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:wtl-digest@... 
    mailto:wtl-fullfeatured@...
(Continue reading)

domehead100 | 5 Aug 2009 15:16
Picon

Re: Bug in CMemDlgTemplate?

--- In wtl@..., "Alain Rist" <ar <at> ...> wrote:
>
> Hi Mike,
> 
> For _ATL_VER < 0x800 (pre VC2008) WTL 8.0 incorrectly defines DLGITEMTEMPLATEEX::id as WORD instead of
DWORD. Changing WORD to DWORD in atldlgs.h #2972 (WTL 8.0 MS distribution) will fix it.
> This bug (
http://sourceforge.net/tracker/?func=detail&aid=1858494&group_id=109071&atid=652372 ) is
fixed in current SVN.
> 
> cheers,
> AR
> 
> [Non-text portions of this message have been removed]
>

Thanks Alain!  Note:  I am using WTL8.0_7161_Final, and it is not fixed in that release.  I think you meant to
say it is fixed in 8.1?

I was getting quite confused because I was looking at the MSDN documentation for VC 7.1, which still listed
.id as a WORD in DLGITEMTEMPLATEEX.

~Mike

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/
(Continue reading)

gilad_no | 6 Aug 2009 15:45
Picon
Favicon

Re: Bug in CMemDlgTemplate?

--- In wtl@..., "domehead100" <domehead100 <at> ...> wrote:
>
> --- In wtl@..., "Alain Rist" <ar <at> > wrote:
> >
> > Hi Mike,
> > 
> > For _ATL_VER < 0x800 (pre VC2008) WTL 8.0 incorrectly defines DLGITEMTEMPLATEEX::id as WORD instead of
DWORD. Changing WORD to DWORD in atldlgs.h #2972 (WTL 8.0 MS distribution) will fix it.
> > This bug (
http://sourceforge.net/tracker/?func=detail&aid=1858494&group_id=109071&atid=652372 ) is
fixed in current SVN.
> > 
> > cheers,
> > AR
> > 
> > [Non-text portions of this message have been removed]
> >
> 
> Thanks Alain!  Note:  I am using WTL8.0_7161_Final, and it is not fixed in that release.  I think you meant to
say it is fixed in 8.1?
> 
> I was getting quite confused because I was looking at the MSDN documentation for VC 7.1, which still listed
.id as a WORD in DLGITEMTEMPLATEEX.
> 
> ~Mike
>

Hi Mike,

From the main WTL web page: "It is always recommended to get the latest release via SVN" :)
(Continue reading)

hawkgao | 9 Aug 2009 17:31
Picon
Favicon

How to set view position in Mainframe?

Hello folks,
In common, the view in a single document mainframe fulfills all the client area. However, I need such view
move down and draw something in the area over the view. For that purpose, I set a new rectangle area at the
Create() function call of View class. Unfortunately, no effect. Then I add MoveWindow() under Create()
function call. Cannot work either. My code bellow,

RECT rc = { 100, 100, 500, 500 };
m_hWndClient = m_view.Create(m_hWnd, rc, NULL, WS_CHILD | WS_VISIBLE  | WS_HSCROLL | WS_VSCROLL |
ES_AUTOHSCROLL | ES_AUTOVSCROLL);
m_view.MoveWindow(&rc);

Any idears?

Thanks,
-Xiang

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

(Continue reading)

hawkgao | 9 Aug 2009 17:34
Picon
Favicon

How to set the custome position of View in MainFrame?

Hello folks,
In common, the view in a single document mainframe fulfills all the client area.
However, I need such view move down and draw something in the area over the
view. For that purpose, I set a new rectangle area at the Create() function call
of View class. Unfortunately, no effect. Then I add MoveWindow() under Create()
function call. Cannot work either. My code in CMainFrame::OnCreate() bellow,

LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
...
RECT rc = { 100, 100, 500, 500 };
m_hWndClient = m_view.Create(m_hWnd, rc, NULL, WS_CHILD | WS_VISIBLE |
WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
m_view.MoveWindow(&rc);
...
}

Any idears?

Thanks,
-Xiang

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
(Continue reading)

hawkgao | 9 Aug 2009 17:40
Picon
Favicon

How to set the custome position of View in MainFrame?

Hello folks,
In common, the view in a single document mainframe occupys all the client area.However, I need such view
move down and draw something in the area over theview. For that purpose, I set a new rectangle area at the
Create() function call of View class. Unfortunately, no effect. Then I add MoveWindow() under the call of
Create(). Cannot work either. My code in CMainFrame::OnCreate() bellow,

LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
/*lParam*/, BOOL& /*bHandled*/)
{
...
RECT rc = { 100, 100, 500, 500 };
m_hWndClient = m_view.Create(m_hWnd, rc, NULL, WS_CHILD | WS_VISIBLE |
WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
m_view.MoveWindow(&rc);
...
}

Any idears?

Thanks,
-Xiang

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
(Continue reading)

hawkgao | 9 Aug 2009 17:50
Picon
Favicon

Re: How to set the custome position of View in MainFrame?

I got it. Mapping WM_SIZE to myself callback function can handle this.

--- In wtl@..., "hawkgao" <hawkgao <at> ...> wrote:
>
> Hello folks,
> In common, the view in a single document mainframe occupys all the client area.However, I need such view
move down and draw something in the area over theview. For that purpose, I set a new rectangle area at the
Create() function call of View class. Unfortunately, no effect. Then I add MoveWindow() under the call of
Create(). Cannot work either. My code in CMainFrame::OnCreate() bellow,
> 
> LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
> /*lParam*/, BOOL& /*bHandled*/)
> {
> ...
> RECT rc = { 100, 100, 500, 500 };
> m_hWndClient = m_view.Create(m_hWnd, rc, NULL, WS_CHILD | WS_VISIBLE |
> WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
> m_view.MoveWindow(&rc);
> ...
> }
> 
> Any idears?
> 
> Thanks,
> -Xiang
>

------------------------------------

Yahoo! Groups Links
(Continue reading)

Mojtaba Fathi | 9 Aug 2009 18:32
Picon
Favicon

Re: How to set the custome position of View in MainFrame?


Hi
I think it is better to reimplement UpdateLayout function and customize it for your needs.
Moji

--- On Sun, 8/9/09, hawkgao <hawkgao@...> wrote:

From: hawkgao <hawkgao@...>
Subject: [wtl] Re: How to set the custome position of View in MainFrame?
To: wtl@...
Date: Sunday, August 9, 2009, 8:20 PM

 

    
                  I got it. Mapping WM_SIZE to myself callback function can handle this.

--- In wtl <at> yahoogroups. com, "hawkgao" <hawkgao <at> ... > wrote:

>

> Hello folks,

> In common, the view in a single document mainframe occupys all the client area.However, I need such view
move down and draw something in the area over theview. For that purpose, I set a new rectangle area at the
Create() function call of View class. Unfortunately, no effect. Then I add MoveWindow() under the call of
Create(). Cannot work either. My code in CMainFrame:: OnCreate( ) bellow,

> 

(Continue reading)

hawkgao | 10 Aug 2009 03:14
Picon
Favicon

Re: How to set the custome position of View in MainFrame?

I check out the implementation of CFrameWindowImpl<>. Your solution is much better.

--- In wtl@..., Mojtaba Fathi <modjtabaf <at> ...> wrote:
>
> 
> Hi
> I think it is better to reimplement UpdateLayout function and customize it for your needs.
> Moji
> 
> --- On Sun, 8/9/09, hawkgao <hawkgao <at> ...> wrote:
> 
> From: hawkgao <hawkgao <at> ...>
> Subject: [wtl] Re: How to set the custome position of View in MainFrame?
> To: wtl@...
> Date: Sunday, August 9, 2009, 8:20 PM
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
>     
>                   I got it. Mapping WM_SIZE to myself callback function can handle this.
> 
> 
(Continue reading)


Gmane