Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A Progress-iner Message System

0.00/5 (No votes)
16 May 2003 1  
A Progress-iner Message System

Introduction

When we write a program, maybe we need several modules, but how a module worked with each other? We always export some funcion, and maybe we need some callback function or virtual function deal with user input. Sometimes it is very anoying to do that, so I wrote this code for it.

Using the code

Before you using this code, you must insert all files in the path KUCMD, and include the file KuCOMMAND.h

Every class you want it can sent or get message must like this:

    class CSend
    {
        DECLARE_COMMAND(CSend)
    public:
        CSend();
    };

now, this class can get a message. and you must add this function:

    bool CPost::OnKuCmd(UINT msgID, DWORD hParam, DWORD lParam)
    {
        switch(msgID) {
        case TEST_SEND:
            ::MessageBox(NULL, (LPCSTR)hParam, "TEST_SEND", MB_OK);
            return true;
        }
        return false;
    }

Now, in any class that like CPost, you can send message TEST_SEND by this code

    KUMSG msg;
    msg.msgID = TEST_SEND;
    msg.hParam = (DWORD)(LPCSTR)strMessage;
    SendCmd(msg);

The sent message will return when it has be deal or

    KUMSG msg;
    msg.msgID = TEST_POST;
    msg.hParam = (DWORD)(LPCSTR)strMessage;
    SendCmd(msg);

To post the message. post message will return immediately. The message could define in KuCOMMAND.h, like this:

    // ============================================================

    #define TEST_SEND        0x01        
    #define TEST_POST        0x02        

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here