예제 #1
0
void CPrinterInfo::WriteSettings(void)
{
	WriteProfileInt(ENTRY_FastBitmaps, FastBitmaps(), GetDefaultFastBitmaps());
	WriteProfileInt(ENTRY_OutlineGammaValue, GetOutlineGamma(), DEFAULT_OUTLINE_GAMMA);
	WriteProfileInt(ENTRY_GammaValue, m_Record.m_nBitmapGamma, DEFAULT_BITMAP_GAMMA);
	WriteProfileInt(ENTRY_FastBitmapGammaValue, m_Record.m_nFastBitmapGamma, DEFAULT_FAST_BITMAP_GAMMA);
	WriteProfileInt(ENTRY_PostscriptType, GetPostScriptType(), m_nDefaultPostScriptType);
	WriteProfileInt(ENTRY_EnvelopePosition, GetEnvelopePosition(), GetDefaultEnvelopePosition());

	if (m_nOrientationType == PORTRAIT)
	{
		WriteProfileFixed(ENTRY_LeftMargin, GetLeftMargin(), m_PhysicalMargins.Left);
		WriteProfileFixed(ENTRY_TopMargin, GetTopMargin(), m_PhysicalMargins.Top);
		WriteProfileFixed(ENTRY_RightMargin, GetRightMargin(), m_PhysicalMargins.Right);
		WriteProfileFixed(ENTRY_BottomMargin, GetBottomMargin(), m_PhysicalMargins.Bottom);
		WriteProfileFixed(ENTRY_LeftOffset, GetLeftOffset(), MakeFixed(0));
		WriteProfileFixed(ENTRY_TopOffset, GetTopOffset(), MakeFixed(0));
	}
	else
	{
		WriteProfileFixed(ENTRY_LeftMarginLandscape, GetLeftMargin(), m_PhysicalMargins.Left);
		WriteProfileFixed(ENTRY_TopMarginLandscape, GetTopMargin(), m_PhysicalMargins.Top);
		WriteProfileFixed(ENTRY_RightMarginLandscape, GetRightMargin(), m_PhysicalMargins.Right);
		WriteProfileFixed(ENTRY_BottomMarginLandscape, GetBottomMargin(), m_PhysicalMargins.Bottom);
		WriteProfileFixed(ENTRY_LeftOffsetLandscape, GetLeftOffset(), MakeFixed(0));
		WriteProfileFixed(ENTRY_TopOffsetLandscape, GetTopOffset(), MakeFixed(0));
	}
	
	WriteProfileInt(ENTRY_UseReverseLandscape, ReverseLandscape(), GetDefaultReverseLandscape());
	WriteProfileInt(ENTRY_DoubleSidedType, GetDoubleSidedType(), 0);
	WriteProfileInt(ENTRY_PrintInstructions, GetPrintInstructions(), DEFAULT_PRINT_INSTRUCTIONS);
	WriteProfileInt(ENTRY_FlagPrintAsBitmap, GetPrintAsBitmap(), FALSE);
}
예제 #2
0
//----------------------------------------------------------------------------
// SaveProfileSettings is called by CDemoApp::InitInstance.
// It saves application settings
//----------------------------------------------------------------------------
void CippsDemoApp::SaveProfileSettings()
{
   CDemoApp::SaveProfileSettings();

   WriteProfileInt("View","ClrGraph",  CippsDemoView::GetColorSignal    ());
   WriteProfileInt("View","ClrGraphBk",CippsDemoView::GetColorSignalBack());
   WriteProfileInt("View","ClrAxis",   CippsDemoView::GetColorAxis      ());
   WriteProfileInt("View","ClrAxisBk", CippsDemoView::GetColorAxisBack  ());

   for (int i=0; i<16; i++)
      WriteProfileInt("View", CustomName(i),
         CColorDlg::GetCustomColor(i));
}
예제 #3
0
//
// Save MakMan/2 Options from INI files
//
VOID SaveOptionsToIni( VOID )
{
    int TileSet, Input, Sound, Priority;

    hini = PrfOpenProfile(habMain, "MAKMAN.INI");

    if (WinIsMenuItemChecked(hwndMenu, IDM_T_CLASSIC))
        TileSet = 0;
    else
       if (WinIsMenuItemChecked(hwndMenu, IDM_T_3D))
          TileSet = 1;
       else
            TileSet = 2;


    if (WinIsMenuItemChecked(hwndMenu, IDM_KEYBOARD))
        Input = 0;
    if (WinIsMenuItemChecked(hwndMenu, IDM_JOY_A))
        Input = 1;
    if (WinIsMenuItemChecked(hwndMenu, IDM_JOY_B))
        Input = 2;


    if (WinIsMenuItemChecked(hwndMenu, IDM_SOUND_ON))
        Sound = 1;
    else
        Sound = 0;

    if (WinIsMenuItemChecked(hwndMenu, IDM_PRI_NORMAL))
        Priority = 0;
    if (WinIsMenuItemChecked(hwndMenu, IDM_PRI_CRIT))
        Priority = 1;
    if (WinIsMenuItemChecked(hwndMenu, IDM_PRI_SERVER))
        Priority = 2;


    if (debOut)
    {
        fprintf(debOut, "TS : %i, Input %i, Sound %i, Prio %i\n", TileSet, Input, Sound, Priority);
        fflush(debOut);
    }

    WriteProfileInt ("Tile Set", TileSet);
    WriteProfileInt ("Input Source", Input);
    WriteProfileInt ("Sound Enabled", Sound);
    WriteProfileInt ("Priority", Priority);

    PrfCloseProfile(hini);
}
예제 #4
0
void CWordPadApp::SaveOptions()
{
	WriteProfileInt(szSection, szWordSel, m_bWordSel);
	WriteProfileInt(szSection, szUnits, GetUnits());
	WriteProfileInt(szSection, szMaximized, m_bMaximized);
	WriteProfileBinary(szSection, szFrameRect, (BYTE*)&m_rectInitialFrame,
		sizeof(CRect));
	WriteProfileBinary(szSection, szPageMargin, (BYTE*)&m_rectPageMargin,
		sizeof(CRect));
	m_optionsText.SaveOptions(szTextSection);
	m_optionsRTF.SaveOptions(szRTFSection);
	m_optionsWord.SaveOptions(szWordSection);
	m_optionsWrite.SaveOptions(szWriteSection);
	m_optionsIP.SaveOptions(szIPSection);
}
예제 #5
0
int CBCGPIE7DemoApp::ExitInstance() 
{
	BCGCBProCleanUp();

	WriteProfileInt (_T("Options"), _T("LargeIcons"), (int)m_bLargeIcons);

	return CWinApp::ExitInstance();
}
예제 #6
0
	BOOL InitInstance() {
		if (!__super::InitInstance()) {
			return FALSE;
		}

		_WIDTH = GetProfileInt(_T("SubtitleSource"), _T("w"), 640);
		_HEIGHT = GetProfileInt(_T("SubtitleSource"), _T("h"), 480);
		_ATPF = GetProfileInt(_T("SubtitleSource"), _T("atpf"), 400000);
		if (_ATPF <= 0) {
			_ATPF = 400000;
		}
		WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
		WriteProfileInt(_T("SubtitleSource"), _T("h"), _HEIGHT);
		WriteProfileInt(_T("SubtitleSource"), _T("atpf"), _ATPF);

		return TRUE;
	}
