vendredi 24 juin 2016

FindWindow( ... ) is not 'finding' created message window

In my code I have a message class that I would like to 'Find' from another process.

class MyWindow : public CWnd
{
public:
  MyWindow::MyWindow(LPCTSTR pszClassName)
  {
    auto wcn = ::AfxRegisterWndClass(NULL);
    auto created = this->CreateEx(0, wcn, pszClassName, 0, 0, 0, 0, 0, HWND_MESSAGE, 0);
  }
};

Then somewhere in my main app.

...
auto pszClassName = _T("MyWindowClass");
auto wnd = new MyWindow(pszClassName);

auto p = FindWindow(pszClassName, nullptr); // = nullptr

// or using FindWindowExW( ... )
p = FindWindowExW(nullptr, nullptr, pszClassName, nullptr);// = nullptr
p = FindWindowExW(HWND_MESSAGE, nullptr, pszClassName, nullptr);// = nullptr

So, regardless what I do, I never seem to 'Find' the created window.

How can I create a window that can be 'Found' using FindWindow[Ex]

Aucun commentaire:

Enregistrer un commentaire