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

📄 c_proc.cpp

📁 对日本KSG震动探测仪器编写的伴侣服务代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// (Version 1.00 :: 10-Mar-1999 :: Harutoshi Yoshida)
/*===================================================================
	俠 俻倳倕倱倲
	-----------------------------------
		Standard Procedure Module
	-----------------------------------
	Program Name        : C_Proc.CPP
	Program Start       : 14-Dec-1998
	Program Completed   : 
===================================================================*/

#include "stdafx.h"
#include "C_File.h"
#include "C_Proc.h"
#include "C_ComProc.h"
#include "C_SeqProc.h"
#include "C_Work.h"
#include "CqMemDC.h"					// ver 1.30


/*=====================================
						m:10-Dec-1998
@p	<< 慄昤夋 >>
堷悢丗	x1, y1		奐巒揰
		x2, y2		廔椆揰
		wid			慄暆
		pal1		怓乮僷儗僢僩俶倧丏乯
		dc			昤夋僗僞僀儖
					 0:慄
					 1:儃僢僋僗
					 2:儃僢僋僗僼傿儖
		lstyle		儔僀儞僗僞僀儖
					 PS_SOLID etc
		pal2		揾傝偮傇偟怓乮僷儗僢僩俶倧丏乯
栠抣丗	側偟
=====================================*/
void g_line(CDC *pDC, int x1, int y1, int x2, int y2, int wid, int pal1, int dc, int lstyle, int pal2)
{
	int t;
	static int	Clr_pal[16][3] = {			// Color Pallete
		/*00*/	{  0,  0,  0},					// BLK
		/*01*/	{  0,  0,255},					// BLU
		/*02*/	{  0,255,  0},					// GRN
		/*03*/	{  0,255,255},					// SKY
		/*04*/	{255,  0,  0},					// RED
		/*05*/	{255,  0,255},					// VLT
		/*06*/	{255,255,  0},					// YLW
		/*07*/  {255,255,255},					// WHT
		// USER
		/*08*/  {100,100,150},					// MAP梡 惵
		/*09*/  {160,160,210},					// MAP梡 敄惵
		/*10*/  {  0,  0,  0},					// user
		/*11*/  {  0,  0,  0},					// user
		/*12*/  {  0,  0,  0},					// user
		/*13*/  {  0,  0,  0},					// user
		/*14*/  {  0,  0,  0},					// user
		/*15*/  {  0,  0,  0},					// sys_clr
	};
	CPen  Pen(lstyle,wid,RGB(Clr_pal[pal1][0],Clr_pal[pal1][1],Clr_pal[pal1][2]));
	CPen* pOldPen = pDC->SelectObject(&Pen);
	CBrush Brush;
	CBrush* pOldBrush;

	Brush.CreateSolidBrush(RGB(Clr_pal[pal2][0],Clr_pal[pal2][1],Clr_pal[pal2][2]));
	pOldBrush = pDC->SelectObject(&Brush);
	switch (dc) {
	case 0:				// LINE
		pDC->MoveTo(x1,y1);
		pDC->LineTo(x2,y2);
		break;
	case 1:				// BOX
		if (x1 > x2) {t = x1; x1 = x2; x2 = t;}
		if (y1 > y2) {t = y1; y1 = y2; y2 = t;}
		pDC->SelectStockObject(NULL_BRUSH);
		pDC->Rectangle(x1,y1,x2,y2);
		break;
	case 2:				// BOX FILL
		if (x1 > x2) {t = x1; x1 = x2; x2 = t;}
		if (y1 > y2) {t = y1; y1 = y2; y2 = t;}
		pDC->Rectangle(x1,y1,x2,y2);
		break;
	}
	pDC->SelectObject(pOldPen);
	pDC->SelectObject(pOldBrush);
	Pen.DeleteObject();
	Brush.DeleteObject();
}