예제 #7
0
void CWinApp::SaveStdProfileSettings()
/************************************/
{
    if( m_pRecentFileList != NULL ) {
        m_pRecentFileList->WriteList();
    }
    if( m_nNumPreviewPages != 0 ) {
        WriteProfileInt( _PreviewSection, _PreviewEntry, m_nNumPreviewPages );
    }
}
void CGrannyViewerApp::SaveConfig()
{
	WriteProfileInt("log", "level", pDebug.GetLoglevel());

	WriteProfileInt("log", "textchunk", nConfig::logTextChunk);
	WriteProfileInt("log", "mesh", nConfig::logMesh);
	WriteProfileInt("log", "object", nConfig::logObject);
	WriteProfileInt("log", "objptr", nConfig::logObjPtr);
	WriteProfileInt("log", "bone", nConfig::logBone);
	WriteProfileInt("log", "boneobj", nConfig::logBoneObj);
	WriteProfileInt("log", "boneanim", nConfig::logBoneAnim);
}
예제 #9
0
BOOL CPrinterInfo::WriteProfileInt(LPCSTR pEntry, UINT wValue, UINT wDefault)
{
	if (wValue == wDefault)
	{
		return RemoveEntry(pEntry);
	}
	else
	{
	/* Unconditional write. */
		return WriteProfileInt(pEntry, wValue);
	}
}
예제 #10
0
void CRegistry::SaveMediaTransferParam(TransferParam &tp, CString pszKey) {
    CCrypto crypt;
    CString csPassword;
    if (Open(pszKey) == ERROR_SUCCESS) {
        WriteProfileInt(_T("Media Service"), tp.iService);   
        WriteProfileString(_T("Media Server"), tp.csServer);
        WriteProfileInt(_T("Media Port"), tp.nPort);   
        WriteProfileString(_T("Media Username"), tp.csUsername);
        WriteProfileInt(_T("Media SavePassword"), tp.bSavePassword);   
        if (tp.bSavePassword) {
            csPassword = crypt.Encode(tp.csPassword);
            WriteProfileString(_T("Media Password"), csPassword);
        } else {
            csPassword.Empty();
            WriteProfileString(_T("Media Password"), csPassword);
        }

        WriteProfileString(_T("Media Directory"), tp.csDirectory);
        WriteProfileString(_T("Media URL"), tp.csUrl);

        Close();
    }
}
예제 #11
0
void CRegistry::SaveChannelTransferParam(TransferParam tp, CString pszKey) {
    CCrypto crypt;
    CString csPassword;
    if (Create(pszKey) == ERROR_SUCCESS) {
        WriteProfileInt(_T("Channel Service"), tp.iService);   
        WriteProfileString(_T("Channel Server"), tp.csServer);
        WriteProfileInt(_T("Channel Port"), tp.nPort);   
        WriteProfileString(_T("Channel Username"), tp.csUsername);
        WriteProfileInt(_T("Channel SavePassword"), tp.bSavePassword);   
        if (tp.bSavePassword) {
            csPassword = crypt.Encode(tp.csPassword);
            WriteProfileString(_T("Channel Password"), csPassword);
        } else {
            csPassword.Empty();
            WriteProfileString(_T("Channel Password"), csPassword);
        }

        WriteProfileString(_T("Channel Directory"), tp.csDirectory);
        WriteProfileString(_T("Channel URL"), tp.csUrl);

        Close();
    }
}
예제 #12
0
void CRegistry::SaveTransferParam(TransferParam tp, CString pszKey) {
    CCrypto crypt;
    CString csPassword;
    if (Create(pszKey) == ERROR_SUCCESS) {
        //Uploader & Media
        WriteProfileInt(_T("Service"), tp.iService);   
        WriteProfileString(_T("Server"), tp.csServer);
        WriteProfileInt(_T("Port"), tp.nPort);   
        WriteProfileString(_T("Username"), tp.csUsername);
        WriteProfileInt(_T("SavePassword"), tp.bSavePassword);   
        if (tp.bSavePassword) {
            csPassword = crypt.Encode(tp.csPassword);
            WriteProfileString(_T("Password"), csPassword);
        } else {
            csPassword.Empty();
            WriteProfileString(_T("Password"), csPassword);
        }

        WriteProfileString(_T("Directory"), tp.csDirectory);

        Close();
    }
}
예제 #13
0
int SetProfileVal(BOOL iMode, LPCTSTR szApp, LPCTSTR szKey, INT iDefVal, LPCTSTR szRoot)
{
	// if iMode = TRUE, then write the given value
	// if       = FALSE, then read the from given key with default value
	int	iCtrl = 0;

	iCtrl = (szRoot[7]=='.');	// Control.ini

	if (iMode == TRUE) {		// Write the given value
		if (iCtrl) {
			WriteProfileInt(szApp, szKey, iDefVal, szRoot);
		}
	} else {					// Read the given value
		if (iCtrl) {
			iDefVal = GetPrivateProfileInt(szApp, szKey, iDefVal, szRoot);
		}
	}
	return iDefVal;
}
BOOL CXTPRegistryManager::WriteProfileDword(LPCTSTR lpszSection, LPCTSTR lpszEntry, DWORD* pValue)
{
	ASSERT(lpszSection != NULL);
	if (m_strINIFileName.IsEmpty())
	{
		CHKey hSecKey(GetSectionKey(lpszSection));
		if (hSecKey == NULL)
			return FALSE;

		m_lResult = ::RegSetValueEx(hSecKey, lpszEntry, NULL, REG_DWORD,
			(LPBYTE)pValue, sizeof(*pValue));

		if (m_lResult != ERROR_SUCCESS)
			return FALSE;

		return TRUE;
	}


	BOOL bResult = WriteProfileInt(lpszSection, lpszEntry, int(*pValue));
	return bResult;
}
예제 #15
0
BOOL CMyglApp::InitInstance()
{

#ifdef _KATMAI
	if (!KatmaiInit()) {
#if 0
		::MessageBox(NULL, "This version requires an Intel Pentium III processor \n Program will be terminated"  
			, _PROGRAM " System Message" , MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL | MB_TOPMOST);

		//AfxMessageBox("This version requires an Intel Katmai processor \n Program will be terminated ");
		return FALSE;
#endif

	}
#endif

 	/*
	// Initialize COM Library (for RSX)
	*/
	m_coResult = CoInitialize(NULL);

#ifdef _COM
	// Initialize the ATL Module
	_Module.Init(ObjectMap,m_hInstance);

#endif


	// 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.
	m_ChoosePixelFormat = 0;
	m_ActiveView = 0;


#ifndef _NSPLUGIN
	Enable3dControls();	// VC 2.0
#endif

	//SetDialogBkColor();	     // set dialog background color to gray
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)


	GReporter::SetCurrent(new GReporter);

    // make sure Gv VRML  database is init !!!
    GvDB::init();

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.
   
   CDocTemplate *pTemplate;

   AddDocTemplate(pTemplate=new CSingleDocTemplate(IDR_MAINFRAME,
			RUNTIME_CLASS(CMyglDoc),
			RUNTIME_CLASS(CMainFrame),     // main SDI frame window
			RUNTIME_CLASS(CMyglView)));

	// command line processing here
	{
	CString fileArg;
	
	// there is a utility function 
	if (m_lpCmdLine[0] != '\0')
	{
		char *p,*p1;

		p=m_lpCmdLine;
		while (*p) {

		 while (isspace(*p)) p++;
		 
		 if ((*p == '-') || (*p == '/')) { // Option start
		 p++;
		 switch (*p++) {
		 case 'X' :
		 case 'x' :
				m_ChoosePixelFormat = 1;
				break;
		 default :
			Reporter.Error("Unknown commandline option '%c' in %s",*p,m_lpCmdLine);
			break;
		 }
		}
		else {	// file argument
#if 0
			if (fileArg.GetLength()>0) {
				Reporter.Error("too many commandline arguments in %s",m_lpCmdLine);
 				while (!isspace(*p)) { if (!*p) break;p++;}
			}		 
		 	else while (!isspace(*p)) {
		   		if (!*p) break;
		   		fileArg += *p;
		   		p++;
		 	}
#else
			if (*p == '"') {
			    p++;
				while (*p != '"') {
		   			if (!*p) break;
		   			fileArg += *p;
		   			p++;
		 		}
				if (*p == '"') p++;
			    while (isspace(*p)) p++;
				break;
				// to do: rest of commandline
			}
			else 
			   fileArg = p;
			break;
#endif

			}
		
		}
	}

	if (fileArg.GetLength() > 0)
	 	OpenDocumentFile(fileArg);	// directly load a file
	else 
	  // create a new (empty) document
	  OnFileNew();
	}


	RegisterShellFileTypes();

	// register all extensions
	{
	CString strFilterExt,strFileTypeName; //strFileTypeId
	if (pTemplate->GetDocString(strFileTypeId,
	   CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty())
		{
			// enough info to register it
			if (!pTemplate->GetDocString(strFileTypeName,
			   CDocTemplate::regFileTypeName))
				strFileTypeName = strFileTypeId;    // use id name

	}

	} // for all extensions
	

	// enable file manager drag/drop and DDE Execute open
	m_pMainWnd->DragAcceptFiles();

	EnableShellOpen();
	// VC 2.0
	// The main window has been initialized, so show and update it.
	//pMainFrame->ShowWindow(m_nCmdShow);
	//pMainFrame->UpdateWindow();

#ifdef _EVALUATION
    // increment runcount 
    int runCount = GetProfileInt("GLView","RunCount",0);
    runCount++;
    WriteProfileInt("GLView","RunCount",runCount);
#endif

    int version = GetProfileInt("GLView","Version",0);
    if (version == 0 || version<_VERSION_INT) {
        version = _VERSION_INT;
        WriteProfileInt("GLView","Version",version);
// Date  WriteProfileInt("GLView","Version",version);
        // increment run-count
    }
	return TRUE;
}
예제 #16
0
int CReClass2015App::ExitInstance()
{
	if (m_hMDIMenu != NULL)	
		FreeResource(m_hMDIMenu);
	if (m_hMDIAccel != NULL)
		FreeResource(m_hMDIAccel);

	AfxOleTerm(FALSE);

	// Release Scintilla
	Scintilla_ReleaseResources();

	WriteProfileInt("Colors", "crBackground", crBackground);
	WriteProfileInt("Colors", "crSelect", crSelect);
	WriteProfileInt("Colors", "crHidden", crHidden);
	WriteProfileInt("Colors", "crOffset", crOffset);
	WriteProfileInt("Colors", "crAddress", crAddress);
	WriteProfileInt("Colors", "crType", crType);
	WriteProfileInt("Colors", "crName", crName);
	WriteProfileInt("Colors", "crIndex", crIndex);
	WriteProfileInt("Colors", "crValue", crValue);
	WriteProfileInt("Colors", "crComment", crComment);
	WriteProfileInt("Colors", "crVTable", crVTable);
	WriteProfileInt("Colors", "crFunction", crFunction);
	WriteProfileInt("Colors", "crChar", crChar);
	WriteProfileInt("Colors", "crCustom", crCustom);
	WriteProfileInt("Colors", "crHex", crHex);
	WriteProfileInt("Display", "gbOffset", gbOffset);
	WriteProfileInt("Display", "gbAddress", gbAddress);
	WriteProfileInt("Display", "gbText", gbText);
	WriteProfileInt("Display", "gbFloat", gbFloat);
	WriteProfileInt("Display", "gbInt", gbInt);
	WriteProfileInt("Display", "gbString", gbString);
	WriteProfileInt("Display", "gbPointers", gbPointers);
	WriteProfileInt("Display", "gbTop", gbTop);
	WriteProfileInt("Display", "gbClassBrowser", gbClassBrowser);
	WriteProfileInt("Display", "gbFilterProcesses", gbFilterProcesses);

	return CWinAppEx::ExitInstance();
}
예제 #17
0
파일: VNCHooks.cpp 프로젝트: tmbx/vnc
BOOL ExitInstance() 
{
	// Free the created atoms
	if (VNC_WINDOWPOS_ATOM != NULL)
	{
		GlobalDeleteAtom(VNC_WINDOWPOS_ATOM);
		VNC_WINDOWPOS_ATOM = NULL;
	}
	if (VNC_POPUPSELN_ATOM != NULL)
	{
		GlobalDeleteAtom(VNC_POPUPSELN_ATOM);
		VNC_POPUPSELN_ATOM = NULL;
	}

	// Write the module settings to disk
	if (sModulePrefs != NULL)
	{
		WriteProfileInt(
			"use_GetUpdateRect",
			prf_use_GetUpdateRect
			);

		WriteProfileInt(
			"use_Timer",
			prf_use_Timer
			);

		WriteProfileInt(
			"use_KeyPress",
			prf_use_KeyPress
			);

		WriteProfileInt(
			"use_LButtonUp",
			prf_use_LButtonUp
			);

		WriteProfileInt(
			"use_MButtonUp",
			prf_use_MButtonUp
			);

		WriteProfileInt(
			"use_RButtonUp",
			prf_use_RButtonUp
			);

		WriteProfileInt(
			"use_Deferral",
			prf_use_Deferral
			);

		free(sModulePrefs);
		sModulePrefs = NULL;
	}

	// Close the registry key for this module
	if (hModuleKey != NULL)
		RegCloseKey(hModuleKey);

	return TRUE;
}
예제 #18
0
BOOL ExitInstance() 
{
	// Free the created atoms
	if (VNC_POPUPSELN_ATOM != NULL)
	{
		// GlobalDeleteAtom(VNC_POPUPSELN_ATOM);
		VNC_POPUPSELN_ATOM = NULL;
	}

	// Write the module settings to disk
	if (sModulePrefs != NULL)
	{
	  // Get the module name
	  char proc_name[_MAX_PATH];
	  DWORD size;

	  // Attempt to get the program/module name
	  if ((size = GetModuleFileName(
		  GetModuleHandle(NULL),
		  (char *) &proc_name,
		  _MAX_PATH
		  )) == 0)
		  return FALSE;

	  // Get the key for the module
#ifdef _MSC_VER 
		_RPT0(_CRT_WARN, "vncHooks : locating user prefs\n");
#endif
	  hModuleKey = GetModuleKey(HKEY_CURRENT_USER, proc_name, true, true);
	  if (hModuleKey == NULL)
		  return FALSE;
#ifdef _MSC_VER 
		_RPT0(_CRT_WARN, "vncHooks : writing user prefs\n");
#endif

		WriteProfileInt(
			"use_GetUpdateRect",
			prf_use_GetUpdateRect
			);

		WriteProfileInt(
			"use_Timer",
			prf_use_Timer
			);

		WriteProfileInt(
			"use_KeyPress",
			prf_use_KeyPress
			);

		WriteProfileInt(
			"use_LButtonUp",
			prf_use_LButtonUp
			);

		WriteProfileInt(
			"use_MButtonUp",
			prf_use_MButtonUp
			);

		WriteProfileInt(
			"use_RButtonUp",
			prf_use_RButtonUp
			);

		WriteProfileInt(
			"use_Deferral",
			prf_use_Deferral
			);

		free(sModulePrefs);
		sModulePrefs = NULL;
	}

	// Close the registry key for this module
  if (hModuleKey != NULL) {
		RegCloseKey(hModuleKey);
    hModuleKey = NULL;
  }

	return TRUE;
}
예제 #19
0
파일: HMMDemo.cpp 프로젝트: JackJone/opencv
void CHMMDemoApp::SaveSettings()
{
    //****************Save Settings into registry)*************************************/
    CString states_string;
    
    //write number of states 
    states_string.Format("%d",  m_dlgHMMParams->m_States[0] );
    for( int i = 0 ; i < m_dlgHMMParams->m_States[0] ; i++ )
    {
        CString add;
        add.Format(" %d", m_dlgHMMParams->m_States[ i + 1 ] );
        states_string+= add;
    }
    //write number of HMM states
    WriteProfileString( "Settings\\HMM", "NumStates", states_string );
    
    //write number of mixtures
    WriteProfileInt("Settings\\HMM", "NumMix", m_dlgHMMParams->m_NumMix );
    
    //write sampling parameters (dctSize, obsSize, delta)
    WriteProfileInt("Settings\\Sampling", "WindowWidth" , m_dlgSamplingParams->m_dctSize.width );
    WriteProfileInt("Settings\\Sampling", "WindowHeight", m_dlgSamplingParams->m_dctSize.height );

    WriteProfileInt("Settings\\Sampling", "DCTCoeffX", m_dlgSamplingParams->m_obsSize.width );
    WriteProfileInt("Settings\\Sampling", "DCTCoeffY", m_dlgSamplingParams->m_obsSize.height );

    WriteProfileInt("Settings\\Sampling", "DeltaX", m_dlgSamplingParams->m_delta.width );
    WriteProfileInt("Settings\\Sampling", "DeltaY", m_dlgSamplingParams->m_delta.height );
    //*******************************End saving Settings *************************************/

    //write scaling params
    WriteProfileInt("Settings\\Scaling", "UseFixedWidth" , m_dlgMiscParams->m_useWidth );
    WriteProfileInt("Settings\\Scaling", "FixedWidth", m_dlgMiscParams->m_FixedWidth );

    WriteProfileInt("Settings\\Scaling", "UseFixedHeight", m_dlgMiscParams->m_useHeight);
    WriteProfileInt("Settings\\Scaling", "FixedHeight", m_dlgMiscParams->m_FixedHeight );

    WriteProfileInt("Settings\\Scaling", "SuppressIntensity", m_dlgMiscParams->m_SuppressIntensity );

}
예제 #20
0
/*func*------------------------------------------------------------------------
  description:
  in :
  out:
-----------------------------------------------------------------------------*/
BOOL CGrEditorApp::InitInstance()
{
	HRESULT hr;
	HFONT hFont;
	LOGFONT logFont;
	CGdiObject *pGdiObject;
	USES_CONVERSION;

   // Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_GR_OLE_INIT_FAILED);
		return FALSE;
	}
	hr = ::CoInitializeSecurity (NULL, -1, NULL, NULL,
	                             RPC_C_AUTHN_LEVEL_NONE, 
	                             RPC_C_IMP_LEVEL_IMPERSONATE, 
	                             NULL, EOAC_NONE, NULL);
	assert (SUCCEEDED (hr));    

   // prevent the Server-Busy dialog
   COleMessageFilter *pFilter = AfxOleGetMessageFilter();
   assert (pFilter);
   if (pFilter != NULL)
   {
      pFilter->EnableNotRespondingDialog(FALSE);
      pFilter->EnableBusyDialog(FALSE);
   }

	AfxEnableControlContainer();

	// 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.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	_Module.Init (ObjectMap, m_hInstance);

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.

	SetRegistryKey (_T ("Softing\\4CONTROLV2\\4CONTROL Engineering"));

   int     iValue;
   CString strKey, strSec;
   strSec.LoadString(IDS_GR_REG_SECTION);

   strKey.LoadString(IDS_GR_REG_RUBBLINE);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 0);
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );   // set Line draw mode to rubberlines

   strKey.LoadString(IDS_GR_REG_RUBB_RECON);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 1);
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );   // set Line draw mode to rubberlines

   strKey.LoadString(IDS_GR_REG_ZOOMVALUE);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 100);
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );   // set zoom factor for 4gr

   // default sizes for element insertion
   strKey.LoadString(IDS_GR_REG_STEPSIZE);
	iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, (4<<16)+4); // <0: AutoSize:on; HiWord:X; LoWord:Y
          WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue );

    // ST actions we yes the STEditor settings ..
	WriteProfileInt    (_T ("ST"), _T ("Case"           ), 0                    );   // keywords are case insensitive
	WriteProfileInt    (_T ("ST"), _T ("Chroma"         ), 1                    );   // coloring enabled
	WriteProfileString (_T ("ST"), _T ("Background"     ), _T ("255,255,255"   ));   // background color white
	WriteProfileString (_T ("ST"), _T ("Default Text"   ), _T ("0,0,0"         ));   // text color black
	WriteProfileString (_T ("ST"), _T ("Quote"          ), _T ("128,128,128"   ));   // string color grey
	WriteProfileString (_T ("ST"), _T ("Comment"        ), _T ("0,128,0"       ));   // comment color red
	WriteProfileString (_T ("ST"), _T ("Comment Start 1"), _T ("(*"            ));   // comments start with (*
	WriteProfileString (_T ("ST"), _T ("Comment End 1"  ), _T ("*)"            ));   // comments end with *)
	WriteProfileInt    (_T ("ST"), _T ("Keep Tabs"      ), 0                    );   // tabs are not converted to spaces
	WriteProfileInt    (_T ("ST"), _T ("Show Tabs"      ), 0                    );   // tabs are not visualized
	WriteProfileInt    (_T ("ST"), _T ("Tab Size"       ), 4                    );   // tab is as wide as 4 spaces
	WriteProfileString (_T ("ST"), _T ("Keywords"       ), _T ("stkeywords.ini"));   //

	// sizeof (LOGFONT) gives you the maximum size of a LOGFONT structure.
	// CGdiObject::GetObject possibly returns less because the font name
	// at the end of the LOGFONT structure may not take the whole space
	// reserved for it.
	hFont = (HFONT)GetStockObject (ANSI_FIXED_FONT);
	pGdiObject = CGdiObject::FromHandle (hFont);
	if (pGdiObject != NULL && pGdiObject->GetObject (sizeof (LOGFONT), &logFont) != 0)
	{
		int iFontSize;
		CWindowDC dc (m_pMainWnd);

		WriteProfileString (_T ("ST"), _T ("Font Name"), A2T (logFont.lfFaceName));
		iFontSize = MulDiv (logFont.lfHeight, 72, dc.GetDeviceCaps (LOGPIXELSY));
		WriteProfileInt (_T ("ST"), _T ("Font Size"), iFontSize);
		WriteProfileInt (_T ("ST"), _T ("Font Weight"), logFont.lfWeight);
		WriteProfileInt (_T ("ST"), _T ("Font Italic"), logFont.lfItalic);
		WriteProfileInt (_T ("ST"), _T ("CharSet"), logFont.lfCharSet);
	};

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	m_pDocTemplate = new CMultiDocTemplate(
		IDR_GR_TYPE,
		RUNTIME_CLASS(CGrEditorDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CGrEditorView));
	m_pDocTemplate->SetServerInfo(
		IDR_GR_TYPE_SRVR_EMB, IDR_GR_TYPE_SRVR_IP,
		RUNTIME_CLASS(CInPlaceFrame));
	AddDocTemplate(m_pDocTemplate);

	// Connect the COleTemplateServer to the document template.
	//  The COleTemplateServer creates new documents on behalf
	//  of requesting OLE containers by using information
	//  specified in the document template.
	m_server.ConnectTemplate(clsid, m_pDocTemplate, FALSE);

	// Register all OLE server factories as running.  This enables the
	//  OLE libraries to create objects from other applications.
	COleTemplateServer::RegisterAll();
		// Note: MDI applications register all server objects without regard
		//  to the /Embedding or /Automation on the command line.

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_GR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

   // create a dummy image .. to solve the problem with DeleteTempMap in OnIdle
   m_pDummyImage = new CImageList();
   VERIFY (m_pDummyImage->Create (16, 15, TRUE, 0, 1));      
   CBitmap bm;
   bm.LoadBitmap (IDR_GR_MAINFRAME);
   m_pDummyImage->Add (&bm, RGB (192, 192, 192));

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CSTCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Check to see if launched as OLE server
	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// Application was run with /Embedding or /Automation.  Don't show the
		//  main window in this case.
		return TRUE;
	}

	// When a server application is launched stand-alone, it is a good idea
	//  to update the system registry in case it has been damaged.
	m_server.UpdateRegistry(OAT_DOC_OBJECT_SERVER);
	COleObjectFactory::UpdateRegistryAll();

	if (cmdInfo.m_bRegServer)
	{
		TCHAR szModule[_MAX_PATH+10];
		LPOLESTR pszModule;
		HRESULT hr;
		LPTYPELIB pTypeLib;
		USES_CONVERSION;

		::GetModuleFileName (m_hInstance, szModule, _MAX_PATH);
		pszModule = T2OLE (szModule);
		hr = LoadTypeLib (pszModule, &pTypeLib);
		if (SUCCEEDED (hr))
		{
			hr = RegisterTypeLib (pTypeLib, pszModule, NULL);
			pTypeLib->Release ();
		};

		return (FALSE);
	};

   // Prevents ProcessShellCommand from displaying
   // a message box when unregistering.
   if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
   {
      cmdInfo.m_bRunEmbedded = true;
   };
	
   // Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

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

	return TRUE;
}
예제 #21
0
BOOL COthelloApp::InitInstance()
{
	AfxEnableControlContainer();

	// 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.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
	
#ifndef	_AS_GREEN_SOFTWARE
	HKEY hkey;
	char* szSubKey="Software\\Setalligence\\Othello";
	DWORD dwDisposition = REG_OPENED_EXISTING_KEY;
#endif

	//MessageBox(NULL, , "", MB_OK);////GetCommandLine()
//	char* cmdBuf = GetCommandLine();
	char* lpCmd = new char[strlen(m_pszHelpFilePath)];
	strcpy(lpCmd, m_pszHelpFilePath);
	char* lpEnd = lpCmd + strlen(m_pszHelpFilePath);
	*(--lpEnd) = 'I';
	*(--lpEnd) = 'N';
	*(--lpEnd) = 'I';
	m_pszProfileName=_tcsdup(lpCmd);

	//MessageBox(NULL, m_pszHelpFilePath, "", MB_OK);

	DWORD Keep=0;
	BOOL LocSound;
	BOOL ShowHint;
	BOOL WBBW;
	BOOL TopMost;
	BOOL Showdata;
	BOOL Animation;
	BOOL UseBook;
	int TimeLimit;
	int PlayerType[2];

#ifdef	_AS_GREEN_SOFTWARE
	BOOL lRet;
	LocSound  = GetProfileInt("UIOption", "LocSound", 1);
	ShowHint  = GetProfileInt("UIOption", "ShowHint", 1);
	WBBW      = GetProfileInt("UIOption","FormalArrangement",1);
	Animation = GetProfileInt("UIOption", "Animation", 0);
	TopMost   = GetProfileInt("UIOption", "TopMost", 0);
	Showdata  = GetProfileInt("UIOption", "ShowData", 1);
	UseBook   = GetProfileInt("Algorithm", "UseBook", 0);
	PlayerType[0] = GetProfileInt("Algorithm", "PlayerBlack", 0);
	PlayerType[1] = GetProfileInt("Algorithm", "PlayerWhite", 0);
	TimeLimit = GetProfileInt("Algorithm", "TimeLimit", 0);
	Keep=1;
#else
	LONG lret= RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey, 0, NULL, 
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition);
	
	if(lret==ERROR_SUCCESS){
		DWORD dwType, dwLength;
		BYTE bContent[10];
		LONG lRet;
		lRet =RegQueryValueEx(hkey, "LocSound", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			LocSound=*(reinterpret_cast<bool*>(bContent));
			Keep|=1;
		}
		lRet =RegQueryValueEx(hkey, "ShowHint", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			ShowHint=*(reinterpret_cast<bool*>(bContent));
			Keep|=2;
		}
		lRet =RegQueryValueEx(hkey, "WBBW", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			WBBW=*(reinterpret_cast<bool*>(bContent));
			Keep|=4;
		}
		lRet =RegQueryValueEx(hkey, "TopMost", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			TopMost=*(reinterpret_cast<bool*>(bContent));
			Keep|=8;
		}
		dwType=REG_BINARY;
		lRet =RegQueryValueEx(hkey, "Player", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			PlayerType[1]=(int)*(reinterpret_cast<short*>(bContent));
			PlayerType[0]=(int)*(reinterpret_cast<short*>(bContent+sizeof(short)));
			Keep|=16;
		}
		lRet =RegQueryValueEx(hkey, "UseBook", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			UseBook=*(reinterpret_cast<bool*>(bContent));
			Keep|=32;
		}	
		lRet =RegQueryValueEx(hkey, "ShowData", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			Showdata=*(reinterpret_cast<bool*>(bContent));
			Keep|=32;
		}
		lRet =RegQueryValueEx(hkey, "Animation", 0, &dwType, bContent, &dwLength);
		if(lRet==ERROR_SUCCESS){
			Animation=*(reinterpret_cast<bool*>(bContent));
			Keep|=32;
		}
		
		RegCloseKey(hkey);
	}
