BOOL CVersionManagerDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_Iocport.Init( MAX_USER, CLIENT_SOCKSIZE, 1 );
	
	for (int i=0; i<MAX_USER; i++)
		m_Iocport.m_SockArrayInActive[i] = new CUser;

	if (!m_Iocport.Listen(_LISTEN_PORT))
	{
		AfxMessageBox("Failed to listen on server port.");
		AfxPostQuitMessage(0);
		return FALSE;
	}

	GetInfoFromIni();
	
	char strConnection[256];
	sprintf_s(strConnection, sizeof(strConnection), "ODBC;DSN=%s;UID=%s;PWD=%s", m_ODBCName, m_ODBCLogin, m_ODBCPwd);

	if (!m_DBProcess.InitDatabase(strConnection)) 
	{
		AfxMessageBox("Unable to connect to the database using the details configured.");
		AfxPostQuitMessage(0);
		return FALSE;
	}

	if (!m_DBProcess.LoadVersionList())
	{
		AfxMessageBox("Unable to load the version list.");
		AfxPostQuitMessage(0);
		return FALSE;
	}

	m_OutputList.AddString(strConnection);
	CString version;
	version.Format("Latest Version : %d", m_nLastVersion);
	m_OutputList.AddString( version );

	::ResumeThread(m_Iocport.m_hAcceptThread);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Beispiel #2
