• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 使用DDE使應用程序可以添加新的程序組

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    浙江省郵電學校56# 姚輝 ---- 當應用程序安裝完畢后,通常都會建立程序組,它們是怎么實現的呢?下面是一種使用DDE來添加新的程序組的例子。 ---- 1.使用MFC新一項目PMGROUP(對話框形式),在對話框中添加三個Edit Box。 ---- 2.使用Class Wizard,添加成員
    浙江省郵電學校56# 姚輝

    ---- 當應用程序安裝完畢后,通常都會建立程序組,它們是怎么實現的呢?下面是一種使用DDE來添加新的程序組的例子。

    ---- 1.使用MFC新一項目PMGROUP(對話框形式),在對話框中添加三個Edit Box。

    ---- 2.使用Class Wizard,添加成員變量m_GroupName,m_ItemName,m_FileName,分別對應添加的三個Edit Box,它們將容納輸入的三個條目(組名,標記名,對應的文件名);

    ---- 3.在頭文件STDAFX.H中,添加下列代碼:

    #include < ddeml.h >

    ---- 4.在應用程序類CPGROUPApp的InitInstance函數中,添加下列代碼:

    BOOL CPMGROUPApp::InitInstance()
    {
    //...
    //Initialze DDEML
    DdeInitialize(&dwDDEInst,NULL,APPCMD_CLIENTONLY,0);

    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
    if(!AddPMGroup(dlg.m_GroupName,dlg.m_ItemName,dlg.m_FileName))
    {
    ::MessageBox(NULL,"PMGroup:DDE Error","Error
    adding group and item.",MB_ICONHAND|MB_OK);
    }

    }
    //...
    }

    ---- 再給CPGROUPApp類添加一個成員變量dwDDEInst:

    ---- DWORD dwDDEInst;(用鼠標在ClassView的CPGROUPApp上點擊右鍵,在彈出的菜單中選取擇Add Member Variable,在對話中分別輸入DWORD和dwDDEInst)

    ---- 因為它是一個以對話框為基礎的應用程序,當單擊確定后,就調用AddPMGroup來添加新的程序組。因此還要給CPGROUPApp類添加上AddPMGroup(用鼠標在ClassView的CPGROUPApp上點擊右鍵,在彈出的菜單中選取擇Add Member Function,在對話中分別輸入int和AddPMGroup。將生成的int CPMGROUPApp::AddPMGroup()改為int CPMGROUPApp::AddPMGroup(CString &group,CString &item,CString &file),在CPGROUPApp中將int AddPMGroup()改為int AddPMGroup(CString &group,CString &item,CString &file)),AddPMGroup的內容為:

    int CPMGROOPApp::AddPMGroup(CString &group,CString &item,CString &file)
    {
    HSZ hszService=DdeCreateStringHandle(dwDDEInst,_T("PROGMAN"),CP_WINANSI);
    HSZ hszTopic=DdeCreateStringHandle(dwDDEInst,_T("PROGMAN"),CP_WINANSI);
    HCONV hConV=DdeConnect(dwDDEInst,hszTopic,hszService,NULL);
    DdeFreeStringHandle(dwDDEInst,hszService);
    DdeFreeStringHandle(dwDDEInst,hszTopic);
    if(!hConV)
    {
    return FALSE;
    }
    //主要內容
    CString cmd="[CreateGroup("+group+")]";//建立組的命令字
    DWORD dwResult;
    LPCTSTR data=(LPCTSTR)cmd;
    DdeClientTransaction((LPBYTE)data,cmd.GetLength (),
    hConV,NULL,CF_TEXT,XTYP_EXECUTE,
    1000,&dwResult);
    cmd="[AddItem("+file+","+item+")]";
        //建立"file"的圖標,"item"為標記的命令字
    data=(LPCTSTR)cmd;
    DdeClientTransaction((LPBYTE)data,cmd.GetLength (),
    hConV,NULL,CF_TEXT,XTYP_EXECUTE,
    1000,&dwResult);
    return TRUE;
    }

    ---- 5.使用Class Wizard給CPMGROUPApp添加一個ExitInstance函數,輸入下列代碼:

    int CPMGROOPApp::ExitInstance()
    {
    // TODO: Add your specialized code here and/or call the base class
    DdeUninitialize(dwDDEInst);
    return CWinApp::ExitInstance();
    }

    ---- 6.按F5運行,分別輸入組名、標名、文件名,按確定看看。

    ---- 7.當然我們也可用其它命令字對程序組進行其它操作:

    ---- [ShowGroup(My Group,1)]

    ---- 顯示并激活名為My Group的組窗口

    ---- [DeleteGroup(My Group)]

    ---- 刪除名為My Group的組

    ---- [ReloadGroup(My Group)]

    ---- 去除并重新裝載名為My Group的組

    ---- [Additem(HELLO.EXE,HELLO)]

    ---- 為HELLO.EXE創建圖標,標記為HELLO

    ---- [ReplaceItem(HELLO)]

    ---- 為名為HELLO的條目去除圖標,并在這里插入下一條目

    ---- [DeleteItem(HELLO)]

    ---- 刪除名為HELLO的條目

    ---- [ExitProgMan(1)]

    ---- 退出程序管理器,并存貯信息(0不存)

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>