如何取得窗体的四个角的坐标?

chenyuandxm 2006-11-15 02:09:26
如题。
或者得到包括标题栏在内的窗体的height?应该如何实现,请各位指点,谢谢!
...全文
237 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnszyuxin 2006-11-15
  • 打赏
  • 举报
回复
LZ要的是什么样的窗体的Size
如果是_Screen的话,可以用_Vfp.Height来取得它的Height.
如果是Top Level Form的话,用Height取得的高度只是Client的高度.
加上你的Toolbar的高度和菜单的高度就是整个窗体的高度了.
当然,还可以使用Window Api 的GetWindowRect来取得四个角的坐标.
这大约是最准确的了
--------------------------------------------------------------
Declare Integer GetWindowRect In WinApi32 Integer,String @
Local lpRect As String
lpRect = REPLI (Chr(0), 16)
= GetWindowRect (YourForm.Hwnd, @lpRect)

lnWinLeft = buf2dword(SUBSTR(lpRect, 1,4))
lnWinTop = buf2dword(SUBSTR(lpRect, 5,4))
lnWinRight = buf2dword(SUBSTR(lpRect, 9,4))
lnWinBottom = buf2dword(SUBSTR(lpRect, 13,4))
lnWinWidth = lnWinRight - lnWinLeft + 1
lnWinHeight = lnWinBottom - lnWinTop + 1

? "*** My Form Rectangle list: "
? " left: " + STR(lnWinLeft, 6)
? " top: " + STR(lnWinTop, 6)
? " right: " + STR(lnWinRight, 6)
? " bottom: " + STR(lnWinBottom, 6)
? " width: " + STR(lnWinWidth, 6)
? " height: " + STR(lnWinHeight, 6)
--------------------------------------------------------------
FUNCTION buf2dword(cBuffer)
RETURN Asc(SUBSTR(cBuffer, 1,1)) + ;
BitLShift(Asc(SUBSTR(cBuffer, 2,1)), 8) +;
BitLShift(Asc(SUBSTR(cBuffer, 3,1)), 16) +;
BitLShift(Asc(SUBSTR(cBuffer, 4,1)), 24)
--------------------------------------------------------------




2,722

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