- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个项目,在该项目中我收到了一个示例代码,它是一个 exe,基本上将两个 activeX 控件加载到一个对话框中。
我需要制作一个 DLL 来使用该控件的功能。
执行此操作的最佳策略是什么?我认为我的 DLL 需要创建窗口的实例。并在构建窗口时获取指向 activeX 控件的指针以使事情发生。
执行此操作的最佳策略是什么?或者是否有可能?
应用程序代码:启动.h #pragma一次
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CStartUpApp:
// See StartUp.cpp for the implementation of this class
//
class CStartUpApp : public CWinApp
{
public:
CStartUpApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CStartUpApp theApp;
启动Dlg.h
#pragma once
#include "xnssdkdevicectrl.h"
#include "xnssdkwindowctrl.h"
// CStartUpDlg dialog
class CStartUpDlg : public CDialog
{
// Construction
public:
CStartUpDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_STARTUP_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
private:
// [ XNS ACTIVEX HELP ]
// -----------------------------------------------------------------------
// XNS Device control and Window control variables
// -----------------------------------------------------------------------
CXnssdkwindowctrl m_ctrlXnsWindow; // XnsWindow control
CXnssdkdevicectrl m_ctrlXnsDevice; // XnsDevice control
public:
afx_msg void OnBnClickedOk();
};
启动.cpp
#include "stdafx.h"
#include "StartUp.h"
#include "StartUpDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CStartUpApp
BEGIN_MESSAGE_MAP(CStartUpApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CStartUpApp construction
CStartUpApp::CStartUpApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CStartUpApp object
CStartUpApp theApp;
// CStartUpApp initialization
BOOL CStartUpApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CStartUpDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
启动Dlg.cpp
#include "stdafx.h"
#include "StartUp.h"
#include "StartUpDlg.h"
// [ XNS ACTIVEX HELP ]
// -----------------------------------------------------------------------
// This files are installed in {$SDK path}\sample_code\include
// You should include this files
// -----------------------------------------------------------------------
#include "XnsCommon.h"
#include "XnsDeviceInterface.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Macro for OutputDebugString()
#define DBG_LOG(...) do{\
CString strMessage = _T("");\
strMessage.AppendFormat(_T("(%S:%d)"), __FUNCTION__, __LINE__); \
strMessage.AppendFormat(__VA_ARGS__);\
OutputDebugString(strMessage);\
}while(0);
// Macro for AfxMessageBox()
#define ERROR_BOX(...) do{\
CString strMessage = _T("");\
strMessage.Format(__VA_ARGS__);\
AfxMessageBox(strMessage);\
}while(0);
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CStartUpDlg dialog
CStartUpDlg::CStartUpDlg(CWnd* pParent /*=NULL*/)
: CDialog(CStartUpDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CStartUpDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_XNSSDKDEVICECTRL, m_ctrlXnsDevice);
DDX_Control(pDX, IDC_XNSSDKWINDOWCTRL, m_ctrlXnsWindow);
}
BEGIN_MESSAGE_MAP(CStartUpDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, &CStartUpDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// CStartUpDlg message handlers
BOOL CStartUpDlg::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
// [ XNS ACTIVEX HELP ]
// -----------------------------------------------------------------------
// Initializes the DLL files.
// For this, XnsActiveX library requires config.xml, device.xml,
// and xns.xml files and the DLL file list should be mentioned
// in Xns.xml file. The path of the DLL file can not exceed 512 bytes
// in length. The XnsActiveX library searches for xns.xml using
// XnsSDKDevice.ocx installed in "{$SDK path}\Config" folder.
// -----------------------------------------------------------------------
long nRet = m_ctrlXnsDevice.Initialize();
if (nRet != ERR_SUCCESS)
{
DBG_LOG(_T("XnsSdkDevice:: Initialize() fail: errno=[%d]\n"), nRet);
}
// [ XNS ACTIVEX HELP ]
// -----------------------------------------------------------------------
// Initializes the XnsSdkWindow control.
// Namely, this will specify the window handle in order to display
// images on the screen.
// -----------------------------------------------------------------------
nRet = m_ctrlXnsWindow.Initialize(NULL, NULL);
DBG_LOG(_T("XnsSdkWindow:: Initialize() return=[%d](%s)\n"),
nRet, m_ctrlXnsDevice.GetErrorString(nRet));
return TRUE; // return TRUE unless you set the focus to a control
}
void CStartUpDlg::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 CStartUpDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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 function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CStartUpDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CStartUpDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
}
我的 dll 头文件
__declspec(dllexport) long init();//initilize app with activeX controls in window
__declspec(dllexport) long getDlgInstance();//get dlg handle to be able to call activeX
__declspec(dllexport) long connect(long handle);//do stuff
最佳答案
应该没有那么难...没有看到你的代码(我怎么可能?),我假设你定义了函数来将 activeX 控件的指针返回给调用者。从您之前提出的问题来看,您知道如何制作 DLL。在一个新的 DLL 项目中获取您需要的所有代码,仅导出您想要从主机应用程序访问的功能,然后您就完成了
关于c++ - VC++ 将示例应用程序转换为 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32244846/
当应用程序启动时,您将从 ViewController(中间的那个)开始。从那里我在右边添加了 VC。当用户点击此 VC 上的按钮时,我希望该 View 消失(我目前只需将其框架更改为 900 即可实
我在 Xcode 7 中使用简单的主/详细信息分割 View 模板,并希望用户从具有主要类别的高级 Master VC 开始,然后选择一个并深入到各个项目 - 仍然在左侧- 然后当他们从第二个主 VC
我有一个名为“firstVC”的 View Controller 和另一个名为“secondVC”的 View Controller 。第二个 VC 将以模态方式呈现在第一个 VC 上,当用户按下第二
我被困在一个问题上,我有一个案例 我有一个父 VC 它有2个容器[childVC A, childVC B] API 正在调用 childVC (UIViewController) A 一旦 chil
我从呈现的 VC 导航到 VC(让我们调用 VC A)。在 VC A 中,我有一个容器 View ,它有一个 VC(让我们调用 VC B)。从 VC B 我提出了另一个 VC(我们称之为 VC C)。
我有一个主 VC(称为 VC A),它有一个子 VC(VC B)。当我点击 VC B 上的按钮时,我将其作为子 VC 关闭,但是一旦完成,我想实例化另一个 VC(VC C)。我通过在 VC B 上创建
我们正在寻求改变用户退出我们应用程序的方式。为了做到这一点,我们要关闭当前 VC 下面的所有 VC,并将另一个 VC 作为根 VC。现在我们正在这样做,我相信这不会从内存中消除下面的任何 VC。 le
我仅使用 segue 在我的应用程序中导航。 我只是想知道,如果我从 1st-VC 导航到 V2,再到 V3,然后再到 4th-VC,如何直接从 4th-VC 导航回 1st VC,而不返回到 V3、
最新的 Xcode/Swift/iOS。 我有一个主 VC(称为 StartVC),其中包含一个子 VC(称为 TopBarVC)via 和嵌入式 segue。子 VC 包含一个按钮,按下该按钮时,会
我试图将从 map 中获得的地址传递到我的其他 View Controller 中并保持相同的设置(即开关仍然打开) mapVC 名为 MapViewController,tableVC 名为 Add
我有一个嵌入在 navigationcontroller 中的 viewcontroller,它将另一个 viewcontroller 推送到堆栈上。这个推送的 View Controller 有一个
昨天更新后,我在 iPad 上遇到了这个问题:如果我加载第二个 View Controller ,它看起来比第一个 View Controller 小(见下图)。有趣的是,自从我在 iPad 上更新了
我的项目有这样的设计: VC1 ---firstSegue----> VC2 ---secondSegue---> VC3 通过使用协议(protocol)/委托(delegate)方法,我可以毫无问
图像不是从一个 VC 到另一个 VC。 问题是将它显示到主 UIViewController 中的 ImageView 。我已将所有内容正确连接到 Storyboard中。 点击here查看我的 St
如何在vc++中调用vc++dll。 在.h文件中 typedef int (*LPVAR)(char * ptr_f, char *CC); HINSTANCE hDLL; 在.cpp 文件中 hD
当我从 VC1 转到 VC2 时,如果 VC2 被解雇,我可以通过在 VC2 中设置协议(protocol)并让 VC1 符合它,轻松地将数据传回 VC1。我想做类似的事情,但有以下区别 当我从 VC
我有一个 VC(A),它有一个容器 View 并根据 segementControl 值更改它的 VC(B-C),我在 A ViewController 中发送请求并获得响应,我想确保 B 和C Vi
所以我在我的应用程序中实现了通用链接,当按下按钮时,我打开了我的第二个应用程序: UIApplication.shared.open(aUrl!) 我也接到了电话: func application(
我想在 ios 中模拟联系人列表。当点击 + 按钮添加联系人时,会出现一个新的 View Controller ,为您提供文本字段以输入联系人姓名和用于保存该联系人的其他信息。一旦你点击完成按钮,下一
我有两个 ViewControllers - Slider 和 Foo。我将 Slider 添加为 Foo subview 并将其框架设置在 Foo VC 中,但是 Slider 的框架没有改变 ->
我是一名优秀的程序员,十分优秀!