Click here to Skip to main content
15,888,351 members
Articles / Desktop Programming / MFC
Article

A Progress-iner Message System

Rate me:
Please Sign up or sign in to vote.
1.13/5 (17 votes)
16 May 2003 40K   448   11   4
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


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralI got it Pin
dharani2-Sep-04 3:07
dharani2-Sep-04 3:07 
Generalsorry Pin
kuhx198017-May-03 6:04
kuhx198017-May-03 6:04 
GeneralRe: sorry Pin
dog_spawn18-May-03 5:49
dog_spawn18-May-03 5:49 
GeneralRe: sorry Pin
kuhx198018-May-03 15:09
kuhx198018-May-03 15:09 
thanks, i'll rewrite it soon.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.