zoukankan      html  css  js  c++  java
  • Dll 学习3 将MDI子窗口封装在DLL中

    结果没有任何高深的技巧,难怪搜遍GOOGLE没有任何有用信息。哎…

    要注意的事项:1.资源的ID尽量不要和主文件重名 2.如果用正规的DLL,注意AFX_MANAGE_STATE(AfxGetStaticModuleState());(见DLL学习1)

    我用的是MFC扩展DLL。

    主程序中菜单相关项:

    void CMainFrame::OnTestDll()
    {
        // TODO: Add your command handler code here
            MessageBox("OK");
        typedef CMDIChildWnd * (*pFunc)(int, bool, CString,CString, CString);//type define a pointer of the function which has a int
                                    //return value and void parameter list.
        hModule=LoadLibrary("FormDll1.dll");//load the dymanic linked libraray
        pFunc pDisplay =(pFunc) GetProcAddress(hModule,"Display");//get the pointer to the function
        (pDisplay)(1, !(77), "1234","D:\\素材","D:\\Save");//invoke the function

    }

    DLL:

    #include "stdafx.h"
    #include <afxdllx.h>
    #include "global.h"
    #include "Resource.h"
    #include "MyDocument.h"
    #include "DeskChildFrame.h"
    #include "MyFormView.h"

    ……

    extern "C" __declspec(dllexport) CMDIChildWnd *  Display(int, bool, CString, CString, CString);
    CMDIChildWnd * Display(int nCode, bool First, CString Confirm, CString ReadPath, CString SavePath)
    {
        g_nCode = nCode;
        g_Confirm = Confirm;
        g_bFirst = First;
        g_ReadPath = ReadPath;
        g_SavePath = SavePath;

        CMultiDocTemplate * pDocTemplate;
        pDocTemplate = new CMultiDocTemplate(
            IDR_WordDll_ICON,
            RUNTIME_CLASS(CMyDocument),
            RUNTIME_CLASS(CDeskChildFrame), // custom MDI child frame
            RUNTIME_CLASS(CMyFormView));
        CString str = "dll测试";
        CDocument* pDoc = pDocTemplate->CreateNewDocument();
        CDeskChildFrame * pFrame = (CDeskChildFrame *)pDocTemplate->CreateNewFrame(pDoc, NULL);
        pDoc->SetTitle(str);
           pDocTemplate->InitialUpdateFrame(pFrame, pDoc);
        return pFrame;
    }

    其中CMyFormView中有一个Formview的资源。

  • 相关阅读:
    NET在后置代码中输入JS提示语句(背景不会变白)
    corev4.css 左菜单修改CSS
    寺庙里的那点荡事儿
    sharepoint 2010中通过命令部署和卸载FEATURE
    定时任务 Timer JOB
    获取MOSS个人站点的SPWeb对象
    C#对Active Directory进行增删修查的类源码
    权限操作
    在SharePoint中,检验用户(SPUser)是否属于给定的组(SPGroup)的方法(代码)
    DirectoryEntry所有字段对应解释
  • 原文地址:https://www.cnblogs.com/meetcomet/p/1588412.html
Copyright © 2011-2022 走看看