Click here to Skip to main content
15,889,034 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 10:01
professionalgeoyar6-Aug-10 10:01 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat6-Aug-10 10:06
Code-o-mat6-Aug-10 10:06 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 11:31
professionalgeoyar6-Aug-10 11:31 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat6-Aug-10 11:36
Code-o-mat6-Aug-10 11:36 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 15:41
professionalgeoyar6-Aug-10 15:41 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 16:08
professionalgeoyar6-Aug-10 16:08 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat6-Aug-10 22:40
Code-o-mat6-Aug-10 22:40 
GeneralRe: Get/Kill focus in MFC Pin
geoyar7-Aug-10 10:01
professionalgeoyar7-Aug-10 10:01 
After a bit of trying and debugging this is what I got:

1. You are right: SetWindowPos with SWP_NOACTIVATE does not send WM_NCACTIVATE to other windows. So

SetWindowPos(&wndTopMost, x, y, cx, cy, SWP_SHOWWINDOW|SWP_NOACTIVATE);

does not change the main dialog/window frame. But control that have received mouse right click and created popup topmost window does lose focus. I had to restore focus manually, using SetFocus().

2. If the position and size of the window are not changing SetWindowPos will not redraw window if you do not call Invalidate() or InvalidateRect/Region() before call to SetWindowPos.

3. The window must be created without WS_VISIBLE. Other way even with WS_EX_NOACTIVALTE main dialog frame changes.

This is a code:

BOOL CTipWnd::CreateTipWnd()
{
BOOL bRes = FALSE;
bRes = CreateEx(WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST|WS_EX_NOACTIVATE,
AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS),
NULL,
WS_POPUP,
0, 0, 0, 0,
NULL,
NULL,
0); // Not visible
if (bRes)
{
CRect tipWndRect = SetTipWndRects();
bRes = SetLayeredWindowAttributes(bkgndCol.ToCOLORREF(), 0, LWA_COLORKEY);
SetWindowPos(&wndBottom, tipWndRect.left, tipWndRect.top, tipWndRect.Width(),
tipWndRect.Height(), SWP_NOACTIVATE); // Still not visible
}

return bRes;
}

void CTipWnd::UpdateTipWnd(..., bool bShow)
{
// Changing window layout
...........................
// Done. Now redraw and show it
if (bShow)
{
Invalidate(FALSE);
CRect tipR;
GetWindowRect(&tipR);
SetWindowPos(&wndTopMost, tipR.left,tipR.top, tipR.Width(), tipR.Height(),
SWP_SHOWWINDOW|SWP_NOACTIVATE);
}
}

And in calling control

void CSliderGdiCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
m_tipWndPtr = new CTipWnd;
m_tipWndPtr->SetOwner(this);
..............
BOOL bRes = m_tipWndPtr->CreateTipWnd();
if (!bRes)
{
delete m_tipWndPtr;
m_tipWndPtr = NULL;
}
else
{
UpdateTipWnd();
SetFocus();
}
}
..................
}



Thank you so much for your help.
geoyar

GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat7-Aug-10 10:17
Code-o-mat7-Aug-10 10:17 
QuestionPosting a lot of data messages to MFC-based GUI Pin
kirilo_l4-Aug-10 5:30
kirilo_l4-Aug-10 5:30 
AnswerRe: Posting a lot of data messages to MFC-based GUI Pin
Chris Meech4-Aug-10 6:46
Chris Meech4-Aug-10 6:46 
Questiondebugging sprintf -VS/C++ Pin
Alan Kurlansky4-Aug-10 5:07
Alan Kurlansky4-Aug-10 5:07 
AnswerRe: debugging sprintf -VS/C++ Pin
Aescleal4-Aug-10 5:29
Aescleal4-Aug-10 5:29 
AnswerRe: debugging sprintf -VS/C++ Pin
Moak5-Aug-10 2:41
Moak5-Aug-10 2:41 
QuestionHow to create a dll wrapper Pin
VentsyV4-Aug-10 4:11
VentsyV4-Aug-10 4:11 
AnswerRe: How to create a dll wrapper Pin
Phil J Pearson4-Aug-10 4:31
Phil J Pearson4-Aug-10 4:31 
JokeRe: How to create a dll wrapper Pin
Sauro Viti4-Aug-10 4:38
professionalSauro Viti4-Aug-10 4:38 
GeneralRe: How to create a dll wrapper Pin
VentsyV4-Aug-10 5:33
VentsyV4-Aug-10 5:33 
GeneralRe: How to create a dll wrapper Pin
Aescleal4-Aug-10 5:55
Aescleal4-Aug-10 5:55 
GeneralRe: How to create a dll wrapper Pin
VentsyV4-Aug-10 6:09
VentsyV4-Aug-10 6:09 
AnswerRe: How to create a dll wrapper Pin
Aescleal4-Aug-10 5:02
Aescleal4-Aug-10 5:02 
GeneralRe: How to create a dll wrapper Pin
VentsyV4-Aug-10 5:31
VentsyV4-Aug-10 5:31 
GeneralRe: How to create a dll wrapper Pin
Aescleal4-Aug-10 5:47
Aescleal4-Aug-10 5:47 
GeneralRe: How to create a dll wrapper Pin
VentsyV4-Aug-10 6:11
VentsyV4-Aug-10 6:11 
GeneralRe: How to create a dll wrapper Pin
Aescleal4-Aug-10 7:54
Aescleal4-Aug-10 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.