pascal里可以调用windows api吗
答案:2 悬赏:40 手机版
解决时间 2021-02-28 11:05
- 提问者网友:情歌越听越心酸
- 2021-02-28 04:06
比如MessageBox这个函数,如果在fp里用的话该怎么写
最佳答案
- 五星知识达人网友:时间的尘埃
- 2021-02-28 05:05
引用windows单元然后直接使用就行了
以下是一个例子
uses windows;
begin
messagebox(0,'这是messagebox的例子,希望你喜欢!','hi~',0)
end.
以下是一个例子
uses windows;
begin
messagebox(0,'这是messagebox的例子,希望你喜欢!','hi~',0)
end.
全部回答
- 1楼网友:孤独入客枕
- 2021-02-28 05:14
该程序演示了如何用鼠标来获得任何像素的rgb颜色。该程序使用了计时器,间隔设置为0.01秒来捕捉事件,使用了getpixel , getcursorpos 和getdc winapi调用,来获得屏幕上任何地方的像素的颜色。 option explicit '在表单中加入计时器,使用鼠标移动到屏幕上任何一处,rgb颜色就会显示在表单中的caption中 ' private type pointapi x as long y as long end type ' private declare function getpixel lib "gdi32" (byval hdc as long, _ byval x as long, byval y as long) as long private declare function getcursorpos lib "user32" (lppoint as pointapi) as long private declare function getwindowdc lib "user32" (byval hwnd as long) as long ' private sub form_load() timer1.interval = 100 end sub ' private sub timer1_timer() dim tpos as pointapi dim stmp as string dim lcolor as long dim ldc as long ' ldc = getwindowdc(0) call getcursorpos(tpos) lcolor = getpixel(ldc, tpos.x, tpos.y) label2.backcolor = lcolor ' stmp = right$("000000" & hex(lcolor), 6) caption = "r:" & right$(stmp, 2) & " g:" & mid$(stmp, 3, 2) & " b:" & left$(stmp, 2) end sub 至于获取当前窗口,可以使用 public declare function getforegroundwindow lib "user32" () as long 获取当前活动窗体的句柄,再使用getwindowtext的api能获取到相应的标题啦! public declare function getforegroundwindow lib "user32" () as long public declare function sendmessage lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any) as long public const wm_gettext = &hd public function getwin() as string dim tmp as long dim ilen as long dim txt as string tmp = getforegroundwindow txt = string(255, chr(0)) ilen = sendmessage(tmp, wm_gettext, len(txt), byval txt) txt = left(txt, ilen) getwin=txt end function 以上代码是获取当前窗体的标题代码!(这里没使用getwindowtext的api) 参考资料:http://jxjy.yangtzeu.edu.cn/hsb/xuexiao/teach/jsjz7/21.htm
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