1

I have window handle and I need get pixel color.

#include "Globals.h"
    void MainHamsterDlg::OnTimer(UINT nIDEvent)
    {
      Sleep(4000);
      HDC hDC = ::GetDC(tempHWND);
      COLORREF rgb = GetPixel(hDC,351,515);

        if(GetPixel(hDC,351,515) == RGB(33,30,28))
          AfxMessageBox(L"Please select or write correct name!");

      ::ReleaseDC(tempHWND, hDC);

       CDialog::OnTimer(nIDEvent);
    }

Debuging says that the COLORREF rgb = GetPixel(hDC,351,515); gets the value 3225917 do i need convert to rgb to check for compare? I dont uderstund what wrong there because i'm new in mfc.

#include "Globals.h"
    void WaitProcessDlg::OnTimer(UINT nIDEvent)
    {
      if(::FindWindow(NULL, str)){
       tempHWND = ::FindWindow(NULL, str);
       ::SetWindowText(tempHWND, L"Weather");
       EndDialog( 0 );
       KillTimer(IDC_PROGRESS1);
       }
      CDialog::OnTimer(nIDEvent);
    } 

Here window handle and its handles window. I checked with changing title.

I'm using Globals to transfer window handle from one dialog box to another.

Globals.h
-------------------
#pragma once
extern HWND tempHWND;
--------------------

So my question is do I need convert to RGB to check for compare? and how?

Klasik
  • 872
  • 1
  • 9
  • 29

1 Answers1

0

I use different code to make that and its work!

HDC hDC = CreateDC(L"DISPLAY",0,0,0);
COLORREF rgb5 = GetPixel(hDC,24,507);
Klasik
  • 872
  • 1
  • 9
  • 29