各位大虾,麻烦你进来看看!我的显示或隐藏Windows的任务栏的API函数调用错在哪里?

时间:2021-11-28 20:16:07
我知道任务栏是一个特殊的窗口,它的窗口类为:Shell—TrayWnd,没有标题,只能用FindWindowEx函数来取得它的句柄: 

  Function long FindWindowEx(long ph, long ch, ref String cn, ref String wn) Library "user32" 
  Function Long ShowWindow(Long hWnd, Long nCmdShow ) Library "user32" 

  用ShowWindow来显示或隐藏窗口:
    
    ulong lul_size = 232 
    string  wn
    uint handle

    wn = Space (lul_size)
     
   handle = FindWindowEx(0,0,"shell—TrayWnd", wn)//wn为空串 

  ShowWindow(handle,0)//隐藏任务栏 

可我一SAVE,它就报错:(0010): Error    c0082: Reference argument must be a non-constant and non-readonly variable reference.
    我要怎样才能得到任务栏的句柄啊?

6 个解决方案

#1


试试这个看
FUNCTION ulong FindWindowA(ulong lpClassName,ref string lpWindowName) LIBRARY "user32.dll"

#2


1   FUNCTION ulong FindWindowEx(ulong hWnd1,ulong hWnd2,ref string lpsz1,ref string lpsz2) LIBRARY "user32.dll" ALIAS FOR "FindWindowExA"
Function Long ShowWindow(Long hWnd, Long nCmdShow) Library "user32.dll"


integer handle
string wn,str_win
str_win="Shell_TrayWnd"
setnull(wn)

handle = FindWindowEX(0,0,str_win,wn) //wn为空串 

ShowWindow(handle,0)// 任务栏隐藏
ShowWindow(handle,5)// 任务栏显示
其实用setposition(topmost!)也可以,在窗口的activate事件里。只是要setposition(notopmost!)

#3


string ls_tmp
ls_tmp = "shell—TrayWnd"
handle = FindWindowEx(0,0,ls_tmp,wn)

#4


Function long FindWindowExA ( long hWnd, long hWndChild, ref string lpszClassName, ref string lpszWindow) library 'user32' 

handle=FindWindowExA (0,0,Shell_TrayWnd,wn)

#5


呵呵,我也遇到过,就是有需要有返回值的参数,不能写常数。
写个变量,付个值就成。

#6


谢谢大家,我终于按照aqua_w(星期天)的方法搞定了,以后还请大家多多关照!

#1


试试这个看
FUNCTION ulong FindWindowA(ulong lpClassName,ref string lpWindowName) LIBRARY "user32.dll"

#2


1   FUNCTION ulong FindWindowEx(ulong hWnd1,ulong hWnd2,ref string lpsz1,ref string lpsz2) LIBRARY "user32.dll" ALIAS FOR "FindWindowExA"
Function Long ShowWindow(Long hWnd, Long nCmdShow) Library "user32.dll"


integer handle
string wn,str_win
str_win="Shell_TrayWnd"
setnull(wn)

handle = FindWindowEX(0,0,str_win,wn) //wn为空串 

ShowWindow(handle,0)// 任务栏隐藏
ShowWindow(handle,5)// 任务栏显示
其实用setposition(topmost!)也可以,在窗口的activate事件里。只是要setposition(notopmost!)

#3


string ls_tmp
ls_tmp = "shell—TrayWnd"
handle = FindWindowEx(0,0,ls_tmp,wn)

#4


Function long FindWindowExA ( long hWnd, long hWndChild, ref string lpszClassName, ref string lpszWindow) library 'user32' 

handle=FindWindowExA (0,0,Shell_TrayWnd,wn)

#5


呵呵,我也遇到过,就是有需要有返回值的参数,不能写常数。
写个变量,付个值就成。

#6


谢谢大家,我终于按照aqua_w(星期天)的方法搞定了,以后还请大家多多关照!