⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapview.cpp

📁 Under CE4.2 view bitmap with shrink and magnify
💻 CPP
字号:
// MapView.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "MapView.h"

#include "MainFrm.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////
//Global objects 
static const TCHAR g_szClassName[] = TEXT("MapView");

HANDLE FindPrevInstance();

// Rotate screen to portrait mode and restore to default
// TRUE:  rotate to portrait
// FALSE: restore to default 

#ifndef OSCAR_200
//#define OSCAR_200
#endif

#ifdef OSCAR_200
void ctRotateScreen(bool bRotate)
{
	DEVMODE dm;
	memset(&dm, 0, sizeof(DEVMODE));
	dm.dmSize = sizeof(DEVMODE);
	if (bRotate)
	{
		dm.dmDisplayOrientation = DMDO_180;
	}
	else
	{
		dm.dmDisplayOrientation = DMDO_270;
	}	
	dm.dmFields = DM_DISPLAYORIENTATION;
	
	int nRetValue = ChangeDisplaySettingsEx(NULL, &dm, NULL, 0, NULL);
	switch (nRetValue)
	{
	case DISP_CHANGE_SUCCESSFUL:
		TRACE0("The settings change was successful.");
		break;
	case DISP_CHANGE_BADFLAGS:
		TRACE0("An invalid set of values was used in the dwFlags parameter.");
		break;
	case DISP_CHANGE_BADMODE:
		TRACE0("The graphics mode is not supported.");
		break;
	case DISP_CHANGE_BADPARAM:
		TRACE0("An invalid parameter was used. This error can include an invalid value or combination of values.");
		break;
	case DISP_CHANGE_FAILED:
		TRACE0("The display driver failed the specified graphics mode.");
		break;
	case DISP_CHANGE_NOTUPDATED:
		TRACE0("ChangeDisplaySettingsEx was unable to write settings to the registry.");
		break;
	case DISP_CHANGE_RESTART:
		TRACE0("The user must restart the computer for the graphics mode to work.");
		break;
	default:
		break;
	}
}
#else
#define ctRotateScreen(bRotate)
#endif

/////////////////////////////////////////////////////////////////////////////
// CMapViewApp

BEGIN_MESSAGE_MAP(CMapViewApp, CWinApp)
	//{{AFX_MSG_MAP(CMapViewApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard file based document commands
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMapViewApp construction

CMapViewApp::CMapViewApp()
	: CWinApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
	m_hEvent = NULL;
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CMapViewApp object

CMapViewApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CMapViewApp initialization

BOOL CMapViewApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

    m_hEvent = FindPrevInstance();
	if (m_hEvent == NULL)
	{
		// We found another instance
		return -1;
	}
	
	ctRotateScreen(TRUE);

	CWnd* pWnd = CWnd::FindWindow( L"HHTaskBar" , NULL ) ; 

	if ( pWnd != NULL )
	{
		if ( pWnd->IsWindowVisible() ) // >IsWindowVisible())
		{
			m_bTaskbarHide=TRUE;
			pWnd->GetWindowRect(m_rtTaskBar);
		}
		else
		{
			m_rtTaskBar.SetRect(0,0,0,0);
			m_bTaskbarHide=FALSE;
		}
		pWnd->MoveWindow(0,320,240,0,FALSE);
	}

	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object.

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	// create and load the frame with its resources

	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_BORDER | WS_SYSMENU | WS_MAXIMIZEBOX |WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);



	// The one and only window has been initialized, so show and update it.
	pFrame->ShowWindow(m_nCmdShow);
	pFrame->UpdateWindow();

	pFrame->MoveWindow(0,0,240,320);
	return TRUE;
}

int CMapViewApp::ExitInstance() 
{
	// TODO: Add your specialized code here and/or call the base class
	CWnd* pWnd = CWnd::FindWindow( L"HHTaskBar" , NULL ) ; 
 
	if ( pWnd != NULL )
	{
		if ( m_bTaskbarHide ) // >IsWindowVisible())
		{
			pWnd->MoveWindow(&m_rtTaskBar,FALSE);
		}
	}

	CloseHandle(m_hEvent);

	ctRotateScreen(FALSE);

	return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
// CMapViewApp message handlers

//////////////////////////////////////////////////////////////////////////
// Global functions definition

HANDLE FindPrevInstance()
{
	HANDLE hEvent;
	HWND   hwnd;
	UINT   cTries = 0;

	// Create a named event
	hEvent = CreateEvent(NULL, TRUE, FALSE, g_szClassName);
	if (hEvent != NULL)
	{
		// If the event already existed, that means there's another copy of our app
		// already running
		if (GetLastError() == ERROR_ALREADY_EXISTS)
		{
			do
			{
				// Just in case the other window needs to finish initialization
				Sleep(cTries ? 250 : 0);

				// Try to find the other application window
				hwnd = FindWindow(NULL,g_szClassName);
				if (hwnd != NULL)
				{
					SetForegroundWindow((HWND)((UINT_PTR)hwnd | 0x01));
					CloseHandle(hEvent);
					return NULL;
				}
			}
			while (++cTries < 2);  // only try twice

			// If we didn't find the window, the other application was probably
			// shutting down, so we'll just continue
		}
	}

	// Done
	return hEvent;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -