9.18(화) 실습-2( SystemparameterInfo )

2007/10/10 17:06

1. 윈도우 자석효과 내보기
[ more.. | less.. ]
// wpos : window 창의위치, Magx,y : 자석효과 범위
void SetMagnetWindow(HWND hwnd, WINDOWPOS* wpos, int Magx, int Magy)
{
      RECT ScreenRc;

      SystemParametersInfo( SPI_GETWORKAREA, 0, &ScreenRc, 0); // 작업표시줄을 뺀 영역이다!!!

      RECT WinRc;
      WinRc.left = wpos->x;
      WinRc.top = wpos->y;
      WinRc.right = wpos->x + wpos->cx;
      WinRc.bottom = wpos->y + wpos->cy;
      int WinWidth = wpos->cx;
      int WinHeight = wpos->cy;

      // 좌
      if( WinRc.left < Magx &&
            WinRc.left> 0 )
      {
            wpos->x = ScreenRc.left;
      }
      // 우
      if( (WinRc.left + WinWidth) > ScreenRc.right - Magx &&
             WinRc.left + WinWidth < ScreenRc.right )
      {
            wpos->x = ScreenRc.right - WinWidth;
      }
      // 상
      if( WinRc.top < Magx &&
            WinRc.top > 0 )
      {
            wpos->y = ScreenRc.top;
      }
      // 하
      if( WinRc.bottom > ScreenRc.bottom - Magy  &&
            WinRc.bottom < ScreenRc.bottom )
      {
            wpos->y = ScreenRc.bottom - WinHeight;
      }
}

Tags

API, 실습