Welcome

首页 / 软件开发 / 汇编语言 / MASM32编程获取任务栏高度

MASM32编程获取任务栏高度2009-10-12 csdn 黄志斌现在偶想让偶的强制休息程序的剩余时间提示窗口在屏幕右下角提示,但是不能挡住任务栏,而要在伤务栏的上方

这可能需要获取任务栏的高度

还是自己查了一下API,找到了下面的方法:

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<; Function: 计算并显示系统任务栏高度;Author: PurpleEndurer;DevEnv: Win XP SP2 + MASM32 v7; log; ----------------------------------------------------; 2008-09-21 Created!;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.386.model flat, stdcalloption casemap:noneinclude masm32includewindows.incinclude masm32includekernel32.incincludelib masm32libkernel32.libinclude masm32includeuser32.incincludelib masm32libuser32.libGetTaskBarHeight proto.datag_hHInstanceHINSTANCE ?g_szAppName db "系统任务栏高度", 0g_szFmtPerD db "系统任务栏高度为:%d", 0g_szBuf200db 200 dup(0)g_szFailtGetHeight db "未能取得!", 0.codestart:invoke GetModuleHandle,NULLmovg_hHInstance, eaxinvoke GetTaskBarHeightinc eax.if ZERO?push MB_ICONERRORpush offset g_szAppName;push for MessageBox()push offset g_szFailtGetHeight ;push for MessageBox() .elsedec eaxinvoke wsprintf, addr g_szBuf200, addr g_szFmtPerD, eaxpush MB_ICONINFORMATION ;push for MessageBox()push offset g_szAppName ;push for MessageBox()push offset g_szBuf200;push for MessageBox().endifpush NULL ;push for MessageBox()call MessageBoxinvoke ExitProcess, eax;///////////////////////////////;Fun: 计算系统任务栏高度; In: (none);Out: 若失败eax=-1,否则eax=高度值; //////////////////////////////GetTaskBarHeight proclocal stDeskRect: RECT;--- 取桌面工作区大小invoke SystemParametersInfo, SPI_GETWORKAREA, NULL, addr stDeskRect, NULLtest eax, eax.if !ZERO? ; 取得了吗?;--- 如果桌面工作区左上角y坐标值不为零,; 说明任务栏在屏幕上方.IF stDeskRect.top != 0mov eax, stDeskRect.top ;工作区左上角y坐标值即任务栏高度.ELSE;--- 取屏幕高度invoke GetSystemMetrics, SM_CYSCREENtest eax, eaxjz @GetTaskBarHeightFailRet ;未能取得.if eax != stDeskRect.bottom;---如果屏幕高度与桌面工作区右下角y坐标值相同,; 那么任务栏在屏幕两侧,屏幕高度即任务栏高度; 否则任务栏在屏幕下方,屏幕高度与桌面工作区右下角y坐标值之差即即任务栏高度sub eax, stDeskRect.bottom.endif.ENDIF.else@GetTaskBarHeightFailRet:mov eax, -1.endifretGetTaskBarHeight endpend start