Retrieving Windows TaskBar Size and Location
A location and size of the Windows Taskbar can be retrieved with SHAppBarMessage Function
.
The code will run "As Is" in VFP 9.0 only because it uses new CTOBIN() parameters. In previous VFP versions the Windows API support classcan be used.
This is sample code. Add error handling and adjust to your requirements as necessary. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #DEFINE ABM_GETTASKBARPOS 5 #DEFINE ABE_LEFT 0 #DEFINE ABE_TOP 1 #DEFINE ABE_RIGHT 2 #DEFINE ABE_BOTTOM 3 lcTaskBarEdge = "left,Top,Right,Bottom" ***loWas = NEWOBJECT("WinApiSupport", "WinApiSupport.fxp") * Prepeare buffer for APPBARDATA Structure lcAppBarData = REPLICATE(CHR(0), 36) * retrieve info SHAppBarMessage( ABM_GETTASKBARPOS, @lcAppBarData) * get Edge info from the structure lnTaskBarEdge = Long2NumFromBuffer(lcAppBarData, 12) * Get the bounding rectangle coordinates lnLeft = Long2NumFromBuffer(lcAppBarData, 16) lnTop = Long2NumFromBuffer(lcAppBarData, 20) * By convention, the right and bottom edges of the rectangle are normally considered exclusive. * In other words, the pixel whose coordinates are ( right, bottom ) * lies immediately outside of the the rectangle. lnRight = Long2NumFromBuffer(lcAppBarData, 24) lnBottom= Long2NumFromBuffer(lcAppBarData, 28) ? 'TaskBar located on the ' + GETWORDNUM(lcTaskBarEdge, lnTaskBarEdge + 1, [,]) ? lnleft, lnTop, lnRight, lnBottom RETURN * Convert Long integer to VFP number from a buffer string at specified offset FUNCTION Long2NumFromBuffer(tcStr, tnOffset) RETURN CTOBIN(SUBSTR(tcStr, tnOffset+1,4), '4rs') * Safe DECLARE FUNCTION SHAppBarMessage(tnMessage, tcBuffer) DECLARE Long SHAppBarMessage in Shell32 Long dwMessage, STRING @pAppBarData RETURN SHAppBarMessage(tnMessage, @tcBuffer)
Comments