void CProgressMeterClass::OnPaint()
{
	PAINTSTRUCT		 	paint;
	BeginPaint(m_hWnd, &paint);
	HDC hdc = paint.hdc;
    RECT rect;                      // get the entire area of the static region
    ::GetClientRect(m_hWnd, &rect);           

	int nCubes, oldmod = 21;

	// try 20 to 30 cubes and select the best fit (least modulo)
	for ( nCubes = 30; nCubes <= 50; nCubes++ )
	{
		int extra = ( rect.right - 4 ) / nCubes;
		int val = ( ( rect.right - 4 ) + ( extra / 2 ) ) % nCubes;

		// is this a better fit than the last try?
		if ( val < oldmod )
		{
			oldmod = val;           // yes, save count
			cubeCount = nCubes;

			// compute the cube width and height for the control
			cubeWidth = ( ( ( rect.right - 4 ) + ( extra / 2 ) ) ) / nCubes;
			cubeHeight = rect.bottom - 4;

			// if this is a perfect fit, look no further
			if ( !val )
				break;
		}
	}		

	WFE_DrawLoweredRect(hdc, &rect);
		
    // draw the center of the control in the button face color
	::InflateRect(&rect, -EDGE_WIDTH, -EDGE_WIDTH);
    ::FillRect( hdc, &rect, sysInfo.m_hbrBtnFace );

    // paint all the cubes that have been painted already (this is for refresh)
    long i;
    long interval = 1000 / cubeCount;
    if ( !interval )
        interval = 1;

    if (percent > 100)
		percent = 100;
	if (percent < 0)
		percent = 0;

    for ( i = 0; i < long(percent) * 1000L / interval / 100; i++ )
        PaintCube( hdc, CASTINT(i) );

	EndPaint(m_hWnd, &paint);
}
Exemple #2
0
void MyApp::OnPaint3D()
{
  sInput2Update(sGetTime());
  PaintCube();
  PrintInput();

  // make XBOX controllers rumble...
  sU32 deviceType = sINPUT2_TYPE_JOYPADXBOX;
  sInt count = sInput2NumDevices(deviceType);
  
  for (sInt i=0; i<count;i++)
  {
    sInput2Device *device = sFindInput2Device(deviceType,i);
    if (device)
      device->SetMotor(device->GetAbs(sINPUT2_JOYPADXBOX_LT)*255,device->GetAbs(sINPUT2_JOYPADXBOX_RT)*255);
  }
}
void CProgressMeterClass::OnStep()
{
	HDC hdc = GetDC(m_hWnd);

    // did we overstep?
    if ( percent < 100 )
    {
        // get the spacing
        long interval = 1000 / cubeCount;
        if ( !interval )
            interval = 1;
        percent++;

        // time to draw another cube?
        if (long(percent) * 1000L / interval / 100 > lastUpdate)
        {   
            PaintCube ( hdc, lastUpdate );
            lastUpdate = CASTINT(long(percent) * 1000L / interval  / 100);
        }
    }
	ReleaseDC(m_hWnd, hdc);
}