/*=====================================
						m:20-Oct-1998
@p	<< 僪儔僀僽僞僀僾妋擣 >>
堷悢丗	lpCommandLine	僐儅儞僪儔僀儞暥帤楍
栠抣丗	0			彂偒崬傒壜擻僪儔僀僽
		1			彂偒崬傒晄壜僪儔僀僽
=====================================*/
int		drive_type_chk(LPCTSTR szFolder)
{
	char tmp[MAX_PATH];
	char dt[3];
	int flg = 1, n;
	CC_File cFile;

	sprintf(tmp, "%s", szFolder);
	dt[0] = tmp[0];
	dt[1] = tmp[1];
	dt[2] = '\0';
	switch (GetDriveType(dt)) {
	case DRIVE_FIXED:							// 僴乕僪僨傿僗僋
	case DRIVE_REMOVABLE:						// 儕儉乕僶僽儖僨傿僗僋
		flg = 0;
		break;
	case DRIVE_REMOTE:							// 僱僢僩儚乕僋僪儔僀僽
//		if (AfxMessageBox("僱僢僩儚乕僋僪儔僀僽偱偡丅\r\n傛傠偟偄偱偡偐丠", MB_OKCANCEL) == IDOK)
			flg = 0;
		break;
	case DRIVE_RAMDISK:							// RAM僨傿僗僋
//		if (AfxMessageBox("RAM僨傿僗僋偱偡丅\r\n傛傠偟偄偱偡偐丠", MB_OKCANCEL) == IDOK)
			flg = 0;
		break;
	case DRIVE_NO_ROOT_DIR:						// 懚嵼偟側偄
		n = cFile.C_GetDrive();					// 僇儗儞僩僪儔僀僽偼"懚嵼偟側偄"偵側傞堊丄妋擣偡傞
		if ( (dt[0] | 0x20) == ('a'+n-1)) {
			flg = 0;
		}
		else {
//			AfxMessageBox("懚嵼偟側偄僪儔僀僽偱偡丅");
		}
		break;
	case DRIVE_CDROM:							// CD-ROM
//		AfxMessageBox("CD-ROM偱偡丅\r\n彂偒崬傔傑偣傫丅");
		break;
	case DRIVE_UNKNOWN:							// 晄柧
	default:									// 堎忢
//		AfxMessageBox("晄柧側僪儔僀僽偱偡丅\r\n慖戰偱偒傑偣傫丅");
		break;
	}
	return flg;
}

/*=====================================
						m:12-Oct-1998
@p	<< 僐儌儞僟僀傾儘僌偐傜偺僼傽僀儖柤庢摼 >>
堷悢丗	lpDispName			昞帵梡僼傽僀儖柤
		lpFileName			慖戰偝傟偨僼傽僀儖柤
		flg					TRUE  : File Open
							FALSE : File Save
栠抣丗	IDOK				俷俲
		IDCANCEL			僉儍儞僙儖
=====================================*/
int	CommonDlgFileOpen(LPCTSTR lpDispName, char *lpFileName, BOOL flg)
{
	// ver 1.30
	//CFileDialog pDlg(flg, NULL, "*.*", OFN_HIDEREADONLY, "慡偰偺僼傽僀儖 (*.*)|*.*||", NULL);
	CFileDialog pDlg(flg, NULL, "*.*", OFN_HIDEREADONLY, "All File's (*.*)|*.*||", NULL);
	char file_name[MAX_PATH], dir_name[MAX_PATH];
	char tmp[MAX_PATH];
	int i, p = 0;
	int ret = IDCANCEL;

	User_work = 1;
	for (i=0; ; i++) {
		if (lpDispName[i] == '\0') break;
		if (lpDispName[i] == '\\') p = i;
	}
	sprintf(dir_name, "%s", lpDispName);
	dir_name[p] = '\0';

	sprintf(file_name, "%s", &lpDispName[p+1]);

	if (flg == TRUE) {
		// ver 1.30
		//pDlg.m_ofn.lpstrTitle = "僼傽僀儖偺巜掕";
		pDlg.m_ofn.lpstrTitle = "Select File";
	}
	else {
		// ver 1.30
		//pDlg.m_ofn.lpstrTitle = "僼傽僀儖偺曐懚";
		pDlg.m_ofn.lpstrTitle = "Save File";
	}
	pDlg.m_ofn.lpstrInitialDir = dir_name;
	pDlg.m_ofn.lpstrFile = file_name;
//	pDlg.m_ofn.Flags |= (OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_CREATEPROMPT);
	pDlg.m_ofn.Flags |= (OFN_HIDEREADONLY | OFN_NOCHANGEDIR);
	if (pDlg.DoModal() == IDOK) {
		sprintf(tmp, "%s", pDlg.GetPathName());
		if (drive_type_chk(tmp) == 0) {
			sprintf(lpFileName, "%s", pDlg.GetPathName());
			ret = IDOK;
		}
	}
	User_work = 0;
	return ret;
}

