易语言, 取两点水平坐标值的问题!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了易语言, 取两点水平坐标值的问题!相关的知识,希望对你有一定的参考价值。

我现在想写这么一个程序: 自定义屏幕上两个点,程序自动取这两个点的水平坐标的绝对值。而且在选取两点的时候,希望屏幕是静止(定格在那里)的。 请问我人可以帮忙吗

参考技术A 意思是比如打开一个记事本,里面有很多的内容,光标在第10行,

但记事本未最大化,求高手赐教如何知道光标在屏幕上的x,y坐标的值?

谢谢
我找到以下代码,但好像要定义指针型变量,请问易如何定义指针型变量?
注意:当前光标就是当前焦点,何谓光标,就是一个类似:“|”的东西!
我现在需要得到它所在的坐标!
声明:发GetCursorPos不要来,视力不好的不要来,发WindowFromPoint的不要来! 看清楚说明!
2楼: 呵呵
GetCaretPos 用于获得光标相对于客户区的坐标
ClientToScreen 用于将客户区坐标转换为屏幕坐标
//----------------------------------------------
var
CurPoint, ScreenPoint: TPoint;
begin
GetCaretPos(CurPoint);
ScreenPoint := ClientToScreen(CurPoint);
label1.Caption := inttostr(ScreenPoint.X)+':'+inttostr(ScreenPoint.Y);
end;
3楼: 你要的结果就是pCaret,最后用SetBound,显示窗体。var
rect: TRect;
pCaret: TPoint;
focushld,windowhld:hwnd;
threadld:dword;
begin
//获得当前活动窗口的句柄
windowhld := GetForegroundWindow;
//获得窗口的进程名
threadld := GetWindowThreadProcessId(Windowhld,nil);
//将输入法的窗口进程附到活动窗口的进程中
AttachThreadInput(GetCurrentThreadId,threadld,true);
//获得当前的输入的窗口的句柄
字串9

focushld := GetFocus;
if focushld = 0 then Exit;
//获得光标的位置相对于活动窗口的坐标
GetCaretPos(pCaret);
//获得输入焦点窗口的区域
GetWindowRect(focushld,rect);
//获得光标位置相对于屏幕的坐标
pCaret.x := pCaret.x + rect.Left;
pCaret.y := pCaret.y + rect.Top;
//分离进程的附属
AttachThreadInput(GetCurrentThreadId,threadld,false);
//设置输入法的位置
SetBounds(pCaret.x, pCaret.y, Width, Height);
Show;
end;
4楼: GetMessagePos 返回最后消息的光标位置
LookupIconIdFromDirectory 返回图标或光标ID坐标 SetConsoleCursorPosition 设置控制台光标位置
GetClipCursor 返回限制光标的矩形的坐标
GetCursorPos 获取鼠标坐标
ClientToScreen 将窗体坐标转换为屏幕坐标
ScreenToClient 将屏幕坐标转换为窗体坐标
GetForegroundwindow获取当前激活的窗口
AttachThreadInput注入对方
GetFocus获取光标所在的窗口
GetWindowPos获取光标窗口的屏幕坐标+ 字串4
GetCaretPos获取光标坐标即最后光标所在的屏幕坐标

用mapwindowpoints能把窗体内的坐标转换为屏幕上的坐标
具体用法:
int MapWindowPoints(
HWND hWndFrom, // handle of window to be mapped from
HWND hWndTo, // handle of window to be mapped to
LPPOINT lpPoints, // address of structure array with points to map
UINT cPoints // number of structures in array
);
关于mapwindowpoints()我有个锁定光标范围的例子:
procedure TForm1.Button1Click(Sender: TObject);
var
Rect:TRect;
begin
Rect:=Button2.BoundsRect;
MapWindowPoints(Handle,0,Rect,2);//Rect为矩形区域,两点表示,所以最后参数为2,如果只转换一个点,最后参数为1;第一个参数代表窗体句柄,第二个参数为0时为屏幕
ClipCursor(@Rect);
end;

procedure SomePrc();
var
TempPoint: TPoint;
begin
GetCursorPos(TempPoint); //此句得到的是屏幕象素点的坐标
Windows.ScreenToClient(Handle, TempPoint); //此句就是把屏幕坐标转化为句柄为Handle的窗体的坐标
Windows.ClientToScreen(Handle, TempPoint); //此句就是把Handle句柄的窗体的坐标再化为屏幕坐标
字串1

