vendredi 28 septembre 2018

using EnumWindows in namespaced class

All, I'm trying to implement EnumWindows behavior in order to close a running executable. I have created a standard class (h/cpp) and only have a couple simple functions in there. The callback function i have defined is causing compilation errors, which clear up as soon as i remove the class namespacing. See code below.

class ProcessLauncher()
{
public:
    ProcessLauncher() {}
    ~ProcessLauncher() {}

    bool CloseApplicationByTitle(const std::string& title)
    {
        //error says: argument of type "BOOL (__stdcall ProcessLauncher::*)(HWND hwnd, LPARAM lParam)" is incompatible with parameter of type "WNDENUMPROC"
        EnumWindows(DoActionByTitle, (LPARAM)WM_CLOSE);
    }

private:
    BOOL CALLBACK DoActionByTitle(HWND hwnd, LPARAM lParam)
    {
        //do stuff
    }
};

SO what in the world am i doing wrong here?

Aucun commentaire:

Enregistrer un commentaire