⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dde_stuf.hpp

📁 a program that generates a pulse-width modulated (PWM)signal.
💻 HPP
📖 第 1 页 / 共 2 页
字号:
        C_DDE_Item* AddItem (const char*, float&);
        C_DDE_Item* AddItem (const char*, double&);
        C_DDE_Item* AddItem (const char*, long double&);
        C_DDE_Item* AddItem (const char*, char&);
        C_DDE_Item* AddItem (const char*, char*, int);

        //  Function returns pointer to the item with the given name
        C_DDE_Item* GetItemWithName (const char*);
        C_DDE_Item* GetItemWithHandle (HSZ);

        //  Functions return the name of this topic and a handle to its DDE string
        const char* GetName (void) { return Name; }
        HSZ GetStringHandle (void) { return hszTopic; }

        bool SendAdviseData (void);         //  Server items send data to clients
        bool PokeChangedData (HCONV);       //  Client items send data to server
        void StartAdviseLinks (HCONV);      //  Tell items to connect advise links
        void EndAdviseLinks (HCONV);        //  and tell them to break advise links
    };


//=====================================================================================
//  Class:  C_DDE_Manager
//      This class encapsulates that part of the DDE interface code which is common to
//      both the DDE server and DDE client objects.  This includes holding basic DDE
//      registration information and managing lists of topics and items.
//=====================================================================================

class C_DDE_Manager : public CBasicList
    {
    protected:
        DWORD idInstance;                   //  Instance handle for DDE system
        DWORD dwThreadId;                   //  ID of thread in which DDE system runs
        HSZ hszService;                     //  Handle of string with service name
        int NumTopics;                      //  Number of topics supported by server
        char* ServiceName;                  //  Name of service provided by server
        bool ReadyToRegister;               //  Flag indicates time to set up DDEML

        //  Functions to find topics within the topic list and items in the item list
        C_DDE_Topic* GetTopicWithName (const char*);
        C_DDE_Topic* GetTopicWithHandle (HSZ);
        C_DDE_Item* GetItemWithName (const char*);
        C_DDE_Item* GetItemWithHandle (HSZ);

    public:
        C_DDE_Manager (void);               //  Constructor initializes variables
        ~C_DDE_Manager (void);              //  Destructor deletes all topics in list

        //  Functions to add a topic to the list
        C_DDE_Topic* AddTopic (const char*);

        //  Tell the DDEML thread it's time to register topic and item names
        void Register_DDE (void);

        //  Function allows caller to see if the DDE thread is ready to register names
        bool IsReadyToRegister (void)
            { return ReadyToRegister; }
    };


//=====================================================================================
//  Class:  C_DDE_Server
//      This class encapsulates a DDE server.  When set up by the user's program, it
//      will maintain a database of variables whose values can be queried by a client
//      program.  The CBasicList ancestor type adds basic linked list handling.
//      Limitations:  There are many; this helps keep the program simple.  Only the
//      text clipboard format is supported.  Only one server may be used in one
//      program at any given time (because the DDEML callback function can find only
//      the one server with which it's associated).
//=====================================================================================

class C_DDE_Server : public C_DDE_Manager
    {
    private:
        HSZPAIR* phszPair;                  //  Points to array of service/topic pairs

        //  These functions respond to messages from a client; all are called by the
        //  DDEML callback function
        HDDEDATA ConnectClient (HSZ, HSZ);
        HDDEDATA WildConnect (HSZ, HSZ);
        HDDEDATA RequestData (WORD, HSZ, HSZ);
        HDDEDATA PokeData (WORD, HSZ, HSZ, HDDEDATA);
        HDDEDATA AdviseStart (WORD, HSZ, HSZ);
        HDDEDATA AdviseRequest (WORD, HSZ, HSZ);
        HDDEDATA AdviseStop (HSZ, HSZ);

        void Initialize (void);             //  Set up the server object
        void Uninitialize (void);           //  Un-setup the same server object
        bool SendAdviseData (void);         //  Send data from advise-linked items

    public:
        C_DDE_Server (const char*);         //  Constrctor starts new thread for DDE
        ~C_DDE_Server (void);               //  Destructor shuts the thread down

        void SetServiceName (const char*);  //  Specify the DDE service name

    //  The DDE server callback function has access to class private data
    friend HDDEDATA EXPENTRY DdeServerCallback (WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA,
                                                DWORD, DWORD);
    friend DWORD WINAPI DDE_ServerThreadFunction (LPVOID lpParam);
    };


//=====================================================================================
//  Class:  C_DDE_Client
//      This class encapsulates DDE client communications.  It allows the user to send
//      and receive data to and from a server application.
//=====================================================================================

class C_DDE_Client : public C_DDE_Manager
    {
    private:
        void Update (void);                 //  Update client's status periodically
        bool PokeChangedData (void);        //  Tell all items to update server's data
        void Initialize (void);             //  Set up the client object
        void Uninitialize (void);           //  Un-setup the same client object
//        bool StartAdviseLink (C_DDE_Item*); //  Start an advise link to a server
//        bool EndAdviseLink (C_DDE_Item*);   //  Break the advise link

        //  Function called by DDE callback processes advise-loop data from a server
        HDDEDATA AdviseData (WORD, HSZ, HSZ, HDDEDATA);

        DWORD dwThreadId;                   //  ID of thread in which DDE system runs
        DWORD idInstance;                   //  Instance handle for DDE system
        bool ReadyToRegister;               //  Flag indicates time to set up DDEML
        HCONV hConversation;                //  Handle to a DDE conversation
        char* ServerName;                   //  String holds name of server to talk to
        char* TopicName;                    //  Name of topic about which to talk
        bool DoConnect;                     //  Signals from user thread to connect
        bool DoDisconnect;                  //  to or disconnect from a server

    public:
        C_DDE_Client (void);                //  Constructor creates a thread for DDE
        ~C_DDE_Client (void);               //  Destructor shuts down the thread

        //  Functions to connect to, and disconnect from, a DDE server
        bool ConnectToServer (const char*, const char*);
        bool DisconnectFromServer (void);

    //  The DDE server callback function has access to class private data
    friend HDDEDATA EXPENTRY DdeClientCallback (WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA,
                                                DWORD, DWORD);
    friend DWORD WINAPI DDE_ClientThreadFunction (LPVOID lpParam);
    };

#endif  //  DDE_STUFF
#endif  //  __WIN32__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -