Beispiel #1
1
static void PaintWindowThread(void *)
{
	/* First tell the main thread we're started */
	_draw_mutex->BeginCritical();
	SetEvent(_draw_thread_initialized);

	/* Now wait for the first thing to draw! */
	_draw_mutex->WaitForSignal();

	while (_draw_continue) {
		/* Convert update region from logical to device coordinates. */
		POINT pt = {0, 0};
		ClientToScreen(_wnd.main_wnd, &pt);
		OffsetRect(&_wnd.update_rect, pt.x, pt.y);

		/* Create a device context that is clipped to the region we need to draw.
		 * GetDCEx 'consumes' the update region, so we may not destroy it ourself. */
		HRGN rgn = CreateRectRgnIndirect(&_wnd.update_rect);
		HDC dc = GetDCEx(_wnd.main_wnd, rgn, DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_INTERSECTRGN);

		PaintWindow(dc);

		/* Clear update rect. */
		SetRectEmpty(&_wnd.update_rect);
		ReleaseDC(_wnd.main_wnd, dc);

		/* Flush GDI buffer to ensure drawing here doesn't conflict with any GDI usage in the main WndProc. */
		GdiFlush();

		_draw_mutex->WaitForSignal();
	}

	_draw_mutex->EndCritical();
	_draw_thread->Exit();
}
void CCatchScreenDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//*****************************************************************************************
	int nHitTest;
	nHitTest=m_rectTracker.HitTest(point);

	m_bShowMsg=TRUE;
	//PaintWindow();
	PaintWindow();

    //判断击中位置
	if(nHitTest<0)
	{
		if(!m_bFirstDraw)
		{
			m_startPt=point;
			m_bDraw=TRUE;
						
			PaintWindow();
		}
	}
	else
	{
		if(m_bFirstDraw)
		{
			m_rectTracker.Track(this,point,TRUE);
			SendMessage(WM_LBUTTONUP,NULL,NULL);
			PaintWindow();

		}
	}
//****************************************************************************************
	CDialog::OnLButtonDown(nFlags, point);
}
Beispiel #3
0
BOOL CCatchScreenDlg::PreTranslateMessage(MSG* pMsg)
{
	if(pMsg->message==WM_KEYDOWN)
	{
		CRect rect(0, 0, 0, 0);
		rect=m_rectTracker.m_rect;

		if(m_bDrawTracker)
		{

			//如果Shift键按下则方向键调整大小
			BOOL isShifeDowm=FALSE;
			int nVirtKey;
			nVirtKey = GetKeyState(VK_SHIFT); 
			if (nVirtKey & SHIFTED) 
				isShifeDowm = TRUE;

			switch(pMsg->wParam)
			{
			case VK_UP:
				//如果按下Shift,则只调整一边
				if(!isShifeDowm)
					rect.top -= 1;
				rect.bottom -= 1;
				m_rectTracker.m_rect=rect;
				PaintWindow();
				break;
			case VK_DOWN:
				rect.top += 1;
				if(!isShifeDowm)
					rect.bottom += 1;
				m_rectTracker.m_rect = rect;
				PaintWindow();
				break;
			case VK_LEFT:
				if(!isShifeDowm)
					rect.left -= 1;
				rect.right -= 1;
				m_rectTracker.m_rect = rect;
				PaintWindow();
				break;
			case VK_RIGHT:
				rect.left += 1;
				if(!isShifeDowm)
					rect.right += 1;
				m_rectTracker.m_rect = rect;
				PaintWindow();
				break;
			}
		}
	}

	return CDialog::PreTranslateMessage(pMsg);
}
static void GlobalPaintWindow(HWND hwnd)
{
	LWPAINTSTRUCT ps;
	BeginGlobalPaint(hwnd, &ps);
	PaintWindow(rootwp, &ps);
	EndGlobalPaint(hwnd, &ps);
}
Beispiel #5
0
void CCatchScreenDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
	m_bShowMsg = FALSE;
	m_bDraw = FALSE;
	PaintWindow();

	CDialog::OnLButtonUp(nFlags, point);
}
static void PaintWindow(HWND hwnd, LWPAINTSTRUCT *ps)
{
	HWND wp;
	
	wp = NextSibling(hwnd);
	if (wp)
	{
		PaintWindow(wp, ps);
	}
	
	PaintWindowNow(hwnd, ps);
	
	wp = Children(hwnd);
	if (wp)
	{
		PaintWindow(wp, ps);
	}
}
void CCatchScreenDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//*****************************************************************************************
	int nHitTest;
	nHitTest=m_rectTracker.HitTest(point);

    //判断击中位置
	if(nHitTest<0)
	{
		if(!m_bFirstDraw)
		{
			//第一次画矩形
			m_startPt=point;
			m_bDraw=TRUE;
			m_bFirstDraw=TRUE;
			//设置当当鼠标按下时最小的矩形大小
			m_rectTracker.m_rect.SetRect(point.x,point.y,point.x+4,point.y+4);	
			
			//保证当鼠标当下时立刻显示信息
			if(m_bFirstDraw)
			  m_bShowMsg=TRUE;		
			DrawTip();
			PaintWindow();
		}
	}
	else
	{
		//保证当鼠标当下时立刻显示信息
		m_bShowMsg=TRUE;		
		PaintWindow();
		
		if(m_bFirstDraw)
		{
			//调束大小时,Track会自动调整矩形大小,在些期间,消息归CRectTracker内部处理
			m_rectTracker.Track(this,point,TRUE);
			//SendMessage(WM_LBUTTONUP,NULL,NULL);
			PaintWindow();

		}
	}
//****************************************************************************************
	CDialog::OnLButtonDown(nFlags, point);
}
Beispiel #8
0
//--------------------------------------------------------------------------
//	功能:绘制窗口(包括子窗口与后继兄弟窗口)
//--------------------------------------------------------------------------
void KWndWindow::Paint()
{
	if (m_Style & WND_S_VISIBLE)
	{
		PaintWindow();
		if (m_pFirstChild)
			m_pFirstChild->Paint();
	}
	if (m_pNextWnd)
		m_pNextWnd->Paint();
}
Beispiel #9
0
void PaintTheBlock(HWND hCtrl, int iColor, int iFigure)

{

	InvalidateRect(hCtrl, NULL, TRUE);

	UpdateWindow(hCtrl);

	PaintWindow(hCtrl, iColor, iFigure);

}
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HRESULT hr;
    int wmId, wmEvent;

    switch (message)
    {
        case WM_COMMAND:
            wmId    = LOWORD(wParam);
            wmEvent = HIWORD(wParam);

            // Parse the menu selections:
            switch (wmId)
            {
                case ID_FILE_START:
                    hr = StartGraph(g_hWnd);
                    if( FAILED(hr) )
                    {
                        return 0;
                    }
                    break;

                case IDM_ABOUT:
                   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
                   break;

                case IDM_EXIT:
                   DestroyWindow(hWnd);
                   break;

                default:
                   return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;

        case WM_PAINT:
            PaintWindow(hWnd);
            break;

        case WM_DESTROY:
            PostQuitMessage(0);
            break;

        case WM_MOVE:
        case WM_SIZE:
            MoveWindow();
            break;

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
void CCatchScreenDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//****************************************************************************************

	m_bShowMsg=FALSE;
	m_bDraw=FALSE;

	PaintWindow();
//****************************************************************************************
	CDialog::OnLButtonUp(nFlags, point);
}
Beispiel #12
0
void CCatchScreenDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	if(m_bDraw)
	{
		m_rectTracker.m_rect.SetRect(m_startPt.x + 1,m_startPt.y + 1,point.x, point.y);
		m_bDrawTracker=TRUE;
		
		PaintWindow();
	}
	CClientDC dc(this);
	DrawTip(dc);
	CDialog::OnMouseMove(nFlags, point);
}
Beispiel #13
0
void CCatchScreenDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	int nHitTest;
	nHitTest = m_rectTracker.HitTest(point);
	m_bShowMsg=TRUE;
	PaintWindow();

    //判断击中位置
	if(nHitTest < 0)
	{
		if(!m_bDrawTracker)
		{
			m_startPt=point;
			m_bDraw=TRUE;
						
			PaintWindow();
		}
		else{
			m_bDrawTracker=FALSE;
			m_rectTracker.m_rect.SetRect(-1, -1, -1, -1);
			m_startPt=point;
			m_bDraw=TRUE;
			
			PaintWindow();
		}
	}
	else
	{
		if(m_bDrawTracker)
		{
			m_rectTracker.Track(this, point, TRUE);
			SendMessage(WM_LBUTTONUP, NULL, NULL);
			PaintWindow();

		}
	}

	CDialog::OnLButtonDown(nFlags, point);
}
void CCatchScreenDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//**************************************************************************************
	   if(m_bDraw)
	   {
			m_rectTracker.m_rect.SetRect(m_startPt.x+1,m_startPt.y+1,point.x,point.y);
			m_bFirstDraw=TRUE;

			PaintWindow();
	   }
	   DrawTip();
//*****************************************************************************************
	CDialog::OnMouseMove(nFlags, point);
}
Beispiel #15
0
void CCatchScreenDlg::OnRButtonDown(UINT nFlags, CPoint point) 
{
	CDialog::OnRButtonDown(nFlags, point);
	if(m_bDrawTracker)
	{
		//如果已经截取矩则清除截取矩形
		m_bDrawTracker=FALSE;
		m_rectTracker.m_rect.SetRect(-1, -1, -1, -1);
		PaintWindow();
	}
	else 
	{
		CDialog::OnCancel();
	}
}
Beispiel #16
0
void CCatchScreenDlg::OnCancel() 
{
	if(m_bDrawTracker)
	{
		m_bDrawTracker=FALSE;
		m_bDraw=FALSE;
		m_rectTracker.m_rect.SetRect(-1,-1,-1,-1);
		PaintWindow();
		this->SendMessage (WM_SETCURSOR, 0 , 0);
	}
	else
	{
		CDialog::OnCancel();
		//PostMessage(WM_CLOSE);
	}
}
Beispiel #17
0
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_KEYUP    - Exit in response to ESC key
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
LRESULT CALLBACK SingleFace::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    UINT wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_ABOUT:
            DialogBox(m_hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
            break;
        case IDM_EXIT:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_KEYUP:
        if (wParam == VK_ESCAPE)
        {
            PostQuitMessage(0);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        // Draw the avatar window and the video window
        PaintWindow(hdc, hWnd);
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
	case WM_SIZE:
		ReSizeGLScene(LOWORD(lParam), HIWORD(lParam));
		break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Beispiel #18
0
/*
	FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)

	PURPOSE: Windows procedure for the main window

	PARAMETERS:
		hWnd	- window handle
		message	- window message
		wParam	- window message parameter (depends on message)
		lParam	- window message parameter (depends on message)

	RETURN:
		If the message was processed, the return value is 0
		If the message was not processed and passed to DefWindowProc
		and the return value depends on the value of that function.

*/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	HANDLE	hEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("P2"));
	HWND	hWndBttn;

	switch (message) {
		case WM_CREATE: // case for when the window is created
			// Create our button
			hWndBttn = CreateWindow( BUTTONCLASS, TEXT("Eat Me"), 
						WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 
						BUTTONOFFSET, 
						BUTTONOFFSET, BUTTONWIDTH, 
						BUTTONHEIGHT, hWnd,
						(HMENU)ID_BUTTON,
						ghInst, NULL );
			CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, (LPVOID)0, 0, 0);
			break;

		case WM_DESTROY: // case for when the window is closed
			PostQuitMessage(0);
			break;

		case WM_COMMAND: // case for menu commands
			switch (LOWORD(wParam)) {
				case ID_BUTTON:
					//MessageBox(NULL, TEXT("You die."), NULL, MB_OK | MB_ICONSTOP);
					SetEvent(hEvent);
					break;
			}
			break;

		case WM_SIZE: // case for when the window is resized
			break;

		case WM_PAINT:
			PaintWindow(hWnd);
			break;

		case WM_CLOSE:
			DestroyWindow(hWnd);
			break;

		default:
			return (int)DefWindowProc(hWnd, message, wParam, lParam);
	}

	return 0;
}
void CCatchScreenDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
//***************************************************************
	if(m_bFirstDraw)
	{
		m_bFirstDraw=FALSE;
		m_bDraw=FALSE;
		m_rectTracker.m_rect.SetRect(-1,-1,-1,-1);
		PaintWindow();
	}
	else
	{
		CDialog::OnCancel();
	}
//*******************************************************************
}
Beispiel #20
0
/******************************************************************************
Function Name   : OnPaint
Input(s)        : -
Output          : void
Functionality   : Draws the Indicators client window
Member of       : CWaitIndicator
Friend of       : -
Author(s)       : Venkatanarayana Makam
Date Created    :
Modifications   :
******************************************************************************/
void CWaitIndicator::OnPaint(void)
{
    // Device context for painting
    CPaintDC dc(this);
    /*CRect ClientRect;

    // Client Rect Painting
    GetClientRect(&ClientRect);
    CBrush omBrush((COLORREF) GetSysColor(COLOR_ACTIVECAPTION));
    dc.FrameRect(&ClientRect, &omBrush);

    // Load Font Deatils
    dc.SetBkMode(TRANSPARENT);

    // Finally Set The text;
    dc.DrawText(m_strTitle, &ClientRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);*/
    PaintWindow(dc);
}
void CCatchScreenDlg::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//****************************************************************************************
	if(m_bFirstDraw)
	{
		//如果已经截取矩则清除截取矩形
		m_bFirstDraw=FALSE;
		m_rectTracker.m_rect.SetRect(-1,-1,-1,-1);
		PaintWindow();
	}
	else
	{
		 //关闭程序
		//ShowWindow(SW_HIDE);
		 PostQuitMessage(0);
	}
//****************************************************************************************
	CDialog::OnRButtonDown(nFlags, point);
}
void CCatchScreenDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//**************************************************************************************
	   if(m_bDraw)
	   {
			//动态调整矩形大小,并刷新画出
		    m_rectTracker.m_rect.SetRect(m_startPt.x+4,m_startPt.y+4,point.x,point.y);
			PaintWindow();
	   }
	   
	   //弥补调整大小和位置时,接收不到MouseMove消息
	   CRect rect;
	   m_tipEdit.GetWindowRect(&rect);
	   if(rect.PtInRect(point))
	   m_tipEdit.SendMessage(WM_MOUSEMOVE);
       
	   ChangeRGB();
//*****************************************************************************************
	CDialog::OnMouseMove(nFlags, point);
}
void CCatchScreenDlg::OnRButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	//****************************************************************************************
	if(m_bFirstDraw)
	{
		//如果已经截取矩则清除截取矩形
		m_bFirstDraw=FALSE;
		//清除矩形大小
		m_rectTracker.m_rect.SetRect(-1,-1,-1,-1);
		DrawTip();
		PaintWindow();
	}
	else
	{
		 //关闭程序
		 //PostQuitMessage(0);
		OnCancel();
	}
//****************************************************************************************
	CDialog::OnRButtonUp(nFlags, point);
}
Beispiel #24
0
/****************************************************************************

 WindowProc: Windows calls this function when we dispatch messages.

 ****************************************************************************/
