Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Find the windows Pin
Cvaji22-Apr-10 0:48
Cvaji22-Apr-10 0:48 
GeneralRe: Find the windows Pin
Code-o-mat22-Apr-10 1:00
Code-o-mat22-Apr-10 1:00 
GeneralRe: Find the windows Pin
Cvaji22-Apr-10 5:27
Cvaji22-Apr-10 5:27 
GeneralRe: Find the windows Pin
Code-o-mat22-Apr-10 6:16
Code-o-mat22-Apr-10 6:16 
GeneralRe: Find the windows Pin
Cvaji22-Apr-10 6:40
Cvaji22-Apr-10 6:40 
GeneralRe: Find the windows Pin
Code-o-mat22-Apr-10 6:44
Code-o-mat22-Apr-10 6:44 
GeneralRe: Find the windows Pin
Cvaji22-Apr-10 6:54
Cvaji22-Apr-10 6:54 
QuestionChild windows and OOP Pin
zoopp22-Apr-10 0:04
zoopp22-Apr-10 0:04 
Hello! I'm working on a library that's going to deal with windows (to be more specific, I'm wrapping some windows APIs that deals with window creation/destruction and messages (like a window click etc.) into OOP).

In the message handler this is what i have:

LRESULT CALLBACK zooppMessageHandler::msgHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    zooppMessageHandler *obj = (zooppMessageHandler*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
    int retVal = false;

    if(obj == NULL)
        if(msg == WM_CREATE || msg == WM_INITDIALOG)    //window creation
            {
                SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(((CREATESTRUCT*)lParam)->lpCreateParams));
                obj = (zooppMessageHandler*)GetWindowLongPtr(hwnd, GWLP_USERDATA);

                retVal = obj->OnInit();

                if(retVal != false)
                    return retVal;
                else
                    return DefWindowProc(hwnd, msg, wParam, lParam);
            }
        else if(msg == WM_PARENTNOTIFY && wParam == WM_CREATE)      //child window creation
            {
            }

    retVal = obj->Handle(msg, wParam, lParam);

    if(retVal != false)
        return retVal;
    else
        return DefWindowProc(hwnd, msg, wParam, lParam);
}


I know that so far it may look a bit unprofessional/unoptimized but i don't care about that yet. As you may see, for normal windows I pass the 'this' pointer into CreateWindowEx() function, and attach it's address to the window's handle with SetWindowLongPtr(). When a message (other tham WM_CREATE, WM_INITDIALOG etc.) comes I just grab the address of 'this' by calling GetWindowLongPtr() and then handle the message.

But...I ran into a problem regarding child windows. As far as I'm aware, when a child window is created the system won't send a WM_CREATE message but instead it will send a WM_PARENTNOTIFY message, wParam contains the child window's message (in my case WM_CREATE) and lParam it's handle. This means I can't pass the address of the object which issued the CreateWindowEx() function into the message handler.

Am I wrong? If no...how can i pass the object's address when creating child windows? For normal windows (as you see in the above code), I get the object's code from lParam which contains a pointer to a CREATESTRUCT structures in which member lpCreateParams points to the address of the object which issued a CreateWindowEx() function call.
AnswerRe: Child windows and OOP Pin
Eugen Podsypalnikov22-Apr-10 2:16
Eugen Podsypalnikov22-Apr-10 2:16 
GeneralRe: Child windows and OOP Pin
zoopp22-Apr-10 4:21
zoopp22-Apr-10 4:21 
Questionidle percentage Pin
Russell'21-Apr-10 23:50
Russell'21-Apr-10 23:50 
AnswerRe: idle percentage Pin
Michel Godfroid22-Apr-10 1:03
Michel Godfroid22-Apr-10 1:03 
Questionnew operator in DllMain of MFC Extension Dll Pin
Member 334509521-Apr-10 23:24
Member 334509521-Apr-10 23:24 
AnswerRe: new operator in DllMain of MFC Extension Dll Pin
Eugen Podsypalnikov21-Apr-10 23:59
Eugen Podsypalnikov21-Apr-10 23:59 
QuestionGenerate series Pin
MsmVc21-Apr-10 21:45
MsmVc21-Apr-10 21:45 
AnswerRe: Generate series Pin
Richard MacCutchan21-Apr-10 21:50
mveRichard MacCutchan21-Apr-10 21:50 
GeneralRe: Generate series Pin
MsmVc21-Apr-10 21:54
MsmVc21-Apr-10 21:54 
GeneralRe: Generate series Pin
Richard MacCutchan21-Apr-10 22:49
mveRichard MacCutchan21-Apr-10 22:49 
AnswerRe: Generate series PinPopular
Stephen Hewitt21-Apr-10 21:54
Stephen Hewitt21-Apr-10 21:54 
GeneralRe: Generate series Pin
MsmVc21-Apr-10 21:56
MsmVc21-Apr-10 21:56 
GeneralRe: Generate series PinPopular
Cedric Moonen21-Apr-10 22:00
Cedric Moonen21-Apr-10 22:00 
GeneralRe: Generate series Pin
MsmVc21-Apr-10 22:01
MsmVc21-Apr-10 22:01 
GeneralRe: Generate series Pin
Chris Losinger22-Apr-10 1:28
professionalChris Losinger22-Apr-10 1:28 
QuestionSDI List Control example Pin
hellogany21-Apr-10 21:00
hellogany21-Apr-10 21:00 
AnswerRe: SDI List Control example Pin
Richard MacCutchan21-Apr-10 21:03
mveRichard MacCutchan21-Apr-10 21:03 

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.