I'm using groupBox to show an area in my prog, and I need to show the cursor position in it. I want to use sth like onMouseMove, but groupBox has just BNClicked and BNDblClicked msgs. How do I do that pls?
thx
bubak
I've done it this way:
I created OnMOuseMove for my app, and a dataRect structure, that is initializes in OnInit :
GetDlgItem(IDC_DATA)->GetWindowRect(dataRect);
in OnMouseMove :
POINT p;
GetCursorPos(&p);
if(PtInRect(dataRect,p))
{
SetDlgItemText(IDC_ActTime,"IN"
}else
{
SetDlgItemText(IDC_ActTime,"out"
}
Everything works ok( in and out), until I move tha window. I though, that it chcecks still the old dataRect and I've moved GetDlgItem(IDC_DATA)->GetWindowRect(dataRect); int onPaint(), but it doesn't help. It stills chceks the first position of dataRect. Why?
bubak
yep, i know, but when I do GetWindoRect, I'll get upper left and bottom right point of my dialog and this will be also relative to screen, so I can do just GetCursorPos and PtInRect and it should work fine, i think. but it does not. ;-(
bubak
ANOTHER ONE BIG QUESTION ;-)
I have an groupbox IDC_DATAQ, and CRect dataRect.
When I do
GetDlgItem(IDC_DATA)->GetWindowRect(dataRect);
in OnInitDIalog, in dataRect will be values relative to dialog border, but when I do it in OnPaint(), the values in dataRect will be relative to screen. Why?
bubak
It is because probably the compiler somehow uses once the GetWindowRect from SDK(even if this takes 2 parameters as I remembewr) and another time the GetWindowRect of the CWnd class.
I didn't try what you say but to better why don't you qualify your functions with :: for the sdk and with this->for the CWnd ones and see what happens.
Also use the two API and CWnd functions
ClientToScreen and ScreenToClient.
Hopet his helps,
s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darkness...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.