/*=====================================
						m:09-Dec-1998
@p	<< 廔椆張棟 >>
堷悢丗	側偟
栠抣丗	側偟
=====================================*/
void	exit_sv()
{
	AfxGetMainWnd()->PostMessage(WM_CLOSE);
}

/*=====================================
						m:26-Jan-1999
@p	<< 僾儔僢僩僼僅乕儉僠僃僢僋 >>
堷悢丗	側偟
栠抣丗	0	Windows 95
		1	Windows NT
		-1	晄柧
=====================================*/
int CheckPlatForm()
{
	OSVERSIONINFO	osInfo;
	int				ret;
	
	ret = -1;
	osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osInfo);
	ret = 0;
	if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {	// Windows 95
		ret = 0;
	}
	else if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {	// Windows NT
		ret = 1;
	}
	return ret;
}

/*=====================================
						m:21-Jan-1999
@p	<< 僗僋儕乕儞僙乕僶乕婲摦 >>
堷悢丗	hWnd			婲摦偡傞恊僂傿儞僪僂僴儞僪儖
栠抣丗	側偟
=====================================*/
void  StartScreenSaver(HWND hWnd)
{
	BOOL bActive = FALSE;
    
	//  僗僋儕乕儞僙乕僶乕偑僐儞僩儘乕儖僷僱儖偱愝掕偝傟偰偄傞偐僠僃僢僋偡傞
	if (SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &bActive, SPIF_UPDATEINIFILE ) == TRUE ) {
		if (bActive == TRUE) {
			//僗僋儕乕儞僙乕僶乕偺婲摦
			SendMessage(hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0);
		}
	}
}

/*=====================================
						m:24-Jan-1999
@p	<< 僗僋儕乕儞僙乕僶乕摦嶌拞妋擣 >>
堷悢丗	側偟
栠抣丗	0	掆巭
		1	婲摦拞
=====================================*/
int CheckScreenSaver(int *wNT, HDESK *hDesk, HWND *hWnd)
{
	int	ret;

	OSVERSIONINFO osInfo;
	osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osInfo);
	ret = 0;
	if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
		// Windows95
		*wNT = 0;
//		HWND hWnd = FindWindow("WindowsScreenSaverClass", NULL);
		*hWnd = FindWindow("WindowsScreenSaverClass", NULL);
		if (*hWnd != NULL){
			ret = 1;
		}
	}
	else if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
		// WindowsNT
		*wNT = 1;
//		HDESK hDesk;
		*hDesk = OpenDesktop("Screen-saver", 0, FALSE, DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);

		if (*hDesk) {
			ret = 1;
		}
	}
	return ret;
}

/*=====================================
						m:21-Jan-1999
@p	<< 僗僋儕乕儞僙乕僶乕掆巭梡 僐乕儖僶僢僋娭悢 >>
堷悢丗	側偟
栠抣丗	側偟
=====================================*/
BOOL CALLBACK StopScreenSaverProc(HWND hWnd, LPARAM lParam)
{
	PostMessage(hWnd, WM_CLOSE, 0, 0L);
	SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_SENDWININICHANGE);
	return TRUE;
}

/*=====================================
						m:21-Jan-1999
@p	<< 僗僋儕乕儞僙乕僶乕掆巭 >>
堷悢丗	側偟
栠抣丗	側偟
=====================================*/
void StopScreenSaver()
{
	int		wNT, exe;
	HDESK	hDesk;
	HWND	hWnd;

	exe = CheckScreenSaver(&wNT, &hDesk, &hWnd);
	if (exe){
		if (wNT){
			EnumDesktopWindows(hDesk, StopScreenSaverProc, 0);
			CloseDesktop(hDesk);
		}
		else{
			PostMessage(hWnd, WM_CLOSE, 0, 0L);
		}
	}
}


/////////////////////////////////////////////////////////////////////

/*-------------------------------------
						m:23-Dec-1998
@p	<< fill memory >>
-------------------------------------*/
void	memfill(char *p, int len, char val)
{
	int a;

	for (a=0;a<len;a++){		//
		*p ++ = val;
	}
}

/*=====================================
						m:08-Mar-1999
@p	<< 媈帡抧恔敪惗 >>
=====================================*/
#if DEMO_SEQ
	void	SeqWrkInit()
	{
		int poi, sp;

⌨️ 快捷键说明

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