分享
 
 
 

如何在PB中实现透明DATAWINDOW?

王朝system·作者佚名  2006-05-27
窄屏简体版  字體: |||超大  

1、简单一点的方法,先用一张大背景图放在WINDOW上,再用DW正好遮挡住的那部分图当作DATAWINDOW的背景图,且将该图置在DW的最底层,同时设各列的背景色为透明即可;

该方法优点是比较简单,缺点是只适用于DW,其他控件不适用,如:LABEL、TEXT、COMMANDBUTTON等;

2、麻烦一点的方法,用API的BITBLT,缺点是比较麻烦,优点是适用于绝大部分控件,效果图见:

http://blog.csdn.net/balloonman2002/gallery/image/63164.aspx

**************************************************************

方法二具体代码如下:

$PBExportHeader$w_trans.srw

forward

global type w_trans from Window

end type

type p_2 from picture within w_trans

end type

type st_2 from statictext within w_trans

end type

type st_1 from statictext within w_trans

end type

type dw_2 from datawindow within w_trans

end type

type dw_1 from datawindow within w_trans

end type

type p_1 from picture within w_trans

end type

end forward

global type w_trans from Window

int X=1056

int Y=480

int Width=2574

int Height=1700

boolean TitleBar=true

string Title="透明DW测试"

long BackColor=15780518

boolean ControlMenu=true

boolean MinBox=true

boolean MaxBox=true

boolean Resizable=true

event ue_paint pbm_paint

event ue_1024 pbm_custom01

p_2 p_2

st_2 st_2

st_1 st_1

dw_2 dw_2

dw_1 dw_1

p_1 p_1

end type

global w_trans w_trans

type prototypes

function long BitBlt ( long hdcdest, long xdest, long ydest, long nwidth,long nheight,long hdcsrc, long xsrc, long ysrc, long dwrop ) library "gdi32"

function long CreateBitmap ( long nwidth, long nheight, long nplanes, long nbitcount, long lpbits ) library "gdi32"

function long SetBkColor ( long hdc, long crcolor ) library "gdi32"

function long SelectObject ( long hdc, long hobject ) library "gdi32"

function long CreateCompatibleBitmap ( long hdc, long nwidth, long nheight ) library "gdi32"

function long CreateCompatibleDC ( long hdc ) library "gdi32"

function long DeleteDC ( long hdc ) library "gdi32"

function long DeleteObject ( long hobject ) library "gdi32"

function long GetDC ( long hwnd ) library "user32"

function Integer ReleaseDC ( long hwnd, long hdc ) library "user32"

end prototypes

type variables

Long il_SrcDC, il_DstDC,il_MapDstDC_Old,il_MapDstHandle, il_OldMapDstHandle,il_SrcWidth,il_SrcHeight,il_color

constant long SRCCOPY = 13369376

constant long NOTSRCCOPY = 3342344

constant long SRCAND = 8913094

constant long SRCINVERT = 6684742

dragobject io_obj

long il_count

OLEObject demo

end variables

forward prototypes

public subroutine wf_maketrans ()

public subroutine wf_makedc ()

public subroutine wf_maketrans ()

public subroutine wf_makedc ()

end prototypes

event ue_paint;//post wf_formbak()

end event

event ue_1024;messagebox("demo","demo")

end event

public subroutine wf_maketrans ();long ll_oldBackGround

Long ll_MapSrcDc,ll_MapDstDC

Long ll_MapSrcHandle, ll_OldMapSrcHandle,ll_MapDstHandle,ll_OldMapDstHandle

Long ll_maskDC, ll_InvertDC, ll_maskHandle, ll_InvertHandle, ll_oldMaskHandle, ll_OldInvertHandle

ll_maskDc = CreateCompatibleDC(il_SrcDC)

ll_maskHandle = CreateBitmap(il_SrcWidth, il_SrcHeight, 1, 1, 0)

ll_OldMaskHandle = SelectObject(ll_MaskDC, ll_MaskHandle)

ll_InvertDC = CreateCompatibleDC(ll_maskDc)

ll_InvertHandle = CreateBitmap(il_SrcWidth, il_SrcHeight, 1, 1, 0)

ll_OldInvertHandle = SelectObject(ll_InvertDC, ll_InvertHandle)

ll_oldBackGround = SetBkColor(il_SrcDC, il_color)

BitBlt(ll_maskDc, 0, 0, il_SrcWidth, il_SrcHeight, il_SrcDC, 0, 0, SRCCOPY)

SetBkColor(il_SrcDC, ll_oldBackGround)

BitBlt( ll_invertDC, 0, 0,il_SrcWidth, il_SrcHeight, ll_maskDC, 0, 0, NOTSRCCOPY)

ll_MapDstDC = CreateCompatibleDC(il_mapdstdc_old)

ll_MapDstHandle = CreateCompatibleBitmap(il_mapdstdc_old, il_SrcWidth, il_SrcHeight)

ll_OldMapDstHandle = SelectObject(ll_MapDstDC, ll_MapDstHandle)

ll_MapSrcDC = CreateCompatibleDC(il_SrcDC)

ll_MapSrcHandle = CreateCompatibleBitmap(il_SrcDC, il_SrcWidth, il_SrcHeight)

ll_OldMapSrcHandle = SelectObject(ll_MapSrcDC, ll_MapSrcHandle)

BitBlt(ll_MapSrcDC, 0, 0, il_SrcWidth, il_SrcHeight, il_SrcDC, 0, 0, SRCCOPY)

BitBlt(ll_MapSrcDc, 0, 0, il_SrcWidth, il_SrcHeight, ll_InvertDC, 0, 0, SRCAND)

BitBlt(ll_MapDstDC, 0, 0, il_SrcWidth, il_SrcHeight, il_MapDstDC_Old, 0,0, SRCCOPY)

BitBlt(ll_MapDstDC, 0, 0, il_SrcWidth, il_SrcHeight, ll_MaskDC, 0, 0 ,SRCAND)

BitBlt(ll_MapDstDC, 0, 0, il_SrcWidth, il_SrcHeight, ll_MapSrcDC, 0 ,0 , SRCINVERT)

BitBlt(il_SrcDC,0,0,il_SrcWidth,il_SrcHeight,ll_MapDstDC,0,0, SRCCOPY)

ll_MaskHandle = SelectObject(ll_MaskDC, ll_OldMaskHandle)

DeleteObject(ll_MaskHandle)

DeleteDC(ll_MaskDC)

ll_Inverthandle = SelectObject(ll_InvertDC, ll_OldInvertHandle)

DeleteObject(ll_InvertHandle)

DeleteDC(ll_InvertDC)

ll_MapSrcHandle = SelectObject(ll_MapSrcDC, ll_OldMapSrcHandle)

DeleteObject(ll_MapSrchandle)

DeleteDC(ll_MapSrcDC)

ll_MapDstHandle = SelectObject(ll_MapDstDC, ll_OldMapDstHandle)

DeleteObject(ll_MapDsthandle)

DeleteDC(ll_MapDstDC)

end subroutine

public subroutine wf_makedc ();Integer DRAWX, DRAWY

il_SrcWidth = UnitsToPixels(io_obj.Width, XUnitsToPixels!)

il_SrcHeight = UnitsToPixels(io_obj.Height, YUnitsToPixels!)

DRAWX = UnitsToPixels(io_obj.X, XUnitsToPixels!)

DRAWY = UnitsToPixels(io_obj.Y, YUnitsToPixels!)

il_MapDstDC_Old = CreateCompatibleDC(il_DstDC)

il_MapDstHandle = CreateCompatibleBitmap(il_DstDC, il_SrcWidth, il_SrcHeight)

il_OldMapDstHandle = SelectObject(il_MapDstDC_Old, il_MapDstHandle)

io_obj.Hide()

p_1.setredraw(true)

BitBlt(il_MapDstDC_Old, 0, 0, il_SrcWidth, il_SrcHeight, il_DstDC, DRAWX, DRAWY, SRCCOPY)

io_obj.show()

end subroutine

on w_trans.create

this.p_2=create p_2

this.st_2=create st_2

this.st_1=create st_1

this.dw_2=create dw_2

this.dw_1=create dw_1

this.p_1=create p_1

this.Control[]={this.p_2,&

this.st_2,&

this.st_1,&

this.dw_2,&

this.dw_1,&

this.p_1}

end on

on w_trans.destroy

destroy(this.p_2)

destroy(this.st_2)

destroy(this.st_1)

destroy(this.dw_2)

destroy(this.dw_1)

destroy(this.p_1)

end on

event open;io_obj = dw_1

il_color = rgb(255,255,255)

il_DstDC = GetDC(Handle(io_obj.Getparent()))

il_SrcDC = GetDC(Handle(io_obj))

dw_1.insertrow(0)

dw_2.insertrow(0)

post wf_makedc()

end event

event close;ReleaseDC(handle(this),il_DstDC)

ReleaseDC(handle(this),il_SrcDC)

il_MapDstHandle = SelectObject(il_MapDstDC_Old, il_OldMapDstHandle)

DeleteObject(il_MapDstHandle)

DeleteDC(il_MapDstDC_Old)

end event

type p_2 from picture within w_trans

int X=1490

int Y=252

int Width=677

int Height=1216

string PictureName="c:\qq2000\newskins\雅典奥运\background.bmp"

boolean FocusRectangle=false

end type

type st_2 from statictext within w_trans

int X=1326

int Y=80

int Width=928

int Height=96

boolean Enabled=false

string Text="普通DW演示:"

boolean FocusRectangle=false

long TextColor=33554432

long BackColor=15780518

int TextSize=-12

int Weight=400

string FaceName="Arial"

FontCharSet FontCharSet=Ansi!

FontFamily FontFamily=Swiss!

FontPitch FontPitch=Variable!

end type

type st_1 from statictext within w_trans

int X=123

int Y=88

int Width=928

int Height=96

boolean Enabled=false

string Text="透明DW演示:"

boolean FocusRectangle=false

long TextColor=33554432

long BackColor=15780518

int TextSize=-12

int Weight=400

string FaceName="Arial"

FontCharSet FontCharSet=Ansi!

FontFamily FontFamily=Swiss!

FontPitch FontPitch=Variable!

end type

type dw_2 from datawindow within w_trans

int X=1358

int Y=336

int Width=992

int Height=1036

int TabOrder=20

boolean BringToTop=true

string DataObject="demo"

boolean Border=false

boolean HScrollBar=true

boolean VScrollBar=true

boolean LiveScroll=true

end type

type dw_1 from datawindow within w_trans

event lbuttondown pbm_lbuttondown

event lbuttonup pbm_lbuttonup

event ue_paint pbm_paint

int X=110

int Y=336

int Width=992

int Height=1036

int TabOrder=10

boolean BringToTop=true

string DataObject="demo"

boolean Border=false

boolean HScrollBar=true

boolean VScrollBar=true

boolean LiveScroll=true

end type

event ue_paint;post wf_maketrans()

end event

event rowfocuschanging;//this.visible = false

//this.visible = true

wf_maketrans()

//this.setfocus()

end event

event scrollvertical;wf_maketrans()

end event

type p_1 from picture within w_trans

int X=233

int Y=252

int Width=677

int Height=1216

string PictureName="c:\qq2000\newskins\雅典奥运\background.bmp"

boolean FocusRectangle=false

end type

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有