📄 callcomdlg.cpp
字号:
// CallCOMDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CallCOM.h"
#include "CallCOMDlg.h"
#include "comdef.h"
#include "IDrive.h"
#include "Simple_ATL.h"
#include "Simple_ATL_i.c"
#include "ATLCOMServer.h"
#include "ATLCOMServer_i.c"
//#include "RemoteDisply.odl"
//#import "ContentTestCOM.tlb"
#import "UserCom.tlb"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*
const GUID IID_Dictionary =
{ 0x54bf6568, 0x1007, 0x11d1,
{ 0xb0, 0xaa, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} } ;
*/
const GUID LIBID_RemoteDisply =
{ 0xC8D068B3, 0xF7B0, 0x494B,
{ 0x86, 0x13, 0xCF, 0xA8, 0x55, 0x61, 0xB6, 0xBE}};
const GUID DIID_IRemoteDisply = {0xF4DDFA65, 0xB34E, 0x41C1,
{0x9B, 0xA9, 0xA3, 0x1B, 0xE9, 0x50, 0x75, 0x65}};
const GUID CLASS_RemoteDisply_ =
{0x5DAAEEF4, 0xDDE2, 0x4B3F,
{0x89, 0x7D, 0x27, 0x67, 0x1E, 0x2B, 0x74, 0xF3}};
IMPLEMENT_OLECREATE2(CLoginDlgAutoProxy, "Login.Application", 0x72946b56, 0x17c1, 0x439f, 0xa1, 0x49, 0x6c, 0x4c, 0x85, 0x9d, 0x94, 0x4)
static const IID IID_ILogin =
{ 0x9da38e13, 0xefad, 0x4d1d, { 0xa9, 0xbc, 0xc1, 0xac, 0xf9, 0x75, 0x40, 0xd3 } };
////////////////////////////////////////////////////////////////////////////
// CCallCOMDlg dialog
CCallCOMDlg::CCallCOMDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCallCOMDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCallCOMDlg)
// 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 CCallCOMDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCallCOMDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCallCOMDlg, CDialog)
//{{AFX_MSG_MAP(CCallCOMDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CALL, OnCall)
ON_BN_CLICKED(IDC_Local, OnLocal)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCallCOMDlg message handlers
BOOL CCallCOMDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
}
// 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 CCallCOMDlg::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 CCallCOMDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCallCOMDlg::OnCall()
{
// TODO: Add your control notification handler code here
HRESULT hr;
IFirst_ATL * mFirstATL;
hr = CoInitialize(0);
if (SUCCEEDED(hr))
hr = CoCreateInstance(CLASS_RemoteDisply_, NULL, CLSCTX_INPROC_SERVER, DIID_IRemoteDisply,
(void**)&mFirstATL);
mFirstATL->ShowName();
mFirstATL->Release();
}
void CCallCOMDlg::OnLocal()
{
// TODO: Add your control notification handler code here
HRESULT hr;
IATLServer * mComServer;
hr = CoInitialize(0);
char Name[] = "192.168.10.55";
COSERVERINFO cs;
memset(&cs, 0, sizeof(cs));
cs.pwszName = _bstr_t(Name);
MULTI_QI qi[1];
memset(qi, 0, sizeof(qi));
qi[0].pIID = &IID_IATLServer;
if (SUCCEEDED(hr))
hr = CoCreateInstanceEx(CLSID_ATLServer, NULL,
CLSCTX_SERVER,
&cs,
1,
qi);
if (SUCCEEDED(hr)){
mComServer = (IATLServer*)(qi[0].pItf);
mComServer->ShowName();
mComServer->Release();
}
}
void CCallCOMDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -