PB开发的程序如何不显示在任务栏

         假设pb开发的程序的主窗口为w_main,如果需要在程序运行时,使w_main的标题不显示在操作系统的任务栏上,可以这样处理:

         (1)建立一个 visible 属性为 false 的 main!  类型窗口,假设为w_hide。

         (2)在application的open事件中,写:

open(w_hide)

open(w_main, w_hide)


然后在 w_main 的 close 事件中写:

if isvalid(w_hide) then close(w_hide)

        这样一来,运行后的pb程序就不会在任务栏上显示了,不过通过按 Alt + Tab 快捷键切换程序时,还是可以看到该pb程序。 如果需要使得pb程序在按 Alt + Tab 快捷键切换程序时不可见,则要加上以下几个步骤:

         (3)建立如下自定义不可视对象 nvo_hideprocess (将以下内容保存为本地文件 nvo_hideprocess.sru ,然后导入pbl中)

$PBExportHeader$nvo_hideprocess.sru
forward
global type nvo_hideprocess from nonvisualobject
end type
end forward

global type nvo_hideprocess from nonvisualobject autoinstantiate
end type

type prototypes
FUNCTION long GetWindowLong(ulong hwnd,long nIndex) LIBRARY "user32.dll" ALIAS FOR "GetWindowLongA"
 
FUNCTION long SetWindowlong(ulong hwnd,long nIndex,long dwNewLong) LIBRARY "user32.dll" ALIAS FOR "SetWindowLongA"
end prototypes

forward prototypes
public subroutine of_hideprocess (long ahwd)
public function boolean of_is_in (long al_in, long al_all)
end prototypes

public subroutine of_hideprocess (long ahwd);//隐藏进程
constant long WS_EX_TOOLWINDOW = 128
Constant long WS_EX_LAYERED = 524288
Constant long WS_EX_APPWINDOW  = 262144
Constant long GWL_EXSTYLE = - 20
constant long WS_EX_PALETTEWINDOW=392
long dwExStyle
dwExStyle = GetWindowLong(ahwd, GWL_EXSTYLE)
if not of_is_in(WS_EX_TOOLWINDOW, dwExStyle) then dwExStyle += WS_EX_TOOLWINDOW
 
SetWindowLong(ahwd, GWL_EXSTYLE, dwExStyle)
end subroutine

public function boolean of_is_in (long al_in, long al_all);
//====================================================================
// 判断数字al_in是不是包含在数字al_all中
// al_all是 1、2、4、8、16、32、64...等数字中的若干个的和
// al_in 是 1、2、4、8、16、32、64...等数字中的某一个
//====================================================================
dec ld
ld = log(al_in) / log(2)
if int(ld) <> ld then return false
long n, m
m = al_in + int(al_all / (al_in * 2)) * (2 * al_in)
if al_all >= m and al_all < m + al_in then return true
return false
end function

on nvo_hideprocess.create
call super::create
TriggerEvent( this, "constructor" )
end on

on nvo_hideprocess.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on


         (4)在 w_hide 的 open 事件中加上:

//Alt + Tab 时,如果不隐藏程序,则屏蔽以下代码
nvo_hideprocess ln
ln.of_hideprocess(handle(this))


 

       

猜你喜欢

转载自blog.csdn.net/yyoinge/article/details/6799141