1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
static CString g_sDescriptionFile;
CString g_appPath;
BOOL g_bNewFile=TRUE;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
static DWORD CALLBACK RichEditStreamCallback(DWORD dwCookie,
LPBYTE pbBuff, LONG cb, LONG FAR *pcb);
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CVisualGesApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// ---------------------------------------------------------------------------------------
DWORD CALLBACK CAboutDlg::RichEditStreamCallback(DWORD dwCookie,
LPBYTE pbBuff, LONG cb, LONG FAR *pcb)
{
UNREFERENCED_PARAMETER(dwCookie);
static HANDLE hFile = INVALID_HANDLE_VALUE;
if(g_bNewFile)
{
g_bNewFile=FALSE;
hFile = CreateFile(g_appPath+g_sDescriptionFile,
GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
}
if(hFile == INVALID_HANDLE_VALUE)
return 1;
//read some data
DWORD bytesRead;
int rt = ReadFile(hFile,pbBuff,cb,&bytesRead,NULL);
if(rt == FALSE)
return 1;
*pcb = bytesRead;
if(bytesRead != (DWORD)cb || bytesRead == 0)
{
if(hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
g_bNewFile=TRUE;
hFile = INVALID_HANDLE_VALUE;
}
}
return 0;
}
// ---------------------------------------------------------------------------------------
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//get the application path
TCHAR buf[_MAX_PATH];
_tcscpy(buf,GetCommandLine());
//remove the program name
int len = _tcslen(buf);
for(int loop = len;loop > 0;loop --)
{
if(buf[loop] == _T('\\'))
{
buf[loop+1] = 0;
break;
}
}
if(loop == 0)
{
_tgetcwd(buf,sizeof(buf));
_tcscat(buf,_T("\\"));
}
if(buf[0] == _T('\"'))
g_appPath = &buf[1];
else
g_appPath = buf;
CRichEditCtrl* re = (CRichEditCtrl*)GetDlgItem(IDC_SAMPLE_DESCRIPTION);
EDITSTREAM es;
es.dwCookie = 0;
es.dwError = 0;
es.pfnCallback = (EDITSTREAMCALLBACK)RichEditStreamCallback;
re->StreamIn(SF_RTF,es);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
} |
Partager