Atl composite control Display of Control Problem

Atl composite control Display of Control Problem

Post by aswin.para » Tue, 11 Jan 2005 15:48:31


Hi,
I have created an ATL composite control and added a list box in it.
I have created a sample page and added this control in the page.

The atl composite control has a property called "visibledlg" which
makes the contol visible or invisible (using ShowWindow(SW_SHOWor
SW_HIDE).

During initialization of the window it has to be in hidden state. So I
have added a window message handler OnWindowPosChanging in that code I
have made it to invisible.
The code looks like this
LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
{
if(m_bVisible==FALSE)
{
LPWINDOWPOS lpwndpos =(LPWINDOWPOS)lParam;
lpwndpos->flags &= ~SWP_SHOWWINDOW ;
}

return 0;
}

And the list box has to be resizied every time the window is resized.
So I have added the OnSize Message Handler
The Code looks like this
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
HWND hwnd=GetDlgItem(IDC_LIST1);
CListBox *pLst=(CListBox*)CWnd::FromHandle(hwnd);


RECT rc;
rc.left = 10;
rc.top = 10;
rc.right = LOWORD(lParam)-10;
rc.bottom = HIWORD(lParam)-10;

pLst->MoveWindow(&rc);
return 0;
}

And in the webpage first consider the ID of the control is Active1
Initially I make the Active1 visibility style to Hidden.
I have a button called "makevisible" when I click it first makes the
visibility style to visible and then it sets the property of the
"visibledlg" to true.
The code looks like this
function MakeVisible()
{
JSControl.style.visibility = JSControl.style.visibility == 'visible'
? 'hidden' : 'visible'; Active1.style.visibility =
Active1.style.visibility == 'visible'? 'hidden' : 'visible';
Active1.VisibleDlg= Active1.VisibleDlg == false ? true : false;
}

The Problem is
When I click the button "makevisible" first it places the control at
the client page position in 0,0 and then it places the control in the
position where I have placed in the page.

Another thing is on the debug version it shows an assertion in the
line ::IsWindow method inside the ShowWindow method of the window
class.

I Set a break point in VisibleDlg and OnInitDialog in the control.
Though I set the active1 style to visible and set the visibledlg
propery to true. First it the call goes to the property and then only
the OnInitDialog is called by the framework.

Well I have put forward the problem I have faced. Incase u need more
requirement plz lemme know.

Can anybody help me in this issue.

Regards
Aswin.N.Paranji