CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2005
    Posts
    133

    Question Derived CWnd Class

    Hi,
    I writting a derived CWnd Class that shows balloon Messages. My problem is when the balloon appear near of the limit of the main window, the exeding part is not visible. How can i make the balloon appear outside the main window?

    Thanks
    Louis-Philippe Frenette
    Arobas Informatique Granby
    http://www.arobasinformatique.com

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Derived CWnd Class

    Maybe with some more info on your code we could help.

  3. #3
    Join Date
    Aug 2005
    Posts
    133

    Re: Derived CWnd Class

    Here's the code i use to create the balloon
    Code:
    m_bTop = bTop;
    	// TODO: Add your specialized code here and/or call the base class
    	int iStringWidht=1, iStringHeight=1, curWidth;
    	int lastPos=-1, curPos = -1;
    	curPos = m_strMessage.Find("\n", curPos+1);
    	while (curPos > lastPos) {
    		curWidth = m_strMessage.Mid(lastPos+1, curPos-lastPos+1).GetLength();
    		if(curWidth > iStringWidht)
    			iStringWidht = curWidth;
    		lastPos = curPos;
    		iStringHeight++;
    		curPos = m_strMessage.Find("\n", curPos+1);
    	}
    	if (iStringHeight == 1)
    		iStringWidht = m_strMessage.GetLength();
    	CRect textRect;
    	WINDOWPLACEMENT place;
    	m_pParent->GetWindowPlacement(&place);
    	CRect parentRect(place.rcNormalPosition);
    	CPoint ptMiddle;
    	ptMiddle.x = place.rcNormalPosition.left + (place.rcNormalPosition.right-place.rcNormalPosition.left)/2;
    	if (bTop) {
    		ptMiddle.y = place.rcNormalPosition.top;
    		textRect = CRect(ptMiddle.x - (iStringWidht*3.5), ptMiddle.y-(17*iStringHeight)-35, ptMiddle.x + (iStringWidht*3.5), ptMiddle.y);
    	}
    	else {
    		ptMiddle.y = place.rcNormalPosition.bottom;
    		textRect = CRect(ptMiddle.x - (iStringWidht*3.5), ptMiddle.y, ptMiddle.x + (iStringWidht*3.5), ptMiddle.y+(17*iStringHeight)+35);
    	}
    	
    
    	return CWnd::Create(BALLONMESSAGE_CLASSNAME, _T(""), WS_CHILD|WS_OVERLAPPED, textRect, m_pParent->GetParent(), 1);
    Result is attached as a jpg
    Attached Images Attached Images
    Louis-Philippe Frenette
    Arobas Informatique Granby
    http://www.arobasinformatique.com

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Derived CWnd Class

    The problem is because you have created a child window (WS_CHILD style) which can reside only in the client area of its parent.
    You have to create a top-level one. Set WS_POPUP style for your needs since WS_OVERLAPPED always has a caption and a border. Of course remove WS_CHILD as well.
    Last edited by ovidiucucu; November 4th, 2006 at 12:24 PM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured