Esempio n. 1
0
int make_move(const GameState* state, int i, int d)
{
  assert(d > 0);
  int player = ai_current_player();
  MoveResult move = is_valid_move(state, player, i, d);
  DEBUG("make_move(): P%d moves %d -> %d (result %d)\n", player, i, i-d, move);
  int src = PT(player,i);
  int dest = PT(player,i-d);
  switch (move)
  {
    case MOVE_INVALID:
      return 0;
    case MOVE_BEAROFF:
      assert(src >= 0 && src < 24);
      SET(state->points[src], MAKEPOINT(player, state->points[src].count-1));
      DEC(state->total[player]);
      ai_set_player_score(player, 15 - state->total[player]);
      DEBUG("make_move(): P%d beared off @ %d; %d left\n", player, i, state->total[player]);
      return 1;
    case MOVE_UNOCCUPIED:
    case MOVE_MERGE:
      assert(src >= 0 && src < 24);
      assert(dest >= 0 && dest < 24);
      SET(state->points[src], MAKEPOINT(player, state->points[src].count-1));
      SET(state->points[dest], MAKEPOINT(player, state->points[dest].count+1));
      return 1;
    case MOVE_HITBLOT:
      assert(src >= 0 && src < 24);
      assert(dest >= 0 && dest < 24);
      SET(state->points[src], MAKEPOINT(player, state->points[src].count-1));
      SET(state->points[dest], MAKEPOINT(player, 1));
      INC(state->bar[player^1]);
      return 1;
  }
}
Esempio n. 2
0
int reenter_from_bar(const GameState* state, int player, int d)
{
  if (d)
  {
    assert(d>=1&&d<=6);
    if (state->bar[player])
    {
      MoveResult move = can_move_to(state, player, 24-d);
      if (move)
      {
        DEBUG("P%d entering from bar @ %d\n", player, 24-d);
        DEC(state->bar[player]);
        int dest = PT(player,24-d);
        switch (move)
        {
          case MOVE_UNOCCUPIED:
          case MOVE_MERGE:
            SET(state->points[dest], MAKEPOINT(player, state->points[dest].count+1));
            return 1;
          case MOVE_HITBLOT:
            SET(state->points[dest], MAKEPOINT(player, 1));
            INC(state->bar[player^1]);
            return 1;
          default:
            assert(0);
        }
        return 1;
      }
    }
  }
  return 0;
}
Esempio n. 3
0
LONG FAR PASCAL _export PAGE::ObjectWndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
	HDC             hdc;
	PAINTSTRUCT     ps;
	DATA1*					layout;
	PAGE*	          page;

	switch (message)
	{

	case WM_CREATE:
		layout = ((DATA1*)((CREATESTRUCT*)lParam)->lpCreateParams);
		SetWindowLong(hwnd, 0, (long)layout);
		return 0;

	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		layout = (DATA1*)GetWindowLong(hwnd, 0);
		page = (PAGE*)GetWindowLong(hPLayout, 0);
		SelectObject(hdc, page->hFont);
		TextOut(hdc, 1, 1, layout->name, lstrlen(layout->name));
		EndPaint(hwnd, &ps);
		return 0;

	case WM_LBUTTONDBLCLK:
		layout = (DATA1*)GetWindowLong(hwnd, 0);
		page = (PAGE*)GetWindowLong(hPLayout, 0);
		if (layout->objid)
    {
			AObjEdit(layout->objid);
			layout->Refresh(page->hLayout);
			layout->Resize(page->hLayout, hwnd);
    }
		break;

	case WM_LBUTTONDOWN:
		page = (PAGE*)GetWindowLong(hPLayout, 0);
		BringWindowToTop(hwnd);
		UpdateWindow(hwnd);

		hWndObj = hwnd;
		SetCapture(page->hLayout);

		ClientToScreen(hwnd, &MAKEPOINT(lParam) );
		ScreenToClient(page->hLayout, &MAKEPOINT(lParam) );

		page->mousex_save = LOWORD(lParam);
		page->mousey_save = HIWORD(lParam);
		GetWindowRect(hwnd, &page->objectRect);

		page->DrawWindowFrame(hwnd);
		break;
	}
	return DefWindowProc (hwnd, message, wParam, lParam);
}
Esempio n. 4
0
void check_cd_event(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
	POINT press;
	short wind_hit = -1,item_hit = -1;

	switch (message) {
		case WM_COMMAND:
			if (LOWORD(wparam) == 150)
				break;
  			cd_find_dlog(hwnd,&wind_hit,&item_hit); // item_hit is dummy
			item_hit = (short) LOWORD(wparam);
			break;
		case WM_KEYDOWN:
			wind_hit = cd_process_syskeystroke(hwnd, wparam, lparam,&item_hit);
			break;

		case WM_CHAR:
			wind_hit = cd_process_keystroke(hwnd, wparam, lparam,&item_hit);
			break;

		case WM_LBUTTONDOWN:
			press = MAKEPOINT(lparam);
			wind_hit = cd_process_click(hwnd,press, wparam, lparam,&item_hit);
			break;
		case WM_RBUTTONDOWN:
			press = MAKEPOINT(lparam);
			wparam = wparam | MK_CONTROL;
			wind_hit = cd_process_click(hwnd,press, wparam, lparam,&item_hit);
			break;

		case WM_PAINT:
			cd_redraw(hwnd);
			break;
		}
	if (wind_hit < 0)
		return;
	switch (wind_hit) {
		case -1: break;
		case 917: edit_day_event_filter(item_hit); break;
		case 970: case 971: case 972: case 973: display_strings_event_filter(item_hit); break;
		case 991: display_pc_event_filter(item_hit); break;
		case 996: display_alchemy_event_filter(item_hit); break;
		case 1010: spend_xp_event_filter (item_hit); break;
		case 1012: case 947: edit_gold_or_food_event_filter (item_hit); break;
		case 1013: pick_race_abil_event_filter (item_hit); break;
		case 1018: select_pc_event_filter (item_hit); break;
		case 1024: edit_xp_event_filter (item_hit); break;
		default: fancy_choice_dialog_event_filter (item_hit); break;
  		}
}
Esempio n. 5
0
/*
   Effect:        Handle any actions relating to the user releasing
                  the left mouse button within the widget.

                  In particular, we need to move || resize the widget
                  if we were moving || resizing. In addition, we need
                  to restore the drag blobs indicating that the widget
                  can be selected.

                  We also release the mouse input, which was captured
                  in WidgetLButtonUp.

                  If someone else has control of the mouse (like the
                  session window || another widget), we won't be getting
                  this mouse message.

   See Also:      WidgetLButtonDown, WidgetLMouseMove.

   Called By:     WidgetWndProc, in response to WM_LBUTTONUP messages.
*/
static void WidgetLButtonUp(HWND hWnd, WORD wParam, LONG lParam)
{
    RECT rcNew, rcInvalid;
    POINT ptNew;
    HWND hWndParent;
    HDC hDC;

    CurrentWidgetInfo.nDragMode = DRAGMODENONE;
    hWndParent = GetParent(hWnd);

    if (CurrentWidgetInfo.bCapture)
    {
        ptNew = MAKEPOINT(lParam);
        ClientToScreen(hWnd, &ptNew);

        CurrentWidgetInfo.bCapture = FALSE;
        hDC = GetDC(hWndParent);

        EraseDragDots(hWndParent, hDC);
        ReleaseCapture();
        ClipCursor(NULL);

        /* Move the widget to the new location. */
        rcNew = CurrentWidgetInfo.rcPrevDots;
        KpsRectSubPt(&rcNew, CurrentWidgetInfo.ptPrev);
        KpsRectAddPt(&rcNew, ptNew);

        rcInvalid = CurrentWidgetInfo.rcPrev;
        InflateRect(&rcInvalid, DragBlobWidth + 5, DragBlobWidth + 5);
        KpsScreenRectToClient(hWndParent, &rcInvalid);

        KpsScreenRectToClient(hWndParent, &rcNew);
        MoveWindow(hWnd,
                   rcNew.left,
                   rcNew.top,
                   max(rcNew.right - rcNew.left, DragBlobWidth * 2),
                   max(rcNew.bottom - rcNew.top, DragBlobWidth * 2),
                   TRUE);
        GetWindowRect(hWnd, &rcNew);
        CurrentWidgetInfo.rcPrev = rcNew;
        CurrentWidgetInfo.rcPrevDots = rcNew;

        BringWindowToTop(hWnd);

        InvalidateRect(hWnd, NULL, TRUE);
        UpdateWindow(hWnd);

        CurrentWidgetInfo.bDotsDrawn = TRUE;

        rcInvalid = CurrentWidgetInfo.rcPrev;
        InflateRect(&rcInvalid, DragBlobWidth + 5, DragBlobWidth + 5);
        KpsScreenRectToClient(hWndParent, &rcInvalid);
        ReleaseDC(hWnd, hDC);
    }

    GetCursorPos(&CurrentWidgetInfo.ptPrev);
    GetWindowRect(hWnd, &CurrentWidgetInfo.rcPrevDots);
    GetWindowRect(hWnd, &CurrentWidgetInfo.rcPrev);
}
Esempio n. 6
0
// setup default game state and initial board
void init_game(GameState* state)
{
  memset(state, 0, sizeof(GameState));
  state->points[PT(0,23)] = MAKEPOINT(0,2);
  state->points[PT(0,7)]  = MAKEPOINT(0,3);
  state->points[PT(0,12)] = MAKEPOINT(0,5);
  state->points[PT(0,5)]  = MAKEPOINT(0,5);
  state->points[PT(1,23)] = MAKEPOINT(1,2);
  state->points[PT(1,7)]  = MAKEPOINT(1,3);
  state->points[PT(1,12)] = MAKEPOINT(1,5);
  state->points[PT(1,5)]  = MAKEPOINT(1,5);
  state->total[0] = 15;
  state->total[1] = 15;
}
Esempio n. 7
0
int Dot2DotProc(
/************************************************************************/
HWND 	hWindow,
LPARAM 	lParam,
UINT 	msg)
{
    int         xPos, yPos;
	int			x, y;
    RECT        rDot;
    HWND        hImageCtrl;

    xPos = LOWORD(lParam);
    yPos = HIWORD(lParam);
    switch (msg)
    {
        case WM_CREATE:	        // mouse down messages
    	case WM_LBUTTONDOWN:
			x = DotPoints[iActiveDot].x - (DOT_DIAMETER / 2);
			y = DotPoints[iActiveDot].y - (DOT_DIAMETER / 2);
			SetRect(&rDot, x, y, x+DOT_DIAMETER, y+DOT_DIAMETER);
			if (PtInRect(&rDot, MAKEPOINT(lParam)))
			{
				SoundStartResource("ICONS", FALSE, 0);
				iActiveDot++;
				hImageCtrl = GetDlgItem(hDot2DotWnd, IDC_HIDDEN_IMAGE);
				PaintDot2Dots(hImageCtrl);
				if (!CheckFinished())
				{
					SoundStartResource("GOODANSWER3", FALSE, 0);
					UpdateDot2DotImage(hDot2DotWnd, NULL);
				}
					
			}
			else
				SoundStartResource("WRONGANSWER3", FALSE, 0);
    		break;

    	case WM_SETCURSOR:
    		return TRUE;

        case WM_LBUTTONUP:
    		break;

        case WM_MOUSEMOVE:	// sent when ToolActive is on
    		break;
    }
    return TRUE;
}
Esempio n. 8
0
/*
	OnButtonDown -- walks through hotspot list.  For each hotspot,
		uses PtInRect to see if its in the rect.  If it is, it uses
		VwrCommand to transmit the hotspot's command to viewer.  Then
		it looks at the Stop/Continue/Jump to setting and uses the return
		value to handle Stop and Continue, or calls setMovie to do a
		jump.
*/ 
BOOL OnButtonDown(PMOVIEINFO pMovieInfo, USHORT msg, USHORT wp, LONG lp)
{
    PHOTSPOT pHotspot;
    DWORD dwFrame;                      
    POINT pt;
    HWND hwnd;
    
    if (!pMovieInfo)
        return FALSE;
    
    pHotspot = pMovieInfo->pHotspotList;
    pt = MAKEPOINT(lp);
    dwFrame = GetMovieFrame(pMovieInfo);
    
    while (pHotspot)
        {        
        if (dwFrame >= pHotspot->BeginFrame && dwFrame <= pHotspot->EndFrame)
            {
            if (PtInRect(&pHotspot->rc, pt) != 0)
                {                
                hwnd = GetParent(pMovieInfo->hwndParent);
                if (!hwnd)
                    hwnd = pMovieInfo->hwndParent;
                VwrCommand(VwrFromHinst(GetWindowWord(hwnd, GWW_HINSTANCE)),
                                NULL, pHotspot->pszCommand, cmdoptNONE);
                switch (pHotspot->OnClick)
                    {
                    case ID_CONTINUE:
                        return (TRUE);                        
                    case ID_STOP:
                        return (FALSE);
                    case ID_JUMP:
                        setMovie(pMovieInfo, pHotspot->ToFrame, NULL);
                        pMovieInfo->dwCurrentFrame = pHotspot->ToFrame;
                        pMovieInfo->fPlaying = FALSE;
                        playMovie(pMovieInfo, 1);
                        return (TRUE);                        
                    default:
                        return (TRUE);                                            
                    }                                
                }
            }
        pHotspot = pHotspot->pNext;                        
        }
    return (TRUE);        
}
Esempio n. 9
0
BOOL SCALE::MouseDown(HWND hwnd, LPARAM lParam)
{
	RECT rect ;
	POINT offsetMouse ;

	if (mousedown)
		return FALSE ;

	SetCapture(hwnd) ;
	mousedown = TRUE ;

	mouse_save = MAKEPOINT(lParam) ;
	offsetMouse.x = mouse_save.x + nHfirstPixel ;
	offsetMouse.y = mouse_save.y + nVfirstPixel ;

	whichpicked = 0 ;
	if(CheckInBitmap (indData.minRect, offsetMouse, &cursor_pos)) //mouse_save, &cursor_pos))
		{
    rect=indData.minRect ;
		whichpicked = 1 ;
		}
	else if(CheckInBitmap (indData.maxRect, offsetMouse, &cursor_pos)) //mouse_save, &cursor_pos))
		{
    rect=indData.maxRect ;
		whichpicked = 2 ;
		}
  else if (CheckInBitmap (scaleData.rect, offsetMouse, &cursor_pos)) //mouse_save, &cursor_pos))
		{
		rect=scaleData.rect ;
		whichpicked = 3 ;
		}
	if (whichpicked)
  	{
		RECT emptyRect ;
		SetRectEmpty(&emptyRect) ;
		OffsetRect (&rect, -nHfirstPixel, -nVfirstPixel) ;
		DrawFrame (hwnd, rect, emptyRect) ;
		}
	return TRUE ;
}
//---------------------------------------------------------------------
// SPECIALWindowProc():
//
//---------------------------------------------------------------------
void SPECIALWindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{        
   POINT           ptPoint;
   static HCURSOR  hcursorShotgun;
   int             index;

   switch (uMsg)
   {                            
      case WM_CREATE:
         SetCapture(hWnd);
         fSpecialMode   = TRUE;
         hcursorShotgun = LoadCursor(g_wpEnvironment.hInst,MAKEINTRESOURCE(IDC_SPECIAL));
         SetCursor(hcursorShotgun);
         break;
         
      case WM_MOUSEMOVE:
      case WM_SETCURSOR:
         SetCursor(hcursorShotgun);         
         break;
         
      case WM_LBUTTONUP:
         ptPoint = MAKEPOINT(lParam);
         ClientToScreen(hWnd,&ptPoint);
         // shoot...
         BigShell(ptPoint);
         // sounds...
         MessageBeep(-1);
         // kick-back...
         for (index=1; index<10; index++)
            SetCursorPos(ptPoint.x+(2*index),ptPoint.y+index);
         break;
         
      case WM_RBUTTONDBLCLK:
         DestroyCursor(hcursorShotgun);
         ReleaseCapture();
         fSpecialMode = FALSE;
         break;
   }         
}
Esempio n. 11
0
/*
	OnButtonDown -- walks through hotspot list.  For each hotspot,
		uses PtInRect to see if its in the rect.  If it is, it uses
		VwrCommand to transmit the hotspot's command to viewer.  Then
		it looks at the Stop/Continue/Jump to setting and uses the return
		value to handle Stop and Continue, or calls setMovie to do a
		jump.
*/ 
BOOL OnButtonDown(PMOVIEINFO pMovieInfo, USHORT msg, USHORT wp, LONG lp)
{
	PHOTSPOT pHotspot;
	DWORD dwFrame;
	POINT pt;

	if (!pMovieInfo)
		return FALSE;
	pHotspot = pMovieInfo->pHotspotList;
	pt = MAKEPOINT(lp);
	dwFrame = GetMovieFrame(pMovieInfo);
	while (pHotspot)
	{
		if (dwFrame >= pHotspot->BeginFrame && dwFrame <= pHotspot->EndFrame)
		{
			if (PtInRect(&pHotspot->rc, pt) != 0)
			{
				FireHspClick(pMovieInfo->hctl, pHotspot);
				switch (pHotspot->OnClick)
				{
				case ID_CONTINUE:
					return (TRUE);
				case ID_STOP:
					return (FALSE);
				case ID_JUMP:
					setMovie(pMovieInfo, pHotspot->ToFrame, NULL);
					pMovieInfo->dwCurrentFrame = pHotspot->ToFrame;
					pMovieInfo->fPlaying = FALSE;
					playMovie(pMovieInfo, 1);
					return (TRUE);
					default:
					return (TRUE);
				}
			}
		}
		pHotspot = pHotspot->pNext;
	}
	return (TRUE);
}
Esempio n. 12
0
//---------------------------------------------------------------------
LRESULT	Window::WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {

#ifdef	_DEBUG
	/*
	char	buf[20];
	sprintf(buf, "0x%x : ", hWnd);
	OutputDebugString(buf);
	*/
	PutWindowMessage(message, wParam, lParam);
#endif

	if ( message==WM_CREATE )
	{
		LPCREATESTRUCT	pc = (LPCREATESTRUCT)lParam;
		Window*	pw = (Window*)(pc->lpCreateParams);
		pw->mWnd = hWnd;
		::SetWindowLong(hWnd, 0, (long)pw);
		bool b = pw->OnCreate(pc);

		gTaskbarCreatedMessage = ::RegisterWindowMessage(TEXT("TaskbarCreated"));

		return	b ? 0 : -1;
	}

	// マウスホイール対応
	if ( message == msgMOUSEWHEEL ) {
		message = WM_MOUSEWHEEL;
		DbgStr("MouseWheel fwKeys:%04x, zDelta:%d, xPos:%d, yPos:%d",
			LOWORD(wParam), (short)HIWORD(wParam),
			(short)LOWORD(lParam), (short)HIWORD(lParam) );
	}

	Window*	p=(Window*)(::GetWindowLong(hWnd, 0));
	if ( p == NULL )
		return	::DefWindowProc(hWnd, message, wParam, lParam);

	if ( message >= WM_USER && message <= 0x7FFF )
		return	p->OnUser(message, wParam, lParam);
	if ( message == gTaskbarCreatedMessage )
		return  p->OnTaskbarRestart();

	switch ( message ) {

	case WM_PAINT:
		{
			PAINTSTRUCT	thePS;
			HDC			theDC = ::BeginPaint(hWnd, &thePS);
			if (theDC != NULL) {
				p->OnPaint(theDC);
				::EndPaint(hWnd, &thePS);
			}
		}
		return	0;

	case WM_NCHITTEST:
		return	p->OnNCHitTest(MAKEPOINT(lParam));

	Handle(WM_ACTIVATE, OnActivate(LOWORD(wParam), HIWORD(wParam), (HWND)lParam));
	Handle(WM_ACTIVATEAPP, OnActivateApp(BOOL(wParam), (DWORD)lParam));
	Handle(WM_DISPLAYCHANGE, OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam));
	/*case WM_DISPLAYCHANGE:
		p->OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam);
		break;*/


	Handle(WM_COMMAND, OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND)lParam));
	Handle(WM_INITMENU, OnInitMenu(HMENU(wParam)));
	Handle(WM_CLOSE, OnClose());
	Handle(WM_DESTROY, OnDestroy());

	Handle(MM_MCINOTIFY, OnMCINotify(WORD(wParam), LONG(lParam)));

	Handle(WM_LBUTTONDOWN, OnLButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONDOWN, OnMButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONDOWN, OnRButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_LBUTTONUP, OnLButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONUP, OnMButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONUP, OnRButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_LBUTTONDBLCLK, OnLButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONDBLCLK, OnMButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONDBLCLK, OnRButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_MOUSEMOVE, OnMouseMove(MAKEPOINT(lParam), wParam));
	Handle(WM_MOUSEWHEEL, OnMouseWheel(LOWORD(wParam), (short)HIWORD(wParam), (short)LOWORD(lParam), (short)HIWORD(lParam)));
	Handle(WM_NCLBUTTONDBLCLK, OnNCLButtonDoubleClick(wParam, MAKEPOINT(lParam)));

	Handle(WM_KEYDOWN, OnKeyDown((int)wParam, (long)lParam));
	Handle(WM_KEYUP, OnKeyUp((int)wParam, (long)lParam));
	Handle(WM_DROPFILES, OnDropFiles(HDROP(wParam)));
	
	Handle(WM_TIMER, OnTimer(wParam, (TIMERPROC*)lParam));

	Handle(WM_DRAWCLIPBOARD, OnDrawClipboard());
	Handle(WM_CHANGECBCHAIN, OnChangeCBChain((HWND)wParam, (HWND)lParam));

	default:
		break;
	}
	return	::DefWindowProc(hWnd, message, wParam, lParam);
}
Esempio n. 13
0
long WINPROC EXPORT SpinControl(
	HWND     hWindow,
	unsigned message,
	WPARAM   wParam,
	LPARAM   lParam)
{
	int    y;
	RECT   ClientRect;
	PAINTSTRUCT ps;
	HDC    hDC;
	BOOL   bDown;
	DWORD  dwStyle;
	long   lReturn;
	static BOOL bTrack, bInTopRect, bInBottomRect;

	switch ( message )
	{
		case WM_GETDLGCODE:
			return( DLGC_WANTARROWS );

		case WM_ERASEBKGND:
		break; // handle ERASEBKGND and do nothing; PAINT covers everything

		case WM_PAINT:
			hDC = BeginPaint( hWindow, &ps );
			GetClientRect( hWindow, &ClientRect );

			y = ClientRect.bottom;
			ClientRect.bottom =
				1 + ( ClientRect.top + ClientRect.bottom + 1 ) / 2;

			if ( ClientRect.bottom & 1 )
				ClientRect.bottom++; // make sure its even

			bDown = bInTopRect && bTrack;
			DrawSpin( hDC, &ClientRect, 1, bDown );
			ClientRect.top = ClientRect.bottom;
			ClientRect.bottom = y;
			bDown = bInBottomRect && bTrack;
			DrawSpin( hDC, &ClientRect, 0, bDown );
//			dwStyle = GetWindowLong(GetDlgItem( GetParent(hWindow),
//			GET_WINDOW_ID(hWindow) ), GWL_STYLE);
//			if ( WS_NOTENABLED & dwStyle )
//				GrayWindow( hDC, hWindow, -1L );
			EndPaint( hWindow, &ps );
		break;

   	case WM_LBUTTONDOWN:
			dwStyle = GetWindowLong(GetDlgItem( GetParent(hWindow),
			GET_WINDOW_ID(hWindow) ), GWL_STYLE);
			if ( WS_NOTENABLED & dwStyle )
				break;
			if ( bTrack )
				break;
			SetCapture( hWindow ); bTrack = TRUE;
			SetFocus( GetDlgItem( GetParent(hWindow),
				GET_WINDOW_ID(hWindow) ) );
			GetClientRect( hWindow, &ClientRect );
			ClientRect.bottom =
				( ClientRect.top + ClientRect.bottom + 1 ) / 2;
			bInTopRect = PtInRect( &ClientRect, MAKEPOINT(lParam) );
			bInBottomRect = !bInTopRect;
			InvalidateRect( hWindow, NULL, FALSE );
			UpdateWindow( hWindow );
			SetTimer( hWindow, bTrack, 500, NULL );
		break;

		case WM_LBUTTONUP:
			if ( !bTrack )
				break;
			KillTimer( hWindow, bTrack );
			ReleaseCapture(); bTrack = FALSE;
			InvalidateRect( hWindow, NULL, FALSE );
			UpdateWindow( hWindow );
			HandleSpinValue( hWindow, bInTopRect, bInBottomRect );
		break;

		case WM_TIMER:
			if ( !bTrack )
				break;
			KillTimer( hWindow, bTrack );
			SetTimer( hWindow, bTrack, 100, NULL );
			HandleSpinValue( hWindow, bInTopRect, bInBottomRect );
		break;

		case WM_LBUTTONDBLCLK:
		break;

		case WM_MOUSEMOVE:
			if ( !bTrack )
				break;
			GetClientRect( hWindow, &ClientRect );
			y = ClientRect.bottom;
			ClientRect.bottom = ( ClientRect.top + ClientRect.bottom ) / 2;
			if ( bInTopRect == !PtInRect( &ClientRect, MAKEPOINT(lParam) ) )
			{
				bInTopRect = !bInTopRect;
				InvalidateRect( hWindow, NULL, FALSE );
				UpdateWindow( hWindow );
			}
			ClientRect.top = ClientRect.bottom;
			ClientRect.bottom = y;
			if ( bInBottomRect == !PtInRect( &ClientRect, MAKEPOINT(lParam) ) )
			{
				bInBottomRect = !bInBottomRect;
				InvalidateRect( hWindow, NULL, FALSE );
				UpdateWindow( hWindow );
			}
		break;

		case WM_ENABLE:
		case WM_SETTEXT:
			lReturn = DefWindowProc( hWindow, message, wParam, lParam );
			InvalidateRect( hWindow, NULL, FALSE );
			UpdateWindow(hWindow);
			return(lReturn);
		break;

		case WM_DESTROY:
			if ( !bTrack )
				break;
			ReleaseCapture();
			bTrack = NO;
		break;

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

	return( TRUE );
}
Esempio n. 14
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
POINT press;
HMENU menu;

	switch (message) {
	case WM_KEYDOWN:
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
		return 0;
		break;

	case WM_CHAR:
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
		return 0;
		break;

	case WM_LBUTTONDOWN:
		cursor_stay();
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
			else {
				SetFocus(hwnd);
				press = MAKEPOINT(lParam);

				All_Done = handle_action(press, wParam,lParam);
				check_game_done();
				}
		return 0;
		break;


	case WM_RBUTTONDOWN:
		cursor_stay();
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
		return 0;
		break;

	case WM_ACTIVATE:
		if (hwnd == mainPtr) {
			if ((LOWORD(wParam) == WA_ACTIVE) ||(LOWORD(wParam) == WA_CLICKACTIVE)) {
				window_in_front = TRUE;
				 }
			if (LOWORD(wParam) == WA_INACTIVE) {
				window_in_front = FALSE;
				}
			}
		return 0;


	case WM_MOUSEMOVE:
		set_cursor(sword_curs);
      return 0;

	case WM_PAINT:
		BeginPaint(hwnd,&ps);
		EndPaint(hwnd,&ps);
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
			else redraw_screen();
		return 0;


	case WM_COMMAND:
		if (hwnd == mainPtr) {

			menu = GetMenu(mainPtr);
			handle_menu((short) LOWORD(wParam), menu);
			check_game_done();
			}
			else {
				check_cd_event(hwnd,message,wParam,lParam);
				}
		return 0;


	case WM_DESTROY:
	case WM_CLOSE:
		if (hwnd == mainPtr) {
		lose_graphics();
		PostQuitMessage(0);
			}
		return 0;
	case WM_QUIT:
      if (hwnd == mainPtr){
			lose_graphics();
			PostQuitMessage(0);
			}
		break;
	}

return DefWindowProc(hwnd,message,wParam,lParam);
}
//---------------------------------------------------------------------
// ClientWindowProc(): 
//---------------------------------------------------------------------
LRESULT WPPALLETE::ClientWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{              
   // Process window message.               
   switch (uMsg)
   {
      case WM_CREATE:
         // Store the window handle for use later.
         SetHandle(hWnd);
         // Let notebook object know that create message is being processed.
         // NOTE: Here is where folder objects have a chance to animate
         //       the zoom effect for window creation.
         OnCreate();
         // Return success so we can continue with the creation of window.
         return ((LRESULT)0);
         
      case WM_ACTIVATE:
         OnActivate(((wParam==WA_INACTIVE)? TRUE : FALSE));
         return (TRUE);
            
      case WM_COMMAND:            
         OnCommand((HWND)LOWORD(lParam),HIWORD(lParam));
         break;
                          
      case WM_SYSCOMMAND:
         // A system command has been requested.
         OnSysCommand((WORD)wParam,lParam);
         break;
         
      case WM_SETTEXT:     
         // Set new window caption text.
         DefWindowProc(hWnd,uMsg,wParam,lParam);
         // Update window caption.
         OnNCPaint();
         break;  
         
      case WM_QUERYDRAGICON:
         return (OnQueryDragIcon());

      case WM_ERASEBKGND:
         OnEraseBackground((HDC)wParam);
         break;
         
      case WM_PAINT:
         OnPaint();
         break;

      case WM_NCACTIVATE: 
         // Handle this message ONLY if the non-client area is becoming active OR
         // the window becoming active or inactive is not a notebook page (modeless dialog).
         // else, do not update non-client area to prevent flickering effect with 
         // notebook window caption.
         OnNCActivate((BOOL)wParam);
         return (TRUE);
           
      case WM_NCPAINT:         
         OnNCPaint();
         return (NULL);
         
      case WM_NCMOUSEMOVE:
         OnNCMouseMove((WORD)wParam,MAKEPOINT(lParam));
         break;
         
      case WM_NCLBUTTONUP:       
      case WM_NCLBUTTONDOWN:
         OnNCLButton(uMsg,(WORD)wParam,MAKEPOINT(lParam));
         break;
         
      case WM_MOUSEMOVE:
         OnMouseMove();
         break;
                   
      case WM_MOVE:
         OnMove(MAKEPOINT(lParam));
         break;                      
                                                              
      case WM_SIZE: 
         OnSize((WORD)wParam,LOWORD(lParam),HIWORD(lParam));
         break;
                    
      case WM_CLOSE:        
         OnClose();
         break;
    
      default:                              
         // Call the default window procedure.
         return (DefWindowProc(hWnd,uMsg,wParam,lParam));
  }                           
                                              
  // We are done processing the window message...                                              
  return (NULL);
}
Esempio n. 16
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    POINT press;
    HMENU menu;
    RECT dlg_rect;
    RECT wind_rect;

    short handled = 0;
    short store_ulx;
    short store_uly;
    short sbar_pos;
    short which_sbar;
    short old_setting;
    short smin;
    short smax;

// First, handle window size
    GetWindowRect(mainPtr,&wind_rect);

    switch (display_mode) { //case 0 is center
    case 1:
        store_ulx = 0;
        store_uly = 0;
        break;
    case 2:
        store_ulx = wind_rect.right - 550 - 21;
        store_uly = 0;
        break;
    case 3:
        store_ulx = 0;
        store_uly = wind_rect.bottom - 422 - 24 - 21;
        break;
    case 4:
        store_ulx = wind_rect.right - 550 - 21;
        store_uly = wind_rect.bottom - 422 - 24 - 21;
        break;
    case 5:
        store_ulx = 0;
        store_uly = 0;
        break;
    default:
        store_ulx = ((wind_rect.right - wind_rect.left) - 536) / 2 - 30;
        store_uly = ((wind_rect.bottom - wind_rect.top) - 478) / 2 + 8;
        break;
    }

    store_ulx -= store_ulx % 8;
    store_uly -= store_uly % 8;

    if ((store_ulx != ulx) || (store_uly != uly))
    {
        ulx = store_ulx;
        uly = store_uly;
        adjust_window_mode();
    }

    switch (message) {
    case WM_KEYDOWN:
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            cursor_go();
            All_Done = handle_syskeystroke(wParam,lParam,&handled);
            check_game_done();
        }
        if (handled == 1)
            FlushEvents(0);

        return 0;

    case WM_CHAR:
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            cursor_go();
            All_Done = handle_keystroke(wParam,lParam);
            check_game_done();
        }
        return 0;

    case WM_LBUTTONDOWN:
        cursor_stay();
        if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam);
        else {
            SetFocus(hwnd);
            press = MAKEPOINT(lParam);
            if (in_startup_mode == false)
                All_Done = handle_action(press, wParam,lParam);
            else 	All_Done = handle_startup_press(press);
            change_cursor(press);
            check_game_done();
        }
        return 0;
        break;

    case WM_RBUTTONDOWN:
        cursor_stay();
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            SetFocus(hwnd);
            press = MAKEPOINT(lParam);
            if (in_startup_mode == false)
                All_Done = handle_action(press, wParam,-2);
            else All_Done = handle_startup_press(press);
            change_cursor(press);
            check_game_done();
        }
        return 0;
        break;

    case WM_ACTIVATE:
        if (hwnd == mainPtr)
        {
            WORD fActive = LOWORD(wParam);

            if ((fActive == WA_ACTIVE) ||(fActive == WA_CLICKACTIVE))
            {
                window_in_front = true;
                GetClientRect(hwnd,&dlg_rect);
                InvalidateRect(hwnd,&dlg_rect,false);
            }

            if (fActive == WA_INACTIVE)
            {
                cursor_stay();
                anim_onscreen = false;
                window_in_front = false;
            }
        }
        return 0;

    case WM_ERASEBKGND:
        if (hwnd != mainPtr) break;
        block_erase = false;
        return 1;

    case WM_MOUSEMOVE:
        if (store_mouse != lParam) cursor_stay();
        store_mouse = lParam;
        press = MAKEPOINT(lParam);
        if (hwnd == mainPtr) {
            change_cursor(press);
            if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING))
                draw_targeting_line(press);
        }
        return 0;

    case WM_PAINT:
        if ((block_erase == true) && (hwnd == mainPtr)) {
            block_erase = false;
        }
        BeginPaint(hwnd,&ps);
        EndPaint(hwnd,&ps);

        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            string_added = true;
            reset_text_bar();
            if (in_startup_mode == true) draw_startup(0);
            else if (first_update == true)
            {
                first_update = false;
                if (overall_mode == MODE_OUTDOORS) redraw_screen(0);
                if ((overall_mode > MODE_OUTDOORS) & (overall_mode < MODE_COMBAT)) redraw_screen(1);
                // 1st update never combat
            }
            else refresh_screen(overall_mode);
        }
        return 0;

    case WM_TIMER:
        switch(wParam) {
        case 1:
            if ((in_startup_mode == false) && (anim_onscreen == true)
                    && (window_in_front == true) && (give_delays == false)) {
                if(PSD[SDF_NO_TER_ANIM] != 1)
                    anim_ticks++;
                initiate_redraw();
            }
            break;
        case 2:
            if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING)) {
                GetCursorPos(&press);
                press.x -= wind_rect.left + 3;
                press.y -= wind_rect.top + 41;
                draw_targeting_line(press);
            }
            if ((in_startup_mode == true) && (window_in_front == true))
                draw_startup_anim();
            break;
        }
        return 0;

    case WM_COMMAND:    // 1006 is dummy event
        // creation events 2000 spend xp 2001 pick graphic 2002 finish up
        if (hwnd == mainPtr) {
            menu = GetMenu(mainPtr);
            All_Done = handle_menu((short) LOWORD(wParam), menu);
            check_game_done();
        }
        else check_cd_event(hwnd,message,wParam,lParam);

        return 0;

    case WM_VSCROLL:
        which_sbar = GetWindowLong((HWND) lParam, GWL_ID);
        switch (which_sbar) {// 1 text  2 items  3 shop
        case 1:
            sbar_pos = GetScrollPos(text_sbar,SB_CTL);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += 11;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= 11;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = 57;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > 58) sbar_pos = 58;
            {
//				SetScrollPos(text_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(text_sbar,SB_CTL,&lpsi,true);
            }
            string_added = true;
            print_buf();
            break;
        case 2:
            old_setting = sbar_pos = GetScrollPos(item_sbar,SB_CTL);
            GetScrollRange(item_sbar,SB_CTL,(int *) &smin,(int *) &smax);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += (stat_window == 7) ? 2 : 8;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= (stat_window == 7) ? 2 : 8;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = smax;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > smax) sbar_pos = smax;
            {
//				SetScrollPos(item_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(item_sbar,SB_CTL,&lpsi,true);
            }
            if (sbar_pos != old_setting)
                put_item_screen(stat_window,1);
            break;
        case 3:
            old_setting = sbar_pos = GetScrollPos(shop_sbar,SB_CTL);
            GetScrollRange(shop_sbar,SB_CTL,(int *) &smin,(int *) &smax);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += 8;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= 8;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = smax;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > smax) sbar_pos = smax;
            {
//				SetScrollPos(shop_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(shop_sbar,SB_CTL,&lpsi,true);
            }
            if (sbar_pos != old_setting)
                draw_shop_graphics(0,shop_sbar_rect);
            break;
        }

        SetFocus(mainPtr);
        return 0;

    case WM_DESTROY:
    case WM_CLOSE:
        if (hwnd == mainPtr)
        {
            lose_graphics();
            PostQuitMessage(0);
        }
        return 0;
    case WM_QUIT:
        if (hwnd == mainPtr)
            lose_graphics();
        break;
    }

    return DefWindowProc(hwnd,message,wParam,lParam);
}
Esempio n. 17
0
/*
 * WindowProc - handle messages for the main application window
 */