-----------------------------------------------------------------------------------
我写了段E程序,但是会出错,跪求高手帮改一改,再传上来。
复件 复件 21.e (4 K) 下载次数:4
不用大家帮忙了。我已搞定
已搞定.e (4 K) 下载次数:24
参考技术B 自己摸索

在opengl中旋转后的坐标值

【中文标题】在opengl中旋转后的坐标值【英文标题】:coordinate values after rotation in opengl 【发布时间】:2014-05-25 13:58:17 【问题描述】:

假设我有一个立方体。说坐标值是这样的。 (1个手臂)

GLfloat vertA[3] =  0.5, 0.5, 0.5;
GLfloat vertB[3] = -0.5, 0.5, 0.5;
GLfloat vertC[3] = -0.5,-0.5, 0.5;
GLfloat vertD[3] =  0.5,-0.5, 0.5;
GLfloat vertE[3] =  0.5, 0.5,-0.5;
GLfloat vertF[3] = -0.5, 0.5,-0.5;
GLfloat vertG[3] = -0.5,-0.5,-0.5;
GLfloat vertH[3] =  0.5,-0.5,-0.5;

如果我翻译成这样

glTranslatef(1,2,3);

然后 1,2 和 3 将分别添加到 x,y 和 z 坐标。这些是翻译后的立方体的新坐标值。但是如果我将它旋转一定程度(有或没有翻译)

glRotatef(25,0,0,1);

现在旋转立方体的坐标是多少? 我在opengl中工作。我在 windows 上使用 c++。

【问题讨论】:

【参考方案1】:

您应该熟悉线性代数和变换矩阵。

glRotate 将生成一个rotation matrix 并将其后乘到当前矩阵。您应该注意这里的一些事情:glTranslate 不会直接向顶点坐标添加任何内容,glRotate 也不会更改坐标。所有这些所做的只是改变一个矩阵。该矩阵将累积所有变换的组成,并在绘制调用期间将一次应用于所有顶点。

在您的情况下,需要围绕 z 轴旋转 25 度,因此不会更改 z 坐标。旋转矩阵将如下所示

|  cos(25°)   -sin(25°)    0        0   |
|  sin(25°)    cos(25°)    0        0   |
|     0           0        1        0   |
|     0           0        0        1   |

要将此矩阵应用于向量 (x,y,z,w)^T,我们只需将矩阵乘以向量即可。 按照那个乘法的规则,我们得到一个新的向量

x' = cos(25°)*x -sin(25°)*y y' = sin(25°)*x +cos(25°)*y z' = z w' = w

这只是单独的旋转,不考虑平移。但是您可以将 zour 顶点的值放入 int 并返回转换后的结果。

【讨论】:

【参考方案2】:

在这里,您将当前矩阵在 z 轴上旋转 25 度。这是 glm::rotate 的代码,其作用相同。

template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> rotate
(
    detail::tmat4x4<T, P> const & m,
    T const & angle,
    detail::tvec3<T, P> const & v
)

    T c = cos(a);
    T s = sin(a);

    detail::tvec3<T, P> axis(normalize(v));
    detail::tvec3<T, P> temp((T(1) - c) * axis);

    detail::tmat4x4<T, P> Rotate(detail::tmat4x4<T, P>::_null);
    Rotate[0][0] = c + temp[0] * axis[0];
    Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
    Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];

    Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
    Rotate[1][1] = c + temp[1] * axis[1];
    Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];

    Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
    Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
    Rotate[2][2] = c + temp[2] * axis[2];

    detail::tmat4x4<T, P> Result(detail::tmat4x4<T, P>::_null);
    Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
    Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
    Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
    Result[3] = m[3];
    return Result;

【讨论】:

以上是关于易语言, 取两点水平坐标值的问题!的主要内容,如果未能解决你的问题,请参考以下文章

C语言求出平面坐标系中任意两点间的距离.点的信息(x坐标值,y坐标值,全为整数)通

易语言 取剪切板文本

易语言如何取剪切板中的部分文本?

易语言如何取剪切板中的部分文本?

易语言取剪辑板文本

易语言 取telnet返回值问题