假設pb開發的程序的主窗口為w_main,如果需要在程序運行時,使w_main的標題不顯示在操作系統的任務欄上,可以這樣處理:
(1)建立一個visible 屬性為false 的main! 類型窗口,假設為w_hide。
(2)在application的open事件中,寫:
[cpp]
open(w_hide)
open(w_main, w_hide)
然後在w_main 的close 事件中寫:
[cpp]
if isvalid(w_hide) then close(w_hide)
這樣一來,運行後的pb程序就不會在任務欄上顯示了,不過通過按Alt + Tab 快捷鍵切換程序時,還是可以看到該pb程序。 如果需要使得pb程序在按Alt + Tab 快捷鍵切換程序時不可見,則要加上以下幾個步驟:
(3)建立如下自定義不可視對象nvo_hideprocess (將以下內容保存為本地文件nvo_hideprocess.sru ,然後導入pbl中)
[cpp]
$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 事件中加上:
[cpp]
//Alt + Tab 時,如果不隱藏程序,則屏蔽以下代碼
nvo_hideprocess ln
ln.of_hideprocess(handle(this))
摘自 yyoinge的專欄