LoginSignup
2
3

More than 5 years have passed since last update.

[Windows][Win32]ウィンドウ取得時の条件・情報のダンプにつかうやつ

Last updated at Posted at 2015-10-15
#include <sstream>

const auto class_is = [](HWND hwnd, LPCTSTR classname) -> bool {
      TCHAR buffer[MAX_PATH] = { 0 };
      ::GetClassName(hwnd, buffer, MAX_PATH);
      // dump
      OutputDebugString(buffer);

      return _tcscmp(classname, buffer) == 0;
    };

const auto window_is = [](HWND hwnd, LPCTSTR windowtitle) -> bool {
      TCHAR buffer[MAX_PATH] = { 0 };
      TCHAR buffer_c[MAX_PATH] = { 0 };
      DWORD pid;
      ::GetWindowThreadProcessId(hwnd, &pid);
      ::GetWindowText(hwnd, buffer, MAX_PATH);
      ::GetClassName(hwnd, buffer_c, MAX_PATH);

      // dump
      std::basic_ostringstream< TCHAR > oss;
      oss << pid << _T(" : ")
        << buffer << _T(" : ")
        << cbuffer << _T("\r\n");

      //std::wstringstream ss;
      //ss << pid << L" : "
        //<< buffer << L" : "
        //<< buffer_c << L"\r\n";

      OutputDebugString(oss.str().c_str());

      return _tcscmp(windowtitle, buffer) == 0;
    };

ダンプ箇所をTCHAR型に変更

追記:2015/10/16

コメントで教えていただきました。ありがとうございます。ダンプ部分がwstring型になっていたので、
TCHAR型に変更したものに書き換えました。

2
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3