#endif
	COthelloDlg dlg;
	m_pMainWnd = &dlg;
	if(Keep){
		dlg.m_Keep = true;
		dlg.m_LocSound =!LocSound;
		dlg.m_ShowHint =!ShowHint;
		dlg.m_WBBW = (WBBW!=FALSE);
		dlg.m_TopMost=!TopMost;
		dlg.m_PlayerType[0]=PlayerType[0];
		dlg.m_PlayerType[1]=PlayerType[1];
		dlg.m_UseBook=!UseBook;
		dlg.m_ShowData=!Showdata;
		dlg.m_bAnimation=!Animation;
		 dlg.m_TimeLimit= TimeLimit;
	}else
		dlg.m_Keep = false;

	int nResponse = dlg.DoModal();
	
	Keep=dlg.m_Keep;
	if(!Keep){
		LocSound		= dlg.m_LocSound;
		ShowHint		= dlg.m_ShowHint;
		WBBW			= dlg.m_WBBW;
		TopMost			= dlg.m_TopMost;
		PlayerType[0]	= dlg.m_PlayerType[0];
		PlayerType[1]	= dlg.m_PlayerType[1];
		UseBook			= dlg.m_UseBook;
		Animation		= dlg.m_bAnimation;
		TimeLimit		= dlg.m_TimeLimit;
#ifdef	_AS_GREEN_SOFTWARE
		lRet =  WriteProfileInt("UIOption", "LocSound", LocSound);
		lRet &= WriteProfileInt("UIOption", "ShowHint", ShowHint);
		lRet &= WriteProfileInt("UIOption", "FormalArrangement", WBBW);
		lRet &= WriteProfileInt("UIOption", "Animation", Animation);
		lRet &= WriteProfileInt("UIOption", "TopMost", TopMost);
		lRet &= WriteProfileInt("UIOption", "ShowData", Showdata);
		lRet &= WriteProfileInt("Algorithm", "UseBook", UseBook);
		lRet &= WriteProfileInt("Algorithm", "PlayerBlack", PlayerType[0]);
		lRet &= WriteProfileInt("Algorithm", "PlayerWhite", PlayerType[1]);
		lRet &= WriteProfileInt("Algorithm", "TimeLimit", TimeLimit);

#else
		lret= RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey, 0, NULL, 
			REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition);
		if(lret==ERROR_SUCCESS){
			Keep = (PlayerType[0]<<16)| PlayerType[1];
			RegSetValueEx(hkey, "LocSound", 0, REG_DWORD, (BYTE*)&LocSound, sizeof(BOOL));
			RegSetValueEx(hkey, "ShowHint", 0, REG_DWORD, (BYTE*)&ShowHint, sizeof(BOOL));
			RegSetValueEx(hkey, "WBBW",     0, REG_DWORD, (BYTE*)&WBBW, sizeof(BOOL));
			RegSetValueEx(hkey, "TopMost",  0, REG_DWORD, (BYTE*)&TopMost, sizeof(BOOL));
			RegSetValueEx(hkey, "Player",   0, REG_DWORD, (BYTE*)&Keep, sizeof(DWORD));
			RegSetValueEx(hkey, "UseBook",  0, REG_DWORD, (BYTE*)&UseBook, sizeof(DWORD));	
			RegSetValueEx(hkey, "ShowData",  0, REG_DWORD, (BYTE*)&Showdata, sizeof(DWORD));	
			RegSetValueEx(hkey, "Animation",  0, REG_DWORD, (BYTE*)&Animation, sizeof(DWORD));	
		}
