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
Printable View
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
Maybe with some more info on your code we could help.
Here's the code i use to create the balloon
Result is attached as a jpgCode: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);
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.