LONG _EXPORT FAR PASCAL WindowProc( HWND window_handle, unsigned msg,
                                     WORD wparam, LONG lparam )
/*************************************************************/
{
    FARPROC             proc;
    HANDLE              inst_handle;
    extra_data          *edata_ptr;
    HDC                 hdc;
    PAINTSTRUCT         ps;
    RECT                rect;
    HBRUSH              brush;

    /*
     * if the message window is ON, send all messages we want to display to the
     * message window, so that we can see what is happening
     * ( before we actually process the message )
     */
    if( MessagesOn ) {
        switch( msg ) {
        case WM_COMMAND:
        case WM_MOUSEMOVE:
        case WM_LBUTTONUP:
        case WM_LBUTTONDOWN:
        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONUP:
        case WM_RBUTTONDOWN:
        case WM_RBUTTONDBLCLK:
        case WM_KEYDOWN:
        case WM_KEYUP:
        case WM_CHAR:
        case WM_TIMER:
        case WM_HSCROLL:
        case WM_VSCROLL:
            SendMessage( MessageWnd, msg, wparam, lparam );
            break;
        }
    }

    /*
     * now process the message
     */
    switch( msg ) {
    case WM_CREATE:
        inst_handle = GetWindowWord( window_handle, GWW_HINSTANCE );
        /*
         * make sure message window is turned OFF to start
         */
        MessagesOn = FALSE;
        CheckMenuItem ( GetMenu( window_handle ), MENU_MESSAGE_WINDOW_ON,
                        MF_BYCOMMAND | MF_UNCHECKED );
        break;
    case WM_LBUTTONDOWN:
        /*
         * zap the target with a lightning bolt!
         */
        edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                            EXTRA_DATA_OFFSET );
        /*
         * set the aim point to where the mouse was just clicked
         * set the bolt start point to the top left corner of the window
         */
        edata_ptr->aim = MAKEPOINT( lparam );
        edata_ptr->bolt.x = edata_ptr->client_rect.right - BOLTWIDTH;
        edata_ptr->bolt.y = edata_ptr->client_rect.top;
        /*
         * shoot the bolt from the current bolt position to the aim point
         */
        ShootBolt( window_handle );
        break;
    case WM_SIZE:
        edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                            EXTRA_DATA_OFFSET );
        /*
         * store the new size of the window
         */
        GetClientRect( window_handle, &edata_ptr->client_rect );
        SetScrollRange( window_handle, SB_HORZ, edata_ptr->client_rect.left,
                        edata_ptr->client_rect.right, TRUE );
        SetScrollRange( window_handle, SB_VERT, edata_ptr->client_rect.top,
                        edata_ptr->client_rect.bottom, TRUE );
        break;
    case WM_COMMAND:
        switch( wparam ) {
        case MENU_ABOUT:
            inst_handle = GetWindowWord( window_handle, GWW_HINSTANCE );
            proc = MakeProcInstance( (FARPROC)About, inst_handle );
            DialogBox( inst_handle,"AboutBox", window_handle, (DLGPROC)proc );
            FreeProcInstance( proc );
            break;
        case MENU_EXIT:
            SendMessage( window_handle, WM_CLOSE, 0, 0L );
            break;
        case MENU_SET_TARGET_SPEED:
            inst_handle = GetWindowWord( window_handle, GWW_HINSTANCE );
            proc = MakeProcInstance( (FARPROC)SpeedDlgProc, inst_handle );
            DialogBoxParam( inst_handle,"SpeedDlg", window_handle, (DLGPROC)proc,
                            (DWORD)SET_TARGET_SPEED );
            FreeProcInstance( proc );
            break;
        case MENU_SET_BOLT_SPEED:
            inst_handle = GetWindowWord( window_handle, GWW_HINSTANCE );
            proc = MakeProcInstance( (FARPROC)SpeedDlgProc, inst_handle );
            DialogBoxParam( inst_handle,"SpeedDlg", window_handle, (DLGPROC)proc,
                            (DWORD)SET_BOLT_SPEED );
            FreeProcInstance( proc );
            break;
        case MENU_SCORE_WINDOW_ON:
            /*
             * toggle the score window on or off
             */
            edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                                EXTRA_DATA_OFFSET );
            if( !edata_ptr->score_on ) {
                TurnScoreWindowOn( window_handle );
                CheckMenuItem ( GetMenu( window_handle ),
                                wparam, MF_BYCOMMAND | MF_CHECKED );
                edata_ptr->score_on = TRUE;
            } else {
                SendMessage( ScoreWnd, WM_CLOSE, 0, 0L );
                CheckMenuItem ( GetMenu( window_handle ), wparam,
                    MF_BYCOMMAND | MF_UNCHECKED );
                edata_ptr->score_on = FALSE;
            }
            break;
        case MENU_SOUND_ON:
            /*
             * toggle the sound on or off
             */
            edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                                EXTRA_DATA_OFFSET );
            if( !edata_ptr->sound_on ) {
                CheckMenuItem ( GetMenu( window_handle ),
                                wparam, MF_BYCOMMAND | MF_CHECKED );
                edata_ptr->sound_on = TRUE;
            } else {
                CheckMenuItem ( GetMenu( window_handle ), wparam,
                    MF_BYCOMMAND | MF_UNCHECKED );
                edata_ptr->sound_on = FALSE;
            }
            break;
        case MENU_MESSAGE_WINDOW_ON:
            /*
             * toggle the message window on or off
             */
            if( !MessagesOn ) {
                TurnMessageWindowOn( window_handle );
                CheckMenuItem ( GetMenu( window_handle ),
                                wparam, MF_BYCOMMAND | MF_CHECKED );
                MessagesOn = TRUE;
            } else {
                SendMessage( MessageWnd, WM_CLOSE, 0, 0L );
                CheckMenuItem ( GetMenu( window_handle ), wparam,
                    MF_BYCOMMAND | MF_UNCHECKED );
                MessagesOn = FALSE;
            }
            break;
        }
        break;
    case WM_PAINT:
        edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                            EXTRA_DATA_OFFSET );
        hdc = BeginPaint (window_handle, &ps);
        /*
         * paint the invalid area with the background colour
         */
        brush = CreateSolidBrush( BACKGROUND );
        FillRect( hdc, &ps.rcPaint, brush );
        DeleteObject( brush );

        rect.left   = edata_ptr->target.x;
        rect.top    = edata_ptr->target.y;
        rect.right  = rect.left + edata_ptr->size.x;
        rect.bottom = rect.top + edata_ptr->size.y;

        /*
         * if part of the target bitmap is invalid, redraw it
         */
        if( IntersectRect( &rect, &rect, &ps.rcPaint ) ) {
            DrawBitmap( hdc, edata_ptr->target_bmp,
                        edata_ptr->target.x, edata_ptr->target.y );
        }
        EndPaint(window_handle, &ps);
        break;
    case WM_HSCROLL:
    case WM_VSCROLL:
        /*
         * use the scrollbars to move the target around
         */
        {
            short position; /* the x or y position of the scrollbar */
            short max;
            short min;

            edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                                EXTRA_DATA_OFFSET );
            position = ( msg == WM_HSCROLL ) ?
                       edata_ptr->target.x : edata_ptr->target.y;

            switch( wparam ) {
            case SB_PAGEDOWN:
                position += 15;
                break;
            case SB_LINEDOWN:
                position++;
                break;
            case SB_PAGEUP:
                position -= 15;
                break;
            case SB_LINEUP:
                position--;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                position = LOWORD( lparam );
                break;
            default:
                return( 0L );
            }
            if( msg == WM_HSCROLL ) {
                GetScrollRange( window_handle, SB_HORZ, (LPINT)&min, (LPINT)&max );
                edata_ptr->target.x = max( min( position, max ), min );
                SetScrollPos( window_handle, SB_HORZ, edata_ptr->target.x , TRUE );
            } else {
                GetScrollRange( window_handle, SB_VERT, (LPINT)&min, (LPINT)&max );
                edata_ptr->target.y = max( min( position, max ), min );
                SetScrollPos( window_handle, SB_VERT, edata_ptr->target.y, TRUE );
            }
            InvalidateRect( window_handle, &edata_ptr->client_rect, FALSE );
        }
        break;
    case WM_MOVE_TARGET:

        /*
         * move the target to a random location on the screen
         */

        edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                            EXTRA_DATA_OFFSET );
        rect.left   = edata_ptr->target.x;
        rect.top    = edata_ptr->target.y;
        rect.right  = rect.left + edata_ptr->size.x;
        rect.bottom = rect.top + edata_ptr->size.y;
        InvalidateRect( window_handle, &rect, TRUE );

        edata_ptr->target = RandPoint( edata_ptr->client_rect, edata_ptr->size );

        rect.left   = edata_ptr->target.x;
        rect.top    = edata_ptr->target.y;
        rect.right  = rect.left + edata_ptr->size.x;
        rect.bottom = rect.top + edata_ptr->size.y;
        InvalidateRect( window_handle, &rect, TRUE );

        /* set the scrollbars to indicate the new position */
        SetScrollPos( window_handle, SB_HORZ, edata_ptr->target.x , TRUE );
        SetScrollPos( window_handle, SB_VERT, edata_ptr->target.y, TRUE );

        break;
    case WM_TIMER:
        SendMessage( window_handle, WM_MOVE_TARGET, 0, 0L );
        break;
        break;
    case WM_DESTROY:
        edata_ptr = (extra_data *) GetWindowLong( window_handle,
                                                  EXTRA_DATA_OFFSET );
        KillTimer( window_handle, TARGET_TIMER );       /* Stops the timer */
        FreeProcInstance( edata_ptr->message_window_proc );
        FreeProcInstance( edata_ptr->score_window_proc );
        PostQuitMessage( 0 );
        break;

    default:
        return( DefWindowProc( window_handle, msg, wparam, lparam ) );
    }
    return( 0L );

} /* WindowProc */
Esempio n. 18
0
long CALLBACK WndProc (HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
//RECT s_rect = {0,0,30,30},d_rect = {0,0,30,30},d2 = {0,0,420,216},s2 = {0,0,420,216};
POINT press;
short handled = 0,sbar_pos = 0,old_setting;
long which_sbar;
int min = 0, max = 0;
HMENU menu;
POINT p;
RECT r;

	switch (message) {
	case WM_KEYDOWN:
		 if (hwnd != mainPtr) {
			check_cd_event(hwnd,message,wParam,lParam);
			}
			else {
				All_Done = handle_syskeystroke(wParam,lParam,&handled);
				}
		return 0;
		break;

	case WM_CHAR:
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
			else {
				All_Done = handle_keystroke(wParam,lParam);
				}
		return 0;
		break;

	case WM_LBUTTONDOWN:
		cursor_stay();
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
			else {
				SetFocus(hwnd);
				press = MAKEPOINT(lParam);

				All_Done = handle_action(press, wParam,lParam);
				check_game_done();
				}
		return 0;
		break;

	case WM_LBUTTONUP:
		mouse_button_held = FALSE;
		break;

	case WM_RBUTTONDOWN:
		mouse_button_held = FALSE;
		cursor_stay();
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
			else {
				SetFocus(hwnd);
				press = MAKEPOINT(lParam);

				All_Done = handle_action(press, wParam,-2);
				check_game_done();
				}
		return 0;
		break;

	case WM_TIMER:
		// first, mouse held?
		if ((wParam == 1) && (mouse_button_held == TRUE)) {
			GetCursorPos(&p);
			ScreenToClient(mainPtr,&p);
			All_Done = handle_action(p, 0,0);
			}
		// second, refresh cursor?
		if ((wParam == 1) && (overall_mode < 60) && (GetFocus() == mainPtr)) {
			GetCursorPos(&p);
			ScreenToClient(mainPtr,&p);
			GetClientRect(mainPtr,&r);
			if (PtInRect(&r,p))
				restore_cursor();
			}

        if(play_anim == TRUE){
            anim_ticks++;
		    if(overall_mode < 60){
        	    draw_terrain();
                }
            if(overall_mode == 62){
            if(store_ter.picture >= 2000)
                csp(813,14,store_ter.picture - 2000, 5);
       	    else if (store_ter.picture >= 400 && store_ter.picture < 1000)
			    csp(813,14,store_ter.picture - 100, 0);

            if(do_choose_anim == TRUE){
                put_choice_pics();
			    }
            }
        }
		break;

	case WM_PALETTECHANGED:
		 palette_suspect = TRUE;
		 return 0;

	case WM_ACTIVATE:
		if (hwnd == mainPtr) {
			if (((wParam == WA_ACTIVE) ||(wParam == WA_CLICKACTIVE)) &&
				(palette_suspect == TRUE)) {
				palette_suspect = FALSE;
				}
			if ((wParam == WA_ACTIVE) ||(wParam == WA_CLICKACTIVE)) {
				window_in_front = TRUE;
				 }
			if (wParam == WA_INACTIVE) {
				window_in_front = FALSE;
				}
			}
		return 0;


	case WM_MOUSEMOVE:
		if ((mouse_button_held == TRUE) && (hwnd == mainPtr)) {
			press = MAKEPOINT(lParam);
			All_Done = handle_action(press, wParam,lParam);
			}
      	restore_cursor();
		return 0;

	case WM_PAINT:
		hdc = BeginPaint(hwnd,&ps);
		EndPaint(hwnd,&ps);
		if (hwnd != mainPtr)
			check_cd_event(hwnd,message,wParam,lParam);
			else redraw_screen();
		return 0;

	case WM_VSCROLL:
		which_sbar = GetWindowLong((HWND) lParam, GWL_ID);
		switch (which_sbar) {
			case 1:
				sbar_pos = GetScrollPos(right_sbar,SB_CTL);
				old_setting = sbar_pos;
				GetScrollRange(right_sbar,SB_CTL,&min,&max);
				switch (LOWORD(wParam)) {
					case SB_PAGEDOWN: sbar_pos += NRSONPAGE - 1; break;
					case SB_LINEDOWN: sbar_pos++; break;
					case SB_PAGEUP: sbar_pos -= NRSONPAGE - 1; break;
					case SB_LINEUP: sbar_pos--; break;
					case SB_TOP: sbar_pos = 0; break;
					case SB_BOTTOM: sbar_pos = max; break;
					case SB_THUMBPOSITION:
					case SB_THUMBTRACK:
						sbar_pos = HIWORD(wParam);
						break;
					}
				if (sbar_pos < 0)
					sbar_pos = 0;
				if (sbar_pos > max)
					sbar_pos = max;

                lpsi.fMask = SIF_POS;
                lpsi.nPos = sbar_pos;
                SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE);
//				SetScrollPos(right_sbar,SB_CTL,sbar_pos,TRUE);

				if (sbar_pos != old_setting)
					draw_rb();
				break;
			}
	    SetFocus(mainPtr);
		return 0;

	case WM_COMMAND:
		if (hwnd == mainPtr) {

			menu = GetMenu(mainPtr);
			handle_menu((short) wParam, menu);
			check_game_done();
			}
			else {
				check_cd_event(hwnd,message,wParam,lParam);
				}
		return 0;


	case WM_DESTROY:
	case WM_CLOSE:
		if (hwnd == mainPtr) {
		discard_graphics();
		PostQuitMessage(0);
			}
		return 0;
	case WM_QUIT:
      if (hwnd == mainPtr)
		discard_graphics();
		break;


	}

