home *** CD-ROM | disk | FTP | other *** search
- // UseAtlTrigXDlg.cpp : implementation file
-
- #include "stdafx.h"
- #include "UseAtlTrigX.h"
- #include "UseAtlTrigXDlg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- // CUseAtlTrigXDlg dialog
- CUseAtlTrigXDlg::CUseAtlTrigXDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CUseAtlTrigXDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CUseAtlTrigXDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-
- m_pTrigX = 0;
- }
-
- void CUseAtlTrigXDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CUseAtlTrigXDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CUseAtlTrigXDlg, CDialog)
- //{{AFX_MSG_MAP(CUseAtlTrigXDlg)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON_EXE, OnButtonExe)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- // CUseAtlTrigXDlg message handlers
- BOOL CUseAtlTrigXDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
-
- return TRUE;
- }
-
- void CUseAtlTrigXDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
-
- HCURSOR CUseAtlTrigXDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
-
- void CUseAtlTrigXDlg::OnButtonExe()
- {
- double x = 1.0, r;
- CString s;
-
- try
- {
- if (0 == m_pTrigX)
- m_pTrigX = ItrigXPtr(CLSID_trigX);
-
- m_pTrigX->ATLcosX(x, &r);
- s.Format("The cosine of %3.1lf is %lf", x, r);
- MessageBox(s);
- }
-
- catch (_com_error &ex)
- {
- _bstr_t bstrSource(ex.Source());
- _bstr_t bstrDescription(ex.Description());
- char szTemp[1024];
- CString csMsg = "Oops - hit an error!\n";
- wsprintf(szTemp, "Code = %08lx\n", ex.Error());
- csMsg += szTemp;
- wsprintf(szTemp, "Code meaning = %s\n", ex.ErrorMessage());
- csMsg += szTemp;
- wsprintf(szTemp, "Source = %S\n", (wchar_t*)bstrSource);
- csMsg += szTemp;
- wsprintf(szTemp, "Description = %S\n", (wchar_t*)bstrDescription);
- csMsg += szTemp;
- MessageBox (csMsg);
- SysFreeString(bstrSource);
- SysFreeString(bstrDescription);
- }
- }
-