VC怎样获取屏幕取点的坐标

想通过屏幕取点,画三次Bezier曲线,怎么获取屏幕取点的坐标,并保存起来。如有源程序,万分感谢!... 想通过屏幕取点,画三次Bezier曲线,怎么获取屏幕取点的坐标,并保存起来。如有源程序,万分感谢! 展开
 我来答
匿名用户
2011-04-01
展开全部
你自己去研究下
// eg11.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include <stdio.h>

HWND MainHwnd;
HWND TrackHwnd;

UINT g_nXCoor;
UINT g_nYCoor;
//
LRESULT CALLBACK WndProcMain (HWND hWnd, UINT message, WPARAM wParam ,LPARAM lParam);
LRESULT CALLBACK WndProcTrack (HWND hWnd, UINT message, WPARAM wParam ,LPARAM lParam);

int _stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrev,
char * lpCmdLine, int nShowCmd )
{

WNDCLASSEX WndClassEx;

WndClassEx.cbSize = sizeof( WNDCLASSEX );
WndClassEx.style = NULL;
WndClassEx.lpfnWndProc = WndProcMain;

WndClassEx.cbClsExtra = 0;
WndClassEx.cbWndExtra = 0;
WndClassEx.hInstance = hInstance;
WndClassEx.hIcon = LoadIcon( NULL, IDI_APPLICATION );
WndClassEx.hCursor = LoadCursor( NULL, IDC_ARROW );
WndClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);

WndClassEx.lpszMenuName = NULL;
WndClassEx.lpszClassName = "MyWndClassMain";
WndClassEx.hIconSm = LoadIcon( NULL, IDI_APPLICATION );

::RegisterClassEx( &WndClassEx );

MainHwnd = CreateWindow ( "MyWndClassMain", "My First Windows", WS_OVERLAPPEDWINDOW,
100, 100, 600, 600, NULL, NULL, hInstance, NULL);

WndClassEx.lpfnWndProc = WndProcTrack;
WndClassEx.lpszClassName = "MyWndClassTrack";
::RegisterClassEx( &WndClassEx );

TrackHwnd = CreateWindow ("MyWndClassTrack", "TrackWindows", WS_OVERLAPPEDWINDOW | WS_CHILD,
0, 0, 200, 50, MainHwnd, NULL, hInstance, NULL);

ShowWindow (MainHwnd, nShowCmd );
ShowWindow (TrackHwnd, nShowCmd );

MSG msg;
while( GetMessage( &msg,NULL,NULL,NULL ) )
{
::DispatchMessage( &msg );
}
return 0;
}

/***************************************************************
* Name:

* Description:

* Input:

* Return:

* History:

* Warning:

****************************************************************/
LRESULT CALLBACK WndProcMain (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_MOUSEMOVE:

g_nXCoor = LOWORD( lParam );
g_nYCoor = HIWORD( lParam );

InvalidateRect( hWnd, NULL,TRUE );

MoveWindow (TrackHwnd, g_nXCoor + 15, g_nYCoor + 15, 200, 50, TRUE );
break;

case WM_PAINT:
{
PAINTSTRUCT PS;
HDC hDC;
RECT rectClient;

hDC = BeginPaint (hWnd, &PS);

GetClientRect ( hWnd, &rectClient);

MoveToEx (hDC, g_nXCoor, rectClient.top, NULL );
LineTo (hDC, g_nXCoor, rectClient.bottom);

MoveToEx (hDC, rectClient.left, g_nYCoor, NULL );
LineTo (hDC, rectClient.right, g_nYCoor);

EndPaint (hWnd, &PS);
}
break;

case WM_DESTROY:
::PostQuitMessage ( 0 );
break;

default:
return ::DefWindowProc(hWnd, message, wParam, lParam );
}

return TRUE;
}

/***************************************************************
* Name:

* Description:

* Input:

* Return:

* History:

* Warning:

****************************************************************/
LRESULT CALLBACK WndProcTrack (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_PAINT:
{
PAINTSTRUCT PS;
HDC hDC;
RECT rectClient;
CHAR strMousePosition[100];

hDC = BeginPaint (hWnd, &PS);

GetClientRect (hWnd, &rectClient);

sprintf (strMousePosition, "Mouse Pt: x= %4d y = %4d", g_nXCoor, g_nYCoor);

TextOut (hDC, 0, 0, strMousePosition, strlen ( strMousePosition));

EndPaint (hWnd, &PS);
}
break;

case WM_DESTROY:
::PostQuitMessage( 0 );
break;

default:

return ::DefWindowProc(hWnd, message, wParam, lParam );
}

return TRUE;
}
另外,虚机团上产品团购,超级便宜
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
天际scy
2011-03-31 · 超过10用户采纳过TA的回答
知道答主
回答量:56
采纳率:0%
帮助的人:25.9万
展开全部
用windows的消息机制,也能知道你当前鼠标的像素坐标。
LOWORD( lParam ), HIWORD( lParam ) 对应的是X,Y坐标
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2011-03-31
展开全部
api函数GetCursorPos
或者你用mfc
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式