return DefWindowProc(hwnd,message,wParam,lParam);
}
Esempio n. 19
0
short check_cd_event(HWND hwnd, UINT message, WPARAM wparam,LPARAM lparam)
{
	POINT press;
	short wind_hit = -1,item_hit = -1;

	switch (message) {
		case WM_COMMAND:
			if ((LOWORD(wparam) >= 150) && (LOWORD(wparam) <= 250))  {

				if (HIWORD(wparam) == EN_ERRSPACE)
					play_sound(0);

				return 0;
				}
			cd_find_dlog(hwnd,&wind_hit,&item_hit); // item_hit is dummy
			item_hit = (short) wparam;
			break;
		case WM_KEYDOWN:
			if ((wparam >= 150) && (wparam <= 250)) {
					return -1;
				}
			wind_hit = cd_process_syskeystroke(hwnd, wparam, lparam,&item_hit);
			break;

		case WM_CHAR:
			wind_hit = cd_process_keystroke(hwnd, wparam, lparam,&item_hit);
			break;

		case WM_LBUTTONDOWN:
			press = MAKEPOINT(lparam);
			wind_hit = cd_process_click(hwnd,press, wparam, lparam,&item_hit);
			break;
		case WM_RBUTTONDOWN:
			press = MAKEPOINT(lparam);
			wparam = wparam | MK_CONTROL;
			wind_hit = cd_process_click(hwnd,press, wparam, lparam,&item_hit);
			break;
		case WM_MOUSEMOVE:
			restore_cursor();
			break;
		case WM_PAINT:
			cd_redraw(hwnd);
			break;
		}
	if (wind_hit < 0)
		return 0;
	switch (wind_hit) {
		case -1: break;
		case 970: case 971: case 972: case 973: display_strings_event_filter(item_hit); break;
		case 800: edit_make_scen_1_event_filter(item_hit); break;
		case 801: edit_make_scen_2_event_filter(item_hit); break;
		case 803: edit_scen_details_event_filter(item_hit); break;
		case 804: edit_scen_intro_event_filter(item_hit); break;
		case 805: set_starting_loc_filter(item_hit); break;
		case 806: edit_spec_item_event_filter(item_hit); break;
		case 807: edit_save_rects_event_filter(item_hit); break;
		case 808: edit_horses_event_filter(item_hit); break;
		case 809: edit_boats_event_filter(item_hit); break;
		case 810: edit_add_town_event_filter(item_hit); break;
		case 811: edit_scenario_events_event_filter(item_hit); break;
		case 812: edit_item_placement_event_filter(item_hit); break;
		case 813: edit_ter_type_event_filter(item_hit); break;
		case 814: edit_monst_type_event_filter(item_hit); break;
		case 815: edit_monst_abil_event_filter(item_hit); break;
		case 816: edit_text_event_filter(item_hit); break;
		case 817: edit_talk_node_event_filter(item_hit); break;
		case 818: edit_item_type_event_filter(item_hit); break;
		case 819: choose_graphic_event_filter(item_hit); break;
		case 820: choose_text_res_event_filter(item_hit); break;
		case 821: edit_basic_dlog_event_filter(item_hit); break;
		case 822: edit_spec_enc_event_filter(item_hit); break;
		case 824: edit_item_abil_event_filter(item_hit); break;
		case 825: edit_special_num_event_filter(item_hit); break;
		case 826: edit_spec_text_event_filter(item_hit); break;
		case 830: new_town_event_filter(item_hit); break;
		case 831: edit_sign_event_filter(item_hit); break;
		case 832: edit_town_details_event_filter(item_hit); break;
		case 833: edit_town_events_event_filter(item_hit); break;
		case 834: edit_advanced_town_event_filter(item_hit); break;
		case 835: edit_town_wand_event_filter(item_hit); break;
		case 836: edit_placed_item_event_filter(item_hit); break;
		case 837: edit_placed_monst_event_filter(item_hit); break;
		case 838: edit_placed_monst_adv_event_filter(item_hit); break;
		case 839: edit_town_strs_event_filter(item_hit); break;
		case 840: edit_area_rect_event_filter(item_hit); break;
		case 841: pick_import_town_event_filter(item_hit); break;
		case 842: edit_dialog_text_event_filter(item_hit); break;
		case 850: edit_out_strs_event_filter(item_hit); break;
		case 851: outdoor_details_event_filter(item_hit); break;
		case 852: edit_out_wand_event_filter(item_hit); break;
		case 854: pick_out_event_filter(item_hit); break;
		case 855: case 856: pick_town_num_event_filter(item_hit); break;
		case 857: change_ter_event_filter(item_hit); break;
		default: fancy_choice_dialog_event_filter (item_hit); break;
		}
	return 0;
}
//---------------------------------------------------------------------
// ClientWindowProc():
//---------------------------------------------------------------------
LRESULT WPNOTEBOOK::ClientWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   // Process window message.
   switch (uMsg)
   {
      case WM_CREATE:
         // Store the window handle for use later.
         SetHandle(hWnd);
         // Let notebook object know that create message is being processed.
         // NOTE: Here is where folder objects have a chance to animate
         //       the zoom effect for window creation.
         OnCreate();
         // Return success so we can continue with the creation of window.
         return ((LRESULT)0);

      case WM_ACTIVATE:
         OnActivate(((wParam==WA_INACTIVE)? TRUE : FALSE));
         return (TRUE);

      // We don't want the client area to have the focus, since it
      // doesn't accept input.  When it gets the focus, which it will
      // when the window is restored from a minimized state, for
      // instance, post a user message to ourselves to reset the
      // focus to the notebook.  Posting the message is necessary
      // because the focus shouldn't be tampered with when processing
      // a WM_SETFOCUS or WM_KILLFOCUS message.
      case WM_SETFOCUS:
         PostMessage(hWnd,WM_WPS_NOTEBOOK_SETFOCUS,0,0L);
         break;

      case WM_WPS_NOTEBOOK_SETFOCUS:
         // Give focus to notebook control in our client area.
         SetFocus(GetDlgItem(hWnd,IDC_NOTEBOOK));
         break;

      case WM_COMMAND:
         if (wParam==IDC_NOTEBOOK)
            OnCommand((HWND)LOWORD(lParam),HIWORD(lParam));
         break;

      case WM_SYSCOMMAND:
         // A system command has been requested.
         OnSysCommand((WORD)wParam,lParam);
         break;

      case WM_SETTEXT:
         // Set new window caption text.
         DefWindowProc(hWnd,uMsg,wParam,lParam);
         // Update window caption.
         OnNCPaint();
         break;

      case WM_QUERYDRAGICON:
         return (OnQueryDragIcon());

      case WM_ERASEBKGND:
         OnEraseBackground((HDC)wParam);
         break;

      case WM_NCACTIVATE:
         // Handle this message ONLY if the non-client area is becoming active OR
         // the window becoming active or inactive is not a notebook page (modeless dialog).
         // else, do not update non-client area to prevent flickering effect with
         // notebook window caption.
         if ((((BOOL)wParam)==TRUE)||(IsPageWindow((HWND)LOWORD(lParam))==FALSE))
            OnNCActivate((BOOL)wParam);
         return (TRUE);

      case WM_NCPAINT:
         OnNCPaint();
         return (NULL);

      case WM_NCMOUSEMOVE:
         OnNCMouseMove((WORD)wParam,MAKEPOINT(lParam));
         break;

      case WM_NCLBUTTONUP:
      case WM_NCLBUTTONDOWN:
         OnNCLButton(uMsg,(WORD)wParam,MAKEPOINT(lParam));
         break;

      case WM_MOUSEMOVE:
         OnMouseMove();
         break;

      case WM_MOVE:
         OnMove(MAKEPOINT(lParam));
         break;

      case WM_SIZE:
         OnSize((WORD)wParam,LOWORD(lParam),HIWORD(lParam));
         break;

      case WM_CLOSE:
         OnClose();
         break;

      default:
         // Call the default window procedure.
         return (DefWindowProc(hWnd,uMsg,wParam,lParam));
  }

  // We are done processing the window message...
  return (NULL);
}
Esempio n. 21
0
BOOL W_CALLBACK KALEditProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#ifdef KALHELP
    char *pStr;

    switch (msg) {
      case WM_GETDLGCODE:
          return 0;

      case WM_KEYUP:
          switch (wParam) {
            case VK_CONTROL:
                bControl = FALSE;
                break;
            case VK_F2:
                WndCheckReportExp(hWnd, "Check", NULL);
                break;
            case VK_TAB:
                return TRUE;
          }
          break;
          
      case WM_KEYDOWN:
          switch (wParam) {
            case VK_CONTROL:
                bControl = TRUE;
                break;
            case VK_TAB:
                if (IsWindowVisible(hWnd))
                {
                    register int i = 4;
                    while (i--) SendMessage(hWnd, WM_CHAR, ' ', 0L);
                    return TRUE;
                }
                break;
            default:
                if (bControl)
                    switch (wParam) {
                      case 'A':
                          return SendNoControlKey(hWnd, VK_HOME, lParam);
                      case 'B':
                          return SendNoControlKey(hWnd, VK_LEFT, lParam);
                      case 'C':
                          SendMessage(hWnd, WM_COPY, 0, 0L);
                          return TRUE;
                      case 'D':
                        {
                            DWORD dwSel = SendMessage(hWnd, EM_GETSEL, 0, 0L);
                            
                            if (HIWORD(dwSel) - LOWORD(dwSel))
                                SendMessage(hWnd, WM_CUT, 0, 0L);
                            else
                                SendNoControlKey(hWnd, VK_DELETE, lParam);

                            return TRUE;
                        }
                      case 'E':
                          return SendNoControlKey(hWnd, VK_END, lParam);
                      case 'F':
                          return SendNoControlKey(hWnd, VK_RIGHT, lParam);
                      case 'K':
                          wParam = VK_DELETE;
                          break;                          
                      case 'N':
                          return SendNoControlKey(hWnd, VK_DOWN, lParam);
                      case 'P':
                          return SendNoControlKey(hWnd, VK_UP, lParam);
                      case 'S':
                          return SendMessage(GetParent(hWnd), WM_COMMAND, 
                                             IDM_FIND, 0L);
                      case 'U':
                          if (SendMessage(hWnd, EM_CANUNDO, 0, 0L))
                              SendMessage(hWnd, EM_UNDO, 0, 0L);
                          return TRUE;
                      case 'V':
                      case 'Y':
                          SendMessage(hWnd, WM_PASTE, 0, 0L);
                          return TRUE;
                      case 'X':
                          SendMessage(hWnd, WM_CUT, 0, 0L);
                          return TRUE;
                    }
          }
          break;

      case WM_CHAR:
          switch (wParam) {
            case VK_RETURN:
                if (IsWindowVisible(hWnd))
                {
                    SendMessage(hWnd, WM_CHAR, 0x0A, 0L);
                    return TRUE;
                }
                break;
            case VK_TAB:
                if (IsWindowVisible(hWnd))
                    return TRUE;
                break;
            case 'B' - '@':
            case 'C' - '@':
            case 'D' - '@':
            case 'F' - '@':
            case 'K' - '@':
            case 'N' - '@':
            case 'P' - '@':
            case 'S' - '@':
            case 'U' - '@':
            case 'V' - '@':
            case 'Y' - '@':
            case 'X' - '@':
                return TRUE;
          }
          break;

#ifndef LIMITED
      case WM_RBUTTONDOWN:
      {
          POINT pt = MAKEPOINT(lParam);
          
          KppSetupPopupMenu(hWnd, hKALPpMainMenu);
          KppIncrementPopupCountCB(EDITW);
          PostKALPopupWnd(hWnd, pt.x, pt.y);
          KppDecrementPopupCountCB(EDITW);
          return TRUE;
      }
#endif

      case WM_COMMAND:
          switch (wParam) {
            case IDM_KNOW:
                pStr = DisplayKnowledgeCmds(CAT_KNOW);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_MATH:
                pStr = DisplayKnowledgeCmds(CAT_MATH);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_STRING:
                pStr = DisplayKnowledgeCmds(CAT_STR);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_LIST:
                pStr = DisplayKnowledgeCmds(CAT_LST);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_LOGIC:
                pStr = DisplayKnowledgeCmds(CAT_LOG);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_FILE:
                pStr = DisplayKnowledgeCmds(CAT_FILE);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_CONTROL:
                pStr = DisplayKnowledgeCmds(CAT_CONS);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_WNDKAL:
                pStr = DisplayKnowledgeCmds(CAT_WND);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_DLL:
                pStr = DisplayKnowledgeCmds(CAT_DLL);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_USER:
                pStr = DisplayAllKnowledgeCmds(CAT_USER);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_ALLKAL:
                pStr = DisplayAllKnowledgeCmds(CAT_ALL);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_CLASS:
                pStr = DisplayItemNames(hWnd, CLASS);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_INSTANCE:
                pStr = DisplayItemNames(hWnd, OBJECT);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_RULE:
                pStr = DisplayItemNames(hWnd, RULE);
                PRINT_COMMAND(hWnd, pStr);
                break;

            case IDM_GOAL:
                pStr = DisplayItemNames(hWnd, GOAL);
                PRINT_COMMAND(hWnd, pStr);
                break;

            default:
                break;
          }

      default:
          break;
    }

    if (hWnd)
        return CallWindowProc(lpEditProc, hWnd, msg, wParam, lParam);
    else
        return FALSE;
