怎么获取鼠标点击图像的消息并获取点击的图像下点的像素灰度
如何获取鼠标点击图像的消息并获取点击的图像上点的像素灰度
具体用到的函数什么的,请教各位了,
最主要的是如何获取鼠标点击的消息,并将点击坐标给确定下来。。
------解决方案--------------------
SDK里面
GetCursorPos
GetPixel
WM_LBUTTONDOWN
------解决方案--------------------
PreTranslateMessage函数过滤WM_LBUTTONDOWN消息
GetPixel()得到像素点
------解决方案--------------------
Petizold写的例子,Programming Windows 5ed,chapter 8,Using the Timer for a Status Report
具体用到的函数什么的,请教各位了,
最主要的是如何获取鼠标点击的消息,并将点击坐标给确定下来。。
------解决方案--------------------
SDK里面
GetCursorPos
GetPixel
WM_LBUTTONDOWN
------解决方案--------------------
PreTranslateMessage函数过滤WM_LBUTTONDOWN消息
GetPixel()得到像素点
------解决方案--------------------
Petizold写的例子,Programming Windows 5ed,chapter 8,Using the Timer for a Status Report
/*------------------------------------------
WHATCLR.C -- Displays Color Under Cursor
(c) Charles Petzold, 1998
------------------------------------------*/
#include <windows.h>
#define ID_TIMER 1
void FindWindowSize (int *, int *) ;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("WhatClr") ;
HWND hwnd ;
int cxWindow, cyWindow ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW
------解决方案--------------------
CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}