0
void AFXAPI AfxOleOnReleaseAllObjects()
{
	// don't shut down the application if user is in control of the app
	if (AfxOleGetUserCtrl())
		return;

	AfxOleSetUserCtrl(TRUE);    // avoid re-entry

	// shut down the application
	CWinApp* pApp = AfxGetApp();
	ASSERT_VALID(pApp);

	if (pApp->m_pMainWnd != NULL)
	{
		// destroy the main window (only if enabled)
		if (pApp->m_pMainWnd->IsWindowEnabled())
		{
			// the main window will post WM_QUIT as part of its shutdown
			pApp->m_pMainWnd->DestroyWindow();
		}
	}
	else if (!afxContextIsDLL)
	{
		// no main window, so just post WM_QUIT.
		AfxPostQuitMessage(0);
	}
}
Beispiel #3
0
Datei: BZDoc.cpp Projekt: tnzk/bz
LPBYTE CBZDoc::QueryMapView1(LPBYTE pBegin, DWORD dwOffset)
{
    LPBYTE p = pBegin + dwOffset;
    if(IsOutOfMap1(p)) {
        if(p == m_pData + m_dwTotal && p == m_pMapStart + m_dwMapSize) return pBegin;	// ###1.61a
        DWORD dwBegin = pBegin - m_pData;
        VERIFY(::UnmapViewOfFile(m_pMapStart));
        m_dwFileOffset = (p - m_pData) & FILEOFFSET_MASK;
        m_dwMapSize = min(options.dwMaxMapSize, m_dwTotal - m_dwFileOffset);
        if(m_dwMapSize == 0) {	// ###1.61a
            m_dwFileOffset = (m_dwTotal - (~FILEOFFSET_MASK + 1)) & FILEOFFSET_MASK;
            m_dwMapSize = m_dwTotal - m_dwFileOffset;
        }
        m_pMapStart = (LPBYTE)::MapViewOfFile(m_hMapping, m_bReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE, 0, m_dwFileOffset, m_dwMapSize);
        TRACE("MapViewOfFile Doc=%X, %X, Offset:%X, Size:%X\n", this, m_pMapStart, m_dwFileOffset, m_dwMapSize);
        if(!m_pMapStart) {
            ErrorMessageBox();
            AfxPostQuitMessage(0);
            return NULL;
        }
        m_pData = m_pMapStart - m_dwFileOffset;
        pBegin = m_pData + dwBegin;
    }
    return pBegin;
}
void CXTPSkinObjectFrame::TrackCaptionButton()
{
    SetCapture();
    BOOL bAccept = FALSE;
    m_pButtonPressed = m_pButtonHot;
    CCaptionButton* pButtonPressed = m_pButtonHot;
    ASSERT(pButtonPressed);

    RedrawFrame();

    while (::GetCapture() == m_hWnd)
    {
        MSG msg;

        if (!::GetMessage(&msg, NULL, 0, 0))
        {
            AfxPostQuitMessage((int)msg.wParam);
            break;
        }

        if (msg.message == WM_LBUTTONUP)
        {
            bAccept = m_pButtonPressed == pButtonPressed;
            break;
        }
        else if (msg.message == WM_NCMOUSELEAVE)
        {

        }
        else if (msg.message == WM_MOUSEMOVE)
        {
            POINT point = msg.pt;
            ScreenToFrame(&point);

            CCaptionButton* pButton = HitTestButton(point) == pButtonPressed ? pButtonPressed : NULL;

            if (pButton != m_pButtonPressed)
            {
                m_pButtonPressed = pButton;
                RedrawFrame();
            }
        }
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    m_pButtonPressed = NULL;
    m_pButtonHot = NULL;
    ReleaseCapture();
    RedrawFrame();

    if (bAccept)
    {
        SendMessage(WM_SYSCOMMAND, pButtonPressed->m_nCommand);
    }
}
Beispiel #5
0
BOOL CCJDockContext::TrackDockBar()
{
	if (::GetCapture() != NULL)
		return FALSE;
	m_pBar->SetCapture();
	ASSERT(m_pBar == CWnd::GetCapture());
	
	while (CWnd::GetCapture() == m_pBar)
	{
		MSG msg;
		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage(msg.wParam);
			break;
		}
		
		switch (msg.message)
		{
		case WM_LBUTTONUP:
			if (m_bDragging)
				EndDragDockBar();
			else
				EndResize();
			return TRUE;
		case WM_MOUSEMOVE:
			if (m_bDragging)
				MoveDockBar(msg.pt);
			else
				Stretch(msg.pt);
			break;
		case WM_KEYUP:
			if (m_bDragging)
				OnKey((int)msg.wParam, FALSE);
			break;
		case WM_KEYDOWN:
			if (m_bDragging)
				OnKey((int)msg.wParam, TRUE);
			if (msg.wParam == VK_ESCAPE)
			{
				CancelLoop();
				return FALSE;
			}
			break;
		case WM_RBUTTONDOWN:
			CancelLoop();
			return FALSE;
			
			// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}
	
	CancelLoop();
	return FALSE;
}
Beispiel #6
0
BOOL CSearchWnd::DoSizeDetails()
{
    MSG* pMsg = &AfxGetThreadState()->m_msgCur;
    CRect rcClient;
    CPoint point;

    GetClientRect( &rcClient );
    if ( m_bPanel )
        rcClient.left += Settings.Skin.SidebarWidth;
    if ( ! ( m_bPaused || m_bWaitMore ) )
        rcClient.top += STATUS_HEIGHT;
    rcClient.bottom -= Settings.Skin.ToolbarHeight;

    ClientToScreen( &rcClient );
    ClipCursor( &rcClient );
    SetCapture();
    ScreenToClient( &rcClient );

    int nOffset = 0xFFFF;

    while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
    {
        while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

        if ( ! AfxGetThread()->PumpMessage() )
        {
            AfxPostQuitMessage( 0 );
            break;
        }

        GetCursorPos( &point );
        ScreenToClient( &point );

        int nSplit = rcClient.bottom - point.y;

        if ( nOffset == 0xFFFF ) nOffset = m_nDetails - nSplit;
        nSplit += nOffset;

        if ( nSplit < 8 )
            nSplit = 0;
        if ( nSplit > rcClient.Height() - Settings.Skin.Splitter - 8 )
            nSplit = rcClient.Height() - Settings.Skin.Splitter;

        if ( nSplit != m_nDetails )
        {
            m_nDetails = nSplit;
            Settings.Search.DetailPanelSize = nSplit;
            OnSize( SIZE_INTERNAL, 0, 0 );
            Invalidate();
        }
    }

    ReleaseCapture();
    ClipCursor( NULL );

    return TRUE;
}
	virtual void OnClick(BOOL /*bKeyboard  = FALSE */, CPoint /*pt  = CPoint */)
	{
		if (GetKeyState(VK_LBUTTON) >= 0)
			return;

		m_bPressed = TRUE;

		CXTPRibbonScrollableBar* pScrollableBar = GetScrollableBar(m_pParent);

		pScrollableBar->OnGroupsScroll(m_bScrollLeft);

		int cmsTimer = GetDoubleClickTime() * 4 / 5;
		m_pParent->SetTimer(IDSYS_SCROLL, cmsTimer, NULL);
		BOOL bFirst = TRUE;

		m_pParent->SetCapture();

		while (::GetCapture() == m_pParent->GetSafeHwnd() && IsVisible())
		{
			MSG msg;

			if (!::GetMessage(&msg, NULL, 0, 0))
			{
				AfxPostQuitMessage((int)msg.wParam);
				break;
			}

			if (msg.message == WM_TIMER && msg.wParam == IDSYS_SCROLL)
			{
				pScrollableBar->OnGroupsScroll(m_bScrollLeft);

				if (bFirst)
				{
					cmsTimer = GetDoubleClickTime() / 10;
					m_pParent->SetTimer(IDSYS_SCROLL, cmsTimer, NULL);
				}
				bFirst = FALSE;
			}
			else if (msg.message == WM_LBUTTONUP)
			{
				break;
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}

		ReleaseCapture();
		m_pParent->KillTimer(IDSYS_SCROLL);

		m_bPressed = FALSE;
		if (!IsVisible()) m_bSelected = FALSE;
		RedrawParent(FALSE);
	}
Beispiel #8
0
bool VBA::updateRenderMethod0(bool force)
{
    bool initInput = false;

    if( display != NULL) {
        if( force ) {
            toolsLoggingClose(); // close log dialog
            initInput = true;
            changingVideoSize = true;
            shutdownDisplay();
            if(input) {
                delete input;
                input = NULL;
            }
            CWnd *pWnd = m_pMainWnd;

            m_pMainWnd = NULL;
            pWnd->DragAcceptFiles(FALSE);
            pWnd->DestroyWindow();
            delete pWnd;

            display = NULL;
        }
    } else {
        display = newDirect3DDisplay();
    }

    if( preInitialize() ) {
        if( display->initialize( sizeX, sizeY ) ) {
            if( initInput ) {
                if( !this->initInput() ) {
                    changingVideoSize = false;
                    AfxPostQuitMessage(0);
                    return false;
                }
                input->checkKeys();
                updateMenuBar();
                changingVideoSize = false;
                updateWindowSize(videoOption);

                m_pMainWnd->ShowWindow(SW_SHOW);
                m_pMainWnd->UpdateWindow();
                m_pMainWnd->SetFocus();

                return true;
            } else {
                changingVideoSize = false;
                return true;
            }
        }
    }
    changingVideoSize = false;
    
    return true;
}
Beispiel #9
0
BOOL CLibraryFrame::DoSizePanel()
{
	MSG* pMsg = &AfxGetThreadState()->m_msgCur;
	CRect rcClient;
	CPoint point;

	GetClientRect( &rcClient );
	rcClient.left += m_nTreeSize + Settings.Skin.Splitter;
	rcClient.top += Settings.Skin.ToolbarHeight + m_nHeaderSize;
	rcClient.bottom -= Settings.Skin.ToolbarHeight;
	ClientToScreen( &rcClient );
	ClipCursor( &rcClient );
	SetCapture();

	ScreenToClient( &rcClient );

	int nOffset = 0xFFFF;

	while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
	{
		while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

		if ( ! AfxGetThread()->PumpMessage() )
		{
			AfxPostQuitMessage( 0 );
			break;
		}

		GetCursorPos( &point );
		ScreenToClient( &point );

		int nSplit = rcClient.bottom - point.y;

		if ( nOffset == 0xFFFF )
			nOffset = m_nPanelSize - nSplit;
		nSplit += nOffset;

		if ( nSplit < 8 )
			nSplit = 0;
		if ( nSplit > rcClient.Height() - Settings.Skin.Splitter - 8 )
			nSplit = rcClient.Height() - Settings.Skin.Splitter;

		if ( nSplit != m_nPanelSize )
		{
			m_nPanelSize = nSplit;
			OnSize( 1982, 0, 0 );
			Invalidate();
		}
	}

	ReleaseCapture();
	ClipCursor( NULL );

	return TRUE;
}
Beispiel #10
0
BOOL CChatWnd::DoSizeView()
{
    MSG* pMsg = &AfxGetThreadState()->m_msgCur;

    CRect rcClient;
    GetClientRect( &rcClient );
    ClientToScreen( &rcClient );
    ClipCursor( &rcClient );
    SetCapture();

    GetClientRect( &rcClient );

    int nOffset = 0xFFFF;

    while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
    {
        while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

        if ( ! AfxGetThread()->PumpMessage() )
        {
            AfxPostQuitMessage( 0 );
            break;
        }

        CPoint point;
        GetCursorPos( &point );
        ScreenToClient( &point );

        int nSplit = rcClient.right - point.x;

        if ( nOffset == 0xFFFF ) nOffset = m_nUsersSize - nSplit;
        nSplit += nOffset;

        nSplit = max( nSplit, 0 );
        nSplit = min( nSplit, (int)rcClient.right - SPLIT_SIZE );

        if ( nSplit < 8 )
            nSplit = 0;
        if ( nSplit > rcClient.right - SPLIT_SIZE - 8 )
            nSplit = rcClient.right - SPLIT_SIZE;

        if ( nSplit != m_nUsersSize )
        {
            m_nUsersSize = nSplit;
            OnSize( 1982, 0, 0 );
            Invalidate();
        }
    }

    ReleaseCapture();
    ClipCursor( NULL );

    return TRUE;
}
Beispiel #11
0
void CMonitorBarCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	if ( m_rcTrack.PtInRect( point ) )
	{
		MSG* pMsg = &AfxGetThreadState()->m_msgCur;
		CRect rcTrack( &m_rcTrack );

		ClientToScreen( &rcTrack );
		ClipCursor( &rcTrack );
		ScreenToClient( &rcTrack );

		rcTrack.DeflateRect( m_rcTab.Width() / 2, 0 );

		m_bTab = TRUE;
		Invalidate();

		while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
		{
			while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

			if ( ! AfxGetThread()->PumpMessage() )
			{
				AfxPostQuitMessage( 0 );
				break;
			}

			CPoint pt;
			GetCursorPos( &pt );
			ScreenToClient( &pt );

			int nPosition = (DWORD)( 110.0f * (float)( pt.x - rcTrack.left ) / (float)rcTrack.Width() );
			if ( nPosition < 0 ) nPosition = 0;
			else if ( nPosition >= 105 ) nPosition = 101;
			else if ( nPosition >= 100 ) nPosition = 100;

			if ( nPosition != (int)Settings.Live.BandwidthScale )
			{
				Settings.Live.BandwidthScale = (DWORD)nPosition;
				Invalidate();
			}
		}

		m_bTab = FALSE;
		ReleaseCapture();
		ClipCursor( NULL );
		Invalidate();
	}
	else
	{
		CControlBar::OnLButtonDown( nFlags, point );
	}
}
void CXTPPopupControl::TrackMove()
{
	SetCapture();

	CPoint ptStart;
	GetCursorPos(&ptStart);

	CXTPWindowRect rcStart(this);

	while (GetCapture() == this)
	{
		MSG msg;

		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage((int)msg.wParam);
			break;
		}

		if (msg.message == WM_LBUTTONUP) break;
		else if (msg.message == WM_MOUSEMOVE)
		{
			CPoint pt(msg.pt);
			CRect rc(rcStart);
			rc.OffsetRect(pt - ptStart);

			CRect rcDeskWnd = XTPMultiMonitor()->GetWorkArea(msg.pt);

			if (rc.left < rcDeskWnd.left) rc.OffsetRect(rcDeskWnd.left - rc.left, 0);
			if (rc.top < rcDeskWnd.top) rc.OffsetRect(0, rcDeskWnd.top - rc.top);
			if (rc.right > rcDeskWnd.right) rc.OffsetRect(rcDeskWnd.right - rc.right, 0);
			if (rc.bottom > rcDeskWnd.bottom) rc.OffsetRect(0, rcDeskWnd.bottom - rc.bottom);

			MoveWindow(rc);
		}
		else if (msg.message == WM_KEYDOWN)
		{
			if (msg.wParam == VK_ESCAPE)
				break;
		}
		else
			DispatchMessage(&msg);

	}
	ReleaseCapture();


	m_stateTarget.rcPopup = m_stateCurrent.rcPopup = CXTPWindowRect(this);
	m_ptPopup = m_stateCurrent.rcPopup.BottomRight();

	Notify(XTP_PCN_POSCHANGED, (LPARAM)this);
}
Beispiel #13
0
void CPanelWnd::PanelSizeLoop()
{
	MSG* pMsg = &AfxGetThreadState()->m_msgCur;

	float nOffset = 10;
	CPoint point;
	CRect rcMDI;

	SendMessage( WM_ENTERSIZEMOVE );

	GetParent()->GetWindowRect( &rcMDI );
	GetParent()->SetCapture();
	ClipCursor( &rcMDI );

	while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
	{
		while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

		if ( ! AfxGetThread()->PumpMessage() )
		{
			AfxPostQuitMessage( 0 );
			break;
		}

		GetCursorPos( &point );
		if ( point.y < rcMDI.top ) point.y = rcMDI.top;
		if ( point.y > rcMDI.bottom ) point.y = rcMDI.bottom;

		float nSplitter = (float)( point.y - rcMDI.top ) / (float)rcMDI.Height();

		if ( nOffset == 10 ) nOffset = m_pGroupParent->m_nGroupSize - nSplitter;
		nSplitter += nOffset;

		if ( nSplitter < 0.1f ) nSplitter = 0.1f;
		if ( nSplitter > 0.9f ) nSplitter = 0.9f;

		if ( nSplitter >= 0.47f && nSplitter <= 0.53f ) nSplitter = 0.5f;

		if ( nSplitter != m_pGroupParent->m_nGroupSize )
		{
			m_pGroupParent->m_nGroupSize = nSplitter;
			GetParent()->SendMessage( WM_SIZE, 1982 );
		}
	}

	ReleaseCapture();
	ClipCursor( NULL );
	SendMessage( WM_EXITSIZEMOVE );
}
Beispiel #14
0
CParentWnd::~CParentWnd()
{
	// Since we didn't create a window, we can't call DestroyWindow to let MFC know we're done.
	// We call AfxPostQuitMessage instead
	TRACE_DESTRUCTOR(CLASS);
	UninitializeGDI();
	UnloadAddIns();
	if (m_hwinEventHook) UnhookWinEvent(m_hwinEventHook);
	UninitializeNamedPropCache();
	WriteToRegistry();
	CloseDebugFile();
	// Since we're killing what m_pMainWnd points to here, we need to clear it
	// Else MFC will try to route messages to it
	theApp.m_pMainWnd = NULL;
	AfxPostQuitMessage(0);
} // CParentWnd::~CParentWnd
int CShadowmapApp::Run()
{
	if (!m_pMainWnd)
		AfxPostQuitMessage(0);

	MSG msg;
	CMainFrame* pFrame = STATIC_DOWNCAST ( CMainFrame, m_pMainWnd );

	if ( QueryPerformanceFrequency ( ( LARGE_INTEGER *) &m_lPerfCounter ) ) { 

		// yes, set m_dwTimeCount and timer choice flag 
		m_bPerFlag = TRUE;
		m_dwTimeCount = unsigned long(m_lPerfCounter / m_lFramesPerSecond);
		QueryPerformanceCounter ( ( LARGE_INTEGER * ) &m_lNextTime ); 
		m_dTimeScale = 1.0 / m_lPerfCounter;
	} else  { 
Beispiel #16
0
void CRemoteWnd::TrackSeek()
{
	MSG* pMsg = &AfxGetThreadState()->m_msgCur;
	CRect rcTrack( &m_rcsMediaSeekTrack );
	CPoint point;

	CMediaFrame* pMediaFrame = CMediaFrame::GetMediaFrame();
	if ( pMediaFrame == NULL ) return;

	ClientToScreen( &rcTrack );
	ClipCursor( &rcTrack );
	ScreenToClient( &rcTrack );
	SetCapture();

	rcTrack.DeflateRect( m_rcMediaSeekTab.Width() / 2, 0 );

	while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
	{
		while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

		if ( ! AfxGetThread()->PumpMessage() )
		{
			AfxPostQuitMessage( 0 );
			break;
		}

		GetCursorPos( &point );
		ScreenToClient( &point );

		float fPosition = (float)( point.x - rcTrack.left ) / (float)rcTrack.Width();
		if ( fPosition < 0.0f ) fPosition = 0.0f;
		if ( fPosition > 1.0f ) fPosition = 1.0f;

		if ( fPosition != m_nMediaSeek )
		{
			m_nMediaSeek = fPosition;
			Invalidate();
		}
	}

	ReleaseCapture();
	ClipCursor( NULL );

	pMediaFrame->SeekTo( m_nMediaSeek );
	m_nMediaSeek = -1;
	Invalidate();
}
Beispiel #17
0
void CRemoteWnd::TrackScaler()
{
	MSG* pMsg = &AfxGetThreadState()->m_msgCur;
	CRect rcTrack( &m_rcsScalerTrack );
	CPoint point;

	ClientToScreen( &rcTrack );
	ClipCursor( &rcTrack );
	ScreenToClient( &rcTrack );
	SetCapture();

	rcTrack.DeflateRect( m_rcScalerTab.Width() / 2, 0 );

	while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
	{
		while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

		if ( ! AfxGetThread()->PumpMessage() )
		{
			AfxPostQuitMessage( 0 );
			break;
		}

		GetCursorPos( &point );
		ScreenToClient( &point );

		int nPosition = (int)( 105.0f * (float)( point.x - rcTrack.left ) / (float)rcTrack.Width() );
		if ( nPosition < 0 ) nPosition = 0;
		else if ( nPosition >= 102 ) nPosition = 101;
		else if ( nPosition >= 100 ) nPosition = 100;

		// ToDo: Settings.Live.BandwidthScaleOut
		if ( nPosition != (int)Settings.Live.BandwidthScaleIn )
		{
			Settings.Live.BandwidthScaleIn = (DWORD)nPosition;
			Invalidate();
		}
	}

	ReleaseCapture();
	ClipCursor( NULL );
	Invalidate();
}
Beispiel #18
0
BOOL COXDragDockContext::Track()
{
    // don't handle if capture already set
    if (::GetCapture() != NULL)
        return FALSE;
	
    // set capture to the window which received this message
    m_pBar->SetCapture();
    ASSERT(m_pBar == CWnd::GetCapture());
	
    // get messages until capture lost or cancelled/accepted
    while(CWnd::GetCapture() == m_pBar)
	{
        MSG msg;
#ifndef _MAC
        if (!::GetMessage(&msg, NULL, 0, 0))
#else
			// don't allow yielding while tracking since we don't have LockWindowUpdate
			if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE|PM_NOYIELD))
            continue;
        if (msg.message == WM_QUIT)
#endif
		{
            AfxPostQuitMessage(PtrToInt(msg.wParam));
            break;
		}
		
        switch (msg.message)
		{
            case WM_LBUTTONUP:		// drag finished 
                EndDrag();
                return TRUE;
				
            case WM_MOUSEMOVE:
                Move(msg.pt);
                break;
				
            case WM_KEYUP:
                OnKey((int)msg.wParam, FALSE);
                break;
				
            case WM_KEYDOWN:
				OnKey((int)msg.wParam, TRUE);
                if (msg.wParam == VK_ESCAPE)
					goto exit_cancel_drag;
                break;
				
			case WM_RBUTTONDOWN:
				goto exit_cancel_drag;
				
				// just dispatch rest of the messages
            default:
                DispatchMessage(&msg);
				break;
		}
	}
    
exit_cancel_drag:			// goto  - can't use break as we're inside a switch()    
	CancelDrag();
	return FALSE;
}
Beispiel #19
0
BOOL CDockContext::Track()
{
	// don't handle if capture already set
	if (::GetCapture() != NULL)
		return FALSE;

	// set capture to the window which received this message
	m_pBar->SetCapture();
	ASSERT(m_pBar == CWnd::GetCapture());

#ifndef _MAC
	// get messages until capture lost or cancelled/accepted
	while (CWnd::GetCapture() == m_pBar)
	{
		MSG msg;
		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage(msg.wParam);
			break;
		}

		switch (msg.message)
		{
		case WM_LBUTTONUP:
			if (m_bDragging)
				EndDrag();
			else
				EndResize();
			return TRUE;
		case WM_MOUSEMOVE:
			if (m_bDragging)
				Move(msg.pt);
			else
				Stretch(msg.pt);
			break;
		case WM_KEYUP:
			if (m_bDragging)
				OnKey((int)msg.wParam, FALSE);
			break;
		case WM_KEYDOWN:
			if (m_bDragging)
				OnKey((int)msg.wParam, TRUE);
			if (msg.wParam == VK_ESCAPE)
			{
				CancelLoop();
				return FALSE;
			}
			break;
		case WM_RBUTTONDOWN:
			CancelLoop();
			return FALSE;

		// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}
#else
	Point   ptCur = {0};

	// get messages until capture lost or cancelled/accepted
	while (CWnd::GetCapture() == m_pBar)
	{
		EventRecord     er;

		if (OSEventAvail(everyEvent, &er))
		{
			GetNextEvent(everyEvent, &er);
			switch (er.what)
			{
			case mouseUp:
				if (m_bDragging)
					EndDrag();
				else
					EndResize();
				return TRUE;

			case keyDown:
			case keyUp:
			case autoKey:
			case app2Evt:
			{
				MSG     msg;

				if (WrapEvent(&er, &msg, PM_REMOVE))
				{
					if (m_bDragging)
						OnKey((int)msg.wParam, msg.message == WM_KEYDOWN);
					if (msg.message == WM_KEYUP && msg.wParam == VK_ESCAPE)
					{
						CancelLoop();
						return FALSE;
					}
				}
				break;
			}

			default:
				break;
			}
		}
		else
		{
			if (!EqualPt(er.where, ptCur))
			{
				POINT pt = {er.where.h, er.where.v};
				if (m_bDragging)
					Move(pt);
				else
					Stretch(pt);
			}
		}
	}
#endif
	CancelLoop();

	return FALSE;
}
Beispiel #20
0
BOOL CDockContext::Track()
{
	// don't handle if capture already set
	if (::GetCapture() != NULL)
		return FALSE;

	// set capture to the window which received this message
	m_pBar->SetCapture();
	ASSERT(m_pBar == CWnd::GetCapture());

	// get messages until capture lost or cancelled/accepted
	while (CWnd::GetCapture() == m_pBar)
	{
		MSG msg;
		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage(msg.wParam);
			break;
		}

		switch (msg.message)
		{
		case WM_LBUTTONUP:
			if (m_bDragging)
				EndDrag();
			else
				EndResize();
			return TRUE;
		case WM_MOUSEMOVE:
			if (m_bDragging)
				Move(msg.pt);
			else
				Stretch(msg.pt);
			break;
		case WM_KEYUP:
			if (m_bDragging)
				OnKey((int)msg.wParam, FALSE);
			break;
		case WM_KEYDOWN:
			if (m_bDragging)
				OnKey((int)msg.wParam, TRUE);
			if (msg.wParam == VK_ESCAPE)
			{
				CancelLoop();
				return FALSE;
			}
			break;
		case WM_RBUTTONDOWN:
			CancelLoop();
			return FALSE;

		// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}

	CancelLoop();

	return FALSE;
}
DROPEFFECT CXTPCustomizeDropSource::_DoDragDrop()
{
	BOOL bMoved = FALSE;

	DROPEFFECT dropEffect = DROPEFFECT_CANCEL;

	BOOL bDone = FALSE;

	while (!bDone && ::GetCapture() == m_hwndCapture)
	{
		MSG msg;

		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage((int)msg.wParam);
			return DROPEFFECT_CANCEL;
		}

		if (::GetCapture() != m_hwndCapture)
		{
			// capture was stolen while repainting
			return DROPEFFECT_CANCEL;
		}

		switch (msg.message)
		{
		case WM_LBUTTONUP:
			bDone = TRUE;
			break;

		case WM_MOUSEMOVE:
			if (!bMoved)
			{
				CPoint pt(msg.pt);
				if (m_pControl && m_pControl->GetParent())
				{
					DROPEFFECT dropEffectDragStart = DROPEFFECT_CANCEL;
					m_pControl->GetParent()->ScreenToClient(&pt);
					m_pControl->OnCustomizeDragOver(m_pControl, pt, dropEffectDragStart);
				}

				bMoved = TRUE;
			}
			m_bMove = !(msg.wParam & MK_CONTROL);
			PickTarget(msg.pt);

			// terminate loop if we happen to get mouse move with button up
			if (!(msg.wParam & MK_LBUTTON))
				bDone = TRUE;

			dropEffect = DROPEFFECT_NONE;
			break;

		case WM_KEYDOWN:
			if (msg.wParam == VK_ESCAPE)
				return DROPEFFECT_CANCEL;

			if (msg.wParam == VK_CONTROL && m_bMove)
			{
				m_bMove = FALSE;
				FreshenCursor();
			}
			break;

		case WM_KEYUP:
			if (msg.wParam == VK_CONTROL && !m_bMove)
			{
				m_bMove = TRUE;
				FreshenCursor();
			}
			break;

		case WM_RBUTTONDOWN:
			return DROPEFFECT_CANCEL;

		default:
			::DispatchMessage(&msg);
		}
	}


	if (m_pTarget)
	{

		dropEffect = m_bMove ? DROPEFFECT_MOVE : DROPEFFECT_COPY;

		CPoint point;
		GetCursorPos(&point);

		m_pTarget->ScreenToClient(&point);
		m_pTarget->ScreenToClient(&m_ptStart);

		m_pTarget->OnCustomizeDrop(m_pControl, dropEffect, point, m_ptStart);
		m_pTarget = 0;
	}

	return dropEffect;
}
Beispiel #22
0
int CServerCtrlDlg::RunModalLoop(DWORD dwFlags)
{
	ASSERT(::IsWindow(m_hWnd)); // window must be created
	ASSERT(!(m_nFlags & WF_MODALLOOP)); // window must not already be in modal state

	// for tracking the idle time state
	BOOL bIdle = TRUE;
	LONG lIdleCount = 0;
	BOOL bShowIdle = (dwFlags & MLF_SHOWONIDLE) && !(GetStyle() & WS_VISIBLE);
	HWND hWndParent = ::GetParent(m_hWnd);
	m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
	MSG* pMsg = &AfxGetThread()->m_msgCur;

	// acquire and dispatch messages until the modal state is done
	for (;;)
	{
		ASSERT(ContinueModal());

		int iRet = RMLPreIdle();

		if (iRet < 0)
			goto ExitModal;
		else if (iRet > 0)
			continue;

		// phase1: check to see if we can do idle work
		while (bIdle &&
			!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE))
		{
			ASSERT(ContinueModal());

			// show the dialog when the message queue goes idle
			if (bShowIdle)
			{
				ShowWindow(SW_SHOWNORMAL);
				UpdateWindow();
				bShowIdle = FALSE;
			}

			// call OnIdle while in bIdle state
			if (!(dwFlags & MLF_NOIDLEMSG) && hWndParent != NULL && lIdleCount == 0)
			{
				// send WM_ENTERIDLE to the parent
				::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
			}
			if ((dwFlags & MLF_NOKICKIDLE) ||
				!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++))
			{
				// stop idle processing next time
				bIdle = FALSE;
			}
		}

		// phase2: pump messages while available
		do
		{
			BOOL ShouldPump = TRUE;

			ASSERT(ContinueModal());

			// See if we are requiring messages to be in queue?
			if ( m_bOnlyPumpIfMessageInQueue )
			{
				// If there isn't a message, don't turn over control to PumpMessage
				//  since it will block
				if ( !::PeekMessage( pMsg, NULL, NULL, NULL, PM_NOREMOVE ) )
				{
					ShouldPump = FALSE;
				}
			}

			// pump message, but quit on WM_QUIT
			if ( ShouldPump )
			{
				if (!AfxGetThread()->PumpMessage())
				{
					AfxPostQuitMessage(0);
					return -1;
				}

				// show the window when certain special messages rec'd
				if (bShowIdle &&
					(pMsg->message == 0x118 || pMsg->message == WM_SYSKEYDOWN))
				{
					ShowWindow(SW_SHOWNORMAL);
					UpdateWindow();
					bShowIdle = FALSE;
				}

				if (!ContinueModal())
					goto ExitModal;

				// reset "no idle" state after pumping "normal" message
				if (AfxGetThread()->IsIdleMessage(pMsg))
				{
					bIdle = TRUE;
					lIdleCount = 0;
				}
			}

		} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
	}
ExitModal:
	m_nFlags &= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
	return m_nModalResult;
}
/*
			等待5秒
*/
int CHTMLViewCapView::RunModalLoop(DWORD dwFlags)
{
			ASSERT(::IsWindow(m_hWnd)); // window must be created
			ASSERT(!(m_nFlags & WF_MODALLOOP)); // window must not already be in modal state

			// for tracking the idle time state
			BOOL bIdle = TRUE;
			LONG lIdleCount = 0;
			BOOL bShowIdle = (dwFlags & MLF_SHOWONIDLE) && !(GetStyle() & WS_VISIBLE);
			HWND hWndParent = ::GetParent(m_hWnd);
			m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
			MSG *pMsg = AfxGetCurrentMessage();

			// acquire and dispatch messages until the modal state is done
			for (;;)
			{
				ASSERT(ContinueModal());

				// phase1: check to see if we can do idle work
				while (bIdle &&
					!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE))
				{
					ASSERT(ContinueModal());

					// show the dialog when the message queue goes idle
					if (bShowIdle)
					{
						ShowWindow(SW_SHOWNORMAL);
						UpdateWindow();
						bShowIdle = FALSE;
					}

					// call OnIdle while in bIdle state
					if (!(dwFlags & MLF_NOIDLEMSG) && hWndParent != NULL && lIdleCount == 0)
					{
						// send WM_ENTERIDLE to the parent
						::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
					}
					if ((dwFlags & MLF_NOKICKIDLE) ||
						!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++))
					{
						// stop idle processing next time
						bIdle = FALSE;
					}
				}

				// Get current time
				//CTime tBeginLoop;
				CTime tEndLoop;
				CTimeSpan span;
				BOOL bQuit = FALSE;

				// phase2: pump messages while available
				do
				{
					ASSERT(ContinueModal());
					TRACE("pump messages!\n");

					//
					//tBeginLoop = CTime::GetCurrentTime();

					// pump message, but quit on WM_QUIT
					if (!AfxPumpMessage())
					{
						AfxPostQuitMessage(0);
						return -1;
					}

					// show the window when certain special messages rec'd
					if (bShowIdle &&
						(pMsg->message == 0x118 || pMsg->message == WM_SYSKEYDOWN))
					{
						ShowWindow(SW_SHOWNORMAL);
						UpdateWindow();
						bShowIdle = FALSE;
					}

					if (!ContinueModal() || bQuit)
						goto ExitModal;

					// reset "no idle" state after pumping "normal" message
					if (AfxIsIdleMessage(pMsg))
					{
						bIdle = TRUE;
						lIdleCount = 0;
					}

					tEndLoop = CTime::GetCurrentTime();
					span =  tEndLoop - m_tBeforeEnterLoop;
					TRACE("Span : %d .\n", span.GetTotalSeconds());
					if (span.GetTotalSeconds() >= m_wating_time_max)
					{
						bQuit = TRUE;
					}

				} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
			}

		ExitModal:
			m_nFlags &= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
			return m_nModalResult;
}
Beispiel #24
0
void VBA::updateWindowSize(int value)
{
  regSetDwordValue("video", value);

  if(value == VIDEO_OTHER) {
    regSetDwordValue("fsWidth", fsWidth);
    regSetDwordValue("fsHeight", fsHeight);
    regSetDwordValue("fsColorDepth", fsColorDepth);
  }

  if(((value >= VIDEO_320x240) &&
      (videoOption != value)) ||
     (videoOption >= VIDEO_320x240 &&
      value <= VIDEO_4X) ||
     fsForceChange) {
    fsForceChange = false;
    changingVideoSize = true;
	if( videoOption <= VIDEO_4X ) {
		lastWindowed = (VIDEO_SIZE)videoOption; // save for when leaving full screen
	} else {
		lastFullscreen = (VIDEO_SIZE)videoOption; // save for when using quick switch to fullscreen
	}
    shutdownDisplay();
    if(input) {
      delete input;
      input = NULL;
    }
    m_pMainWnd->DragAcceptFiles(FALSE);
    CWnd *pWnd = m_pMainWnd;
    m_pMainWnd = NULL;
    pWnd->DestroyWindow();
    delete pWnd;
    videoOption = value;
    if(!initDisplay()) {
      if(videoOption == VIDEO_320x240 ||
         videoOption == VIDEO_640x480 ||
         videoOption == VIDEO_800x600 ||
         videoOption == VIDEO_1024x768 ||
         videoOption == VIDEO_1280x1024 ||
         videoOption == VIDEO_OTHER) {
        regSetDwordValue("video", VIDEO_1X);
      }
      changingVideoSize = false;
      AfxPostQuitMessage(0);
      return;
    }
    if(!initInput()) {
      changingVideoSize = false;
      AfxPostQuitMessage(0);
      return;
    }
    input->checkKeys();


    changingVideoSize = FALSE;
    updateWindowSize(videoOption);
    return;
  }

  sizeX = 240;
  sizeY = 160;

  videoOption = value;

  surfaceSizeX = sizeX;
  surfaceSizeY = sizeY;

  switch(videoOption) {
  case VIDEO_1X:
    surfaceSizeX = sizeX;
    surfaceSizeY = sizeY;
    break;
  case VIDEO_2X:
    surfaceSizeX = sizeX * 2;
    surfaceSizeY = sizeY * 2;
    break;
  case VIDEO_3X:
    surfaceSizeX = sizeX * 3;
    surfaceSizeY = sizeY * 3;
    break;
  case VIDEO_4X:
    surfaceSizeX = sizeX * 4;
    surfaceSizeY = sizeY * 4;
    break;
  case VIDEO_320x240:
  case VIDEO_640x480:
  case VIDEO_800x600:
  case VIDEO_1024x768:
  case VIDEO_1280x1024:
  case VIDEO_OTHER:
    {
      int scaleX = 1;
      int scaleY = 1;
      scaleX = (fsWidth / sizeX);
      scaleY = (fsHeight / sizeY);
      int min = scaleX < scaleY ? scaleX : scaleY;
      if(maxScale)
        min = min > maxScale ? maxScale : min;
      surfaceSizeX = min * sizeX;
      surfaceSizeY = min * sizeY;
      if(fullScreenStretch) {
        surfaceSizeX = fsWidth;
        surfaceSizeY = fsHeight;
      }
    }
    break;
  }

  rect.right = sizeX;
  rect.bottom = sizeY;

  int winSizeX = sizeX;
  int winSizeY = sizeY;

  if(videoOption <= VIDEO_4X) {
    dest.left = 0;
    dest.top = 0;
    dest.right = surfaceSizeX;
    dest.bottom = surfaceSizeY;

    DWORD style = WS_POPUP | WS_VISIBLE;

    style |= WS_OVERLAPPEDWINDOW;

    AdjustWindowRectEx(&dest, style, TRUE, 0); //WS_EX_TOPMOST);

    winSizeX = dest.right-dest.left;
    winSizeY = dest.bottom-dest.top;

      m_pMainWnd->SetWindowPos(0, //HWND_TOPMOST,
                               windowPositionX,
                               windowPositionY,
                               winSizeX,
                               winSizeY,
                               SWP_NOMOVE | SWP_SHOWWINDOW);

	  // content of old seperate 'winCheckMenuBarInfo' function:
      MENUBARINFO info;
      info.cbSize = sizeof(MENUBARINFO);
	  GetMenuBarInfo( theApp.m_pMainWnd->GetSafeHwnd(), OBJID_MENU, 0, &info );
      int menuHeight = GetSystemMetrics(SM_CYMENU); // includes white line
      if((info.rcBar.bottom - info.rcBar.top) > menuHeight) // check for double height menu
	  {
        winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
        m_pMainWnd->SetWindowPos(
                                        0, //HWND_TOPMOST,
                                        theApp.windowPositionX,
                                        theApp.windowPositionY,
                                        winSizeX,
                                        winSizeY,
                                        SWP_NOMOVE | SWP_SHOWWINDOW);
      }
  }

  adjustDestRect();

  if(display)
    display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top);

  m_pMainWnd->RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
}
Beispiel #25
0
void systemFrame()
{
	if (theApp.altAviRecordMethod && theApp.aviRecording)
	{
		if (theApp.aviRecorder)
		{
			if (!theApp.aviRecorder->IsSoundAdded())
			{
				WAVEFORMATEX wfx;
				memset(&wfx, 0, sizeof(wfx));
				wfx.wFormatTag		= WAVE_FORMAT_PCM;
				wfx.nChannels		= 2;
				wfx.nSamplesPerSec	= 44100 / soundQuality;
				wfx.wBitsPerSample	= 16;
				wfx.nBlockAlign		= (wfx.wBitsPerSample / 8) * wfx.nChannels;
				wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
				wfx.cbSize = 0;
				theApp.aviRecorder->SetSoundFormat(&wfx);
			}
			theApp.aviRecorder->AddSound((u8 *)soundFrameSound, soundFrameSoundWritten * 2);
		}
	}

	soundFrameSoundWritten = 0;

	// no more stupid updates :)

	extern int quitAfterTime;                   // from VBA.cpp
	void	   VBAMovieStop(bool8 suppress_message); // from ../movie.cpp
	if (quitAfterTime >= 0 && systemCounters.frameCount == quitAfterTime)
	{
		VBAMovieStop(true);
		AfxPostQuitMessage(0);
	}

	// change the sound speed, or set it to normal - must always do this or it won't get reset after a change, but that's OK
	// because it's inexpensive
	if (theApp.sound)
	{
		theApp.sound->setSpeed(
		    speedup || theApp.winPauseNextFrame || !synchronize || theApp.accuratePitchThrottle || theApp.useOldSync
			? 1.0f : (float)theApp.throttle / 100.0f);
	}

	// if a throttle speed is set and we're not allowed to change the sound frequency to achieve it,
	// sleep for a certain amount each time we get here to approximate the necessary slowdown
	if (synchronize && (theApp.accuratePitchThrottle || !theApp.sound || theApp.throttle < 6) /*&& !theApp.winPauseNextFrame*/)
	{
		/// FIXME: this is still a horrible way of achieving a certain frame time
		///        (look at what Snes9x does - it's complicated but much much better)

		static float sleepAmt = 0.0f; // variable to smooth out the sleeping amount so it doesn't oscillate so fast
//		if(!theApp.wasPaused) {
		if (!speedup)
		{
			u32 time = systemGetClock();
			u32 diff = time - theApp.throttleLastTime;
			if (theApp.wasPaused)
				diff = 0;

			int target = (100000 / (60 * theApp.throttle));
			int d	   = (target - diff);

			if (d > 1000) // added to avoid 500-day waits for vba to start emulating.
				d = 1000;  // I suspect most users aren't that patient, and would find 1 second to be a more reasonable delay.

			sleepAmt = 0.8f * sleepAmt + 0.2f * (float)d;
			if (d - sleepAmt <= 1.5f && d - sleepAmt >= -1.5f)
				d = (int)(sleepAmt);

			if (d > 0)
			{
				Sleep(d);
			}
		}
		theApp.throttleLastTime = systemGetClock();
		//}
		//else
		//{
		// Sleep(100);
		//}
	}

	if (systemCounters.frameCount % 10 == 0)
	{
		if (theApp.rewindMemory)
		{
			if (++theApp.rewindCounter >= (theApp.rewindTimer))
			{
				theApp.rewindSaveNeeded = true;
				theApp.rewindCounter	= 0;
			}
		}
		if (systemSaveUpdateCounter)
		{
			if (--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED)
			{
				winWriteBatteryFile();
				systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
			}
		}
	}

	theApp.wasPaused = false;
///  theApp.autoFrameSkipLastTime = time;
}