OFNHookProc problem

I have tried to write a program, in which the GetOpenFileName dialog box does not close. However, it seems to be missing something, since it does close, ya dig?

I think that the problem is the OFNHookProc function, but I cannot identify it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uiMsg)
    {
        case WM_NOTIFY:
            NMHDR mess;
            OFNOTIFY ofno;
            memcpy(&ofno, &lParam, sizeof(OFNOTIFY));
            if (mess.code == CDN_FILEOK)
                SetWindowLong(mess.hwndFrom, DWL_MSGRESULT, 1);
            return 1;
            break;
        default:
            return 0;
            break;
    }
    return 0;
}


Thank you, and good luck.

EDIT: I want to specify, that in the compiler, I do not get any errors.
Last edited on
Naturally, I didn't copy the lParam data to the NMHDR mess structure, but this code doesn't work either:

1
2
3
4
5
6
7
case WM_NOTIFY:
            NMHDR mess;
            memcpy(&mess, &lParam, sizeof(NMHDR));
            if (mess.code == CDN_FILEOK)
                SetWindowLong(mess.hwndFrom, DWL_MSGRESULT, 1);
            return 1;
            break;


What am I doing wrong?
Now, the reason I confused NMHDR with OFNOTIFY, is that, on MSDN, there is one article about CDN_FILEOK on https://msdn.microsoft.com/en-us/library/windows/desktop/ms646857(v=vs.85).aspx which tells me, that lParam is a pointer to an OFNOTIFY structure. On the other hand, there is another article about WM_NOTIFY on https://msdn.microsoft.com/en-us/library/windows/desktop/bb775583(v=vs.85).aspx that tells me, that the same parameter is a pointer to an NMHDR structure.

I thought that CDN_FILEOK was some kind of submessage to WM_NOTIFY, but I seem to be missing something.
Last edited on
I have localised the problem to the SetWindowLong function. It fails when I run the program (it returns 0), but GetLastError returns 0 (it doesn't give me an error message). Since I am running on a 64 bit platform (Windows 8), I tried using SetWindowLongPtr instead, but nothing changed.

By the way, I do receive the CDN_FILEOK message, that I have confirmed. SetWindowLong is the only problem.
Nailed it! I had all kinds of ludicrous solutions to finding the right HWND, and I did not check the parameters for OFNHookProc of some reason. Anyway, goodbye.
Topic archived. No new replies allowed.