in my application i need to draw some shapes over video continuously.
i have used direct show for video play back & gdi for drawing shapes
now suppose for drawing shapes i have used following function
void threadPaint( void * )
{
WINDOWPLACEMENT lpwndpl_v1;
GetWindowPlacement(hw,&lpwndpl_v1);
HDC hdc;
hdc = BeginPaint(hw, &ps);
Graphics graphics(hw);
Pen pen3(Color(255, 0,0,255),10);
while(threadAna) {
graphics.DrawLine(&pen3,lpwndpl_v1.rcNormalPosition.left+40,lpwndpl_v1.rcNormalPosition.top+90,lpwndpl_v1.rcNormalPosition.right,lpwndpl_v1.rcNormalPosition.top+90);
}
EndPaint(hw, &ps);
}
i call this thread using
threadAna=1;
_beginthread( threadPaint, 0, (void*)12 );
Sleep(20);
in my application i used function
SetWindowPos()
&
ShowWindow()
at various places.
for example at
WM_MOUSEMOVE
::SetWindowPos(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), HWND_TOPMOST, lpwndpl_home.rcNormalPosition.left+9, lpwndpl_home.rcNormalPosition.bottom, 55,18, SWP_NOZORDER );
SetWindowText(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), "HOME");
ShowWindow(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), TRUE);
now my problem is that whenever i mouse move or press some button where i used
SetWindowPos()
&
ShowWindow()
whole window is affected(i think its updated in unusual way).
if i did not use the thread then application runs fine..