#endif
	}
	if (nResponse == IDOK)
	{

	}
	else if (nResponse == IDCANCEL)
	{

	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
예제 #22
0
파일: T42.cpp 프로젝트: Anonymousvn/T42
void CT42App::SaveSettings()
{
	WriteProfileInt("Settings","AwayOnScreenSaver",m_bAwayOnScreenSaver);

	Klever::SaveStringList(m_t42Callees,"T42HotList");
	Klever::SaveStringList(m_t42Callers,"T42Callers");
	WriteProfileInt("T42Window","AutosaveLayout",m_bt42AutosaveLayout);
	WriteProfileInt("Settings","T42MaxCallers",m_maxT42Callers);
	WriteProfileInt("Settings","T42MaxCallees",m_maxT42Callees);
	WriteProfileString("Settings","T42CallsLog",m_t42CallsFile);
	WriteProfileInt("Settings","T42TalkPort",m_T42TalkPort);

	WriteProfileString("Sounds","T42Bell",m_sndT42Bell);
	WriteProfileString("Sounds","T42Prompt",m_sndT42Prompt);
	WriteProfileInt("Sounds","T42PromptLoop",m_bT42PromptLoop);
	WriteProfileString("Sounds","T42Wake",m_sndT42Wake);

	Klever::WriteProfileString("Secretary","T42Greeting",m_T42SGreeting);
	WriteProfileInt("Secretary","T42BytesLimit",m_T42SBytesLimit);
	WriteProfileInt("Secretary","T42TimeLimit",m_T42STimeLimit.GetTotalSeconds());
	WriteProfileInt("Secretary","T42WinLimit",m_T42SWinLimit);

	WriteProfileInt("Fonts","T42LocalBG",m_crT42LocalBG);
	WriteProfileInt("Fonts","T42RemoteBG",m_crT42RemoteBG);
	WriteProfileBinary("Fonts","T42Local",(LPBYTE)&m_fmtT42Local,sizeof(m_fmtT42Local));
	WriteProfileBinary("Fonts","T42Remote",(LPBYTE)&m_fmtT42Remote,sizeof(m_fmtT42Remote));
	WriteProfileBinary("Fonts","T42System",(LPBYTE)&m_fmtT42System,sizeof(m_fmtT42System));

	FlushT42CallsLog();
}
예제 #23
0
void CGMapViewerApp::SaveConfig()
{
	CString csValue;

    WriteProfileString("Settings", "Ch1 Basefile Path", m_gvInfo.csBasePath[0]);
    WriteProfileString("Settings", "Ch2 Basefile Path", m_gvInfo.csBasePath[1]);
    WriteProfileString("Settings", "Ch3 Basefile Path", m_gvInfo.csBasePath[2]);
    WriteProfileString("Settings", "Ch4 Basefile Path", m_gvInfo.csBasePath[3]);

    WriteProfileInt("Settings", "Track Mode", m_gvInfo.nTrackMode);	
    WriteProfileInt("Settings", "Cursor1 Visable", m_gvInfo.bCursor1Visible?1:0);
    WriteProfileInt("Settings", "Cursor2 Visable", m_gvInfo.bCursor2Visible?1:0);
    WriteProfileInt("Settings", "Measure Graph Visable", m_gvInfo.bMeasureGraphVisible?1:0);
    WriteProfileInt("Settings", "Filtered Graph Visable", m_gvInfo.bFilterGraphVisible?1:0);
    WriteProfileInt("Settings", "Base Graph Visable", m_gvInfo.bBaseGraphVisible?1:0);
    WriteProfileInt("Settings", "Filtered Base Graph Visable", m_gvInfo.bBaseFilterGraphVisible?1:0);
    WriteProfileInt("Settings", "Difference Graph Visable", m_gvInfo.bDiffGraphVisible?1:0);

    WriteProfileInt("Settings", "Zoom Hold", m_gvInfo.bHoldZoom?1:0);
	WriteProfileInt("Settings", "Find Peak", m_gvInfo.bFindPeak?1:0);
	int nEventMode=0;
	switch(m_gvInfo.uEventMode)
	{
	case EVENT_OPEN:
		nEventMode = 0;
		break;
	case EVENT_SHORT:
		nEventMode = 1;
	    break;
	default:
		nEventMode = 4;
	}
	WriteProfileInt("Settings", "Event Mode", nEventMode);

	csValue.Format("%f", m_gvInfo.dMinX);
    WriteProfileString("Settings", "Zoom MinX", csValue);
	csValue.Format("%f", m_gvInfo.dMaxX);
    WriteProfileString("Settings", "Zoom MaxX", csValue);
	csValue.Format("%f", m_gvInfo.dMinY);
    WriteProfileString("Settings", "Zoom MinY", csValue);
	csValue.Format("%f", m_gvInfo.dMaxY);
    WriteProfileString("Settings", "Zoom MaxY", csValue);

    WriteProfileInt("Settings", "Use Basedata", m_gvInfo.bUseBase?1:0);

    WriteProfileInt("Settings", "ScanPos 5", m_gvInfo.nScanPos5);
    WriteProfileInt("Settings", "ScanPos 15", m_gvInfo.nScanPos15);
    WriteProfileInt("Settings", "ScanPos 45", m_gvInfo.nScanPos45);
    WriteProfileInt("Settings", "ScanPos 100", m_gvInfo.nScanPos100);
    WriteProfileInt("Settings", "ScanPos 200", m_gvInfo.nScanPos200);
    WriteProfileInt("Settings", "ScanPos 500", m_gvInfo.nScanPos500);
    WriteProfileInt("Settings", "ScanPos 1000", m_gvInfo.nScanPos1000);
    WriteProfileInt("Settings", "ScanPos 2000", m_gvInfo.nScanPos2000);
    WriteProfileInt("Settings", "ScanPos 5000", m_gvInfo.nScanPos5000);
    WriteProfileInt("Settings", "ScanPos 10000", m_gvInfo.nScanPos10000);

	WriteProfileString("Settings", "Last Access Directory", m_gvInfo.csLastAccessDir);

	/*-------------------------------------------------------------------------
	 *	Smoothing 적용횟수
	 *-----------------------------------------------------------------------*/
    WriteProfileInt("Settings", "Smoothing Repeat Count", m_gvInfo.nRepeatCnt);

	/*-------------------------------------------------------------------------
	 * 에러보정
	 *-----------------------------------------------------------------------*/
    WriteProfileInt("Settings", "Smoothing Error Correct", m_gvInfo.nSmoothErrCor);	
}
예제 #24
0
파일: wed.cpp 프로젝트: akavel/wed-editor
BOOL 	CWedApp::SaveAllModified()

{
	// Save reopen information:
	CString	buf;
	CPtrList il;
	int		row, col;

    // Save list of buffers
	if(!comline)
    	{
		int count = 0;
		POSITION Pos = pDocTemplate->GetFirstDocPosition();
		// Make a list, current edited buffer as last
		for(;;)
			{
			if(!Pos)
				break;
			CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos);
			POSITION pos = doc->GetFirstViewPosition();
			CView *cv = doc->GetNextView(pos); 	ASSERT_VALID(cv);
			if(cv != currentedit)
				il.AddTail(cv);
			}

	if(currentedit)
		il.AddTail(currentedit);

	POSITION pos = il.GetHeadPosition();
	for(;;)
		{
		if(!pos)
			break;
		CView *cv = (CView*)il.GetNext(pos);
		if(!cv)
			break;
		ASSERT_VALID(cv);

		CWedDoc* doc = (CWedDoc*)cv->GetDocument();
		if(!doc)
			break;
		ASSERT_VALID(doc);

		CString fline =doc->strlist.GetLine(0);

		// If it is a new doc
 		if(doc->strlist.GetCount() == 1 &&
			fline.GetLength() == 0)
			{
			//P2N("New doc: %d\r\n",  doc);
			}
		else
			{
			CString file = doc->GetPathName();
			row = ((CWedView*)cv)->row; col = ((CWedView*)cv)->col;
			buf.Format("%d", count + 1);

			WriteProfileString(strSection,  strStringItem + buf, file);
			WriteProfileInt(strSection,  strStringItem + buf + "row", row);
			WriteProfileInt(strSection,  strStringItem + buf + "col", col);
			count++;
			}
		}
	WriteProfileInt(strSection, strIntItem, count);
	}

	// Serialize holdings
	message ("Saving holdings");
	SaveHoldings();

	// Serialize macros
	message ("Saving macros");
	SaveMacros();

	// Save config information:
	CTime t = CTime::GetCurrentTime();
	WriteProfileInt(strConfig, "strLastUsage", (int)t.GetTime());
	WriteProfileInt(strConfig, "strUsage", use);

	// Save main frame window placement
	WINDOWPLACEMENT wp;
	pMainFrame->GetWindowPlacement(&wp);
	WriteProfileInt(strConfig, "WindowState",  wp.showCmd);
	// Save file informaion

	// Save current window focus:

	// Save font info
    LOGFONT lf; ff.GetObject(sizeof(LOGFONT), &lf);
	WriteProfileString(strConfig,  strFontName, lf.lfFaceName);
	WriteProfileInt(strConfig,  strFontSize, lf.lfHeight);
	WriteProfileInt(strConfig,  strFontWeight, lf.lfWeight);
	WriteProfileInt(strConfig,  strFontItalic, lf.lfItalic);

	// Save color info
	WriteProfileInt(strConfig,  strColorBg, 	bgcol);
	WriteProfileInt(strConfig,  strColorFg, 	fgcol);
	WriteProfileInt(strConfig,  strColorSel , 	selcol );
    WriteProfileInt(strConfig,  strColorCSel, 	cselcol);
    WriteProfileInt(strConfig,  strColorAdd , 	cadd   );
    WriteProfileInt(strConfig,  strColorDel , 	cdel   );
    WriteProfileInt(strConfig,  strColorChg , 	cchg   );
    WriteProfileInt(strConfig,  strColorComm, 	comm   );
    WriteProfileInt(strConfig,  strColorSrc , 	srcc   );
    WriteProfileInt(strConfig,  strColorLong , 	clng   );

	// Save backwrap
	WriteProfileInt(strConfig,  strBackWrap , backwrap);

	// Save tab2space
	WriteProfileInt(strConfig,  strTab2Space, Tab2Space);

	// Save tabstop
	WriteProfileInt(strConfig,  strTabStop, tabstop);




	return CWinApp::SaveAllModified();
}
예제 #25
0
//
// ~C[!output PROJECT_NAME]
//
C[!output PROJECT_NAME]::~C[!output PROJECT_NAME]() 
{
	// TODO: write parameters from profile
	WriteProfileInt("[!output PROJECT_NAME]", "param1", m_[!output PROJECT_NAME]Parameters.param1);
	WriteProfileInt("[!output PROJECT_NAME]", "param2", m_[!output PROJECT_NAME]Parameters.param2);
}
예제 #26
0
BOOL CETApplicationApp::InitInstance()
{
    // InitCommonControlsEx() is required on Windows XP if an application
    // manifest specifies use of ComCtl32.dll version 6 or later to enable
    // visual styles.  Otherwise, any window creation will fail.
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // Set this to include all the common control classes you want to use
    // in your application.
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);

    /*	SetRegistryKey(_T("EartronicIni"));

    	WriteProfileInt(_T("Lang"),_T("CHINESE"),0);
    	WriteProfileInt(_T("Lang"),_T("ENGLISH"),1);
    	WriteProfileInt(_T("Lang"),_T("GERMANY"),2);

    	int ret =0;
    	CString str;
    	ret = ::MessageBox(NULL,_T("Yes for English, No for Germany"),_T("Choose Version"),MB_YESNO);

    	str =  (ret == IDYES) ? _T("ENGLISH") :_T("GERMANY");

    	nLanguage = GetProfileInt(_T("Lang"),str,ENGLISH);
    	if(nLanguage != ENGLISH)
    	{
    		CString strFile;
    		strFile = _T("MultiLang.dll");
    		hResourceHandle =LoadLibrary(strFile); //AfxLoadLibrary(strFile);
    		ASSERT(hResourceHandle);
    		if(hResourceHandle)
    		{
    			AfxSetResourceHandle(hResourceHandle);
    		}
    	}
    */
    CWinAppEx::InitInstance();


    // Initialize OLE libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        return FALSE;
    }

    AfxEnableControlContainer();

    EnableTaskbarInteraction();


    // AfxInitRichEdit2() is required to use RichEdit control
    // AfxInitRichEdit2();

    // 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
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization
    //SetRegistryKey(_T("Local AppWizard-Generated Applications"));
    SetRegistryKey(_T("EartronicIni"));

    LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)

    WriteProfileInt(_T("Lang"),_T("CHINESE"),0);
    WriteProfileInt(_T("Lang"),_T("ENGLISH"),1);
    WriteProfileInt(_T("Lang"),_T("GERMANY"),2);

    if(GetProfileInt(_T("Audiomed"),_T("count down"),-1) == -1)   // -1 is can't find
    {
        WriteProfileInt(_T("Audiomed"),_T("count down"),45);
    }
    else
    {
        g_countDown = GetProfileInt(_T("Audiomed"),_T("count down"),0);
    }

    int ret =0;
    CString str;
    //	ret = ::MessageBox(NULL,_T("Yes for English, No for Germany"),_T("Choose Version"),MB_YESNO);

    //	str =  (ret == IDYES) ? _T("ENGLISH") :_T("GERMANY");
    //	str =  _T("GERMANY"); //_T("ENGLISH");
    //	nLanguage = GetProfileInt(_T("Lang"),str,ENGLISH);

    CString strFile;
    strFile = _T("MultiLang.dll");
    hResourceHandle =LoadLibrary(strFile); //AfxLoadLibrary(strFile);
    //	ASSERT(hResourceHandle);
    if(hResourceHandle)
    {
        AfxSetResourceHandle(hResourceHandle);
    }

    InitContextMenuManager();

    InitKeyboardManager();

    InitTooltipManager();
    CMFCToolTipInfo ttParams;
    ttParams.m_bVislManagerTheme = TRUE;
    theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
            RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

    // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views
    CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(IDR_ETApplicationTYPE,
                                         RUNTIME_CLASS(CETApplicationDoc),
                                         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
                                         RUNTIME_CLASS(CETApplicationView));
    if (!pDocTemplate)
        return FALSE;
    AddDocTemplate(pDocTemplate);

    // create main MDI Frame window
    CMainFrame* pMainFrame = new CMainFrame;
    if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
    {
        delete pMainFrame;
        return FALSE;
    }
    m_pMainWnd = pMainFrame;
    // call DragAcceptFiles only if there's a suffix
    //  In an MDI app, this should occur immediately after setting m_pMainWnd

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);



    // Dispatch commands specified on the command line.  Will return FALSE if
    // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;
    // The main window has been initialized, so show and update it
    pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
    pMainFrame->UpdateWindow();

    return TRUE;
}
// ************************************************************
// コマンドライン引数による振り分け
// (インストール/アンインストール/設定ダイアログ/削除実行)
// ************************************************************
BOOL CCompDelApp::ProcessCommandline()
{
	CString sAfxMsg;
	// ************************************************************
	// 初回の実行のみ、インストールダイアログを出現
	// ************************************************************
	if(!ChkHkcuInstReg())
	{	// インストールフラグが見つからない
		CDlgInstall dlgInst;
		// インストールダイアログの表示
		dlgInst.m_CONTEXT = FALSE;
		dlgInst.m_DESKTOP = TRUE;
		dlgInst.m_MENU = FALSE;
		dlgInst.m_UNIN = 1;

		if(dlgInst.DoModal() == IDOK)
		{
			::MkHkcuInstReg();		// インストールフラグの書き込み
			if(dlgInst.m_UNIN == 0)
			{	// レジストリのアンインストールメニューを作成
				if(IsWinNT()) ::MkHkcuUninstMnu();	// WinNT 系列のとき HKCU
				else  ::MkHklmUninstMnu();	// Win95 系列のとき HKLM
			}
			else
				::MkUninstMnu();		// スタートメニューにアンインストール・ショートカットを作成
			if(dlgInst.m_CONTEXT)
				::MkSendtoMnu();		// 送るメニューにショートカット作成
			if(dlgInst.m_DESKTOP)
				::MkDesktopMnu();		// デスクトップにショートカット作成
			if(dlgInst.m_MENU)
				::MkProgramsMnu();		// スタートメニューにショートカット作成
		}
		else return FALSE;	// インストール却下
	}

	// ************************************************************
	// 動作モードをレジストリより読み込む
	// ************************************************************
	MyFile.n_NDispN = GetProfileInt("Settings","NDispN",0);
	MyFile.n_NDispE = GetProfileInt("Settings","NDispE",0);
	MyFile.n_Dummy = GetProfileInt("Settings","Dummy",0);
	MyFile.n_DummySkip = GetProfileInt("Settings","DummySkip",1);
	MyFile.n_Date = GetProfileInt("Settings","Date",1);
	MyFile.n_rNull = GetProfileInt("Settings","rNull",1);
	MyFile.n_rZLen = GetProfileInt("Settings","rZLen",1);
	MyFile.n_rRen = GetProfileInt("Settings","rRen",1);
	MyFile.n_nOvwr = GetProfileInt("Settings","nOvwr",3);
	MyFile.n_nFiles = GetProfileInt("Settings","nFiles",40);
	MyFile.n_Confirm = GetProfileInt("Settings","Confirm",0);
	MyFile.n_DispF = GetProfileInt("Settings","DispF",1);
	MyFile.n_Log = GetProfileInt("Settings","Log",1);

	MyFile.b_AntiCache = GetProfileInt("Settings","AddWipe",0);
	MyFile.n_UntiFolder = GetProfileInt("Settings","rAntiFolder",0);
	MyFile.n_UnticacheSize = GetProfileInt("Settings","nAnticacheSize",20);
	MyFile.n_bAntiOneShot = GetProfileInt("Settings","bAntiOneShot",1);
	MyFile.n_BufferSize = GetProfileInt("Settings","m_nBufferSize",2048);
	MyFile.n_Overrun = GetProfileInt("Settings","m_nOverrun",0);
	MyFile.n_DodChar = GetProfileInt("Settings","m_nDodChar",(int)'A');

	MyFile.b_NotRemove = GetProfileInt("Settings","bNotDel",0);


	// ************************************************************
	// 設定ダイアログ表示。
	// ************************************************************
	if(!strlen(m_lpCmdLine))
	{	// コマンドライン引数なしのときは、設定ダイアログ
		// メインダイアログの表示
		sAfxMsg.LoadString(AFX_STR_MAINDLG);
		CPropertySheet dlg((LPCSTR)sAfxMsg);	// ダイアログのベース
		// プロパティーシート
		CDlgPDel dlgPDel;
		CDlgPDel2 dlgPDel2;
		CDlgPDel3 dlgPDel3;
		CDlgPDisp dlgPDisp;
		CDlgPOther dlgPOther;

		m_pMainWnd = &dlg;	// このダイアログをメインフレームとする
		dlgPDisp.m_NDispN = MyFile.n_NDispN;
		dlgPDisp.m_NDispE = MyFile.n_NDispE;
		dlgPDel3.m_bDummy = MyFile.n_Dummy;
		dlgPDel3.m_bDummySkip = MyFile.n_DummySkip;
		dlgPDel3.m_nFiles = MyFile.n_nFiles;
		dlgPDel.m_Date = MyFile.n_Date;
		dlgPDel.m_rNull = MyFile.n_rNull;
		dlgPDel.m_rZLen = MyFile.n_rZLen;
		dlgPDel.m_rRen = MyFile.n_rRen;
		dlgPDel.m_nOvwr = MyFile.n_nOvwr;
		dlgPDel3.m_AntiCache = MyFile.b_AntiCache;
		dlgPDel3.m_rAntiFolder = MyFile.n_UntiFolder;
		dlgPDel3.m_nAnticacheSize = MyFile.n_UnticacheSize;
		dlgPDel3.m_bAntiOneShot = MyFile.n_bAntiOneShot;
		dlgPDel2.m_nBufferSize = MyFile.n_BufferSize;
		dlgPDel2.m_nOverrun = MyFile.n_Overrun;
		dlgPDel2.m_nDodChar = MyFile.n_DodChar;
		dlgPDisp.m_Confirm = MyFile.n_Confirm;
		dlgPDisp.m_DispF = MyFile.n_DispF;
		dlgPDisp.m_Log = MyFile.n_Log;
		dlgPDel2.m_bNotRemove = MyFile.b_NotRemove;

		// プロパティーページの連結
		dlg.AddPage(&dlgPDel);
		dlg.AddPage(&dlgPDisp);
		dlg.AddPage(&dlgPDel2);
		dlg.AddPage(&dlgPDel3);
		dlg.AddPage(&dlgPOther);
		// プロパティーシートの属性変更
		dlg.m_psh.dwFlags=(dlg.m_psh.dwFlags|PSH_NOAPPLYNOW);// &(~PSH_HASHELP);
		if(dlg.DoModal() == IDOK)
		{
			if(dlgPDisp.m_NDispN != (int)GetProfileInt("Settings","NDispN",0))
				WriteProfileInt("Settings","NDispN",dlgPDisp.m_NDispN);	
			if(dlgPDisp.m_NDispE != (int)GetProfileInt("Settings","NDispE",0))
				WriteProfileInt("Settings","NDispE",dlgPDisp.m_NDispE);	
			if(dlgPDel3.m_bDummy != (int)GetProfileInt("Settings","Dummy",0))
				WriteProfileInt("Settings","Dummy",dlgPDel3.m_bDummy);	
			if(dlgPDel3.m_bDummySkip != (int)GetProfileInt("Settings","DummySkip",1))
				WriteProfileInt("Settings","DummySkip",dlgPDel3.m_bDummySkip);	
			if(dlgPDel3.m_nFiles != (int)GetProfileInt("Settings","nFiles",40))
				WriteProfileInt("Settings","nFiles",dlgPDel3.m_nFiles);	
			if(dlgPDel.m_Date != (int)GetProfileInt("Settings","Date",1))
				WriteProfileInt("Settings","Date",dlgPDel.m_Date);	
			if(dlgPDel.m_rNull != (int)GetProfileInt("Settings","rNull",1))
				WriteProfileInt("Settings","rNull",dlgPDel.m_rNull);
			if(dlgPDel.m_rZLen != (int)GetProfileInt("Settings","rZLen",1))
				WriteProfileInt("Settings","rZLen",dlgPDel.m_rZLen);
			if(dlgPDel.m_rRen != (int)GetProfileInt("Settings","rRen",1))
				WriteProfileInt("Settings","rRen",dlgPDel.m_rRen);
			if(dlgPDel.m_nOvwr != (int)GetProfileInt("Settings","nOvwr",3))
				WriteProfileInt("Settings","nOvwr",dlgPDel.m_nOvwr);
			if(dlgPDel3.m_AntiCache != (int)GetProfileInt("Settings","AddWipe",0))
				WriteProfileInt("Settings","AddWipe",dlgPDel3.m_AntiCache);
			if(dlgPDel3.m_rAntiFolder != (int)GetProfileInt("Settings","rAntiFolder",0))
				WriteProfileInt("Settings","rAntiFolder",dlgPDel3.m_rAntiFolder);
			if(dlgPDel3.m_nAnticacheSize != (int)GetProfileInt("Settings","nAnticacheSize",20))
				WriteProfileInt("Settings","nAnticacheSize",dlgPDel3.m_nAnticacheSize);
			if(dlgPDel3.m_bAntiOneShot != (int)GetProfileInt("Settings","bAntiOneShot",1))
				WriteProfileInt("Settings","bAntiOneShot",dlgPDel3.m_bAntiOneShot);
			if(dlgPDel2.m_nOverrun != (int)GetProfileInt("Settings","m_nOverrun",1024))
				WriteProfileInt("Settings","m_nOverrun",dlgPDel2.m_nOverrun);
			if(dlgPDel2.m_nDodChar != GetProfileInt("Settings","m_nDodChar",(int)'A'))
				WriteProfileInt("Settings","m_nDodChar",dlgPDel2.m_nDodChar);
			if(dlgPDel2.m_nBufferSize != (int)GetProfileInt("Settings","m_nBufferSize",2048))
				WriteProfileInt("Settings","m_nBufferSize",dlgPDel2.m_nBufferSize);
			if(dlgPDisp.m_Confirm != (int)GetProfileInt("Settings","Confirm",0))
				WriteProfileInt("Settings","Confirm",dlgPDisp.m_Confirm);
			if(dlgPDisp.m_DispF != (int)GetProfileInt("Settings","DispF",1))
				WriteProfileInt("Settings","DispF",dlgPDisp.m_DispF);
			if(dlgPDisp.m_Log != (int)GetProfileInt("Settings","Log",1))
				WriteProfileInt("Settings","Log",dlgPDisp.m_Log);
			if(dlgPDel2.m_bNotRemove != (int)GetProfileInt("Settings","bNotDel",0))
				WriteProfileInt("Settings","bNotDel",dlgPDel2.m_bNotRemove);

		}
	}
	// ************************************************************
	// アンインストール
	// ************************************************************
	else if(!strcmp(m_lpCmdLine, "/delete"))
	{	// アンインストール
		sAfxMsg.LoadString(AFX_STR_UNIN_CONFERM);
		if(::MessageBox(NULL, (LPCSTR)sAfxMsg, "CompleteDelete Uninstaller", MB_YESNO|MB_ICONQUESTION) != IDYES)
			return FALSE;
		::RmUserReg();			// ユーザ領域のレジストリデータの削除
		::RmHkcuInstReg();		// HKCU の インストールフラグの削除
		::RmUninstMnu();		// スタートメニューのアンインストール・ショートカットを削除
		::RmHkcuUninstMnu();	// レジストリのアンインストールメニューを削除 HKCU
		::RmHklmUninstMnu();	// レジストリのアンインストールメニューを削除 HKLM
		::RmDesktopMnu();		// デスクトップを削除
		::RmProgramsMnu();		// スタートメニューを削除
		::RmSendtoMnu();		// 送るメニューを削除
	}
	// ************************************************************
	// ファイルの削除 メインプログラムの実行
	// ************************************************************
	else
	{

		// ログ用CStringポインタの引渡し
		sLogStr = "";
		MyFile.sLogStr = &sLogStr;
		// 削除メインルーチン
		MyFile.DeleteMain(m_lpCmdLine);

		// ログの表示
		if(MyFile.n_Log)
		{
			CDlgHelpDoc dlgHelp;
			dlgHelp.m_edit_main = sLogStr;
			dlgHelp.DoModal();
		}
	}
	return TRUE;
}
예제 #28
0
파일: SageApp.cpp 프로젝트: AlexS2172/IVRM
void CSageApp::PersistWindowPlacement(CWnd*  pWnd, LPCTSTR RelativePath, BOOL bDirection)
    // bDirection TRUE for Save, FALSE for Load
{
    ASSERT_VALID(pWnd);
    ASSERT_KINDOF(CWnd, pWnd);

    if (!pWnd || !::IsWindow(pWnd->m_hWnd) || !RelativePath )
        return;

    WINDOWPLACEMENT     wndpl = {0};
    wndpl.length = sizeof(WINDOWPLACEMENT);

    if (bDirection)
    {
        if (GetWindowPlacement(pWnd->m_hWnd, &wndpl))
        {
        	WriteProfileInt(RelativePath, _T("Flags"), wndpl.flags);
        	WriteProfileInt(RelativePath, _T("MaxPositionX"), wndpl.ptMaxPosition.x);
        	WriteProfileInt(RelativePath, _T("MaxPositionY"), wndpl.ptMaxPosition.y);
        	WriteProfileInt(RelativePath, _T("MinPositionX"), wndpl.ptMinPosition.x);
        	WriteProfileInt(RelativePath, _T("MinPositionY"), wndpl.ptMinPosition.y);
        	WriteProfileInt(RelativePath, _T("NormalPositionLeft"), wndpl.rcNormalPosition.left);
        	WriteProfileInt(RelativePath, _T("NormalPositionTop"), wndpl.rcNormalPosition.top);
        	WriteProfileInt(RelativePath, _T("NormalPositionRight"), wndpl.rcNormalPosition.right);
        	WriteProfileInt(RelativePath, _T("NormalPositionBottom"), wndpl.rcNormalPosition.bottom);
        	WriteProfileInt(RelativePath, _T("ShowCmd"), wndpl.showCmd);
        }
    }
    else
    {
       	wndpl.ptMaxPosition.x = GetProfileInt(RelativePath, _T("MaxPositionX"), 0xffff);
       	wndpl.ptMaxPosition.y = GetProfileInt(RelativePath, _T("MaxPositionY"), 0xffff);
       	wndpl.ptMinPosition.x = GetProfileInt(RelativePath, _T("MinPositionX"), 0xffff);
       	wndpl.ptMinPosition.y = GetProfileInt(RelativePath, _T("MinPositionY"), 0xffff);

        if ((wndpl.flags = GetProfileInt(RelativePath, _T("Flags"), 0xffff)) == 0xffff ||
        	(wndpl.rcNormalPosition.left = GetProfileInt(RelativePath, _T("NormalPositionLeft"), 0xffff)) == 0xffff ||
        	(wndpl.rcNormalPosition.top = GetProfileInt(RelativePath, _T("NormalPositionTop"), 0xffff)) == 0xffff ||
        	(wndpl.rcNormalPosition.right = GetProfileInt(RelativePath, _T("NormalPositionRight"), 0xffff)) == 0xffff ||
        	(wndpl.rcNormalPosition.bottom = GetProfileInt(RelativePath, _T("NormalPositionBottom"), 0xffff)) == 0xffff ||
        	(wndpl.showCmd = GetProfileInt(RelativePath, _T("ShowCmd"), 0xffff)) == 0xffff)
        {
           	wndpl.ptMaxPosition.x = GetProfileInt(RelativePath, _T("MaxPositionX"), 0xffff);
           	wndpl.ptMaxPosition.y = GetProfileInt(RelativePath, _T("MaxPositionY"), 0xffff);
       	    wndpl.ptMinPosition.x = GetProfileInt(RelativePath, _T("MinPositionX"), 0xffff);
       	    wndpl.ptMinPosition.y = GetProfileInt(RelativePath, _T("MinPositionY"), 0xffff);

            if ((wndpl.flags = GetProfileInt(RelativePath, _T("Flags"), 0xffff)) == 0xffff ||
            	(wndpl.rcNormalPosition.left = GetProfileInt(RelativePath, _T("NormalPositionLeft"), 0xffff)) == 0xffff ||
        	    (wndpl.rcNormalPosition.top = GetProfileInt(RelativePath, _T("NormalPositionTop"), 0xffff)) == 0xffff ||
            	(wndpl.rcNormalPosition.right = GetProfileInt(RelativePath, _T("NormalPositionRight"), 0xffff)) == 0xffff ||
            	(wndpl.rcNormalPosition.bottom = GetProfileInt(RelativePath, _T("NormalPositionBottom"), 0xffff)) == 0xffff ||
            	(wndpl.showCmd = GetProfileInt(RelativePath, _T("ShowCmd"), 0xffff)) == 0xffff)
            {
        	    pWnd->ShowWindow(SW_SHOW);
                return;
            }
        }

        SetWindowPlacement(pWnd->m_hWnd, &wndpl);
    }
}
예제 #29
0
BOOL CBCGPGanttDemoApp::WriteSectionInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue )
{
    return WriteProfileInt(lpszSection, lpszEntry, nValue);
}
예제 #30
0
void CPrinterInfo::GetDeviceInfo(HGLOBAL hDevMode, HDC in_hDC)
{
	// Ignore the incoming DC since we may not be able to change it via ResetDC.
	in_hDC = NULL;
/*
// I don't trust these printer drivers.
// I know for sure that some drivers are bad; there may be more than what
// I know (from another program).
// We will use an INI file mechanism to try and detect and skip over the
// bad ones. Unfortunately, this assumes that a bad one will cause a GP
// fault...
*/
	if (!GetProfileInt(ENTRY_BadDC, FALSE))
	{
	
		/*
		// We set the INI file setting now. If this fails for any reason
		// (particularly for a GP fault), then it will be set forever as "bad".
		*/
	
		WriteProfileInt(ENTRY_BadDC, TRUE);
	
#ifndef WIN32
		LPFNDEVCAPS DeviceCapabilities = NULL;
		CString csDriverName = m_csDriverName + ".DRV";
	
		UINT uSEM = ::SetErrorMode(SEM_NOOPENFILEERRORBOX);
		HINSTANCE hDriver = ::LoadLibrary((LPSTR)(LPCSTR)csDriverName);
		::SetErrorMode(uSEM);
	
		if ((UINT)hDriver >= 32)
		{
			DeviceCapabilities = (LPFNDEVCAPS)GetProcAddress(hDriver, "DeviceCapabilities");
		}
#endif

		if (DeviceCapabilities != NULL)
		{
		/*
		// Read the number of copies setting.
		*/
			m_Record.m_nCopies = (int)DeviceCapabilities((LPSTR)(LPCSTR)m_csPrinterName,
															 (LPSTR)(LPCSTR)m_csOutputName,
															 DC_COPIES,
															 NULL,
															 NULL);
			TRACE1("Supports %d copies\n", m_Record.m_nCopies);
	
		/*
		// Read the landscape orientation setting.
		*/
			m_Record.m_nOrientation = (int)DeviceCapabilities((LPSTR)(LPCSTR)m_csPrinterName,
																	(LPSTR)(LPCSTR)m_csOutputName,
																	(WORD)DC_ORIENTATION,
																	NULL,
																	NULL);
			TRACE1("Orientation is %d degrees\n", m_Record.m_nOrientation);
	
		/*
		// Read the number of bins.
		*/
			int nBins = (int)DeviceCapabilities((LPSTR)(LPCSTR)m_csPrinterName,
																	(LPSTR)(LPCSTR)m_csOutputName,
																	(WORD)DC_BINS,
																	NULL,
																	NULL);
			if (nBins > 0 && nBins < 32768/sizeof(WORD))
			{
			/* Read the bins. */
				WORD* pBins = new WORD[nBins];
				if (pBins != NULL)
				{
					DeviceCapabilities((LPSTR)(LPCSTR)m_csPrinterName,
								  (LPSTR)(LPCSTR)m_csOutputName,
								  (WORD)DC_BINS,
								  (LPSTR)pBins,
								  NULL);
	
					// Assume FALSE until found.
					m_Record.m_nTractor = 0;
	
					for (int i = 0; i < nBins; i++)
					{
						if (pBins[i] == DMBIN_TRACTOR)
						{
						// We found it.
							m_Record.m_nTractor = 1;
							break;
						}
					}
					delete [] pBins;
				}
			}
		}
#ifndef WIN32
		if ((UINT)hDriver >= 32)
		{
			::FreeLibrary(hDriver);
		}
#endif
	
		WriteProfileInt(ENTRY_BadDC, FALSE, FALSE);
	}

/*
// Compute the desired orientation (as it is stored in the DevMode structure
*/

	SHORT desired_orientation = m_nOrientationType == PORTRAIT
					? DMORIENT_PORTRAIT
					: DMORIENT_LANDSCAPE;

	HDC hDC = NULL;

/* If we have no DC, create one now. */

	CPrintDialog pd(TRUE);

	AfxGetApp()->GetPrinterDeviceDefaults(&pd.m_pd);

	hDevMode = pd.m_pd.hDevMode;
	LPDEVMODE dm = NULL;
	DWORD dwOrgFields;
	int nOrgOrientation; 
	if (hDevMode != NULL)
	{
		dm = (LPDEVMODE)::GlobalLock(pd.m_pd.hDevMode);
		if (dm != NULL)
		{
			dwOrgFields = dm->dmFields;
			nOrgOrientation = dm->dmOrientation;
			dm->dmFields |= DM_ORIENTATION;
			dm->dmOrientation = desired_orientation;
		}
	}

	if (pd.m_pd.hDevNames != NULL)
	{
		HDC dc_save = pd.m_pd.hDC;
		hDC = pd.CreatePrinterDC();
		pd.m_pd.hDC = dc_save;
	}


/*
// Now update the paper info.
*/

/* Lock the dev mode structure if we have one. */

	SHORT orientation = DMORIENT_PORTRAIT;		/* In case we fail. */
	int paper_source = DMBIN_AUTO;				/* In case we fail. */

	if (dm != NULL)
	{
		if (dm->dmFields & DM_ORIENTATION)
		{
			orientation = dm->dmOrientation;
			ASSERT(orientation == desired_orientation);
		}
		if (dm->dmFields & DM_DEFAULTSOURCE)
		{
			paper_source = dm->dmDefaultSource;
		}
	}

	// Save the paper size from the DEVMODE structure: DMPAPER_LETTER, ...

	if (dm != NULL)
	{
		m_nDevModePaperSize = dm->dmPaperSize;
	}
	else
	{
		m_nDevModePaperSize = DMPAPER_LETTER;
	}

/* Set the paper type. */

	m_nPaperType = paper_source == DMBIN_TRACTOR
							? PAPER_TYPE_CONTINUOUS
							: PAPER_TYPE_CUT_SHEET;

	int nPaperXUnit, nPaperYUnit;
	int nPaperWidth, nPaperHeight;
	int nPrintableWidth, nPrintableHeight;
	int nLeftOffset, nTopOffset;

	if (hDC == NULL)
	{
	/* Some stupid defaults. (8 1/2" by 11"). */
		nPaperXUnit = 1000;
		nPaperYUnit = 1000;

		nPaperWidth = 8500;
		nPaperHeight = 11000;

		nPrintableWidth = 8000;
		nPrintableHeight = 10500;

		nLeftOffset = 250;
		nTopOffset = 250;

		m_nDefaultPostScriptType = 0;		// Assume no.
	}
	else
	{
		/* Lock the DevMode structure! */

#if 0
		LPDEVMODE dm;
		if (hDevMode != NULL && (dm = (LPDEVMODE)GlobalLock(hDevMode)) != NULL)
		{
		/* Well, we have it now... */

//			if (!(dm->dmFields & DM_ORIENTATION)
//						|| dm->dmOrientation != desired_orientation)
			{
			/*
			// Orientation is not set or not what we want.
			// Force it to be what we want.
			*/
				dm->dmFields |= DM_ORIENTATION;
				dm->dmOrientation = desired_orientation;
				orientation = desired_orientation;
				ResetDC(hDC, dm);
			}
			GlobalUnlock(hDevMode);
		}
#endif

		m_Record.m_nNumColors = GetDeviceCaps(hDC, NUMCOLORS);
		m_Record.m_nRasterCaps = GetDeviceCaps(hDC, RASTERCAPS);
		m_Record.m_nBitsPixel = GetDeviceCaps(hDC, BITSPIXEL);
		m_Record.m_nPlanes = GetDeviceCaps(hDC, PLANES);

	/* Get the device specifications. */
		nPaperXUnit = GetDeviceCaps(hDC, LOGPIXELSX);
		nPaperYUnit = GetDeviceCaps(hDC, LOGPIXELSY);

		nPrintableWidth = GetDeviceCaps(hDC, HORZRES);
		nPrintableHeight = GetDeviceCaps(hDC, VERTRES);

		POINT p;

		if (::Escape(hDC, GETPHYSPAGESIZE, NULL, NULL, &p) > 0)
		{
			nPaperWidth = p.x;
			nPaperHeight = p.y;
		}
		else
		{
			nPaperWidth = nPrintableWidth;
			nPaperHeight = nPrintableHeight;
		}

		if (::Escape(hDC, GETPRINTINGOFFSET, NULL, NULL, &p) > 0)
		{
			nLeftOffset = p.x;
			nTopOffset = p.y;
			od("Printing offset: %d, %d\r\n", p);
		}
		else
		{
			nLeftOffset = (nPaperWidth - nPrintableWidth)/2;
			nTopOffset = (nPaperHeight - nPrintableHeight)/2;
		}

		od("PhysPageSize: %d, %d; ", nPaperWidth, nPaperHeight);
		od("w:%d, h:%d, xres:%d, yres:%d\r\n",
					nPrintableWidth, nPrintableHeight,
 					nPaperXUnit, nPaperYUnit);

		// Determine the PostScript type at this time since we have a DC.
		m_nDefaultPostScriptType = DeterminePostScriptType(hDC);

		// Delete the DC if we created it.
		if (hDC != in_hDC)
		{
			DeleteDC(hDC);
		}

		if (orientation == DMORIENT_LANDSCAPE)
		{
		/* Device orientation is landscape. Reverse everything. */
			int tmp;

			tmp = nPrintableWidth;
			nPrintableWidth = nPrintableHeight;
			nPrintableHeight = tmp;

			tmp = nPaperWidth;
			nPaperWidth = nPaperHeight;
			nPaperHeight = tmp;

			tmp = nPaperXUnit;
			nPaperXUnit = nPaperYUnit;
			nPaperYUnit = tmp;

			// Pull in our orientation setting NOW
			m_Record.m_nOrientation = GetProfileInt(ENTRY_Orientation, m_Record.m_nOrientation);
			int nOrientation = m_Record.m_nOrientation;
			if (nOrientation == -1)
			{
				nOrientation = 90;			// Assume
				m_Record.m_nTractor = GetProfileInt(ENTRY_Tractor, m_Record.m_nTractor);
				if (m_Record.m_nTractor == 1 || paper_source == DMBIN_TRACTOR)
				{
					m_Record.m_nTractor = 1;
					nOrientation = 270;
				}
			}

			if (nOrientation == 90)
			{
				int nNewTop = nPaperHeight - (nLeftOffset + nPrintableHeight);
				nLeftOffset = nTopOffset;
				nTopOffset = nNewTop;
			}
			else
			{
				ASSERT(nOrientation == 270);
				int nNewLeft = nPaperWidth - (nTopOffset + nPrintableWidth);
				nTopOffset = nLeftOffset;
				nLeftOffset = nNewLeft;
			}
		}

	/*
	// Tractor paper is fine, but if we can't print on the full page, it
	// will have to be cut sheet.
	*/

#if 0
		if (m_nPaperType == PAPER_TYPE_CONTINUOUS
				&& nPrintableHeight != nPaperHeight)
		{
			m_nPaperType = PAPER_TYPE_CUT_SHEET;
		}
#else
		if (nPrintableHeight == nPaperHeight)
		{
			m_nPaperType = PAPER_TYPE_CONTINUOUS;
		}
		else
		{
			m_nPaperType = PAPER_TYPE_CUT_SHEET;
		}
#endif
	}


/*
// Store the values we computed in the member variables.
*/

	CFixed lXUnits = MakeFixed(nPaperXUnit);
	CFixed lYUnits = MakeFixed(nPaperYUnit);

	m_PaperSize.x = DivFixed(MakeFixed(nPaperWidth), lXUnits);
	m_PaperSize.y = DivFixed(MakeFixed(nPaperHeight), lYUnits);
	m_PrintableSize.x = DivFixed(MakeFixed(nPrintableWidth), lXUnits);
	m_PrintableSize.y = DivFixed(MakeFixed(nPrintableHeight), lYUnits);
	m_PhysicalMargins.Left = DivFixed(MakeFixed(nLeftOffset), lXUnits);
	m_PhysicalMargins.Top = DivFixed(MakeFixed(nTopOffset), lYUnits);
	m_PhysicalMargins.Right = m_PaperSize.x - (m_PrintableSize.x + m_PhysicalMargins.Left);
	m_PhysicalMargins.Bottom = m_PaperSize.y - (m_PrintableSize.y + m_PhysicalMargins.Top);

	if (dm != NULL)
	{
		ASSERT(hDevMode != NULL);
		
		dm->dmFields = dwOrgFields;
		dm->dmOrientation = nOrgOrientation;
		::GlobalUnlock(hDevMode);
	}
}