#else
    return FALSE;
#endif
}
Esempio n. 22
0
/*
   Effect:        Handle any actions relating to the mouse moving within
                  the widget.

                  In particular, send the mouse message right back up to
                  the parent. This way the parent knows where the mouse
                  is for drawing guidelines.

                  If we have control of the mouse, then we can assume we
                  are dragging around a widget; draw the rectangle for that
                  widget around the current cursor location.

                  If someone else has control of the mouse (like the
                  session window || another widget), we won't be getting
                  this mouse message.

   Called By:     WidgetWndProc, in response to WM_MOUSEMOVE messages.
*/
static void WidgetLMouseMove(HWND hWnd, WORD wParam, LONG lParam)
{
    POINT pt, ptScreen;
    LONG lPoint;
    HWND hWndParent;
    RECT rcNew;
    HDC hDC, hDC2;

    hWndParent = GetParent(hWnd);

    /*=======================================*/
    /*   Send mouse movement msg to parent.  */
    /*=======================================*/
    pt = MAKEPOINT(lParam);
    ClientToScreen(hWnd, &pt);
    ptScreen = pt;
    ScreenToClient(hWndParent, &pt);

    lPoint = MAKELONG(pt.x, pt.y);
    SendMessage(hWndParent, WM_MOUSEMOVE, wParam, lPoint);

    if (CurrentWidgetInfo.bCapture)
    {
        hDC = GetDC(hWndParent);
        hDC2 = GetDC(hWnd);

        /* Erase the previous drag dots. */
        EraseDragDots(hWndParent, hDC);
        EraseDragDots(hWnd, hDC2);
        SetRectEmpty(&rcPrev);

        /*===================================*/
        /* Compute new drag dots.            */
        /*===================================*/
        rcNew = CurrentWidgetInfo.rcPrevDots;
        switch (CurrentWidgetInfo.nDragMode) {
          case DRAGMODEINTERIOR:
              KpsRectSubPt(&rcNew, CurrentWidgetInfo.ptPrev);
              KpsRectAddPt(&rcNew, ptScreen);
              break;

          case DRAGMODEUPPERLEFT:
              rcNew.left = min(ptScreen.x, rcNew.right);
              rcNew.top = min(ptScreen.y, rcNew.bottom);
              break;

          case DRAGMODEUPPERRIGHT:
              rcNew.right = max(ptScreen.x, rcNew.left);
              rcNew.top = min(ptScreen.y, rcNew.bottom);
              break;

          case DRAGMODELOWERLEFT:
              rcNew.left = min(ptScreen.x, rcNew.right);
              rcNew.bottom = max(ptScreen.y, rcNew.top);
              break;

          case DRAGMODELOWERRIGHT:
              rcNew.right = max(ptScreen.x, rcNew.left);
              rcNew.bottom = max(ptScreen.y, rcNew.top);
              break;

          case DRAGMODEMIDLEFT:
              rcNew.left = min(ptScreen.x, rcNew.right);
              break;

          case DRAGMODEMIDRIGHT:
              rcNew.right = max(ptScreen.x, rcNew.left);
              break;

          case DRAGMODEMIDTOP:
              rcNew.top = min(ptScreen.y, rcNew.bottom);
              break;

          case DRAGMODEMIDBOTTOM:
              rcNew.bottom = max(ptScreen.y, rcNew.top);
              break;
          }                        /* switch */

        /*===================================*/
        /* Draw drag rectangle if necessary. */
        /*===================================*/
        DrawDragDots(hWndParent, hDC, rcNew, TRUE);
        DrawDragDots(hWnd, hDC2, rcNew, TRUE);
        CurrentWidgetInfo.rcPrevDots = rcNew;
        CurrentWidgetInfo.ptPrev = ptScreen;

        ReleaseDC(hWnd, hDC2);
        ReleaseDC(hWndParent, hDC);
    }
}
Esempio n. 23
0
/*
   Effect:     Handle all messages sent by Windows to widgets when
               the layout window is in development mode.

   Called By:  Windows.

   Note:       This routine needs to be exported in kappa.def.

   See Also:   WidgetSubclassAllChildren, WidgetUnsubclassAllChildren.
*/
LRESULT W_CALLBACK LayoutWidgetWndProc(HWND hWnd, UINT msg, 
				       WPARAM wParam, LPARAM lParam)
{
    BOOL bSendToOriginal;
    ITEMID idWidget;
    int nDragMode;
    POINT ptScreen;

    bSendToOriginal = TRUE;

    switch (msg) {
      case WM_RBUTTONDOWN:
          ptScreen = MAKEPOINT(lParam);
          ClientToScreen(hWnd, &ptScreen);
          nDragMode = InCurrentWidget(ptScreen);
          WidgetRButtonDown(hWnd, ptScreen);
          bSendToOriginal = FALSE;
          break;

      case WM_RBUTTONUP:
          if (IsWindowVisible(hWndSessionAligner))
          {
              idWidget = KpsGetWidgetFromWindow(hWnd);
              SendMessage(hWndSessionAligner, WM_INITDIALOG, 0, 
                          (long) idWidget);
          }
          break;

      case WM_LBUTTONDOWN:
          ptScreen = MAKEPOINT(lParam);
          ClientToScreen(hWnd, &ptScreen);
          nDragMode = InCurrentWidget(ptScreen);
          if (nDragMode)
              WidgetLButtonDown(hWnd, nDragMode, ptScreen);
          else
              WidgetLButtonDown(hWnd, DRAGMODEINTERIOR, ptScreen);
          bSendToOriginal = FALSE;
          break;

      case WM_LBUTTONUP:
          /* this test here is odd but it fixes bug 21993 */
          if (hWnd == CurrentWidgetInfo.hWnd)
          {
              WidgetLButtonUp(hWnd, wParam, lParam);
              if (CurrentWidgetInfo.hPrevWnd)
              {
                  if (KpsIsAWidget(CurrentWidgetInfo.hWnd))
                  {
                      InvalidateRect(CurrentWidgetInfo.hPrevWnd, NULL, TRUE);
                      UpdateWindow(CurrentWidgetInfo.hPrevWnd);
                  }
                  CurrentWidgetInfo.hPrevWnd = NULL;
              }
          }
          bSendToOriginal = FALSE;
          if (IsWindowVisible(hWndSessionAligner))
          {
              idWidget = KpsGetWidgetFromWindow(hWnd);
              SendMessage(hWndSessionAligner, WM_INITDIALOG, 0,
                          (long) idWidget);
          }
          break;

      case WM_LBUTTONDBLCLK:
          if (IsWindow(CurrentWidgetInfo.hWnd))
          {
              KpsPostWidgetOptions(hWnd, CurrentWidgetInfo.hWnd);
              bSendToOriginal = FALSE;
          }
          else
              bSendToOriginal = TRUE;
          break;

      case WM_MOUSEMOVE:
          WidgetLMouseMove(hWnd, wParam, lParam);
          bSendToOriginal = FALSE;
          break;

      default:
          break;
    }

    if (bSendToOriginal)
        return WidgetDefaultWndProc(hWnd, msg, wParam, lParam);
    else
        return FALSE;
}