WM_DROPFILES not called on x64

918 Views Asked by At

How to make drag & drop? On the win32 machine it works without problems but on the x64 the WM_DROPFILES message is not called at all. Where is the problem?

static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch(msg) {
        case WM_CREATE: {   
      SetTimer(hWnd, 0, int(1000./24), NULL);
            DragAcceptFiles(hWnd, true);
            return 0;
        }
        case WM_DROPFILES: {    
            DEBUG;
            return 0;
        }
    case WM_DESTROY: 
            KillTimer(hWnd, 0);
      PostQuitMessage(0);
    break;
      return DefWindowProc(hWnd, msg, wParam, lParam);
    }
    return 0;
}

        HWND hWnd; WNDCLASSEX wCs; 
        static const char* wndClassName = "WndClass";

        wCs.cbSize          = sizeof wCs;
        wCs.style           = CS_HREDRAW | CS_VREDRAW;
        wCs.lpfnWndProc     = WindowProc;
        wCs.cbClsExtra      = 0;
        wCs.cbWndExtra      = 0;
        wCs.hInstance       = hInstance;
        wCs.hIcon           = LoadIcon(hInstance, MAKEINTRESOURCE(ID_MYICON));
        wCs.hCursor         = LoadCursor(NULL, IDC_ARROW);
        wCs.hbrBackground   = NULL;
        wCs.lpszMenuName    = NULL;
        wCs.lpszClassName   = wndClassName;
        wCs.hIconSm         = LoadIcon(hInstance, MAKEINTRESOURCE(ID_MYICON));

        if (RegisterClassEx(&wCs)) {
            hWnd = CreateWindowEx(
                WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES,           // extended window style
                wndClassName,   // registered class name
                TEXT("APP"),    // and window title
                WS_OVERLAPPEDWINDOW,        // window style
                CW_USEDEFAULT, CW_USEDEFAULT, g_winw, g_winh,   
                NULL, NULL, hInstance,      // handle to application instance
                this                        // if need to take pointer
            );
            SetWindowLongPtr(hWnd, GWLP_USERDATA, (LPARAM)this);
        }
        if(hWnd==NULL) {
            MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
            return E_FAIL;
        }
        if (s_winstate==3)
            ShowWindow(hWnd, SW_MAXIMIZE);
        else
            ShowWindow(hWnd, SW_SHOWNORMAL);
        UpdateWindow(hWnd);
        mHInstance=hInstance;       
        hfont = CreateFont(15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
        SendMessage(hWnd,  WM_SETFONT, (WPARAM)hfont,  TRUE);

I found in another topic from here that drag & drop would be problems with x64 Drag-and-drop from 32 to 64-bit

The difference is that the WM_DROPFILES message doesn't appear to me at all

1

There are 1 best solutions below

1
On

Adding

    ChangeWindowMessageFilter (WM_DROPFILES, MSGFLT_ADD);
    ChangeWindowMessageFilter (WM_COPYDATA, MSGFLT_ADD);
    ChangeWindowMessageFilter (0x0049, MSGFLT_ADD);

After SendMessage(hWnd, WM_SETFONT, (WPARAM)hfont, TRUE); solve the problem - thanks.