LRESULT CALLBACK WindowProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
)
{
  switch(uMsg) {
  
  // we get the WM_CLOSE message when our close (X) box has been clicked.
  // we need to respond to it to make sure our program stops when its window
  // is closed.

  case WM_PAINT:
    {
      PAINTSTRUCT ps;

      // get the DC we're supposed to use from Windows
      BeginPaint(hwnd, &ps);
      HDC hdc = ps.hdc;
      
      // paint our window (function is defined above)
      PaintWindow(hdc);
      
      // tell Windows we're done painting.
      EndPaint(hwnd, &ps);
    }
    // we processed the message, so return 0.
    return(0);

  case WM_CLOSE: // our close button has been hit!  quit!
    PostQuitMessage(0);
    return(0);
  }

  // all the other messages, we don't care about, so we let DefWindowProc
  // handle them.
  return(DefWindowProc(hwnd, uMsg, wParam, lParam));
}
Beispiel #25
0
void CCatchScreenDlg::CaptureIt()
{
	m_bSleeping = false;
	//截取屏幕到位图中
	CRect rect(0, 0, m_nCXScreen, m_nCYScreen);
	SetRedraw(FALSE);
	m_OrgBackgroundBitmap.Attach(CopyScreenToBitmap(&rect));
	CClientDC dc(this);
	m_BackgroundBitmap.Attach(CreateTransparentColorBitmap(&dc, &m_OrgBackgroundBitmap, rect));
	
	//把对化框设置成全屏顶层窗口
	 SetWindowPos(&wndTopMost, 0, 0, m_nCXScreen, m_nCYScreen, SWP_SHOWWINDOW);

	SetRedraw();
	//移动操作提示窗口
	m_wndTipEdit.GetWindowRect(&rect);
    m_wndTipEdit.MoveWindow(10, 10, rect.Width(), rect.Height());
    
	m_bDrawTracker=FALSE;
	m_rectTracker.m_rect.SetRect(-1, -1, -1, -1);
	PaintWindow();
	//显示操作提示窗口文字
	DrawTip(dc);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HINSTANCE hInstance = GetModuleHandle(NULL);
    switch (message)
    {
    case WM_CREATE:
    {
        return(0);
    }
    case WM_PAINT:
    {
        PaintWindow(hwnd);
        return(0);
    }
    case SC_MAXIMIZE:
    {
        PaintWindow(hwnd);
        return(0);
    }
    case WM_TIMER:
    {
        switch (wParam)
        {
        case(TIMER_WINDOW_REFRESH) :
        {
            switch (controller->CalibrationStep())
            {
            case(1) :
            {
                hwndCalibrationButton = CreateWindow(TEXT("Button"), TEXT("Calibration Step 1"),
                                                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 20, 500, 180, 50,
                                                     hwnd, (HMENU)IDB_CALIBRATION, hInstance, NULL);
                controller->CalibrationInterfaceStepUp();
                break;
            }
            }
            break;
        }
        default:
        {
            break;
        }

        }
        return(0);
    }
    case WM_DESTROY:
    {
        PostQuitMessage(0);
        return(0);
    }
    case WM_COMMAND:
    {
        switch (LOWORD(wParam))
        {
        case (IDB_CALIBRATION) :
        {
            INT nCalibrationStep = controller->CalibrationStep();
            switch (nCalibrationStep)
            {
            case(2) :
            {
                if (controller->ButtonClick_Calibration(0))
                {
                    controller->CalibrationInterfaceStepUp();
                    hwndMarkDistance = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), TEXT(""),
                                                      WS_CHILD | WS_VISIBLE, 20, 450, 180, 25,
                                                      hwnd, (HMENU)IDE_MARKDISTANCE, hInstance, NULL);
                    SendMessage(hwndCalibrationButton, WM_SETTEXT, (WPARAM)NULL, (LPARAM)L"Calibration Step 2");
                    //	SendMessage(hwndCalibrationButton, WM_CLOSE, NULL, NULL);     //ver2
                }
                break;
            }
            case(3) :
            {
                WCHAR wsMarkDistance[256];
                CHAR sMarkDistance[256];
                DOUBLE fMarkDistance;
                GetWindowText(hwndMarkDistance, wsMarkDistance, 256);
                INT wsLen = wcslen(wsMarkDistance);
                WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wsMarkDistance, wsLen, (LPSTR)sMarkDistance, wsLen, NULL, NULL);
                fMarkDistance = atof(sMarkDistance);
                if (controller->ButtonClick_Calibration(fMarkDistance))
                {
                    controller->CalibrationInterfaceStepUp();
                    SendMessage(hwndCalibrationButton, WM_CLOSE, NULL, NULL);
                    SendMessage(hwndMarkDistance, WM_CLOSE, NULL, NULL);
                }
                break;
            }
            default:
            {
                break;
            }
            }
        }
        default:
        {
            break;
        }
        }
    }
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
Beispiel #27
0
LONG FAR PASCAL WndProc(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam)
{
	int NewX, NewY, i;

	switch (messg)
	{
	 case WM_PAINT:
        PaintWindow(hWnd);
     	break;
	 case WM_MOUSEMOVE:
		MouseX = LOWORD(lParam) - 32;
		MouseY = HIWORD(lParam) - 45;
		Counter2 = 0;
		break;
	 case WM_TIMER:
		switch (State) {
			case 0:
            	State = 4;
				Pic = 0;
				Counter = 0;
				LastX = MouseX;
				LastY = MouseY;
				break;
			case 1:
				if ((LastX != MouseX) || (LastY != MouseY)) {
					if (MouseX > (LastX + SPEED)) {
						NewX = LastX + SPEED;
						Sec = 0;
					}
					else if (MouseX < (LastX - SPEED)) {
						NewX = LastX - SPEED;
						Sec = 8;
					} else {
						NewX = MouseX;
            		}

					if (MouseY > (LastY + SPEED)) {
						NewY = LastY + SPEED;
					}
					else if (MouseY < (LastY - SPEED)) {
						NewY = LastY - SPEED;
					} else {
						NewY = MouseY;
            		}

					DisplayPic(hWnd, NewX, NewY, Pic + Sec);
					Pic = ((Pic + 1) % 8);

					LastX = NewX;
					LastY = NewY;

					if (Counter != 500) {
						Counter ++;
					}
					else {
						Counter = 0;
						Counter2 = 0;
                        Pic = 0;
                    	State = 6;
                    }
				} else {
					State = 2;
					Counter = 0; 
				}
				break;
			case 2:
				if ((LastX != MouseX) || (LastY != MouseY)) {
					State = 1;
					Pic = 0;
                    Counter = 0;
				} else {
					if (Counter < 100) {
						Counter ++;
						if (Counter == 1)
							DisplayPic(hWnd, LastX, LastY, 16);

					} else {
						Pic = 0;
						State = 3;
                        Counter = 0;
					} 
				}
				break;
			case 3:
				if ((LastX != MouseX) || (LastY != MouseY)) {
					State = 5;
                    Counter = 0;
				} else {
					if (Counter != 10) {
						Counter ++;
					}
					else if (Pic < 5) {
						Counter = 0;
						Pic ++;
						DisplayPic(hWnd, LastX, LastY, Pic + 16);
					}
					else {
						State = 4;
						Counter = 0;
						Pic = 0;
                    }
				}
				break;
			case 4:
				if ((LastX != MouseX) || (LastY != MouseY)) {
					State = 5;
					Counter = 0;
                    Pic = 5;
				} else {
					if (Counter == 20) {
						DisplayPic(hWnd, LastX, LastY, 22);
					}
					else if (Counter == 40) {
						DisplayPic(hWnd, LastX, LastY, 21);
					}
					else if (Counter == 100) {
						Counter = 0;
					};
					Counter ++;
				}
				break;
			case 5:
				if (Counter == 10) {
					if (Pic > 0) {
						Pic --;
						DisplayPic(hWnd, LastX, LastY, 16 + Pic);
					}
					else {
						State = 1;
						Counter = 0;
                        Pic = 0;
                    }
				}
                else { 
					Counter ++;
                }
				break;
			case 6:
				if (Counter == 3) {
					if (Pic > 8) {
						Pic = 4;
                        Counter2 ++;
					}
                    if (Counter2 < 4) {
						DisplayPic(hWnd, LastX, LastY, 23 + Pic);
                    	Pic ++;
						Counter = 0;
					}
					else {
						Counter2 = 0;
						Counter = 0;
						Pic = 0;
                        State = 1;
                    }
				}
				else {
                	Counter ++;
				}
				break;
            };
		break;
	 case WM_COMMAND:
		switch (wParam) {
			case 101:
				if (TestParety(hWnd))
					fDialog ("DIALOG_1", hWnd, (FARPROC)AboutDialogProc);
			break;
			case 102:
				ExitApp(hWnd);
            break;
        }
     	break;
	 case WM_SIZE:
		if (wParam == SIZE_MINIMIZED) {
			MouseX = - 10;
			MouseY = - 20;
			State = 1;
			Pic = 0;
            Counter = 0;
		}
        break;
	 case WM_DESTROY:
		ExitApp(hWnd);
 		break;
	 default:
		return DefWindowProc(hWnd, messg, wParam, lParam);
	 }
     return 0L;
} 
Beispiel #28
0
/******************************************************************************
Function Name   : Redraw
Input(s)        : -
Output          : void
Functionality   : Redraws the window.
Member of       : CWaitIndicator
Friend of       : -
Author(s)       : Venkatanarayana Makam
Date Created    :
Modifications   :
******************************************************************************/
void CWaitIndicator::Redraw(void)
{
    CClientDC dc(this);
    PaintWindow(dc);
    PaintWindow(dc);
}
//-----------------------------------------------------------------------------
// Subclassed Window Callback
//-----------------------------------------------------------------------------
LRESULT CVsVGuiWindow::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch ( uMsg )
	{
	case WM_NCDESTROY:
		// WM_NCDESTROY is the last message, detach the object from the window handle
		if ( hWnd == m_hWnd )
		{
			Detach();
			LRESULT lr = ::DefSubclassProc( hWnd, uMsg, wParam, lParam );
			delete this;
			return lr;
		}
		break;
	 
	case WM_GETDLGCODE:
		return DLGC_WANTALLKEYS | DLGC_WANTCHARS; // forward all keyboard into to vgui panel	

	case WM_SETCURSOR:
		return 1;	// don't pass WM_SETCURSOR
	  
	case WM_MOUSEACTIVATE:
		if ( hWnd == m_hWnd )
		{
			HWND hFocus = GetFocus();
			if ( hFocus != m_hKeyFocusWnd )
			{
				SetFocus( m_hKeyFocusWnd );
			}
			return MA_ACTIVATE;
		}
		break;

	case WM_SETFOCUS:
		if ( hWnd == m_hWnd )
		{
			g_pMayaVGui->SetFocus( m_hWnd, m_hVGuiContext );
			return 0;
		}
		break;

	case WM_KILLFOCUS:
		if ( hWnd == m_hWnd )
		{
			if ( g_pMayaVGui->HasFocus( m_hWnd ) )
			{
				g_pMayaVGui->SetFocus( NULL, 0 );
			}
			return 0;
		}
		break;
		 
	case WM_PAINT:
		if ( hWnd == m_hWnd )
		{
			PaintWindow();
			return 0;
		}
		break;
	}
	 
	return ::DefSubclassProc( hWnd, uMsg, wParam, lParam );
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static BOOL   fContinueCalc = FALSE ;
     static HAB    hab ;
     static HWND   hwndMenu ;
     static INT    iStatus = STATUS_READY ;
     static INT    iCurrentRep = IDM_10 ;
     static LONG   lCalcRep, lRepAmts [] = { 10, 100, 1000, 10000, 100000 } ;
     static ULONG  ulElapsedTime ;
     double        A ;
     LONG          lRep ;
     QMSG          qmsg ;

     switch (msg)
          {
          case WM_CREATE:
               hab = WinQueryAnchorBlock (hwnd) ;

               hwndMenu = WinWindowFromID (
                               WinQueryWindow (hwnd, QW_PARENT),
                               FID_MENU) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case IDM_10:
                    case IDM_100:
                    case IDM_1000:
                    case IDM_10000:
                    case IDM_100000:
                         WinCheckMenuItem (hwndMenu, iCurrentRep, FALSE) ;
                         iCurrentRep = COMMANDMSG(&msg)->cmd ;
                         WinCheckMenuItem (hwndMenu, iCurrentRep, TRUE) ;
                         return 0 ;

                    case IDM_START:
                         WinEnableMenuItem (hwndMenu, IDM_START, FALSE) ;
                         WinEnableMenuItem (hwndMenu, IDM_ABORT, TRUE) ;

                         iStatus = STATUS_WORKING ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;

                         lCalcRep = lRepAmts [iCurrentRep - IDM_10] ;
                         fContinueCalc = TRUE ;
                         ulElapsedTime = WinGetCurrentTime (hab) ;

                         qmsg.msg = WM_NULL ;

                         for (A = 1.0, lRep = 0 ; lRep < lCalcRep ; lRep++)
                              {
                              A = Savage (A) ;

                              while (WinPeekMsg (hab, &qmsg, NULLHANDLE,
                                                 0, 0, PM_NOREMOVE))
                                   {
                                   if (qmsg.msg == WM_QUIT)
                                        break ;

                                   WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0) ;
                                   WinDispatchMsg (hab, &qmsg) ;

                                   if (!fContinueCalc)
                                        break ;
                                   }
                              if (!fContinueCalc || qmsg.msg == WM_QUIT)
                                   break ;
                              }
                         ulElapsedTime = WinGetCurrentTime (hab) - 
                                                  ulElapsedTime ;

                         if (!fContinueCalc || qmsg.msg == WM_QUIT)
                              iStatus = STATUS_READY ;
                         else
                              iStatus = STATUS_DONE ;

                         WinInvalidateRect (hwnd, NULL, FALSE) ;

                         WinEnableMenuItem (hwndMenu, IDM_START, TRUE) ;
                         WinEnableMenuItem (hwndMenu, IDM_ABORT, FALSE) ;
                         return 0 ;

                    case IDM_ABORT:
                         fContinueCalc = FALSE ;
                         return 0 ;
                    }
               break ;

          case WM_PAINT:
               PaintWindow (hwnd, iStatus, lCalcRep, ulElapsedTime) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }