PB開發(fā)的程序如何不顯示在任務(wù)欄
來源:程序員人生 發(fā)布時(shí)間:2013-11-27 10:43:45 閱讀次數(shù):4230次
假設(shè)pb開發(fā)的程序的主窗口為w_main,如果需要在程序運(yùn)行時(shí),使w_main的標(biāo)題不顯示在操作系統(tǒng)的任務(wù)欄上,可以這樣處理:
(1)建立一個(gè)visible 屬性為false 的main! 類型窗口,假設(shè)為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)
這樣一來,運(yùn)行后的pb程序就不會(huì)在任務(wù)欄上顯示了,不過通過按Alt + Tab 快捷鍵切換程序時(shí),還是可以看到該pb程序。 如果需要使得pb程序在按Alt + Tab 快捷鍵切換程序時(shí)不可見,則要加上以下幾個(gè)步驟:
(3)建立如下自定義不可視對(duì)象nvo_hideprocess (將以下內(nèi)容保存為本地文件nvo_hideprocess.sru ,然后導(dǎo)入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);//隱藏進(jìn)程
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);
//====================================================================
// 判斷數(shù)字al_in是不是包含在數(shù)字al_all中
// al_all是1、2、4、8、16、32、64...等數(shù)字中的若干個(gè)的和
// al_in 是1、2、4、8、16、32、64...等數(shù)字中的某一個(gè)
//====================================================================
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 時(shí),如果不隱藏程序,則屏蔽以下代碼
nvo_hideprocess ln
ln.of_hideprocess(handle(this))
摘自 yyoinge的專欄
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)