Click here to Skip to main content
15,920,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: E-TEAM Pin
Gert Boddaert16-May-00 23:14
Gert Boddaert16-May-00 23:14 
GeneralRe: E-TEAM Pin
George19-May-00 4:56
George19-May-00 4:56 
GeneralComputer System Hardware Classes Pin
Cory M Hicks15-May-00 12:16
sussCory M Hicks15-May-00 12:16 
Generalowner drawn menu tabs Pin
Justin decker15-May-00 8:29
sussJustin decker15-May-00 8:29 
GeneralUsing updated ActiveX controls Pin
Sid Price15-May-00 7:43
Sid Price15-May-00 7:43 
QuestionHow to print MshFlexgrid in VC++ ? Pin
Cheickna15-May-00 0:10
Cheickna15-May-00 0:10 
GeneralContextMenu! Help! Pin
charisma14-May-00 17:22
charisma14-May-00 17:22 
GeneralBringing the window and/or view containing an SDI ActiveX Control to the top Pin
Mike G.14-May-00 16:44
Mike G.14-May-00 16:44 
Hello everyone:

I have a question about bringing a window containing an ActiveX control to the top if it is partially obscured by another window. It's kind of long but please bear with me.

For instance, say MyControl is my ActiveX Control I created that is inside a client consisting of a single window (we'll call it MyClient) - note that the client area of MyControl fills up the entire window of MyClient. Suppose another application's window obscures partially the MyClient window with MyControl in it (therefore, MyClient does not have focus). If I click on the non-obscured area of MyClient (which is actually clicking on the non-obscured client area of MyControl), how can I bring MyClient and coincidentally MyControl to the forefront and setfocus on MyClient?

Now, here comes the twist. MyControl follows the Single Document-View (SDI) architecture. That is, the client area of MyControl is actually a CScrollView, with a CDocument, as part of CSingleDocTemplate object created in the InitInstance of the MyControl's COleControlModule. The CMainFrame is derived from CFrameWnd, but it has no caption bar or border, thereby allowing for a more visually pleasing embedded appearance in the client.

So, what I did was handle the WM_LBUTTONUP handler of my derived CScrollView. I then propagated the the WM_LBUTTONUP msg up to my MyControl's derived COleControl class. There, I managed to get the IOleContainer interface pointer as illustrated below (CMyCtrl is derived from COleControl):

void CMyCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
IOleContainer* pContainer = NULL;
BOOL rc = FALSE;

if(SUCCEEDED(GetClientSite()->GetContainer(&pContainer)))
{
CWnd* pParent = GetParent();

if(pParent)
{

CRect parentrect, rect;
pParent->GetWindowRect(&parentrect);
GetWindowRect(&rect);

//pParent->SetWindowPos(&wndTop, parentrect.left, parentrect.top, parentrect.Width(), parentrect.Height(), SWP_NOMOVE | SWP_NOSIZE );

pParent->SetFocus();
}

}

if(pContainer)
pContainer->Release();

COleControl::OnLButtonUp(nFlags, point);
}

The "pParent->SetFocus()" works with the control inside a CWnd of a container application, but how can I make it work if MyControl is embedded in the _view of an SDI client application_? Is there anything that I can do with IOleContainer pointer pContainer to bring the container (be it a dialog, a window, or a CView) to the forefront when it is clicked on?

And here's the other thing - say that MyControl does not have focus and it is in MyClient's window. However, MyClient's window (that has MyControl in it) is partially obscured by another application's window, but the unobscured part of MyControl has an edit box (the edit box is a child MFC control and is part of MyControl's CScrollView) visible, and the user clicks on the edit box to set focus on it AND to bring MyClient to the top over the other application's window. How can I do this?

And to make things even more complicated, how can you do this without adding/changing code in MyClient, and only do it MyControl's codebase?

I know my message/query is kind of long, but I would appreciate any help that you can give me.

Thank you very much.

- Mike G


GeneralTrial version Pin
James Khan14-May-00 0:17
James Khan14-May-00 0:17 
GeneralRe: Trial version Pin
Mark Swann14-May-00 4:58
Mark Swann14-May-00 4:58 
GeneralTrial version Pin
James Khan14-May-00 8:14
James Khan14-May-00 8:14 
QuestionSAPI ? Pin
Member 237512-May-00 16:22
Member 237512-May-00 16:22 
QuestionHosting Band objects? Pin
Nick Hodapp12-May-00 10:52
sitebuilderNick Hodapp12-May-00 10:52 
AnswerRe: Hosting Band objects? Pin
Buck12-May-00 20:12
Buck12-May-00 20:12 
GeneralRe: Hosting Band objects? Pin
Nick Hodapp15-May-00 5:53
sitebuilderNick Hodapp15-May-00 5:53 
GeneralListView control Pin
hitokiribattousai12-May-00 7:35
hitokiribattousai12-May-00 7:35 
GeneralRe: ListView control Pin
Mark Swann12-May-00 10:32
Mark Swann12-May-00 10:32 
GeneralRe: ListView control Pin
hitokiribattousai12-May-00 17:52
hitokiribattousai12-May-00 17:52 
GeneralRe: ListView control Pin
Mark Swann13-May-00 16:38
Mark Swann13-May-00 16:38 
GeneralRe: ListView control Pin
Mark Swann13-May-00 17:42
Mark Swann13-May-00 17:42 
GeneralRe: ListView control Pin
Kurt15-May-00 3:01
Kurt15-May-00 3:01 
GeneralInternet Pin
Alpesh Makwana12-May-00 2:13
Alpesh Makwana12-May-00 2:13 
GeneralRe: Internet Pin
Alex Gorev16-May-00 4:31
Alex Gorev16-May-00 4:31 
GeneralRe: Internet Pin
Alfadhly19-May-00 8:47
sussAlfadhly19-May-00 8:47 
GeneralRe: Internet Pin
Alfadhly19-May-00 8:49
sussAlfadhly19-May-00 8:49 

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.