Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MyFileIO.cpp
Package: modelmagic3d.zip [view]
Upload User: cding2008
Upload Date: 2007-01-03
Package Size: 1812k
Code Size: 4k
Category:
OpenGL program
Development Platform:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // MyFileIO.cpp : File I/O helper implementation
- //
- // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1998
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is freely distributable without licensing fees and is
- // provided without guarantee or warrantee expressed or implied. This
- // program is -not- in the public domain.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "MyFileIO.h"
- /////////////////////////////////////////////////////////////////////////////
- // Helpers for saving/restoring window state in the ini file
- static TCHAR szFormat[] = _T("%u,%u,%d,%d,%d,%d,%d,%d,%d,%d");
- BOOL PASCAL NEAR ReadWindowPlacement(LPWINDOWPLACEMENT pwp, LPSTR lpszSection, LPSTR lpszWindowName)
- {
- CString strBuffer = AfxGetApp()->GetProfileString(lpszSection, lpszWindowName);
- if (strBuffer.IsEmpty())
- return FALSE;
- WINDOWPLACEMENT wp;
- int nRead = _stscanf(strBuffer, szFormat,
- &wp.flags, &wp.showCmd,
- &wp.ptMinPosition.x, &wp.ptMinPosition.y,
- &wp.ptMaxPosition.x, &wp.ptMaxPosition.y,
- &wp.rcNormalPosition.left, &wp.rcNormalPosition.top,
- &wp.rcNormalPosition.right, &wp.rcNormalPosition.bottom);
- if (nRead != 10)
- return FALSE;
- wp.length = sizeof wp;
- *pwp = wp;
- return TRUE;
- }
- void PASCAL NEAR WriteWindowPlacement(LPWINDOWPLACEMENT pwp, LPSTR lpszSection, LPSTR lpszWindowName)
- // write a window placement to settings section of app's ini file
- {
- TCHAR szBuffer[sizeof("-32767")*8 + sizeof("65535")*2];
- wsprintf(szBuffer, szFormat,
- pwp->flags, pwp->showCmd,
- pwp->ptMinPosition.x, pwp->ptMinPosition.y,
- pwp->ptMaxPosition.x, pwp->ptMaxPosition.y,
- pwp->rcNormalPosition.left, pwp->rcNormalPosition.top,
- pwp->rcNormalPosition.right, pwp->rcNormalPosition.bottom);
- AfxGetApp()->WriteProfileString(lpszSection, lpszWindowName, szBuffer);
- }
- void DisplayFileIOException(CFileException* exception)
- {
- if(exception->m_cause == CFileException::none )
- AfxMessageBox("No error occured. False exception??", MB_OK, NULL);
- if(exception->m_cause == CFileException::generic )
- AfxMessageBox("An unspecified error occurred!", MB_OK, NULL);
- if(exception->m_cause == CFileException::fileNotFound )
- AfxMessageBox("The file could not be located!", MB_OK, NULL);
- if(exception->m_cause == CFileException::badPath )
- AfxMessageBox("All or part of the path is invalid!", MB_OK, NULL);
- if(exception->m_cause == CFileException::tooManyOpenFiles )
- AfxMessageBox("The permitted number of open files was exceeded!", MB_OK, NULL);
- if(exception->m_cause == CFileException::accessDenied )
- AfxMessageBox("The file could not be accessed!", MB_OK, NULL);
- if(exception->m_cause == CFileException::invalidFile )
- AfxMessageBox("There was an attempt to use an invalid file handle!", MB_OK, NULL);
- if(exception->m_cause == CFileException::removeCurrentDir )
- AfxMessageBox("The current working directory cannot be removed!", MB_OK, NULL);
- if(exception->m_cause == CFileException::directoryFull )
- AfxMessageBox("There are no more directory entries!", MB_OK, NULL);
- if(exception->m_cause == CFileException::badSeek )
- AfxMessageBox("There was an error trying to set the file pointer!", MB_OK, NULL);
- if(exception->m_cause == CFileException::hardIO )
- AfxMessageBox("There was a hardware error!", MB_OK, NULL);
- if(exception->m_cause == CFileException::sharingViolation )
- AfxMessageBox("SHARE.EXE was not loaded, or a shared region was locked!", MB_OK, NULL);
- if(exception->m_cause == CFileException::lockViolation )
- AfxMessageBox("There was an attempt to lock a region that was already locked!", MB_OK, NULL);
- if(exception->m_cause == CFileException::diskFull )
- AfxMessageBox("The disk is full!", MB_OK, NULL);
- if(exception->m_cause == CFileException::endOfFile )
- AfxMessageBox("The end of file was reached!", MB_OK, NULL);
- }