Jump to content
  • Advertisement
Sign in to follow this  
Devil9000

[MFC / DirectX 9] CSplitterWnd - Mouse Position inside...

This topic is 4552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, i am programming a level editor for a commercial game project but temporary i have got a little problem: I want to know how to get the mouse position inside a CSplitterWnd. I have used MFC and our DirectX Engine for this Level Editor. If someone has an idea, please tell me! Deviloper Devil Entertainment [Edited by - Devil9000 on January 30, 2006 2:27:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
I think, that i can get a pointer to the CWnd of the active Frame with the following code:

CPoint point;
GetCursorPos(&point);
CWnd* pWnd = ChildWindowFromPoint(point, CWP_ALL);

But I can't get the mouse position inside the SplitterFrame...

Any Ideas?

Deviloper
Devil Entertainment

Share this post


Link to post
Share on other sites
Once you've got both the cursor position in screen coordinates and a CWnd* to the window below you can call pWnd->ScreenToClient on the coordinates to get them transformed to client coordinates.

Alternatively you can use GetPane from the CSplitterWnd to get the CWnd handles to a specific pane.

Share this post


Link to post
Share on other sites
Quote:

Alternatively you can use GetPane from the CSplitterWnd to get the CWnd handles to a specific pane.

Hmm, yes, that will be posible when you have a handle to the CSplitterWnd... but i have no handle in that class....

Quote:

Once you've got both the cursor position in screen coordinates and a CWnd* to the window below you can call pWnd->ScreenToClient on the coordinates to get them transformed to client coordinates.

Thx... i will try it... and reply :)

Deviloper
Devil Entertainment

[Edited by - Devil9000 on January 30, 2006 2:06:10 PM]

Share this post


Link to post
Share on other sites
So, i have tryed it, but i didn't get the right Coordinates. I have used the following source:

void CMainFrame::OnIndicatorPos(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
CPoint point;
char cText[128];

GetCursorPos(&point);
ScreenToClient(&point);
CWnd* pWnd = ChildWindowFromPoint(point, CWP_ALL);
if(!pWnd)
sprintf(cText, "-, -");
else
{
pWnd->ScreenToClient(&point);
GetCursorPos(&point);

sprintf(cText, "%d, %d", point.x, point.y);
}

pCmdUI->SetText(cText);
}


Have you got any ideas?

Someone i.O. Deviloper
Devil Entertainment

Share this post


Link to post
Share on other sites
You're using ScreenToClient twice, that won't work out. The coordinates are relative to the client area of the main window after the first call.

Inside your if clause exchange the GetCursorPos and ScreenToClient call.

Share this post


Link to post
Share on other sites
Quote:

You're using ScreenToClient twice, that won't work out.

Sry guy, but i dont agree with you. The first ScreenToClient is for the CMainFrame.... cause of the menu...

But I have tryed the way you descibed... but it didn't work :D


void CMainFrame::OnIndicatorPos(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
CPoint point;
char cText[128];

GetCursorPos(&point);
// ScreenToClient(&point);
CWnd* pWnd = ChildWindowFromPoint(point, CWP_ALL);
if(!pWnd)
sprintf(cText, "-, -");
else
{
GetCursorPos(&point);
pWnd->ScreenToClient(&point);

sprintf(cText, "%d, %d", point.x, point.y);
}

pCmdUI->SetText(cText);
}

The Pos which is returned by the GetCursorPos() function is still not the wanted value...

Have you got any ideas?

Deviloper
Devil Entertainment

[Edited by - Devil9000 on January 31, 2006 1:46:42 PM]

Share this post


Link to post
Share on other sites
Sorry, misunderstanding.

The first ScreenToClient is necessary to get the child window below the mouse. The only thing off then was the switching of GetCursorPos and ScreenToClient inside the if clause.

So it ought to look like this:


void CMainFrame::OnIndicatorPos(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
CPoint point;
char cText[128];

GetCursorPos(&point);
ScreenToClient(&point);
CWnd* pWnd = ChildWindowFromPoint(point, CWP_ALL);
if(!pWnd)
sprintf(cText, "-, -");
else
{
GetCursorPos(&point);
pWnd->ScreenToClient(&point);

sprintf(cText, "%d, %d", point.x, point.y);
}

pCmdUI->SetText(cText);
}

Share this post


Link to post
Share on other sites
what exactly are you doing that you want the mouse coordinates inside a splitterwindow instead of inside the views of the splitterwindow?

Share this post


Link to post
Share on other sites
Quote:

what exactly are you doing that you want the mouse coordinates inside a splitterwindow instead of inside the views of the splitterwindow?

;) You are right.. sry. i want the mouse coordinates inside the views of the SplitterWindow cause of the Picking function and the model drag and drop... If already wondered why the middel of Splitter has with the code above the coordinates 0,0 :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!