📄 custom1dlg.cpp
字号:
// custom1Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "custom1.h"
#include "custom1Dlg.h"
#include "D:/COM/server1/server1_i.c"
#include "D:/COM/server1/server1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 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)
//}}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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCustom1Dlg dialog
CCustom1Dlg::CCustom1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CCustom1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCustom1Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCustom1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCustom1Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCustom1Dlg, CDialog)
//{{AFX_MSG_MAP(CCustom1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SUM, OnSum)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCustom1Dlg message handlers
BOOL CCustom1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CCustom1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCustom1Dlg::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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCustom1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCustom1Dlg::OnSum()
{
// TODO: Add your control notification handler code here
CoInitialize(NULL);
Izhujian1 *iactivexi=NULL;
HRESULT hr;
CString cs_display=_T("");
CString cs_inivalue=_T("");
CString cs_x=_T("");
CString cs_y=_T("");
CString cs_z=_T("");
long x_inivalue=1;
long y_inivalue=1;
long z_inivalue=2;
long put_inivalue=0;
long get_inivalue=0;
hr=CoCreateInstance(CLSID_zhujian1,NULL,CLSCTX_ALL,IID_Izhujian1,(void**)&iactivexi);
if (SUCCEEDED(hr)){
//this->GetDlgItemText(IDC_INIVALUE,cs_inivalue);
//put_inivalue=atoi(cs_inivalue);
//hr=iactivexi->put_total(put_inivalue);
if (SUCCEEDED(hr)){
this->GetDlgItemText(IDC_XVALUE,cs_x);
this->GetDlgItemText(IDC_YVALUE,cs_y);
this->GetDlgItemText(IDC_ZVALUE,cs_z);
x_inivalue=atoi(cs_x);
y_inivalue=atoi(cs_y);
z_inivalue=atoi(cs_z);
hr=iactivexi->sum1(x_inivalue,y_inivalue,z_inivalue);
if (SUCCEEDED(hr)){
hr=iactivexi->get_total(&get_inivalue);
if (SUCCEEDED(hr)){
cs_display.Format("value total:%d ",get_inivalue);
}else{
cs_display=_T("get_total execute failed");
}
}else{
cs_display=_T("sum execute failed");
}
}else{
cs_display=_T("put_total execute failed");
}
}else{
cs_display=_T("CoCreateInstance execute failed");
}
this->SetDlgItemText(IDC_DISPLAY,cs_display);
CoUninitialize();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -