Click here to Skip to main content
15,924,193 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WM_MOUSEMOVE Child Window Pin
Mircea Puiu20-Oct-05 4:43
Mircea Puiu20-Oct-05 4:43 
GeneralRe: WM_MOUSEMOVE Child Window Pin
nermsk20-Oct-05 7:33
nermsk20-Oct-05 7:33 
GeneralRe: WM_MOUSEMOVE Child Window Pin
Mircea Puiu20-Oct-05 8:11
Mircea Puiu20-Oct-05 8:11 
AnswerRe: WM_MOUSEMOVE Child Window Pin
TheJonzer20-Oct-05 10:00
TheJonzer20-Oct-05 10:00 
Hi -

I did this.

The best way to do it is to have the child window capture the mouse input and move itself.

MFC makes it easy to do. You can do it with a WIN32 API windProc - but it's more straight foward in MFC.


void myStatic::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
::SetCapture(*this) ;
::OutputDebugString("myStatic::OnLButtonDown\n") ;

mdown = 1 ;
m_x = point.x ;
m_y = point.y ;

// CStatic::OnLButtonDown(nFlags, point);
}

void myStatic::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if( mdown )
{
::OutputDebugString("myStatic::OnMouseMove\n") ;

RECT lrect ;
::GetWindowRect(*this,&lrect) ;

point.x -= m_x;// modify the pt with the saved point
point.y -= m_y;

POINT lpt ;
lpt.x = lrect.left ;
lpt.y = lrect.top ;

::ScreenToClient(*this->GetParent(),&lpt) ;

lpt.x += point.x ;
lpt.y += point.y ;

::SetWindowPos( *this, 0, lpt.x, lpt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE );
}
// CStatic::OnMouseMove(nFlags, point);
}

void myStatic::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if( mdown )
{
mdown = 0 ;

::OutputDebugString("myStatic::OnLButtonUp\n") ;

::ReleaseCapture() ;
}

// CStatic::OnLButtonUp(nFlags, point);
}

- Joe

-- modified at 16:28 Thursday 20th October, 2005
QuestionCStatic derived class Pin
cedric_craze20-Oct-05 4:04
cedric_craze20-Oct-05 4:04 
AnswerRe: CStatic derived class Pin
Cedric Moonen20-Oct-05 4:15
Cedric Moonen20-Oct-05 4:15 
AnswerRe: CStatic derived class Pin
Mircea Puiu20-Oct-05 4:27
Mircea Puiu20-Oct-05 4:27 
GeneralRe: CStatic derived class Pin
cedric_craze20-Oct-05 5:32
cedric_craze20-Oct-05 5:32 
GeneralRe: CStatic derived class Pin
Mircea Puiu20-Oct-05 5:36
Mircea Puiu20-Oct-05 5:36 
GeneralRe: CStatic derived class Pin
cedric_craze20-Oct-05 5:48
cedric_craze20-Oct-05 5:48 
Questionwriting an xml file. Pin
swaapu20-Oct-05 1:47
swaapu20-Oct-05 1:47 
AnswerRe: writing an xml file. Pin
sunit520-Oct-05 2:45
sunit520-Oct-05 2:45 
QuestionRe: writing an xml file. Pin
David Crow20-Oct-05 4:35
David Crow20-Oct-05 4:35 
AnswerRe: writing an xml file. Pin
sunit520-Oct-05 5:34
sunit520-Oct-05 5:34 
AnswerRe: writing an xml file. Pin
ThatsAlok20-Oct-05 19:23
ThatsAlok20-Oct-05 19:23 
Questionduplicate nodes in tree view control Pin
QuickDeveloper20-Oct-05 1:45
QuickDeveloper20-Oct-05 1:45 
AnswerRe: duplicate nodes in tree view control Pin
PJ Arends20-Oct-05 11:25
professionalPJ Arends20-Oct-05 11:25 
GeneralRe: duplicate nodes in tree view control Pin
QuickDeveloper20-Oct-05 22:43
QuickDeveloper20-Oct-05 22:43 
GeneralRe: duplicate nodes in tree view control Pin
PJ Arends20-Oct-05 23:16
professionalPJ Arends20-Oct-05 23:16 
GeneralRe: duplicate nodes in tree view control Pin
QuickDeveloper21-Oct-05 0:34
QuickDeveloper21-Oct-05 0:34 
GeneralRe: duplicate nodes in tree view control Pin
PJ Arends21-Oct-05 7:54
professionalPJ Arends21-Oct-05 7:54 
QuestionHow to make scrolling marquee ? Pin
Amarelia20-Oct-05 1:45
Amarelia20-Oct-05 1:45 
AnswerRe: How to make scrolling marquee ? Pin
Mircea Puiu20-Oct-05 4:30
Mircea Puiu20-Oct-05 4:30 
AnswerRe: How to make scrolling marquee ? Pin
PJ Arends20-Oct-05 11:29
professionalPJ Arends20-Oct-05 11:29 
Questiondsw NOT OPENING !!!! Pin
dharani20-Oct-05 1:40
dharani20-Oct-05 1:40 

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.