appstatic.cpp

来自「VC&Matlab混合编程实现无线电导航指示器」· C++ 代码 · 共 129 行

CPP
129
字号
// APPStatic.cpp: implementation of the APPStatic class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "RADIO.h"
#include "APPStatic.h"

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


double APPStatic::app_dMagneticErrorAngle=2.0;//磁偏角(磁北相对于真北,顺时针为正)
LONG APPStatic::app_lTimeEllapse=100;//仿真时间步长ms,就是定时器的timeellapse
double APPStatic::app_dSimuTime=0.0;//仿真时间static,就是航迹的真实时间
CSize APPStatic::app_sizeSheet1=CSize(1010,780);//Sheet1的大小
CSize APPStatic::app_sizeSheet2=CSize(1024,650);//Sheet2的大小
COLORREF APPStatic::colorDlg=RGB(0,39,79);//对话框背景色
CString APPStatic::strStopSimu="停止运行";//停止仿真时工具条字符串
CString APPStatic::strOnSimu="正在运行";//正在仿真时工具条字符串
CString APPStatic::strWndTitle="无线电导航指示器";//大标题
int APPStatic::nFirstSheet=0;//初始显示的tab




//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

APPStatic::APPStatic()
{

}

APPStatic::~APPStatic()
{

}

CString APPStatic::Time2String(double dTime){
	//时间(s)转成字符串
	CString strTime;	
	double dHr=(double)(LONG)(dTime/3600);
    double dMi=(double)(LONG)((dTime-dHr*3600)/60);
	double dSec=dTime-dHr*3600-dMi*60;
	strTime.Format("%2ld:%2ld:%6.3lf",(LONG)dHr,(LONG)dMi,dSec);
	return strTime;
	
}

void APPStatic::GetDoubleColor(COLORREF rgb,double* pdColor){
	double r=(double)GetRValue(rgb);
	double g=(double)GetGValue(rgb);
	double b=(double)GetBValue(rgb);
	
	pdColor[0]=r/255.0;
	pdColor[1]=g/255.0;
	pdColor[2]=b/255.0;
}

CRADIOView* APPStatic::GetMainView()
{
    return (CRADIOView*)(((CFrameWnd*)(AfxGetApp()->m_pMainWnd))->GetActiveView());

}

BOOL APPStatic::RegisterActivex(LPCSTR szActivexFileName)
{
	//装载ActiveX控件
	HINSTANCE hLib = LoadLibrary(szActivexFileName);
	if (hLib < (HINSTANCE)HINSTANCE_ERROR)
	{
		::MessageBox(NULL,TEXT("不能载入ActiveX文件!"),TEXT("结果"),MB_OK);
		return FALSE;
	}
	//获取注册函数DllRegisterServer地址
	FARPROC lpDllEntryPoint; 
	lpDllEntryPoint = GetProcAddress(hLib,_T("DllRegisterServer"));
	//调用注册函数DllRegisterServer
	if(lpDllEntryPoint!=NULL)
	{
		if(FAILED((*lpDllEntryPoint)()))
		{
			::MessageBox(NULL,TEXT("调用DllRegisterServer失败!)"),TEXT("结果"),MB_OK);
			::FreeLibrary(hLib);
			return FALSE;
		}
		//::MessageBox(NULL,TEXT("注册成功"),TEXT("结果"),MB_OK);
		return TRUE;
	}
	else
	{	::MessageBox(NULL,TEXT("调用DllRegisterServer失败!"),TEXT("结果"),MB_OK);
	     return FALSE;
	}
}

BOOL APPStatic::UnRegisterActivex(LPCSTR szActivexFileName)
{
//装载ActiveX控件
	HINSTANCE hLib = LoadLibrary(szActivexFileName);
	if (hLib < (HINSTANCE)HINSTANCE_ERROR)
	{
		::MessageBox(NULL,TEXT("不能载入ActiveX文件!"),TEXT("结果"),MB_OK);
		return FALSE;
	}
	//获取注册函数DllRegisterServer地址
	FARPROC lpDllEntryPoint; 
	lpDllEntryPoint = GetProcAddress(hLib,TEXT("DllUnregisterServer"));
	//调用注册函数DllRegisterServer
	if(lpDllEntryPoint!=NULL)
	{
		if(FAILED((*lpDllEntryPoint)()))
		{
			::MessageBox(NULL,TEXT("调用DllUnRegisterServer失败!)"),TEXT("结果"),MB_OK);
			::FreeLibrary(hLib);
			return FALSE;
		}
		//::MessageBox(NULL,TEXT("反注册成功"),TEXT("结果"),MB_OK);
		return TRUE;
	}
	else
		::MessageBox(NULL,TEXT("调用DllUnRegisterServer失败!"),TEXT("结果"),MB_OK);
	return FALSE;
}

⌨️ 快捷键说明

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