PB中实现带工具栏的Popup窗口

PB中实现带工具栏的Popup窗口

作者:he1106()

 

 

 

       经常有人抱怨popup窗口太单调,加个菜单连工具条都没有,不过,嘿嘿!!!想点办法没有做不到的,好拉,进入正题。

 

 

 

       利用三个API函数:

 

 

 

      

       SetWindowLong  //设置窗口附加内存长型数值 

GetWindowLong  //设置窗口附加内存长型数值

       SetParent        //改变父窗口

 

 

 

 

 

 

       创建一个菜单,随便加点什么,不过别忘了Picture,保存为m_Toolbar_Top

 

 

 

我是这样设置的:

                     菜单

                            新增        SelectScript!

                            编辑        EditStops5!

                            保存        Save!

                            退出        Edit!

      

       在新增的Clicked事件写下代码:

       MessageBox(“”,”新增!”)  //用于测试菜单

 

 

 

 

 

 

       新建一个窗口,保存为w_Toolbar_Top,设置如下属性:

                     Window Type = Mdi Frame

                     Menu Name = m_Toolbar_Top

                     Control Menu = False

                     Maximize Box = False

                     Minimize Box = False

                     Resizable = False

                     Width = 2000

                     Height = 188

      

 

 

 

       声明Local External Functions

 

 

 

function ulong SetWindowLong(ulong whnd, int index, ulong newlong) library "user32.dll" alias for "SetWindowLongA"

function ulong GetWindowLong(ulong whnd, int index) library "user32.dll" alias for  "GetWindowLongA"

function long SetParent(long hwndChild, long hwndNewParent) library "user32.dll"

 

 

 

 

 

 

声明Instance Variables

 

 

 

window ParentWindow

 

 

 

 

 

 

Activate事件:

 

 

 

Post SetFocus(ParentWindow)

 

 

 

 

 

 

Open事件:

 

 

 

ParentWindow = Message.PowerObjectParm

 

 

 

String ls_Text

uLong ll_Style

CONSTANT Int GWL_STYLE = -16

CONSTANT uLong WS_CAPTION = 12582912

CONSTANT uLong WS_CHILD = 1073741824

CONSTANT uInt MF_BYPOSITION =   1024

 

 

 

// 改变当前的窗口

SetParent(handle(this), handle(parentwindow))

 

 

 

// 去掉掉状态栏

ll_style = GetWindowLong(handle(this), GWL_STYLE)

ll_style -= WS_CAPTION

SetWindowLong(handle(this), GWL_STYLE, ll_style)

// 将窗口设置为子窗口

ll_style += WS_CHILD

SetWindowLong(handle(this), GWL_STYLE, ll_style)

 

 

 

// 将工具条设置在窗口顶部

Move(0, 0)

Resize(parentwindow.WorkSpaceWidth(), 165)

 

 

 

 

 

 

 

 

 

最后新建一Popup类型的窗口,保存为w_Popup

 

 

 

Open事件

OpenWithParm(w_toolbar_Top, this)

 

 

 

在应用的Open事件:

ToolbarUserControl = False

open(w_popup)

 

 

 

运行就可以了,哈哈,什么,你说一个工具条不够用,想在左边再加一个,晕!!!

 

 

 

 

 

 

新建一个菜单,保存为m_Toopbar_Left(建议和m_Toopbar_Top的项不一样,这样容易分辨)

 

 

 

 

 

 

继承w_Toopbar_Top  保存为w_Toopbar_Left,设置窗口的属性:

                            Menu Name = m_Toopbar_Left

Width = 9

                  Height = 1500

                  Alignment = Left

 

 

 

Open事件中写上

//设置工具条在窗口的左边

Move(0, 105)

this.Resize(125, parentwindow.WorkSpaceHeight())

 

 

 

w_PopupOpen事件改为:

OpenWithParm(w_toolbar_Top, this)

OpenWithParm(w_toolbar_Lft, this)

 

 

 

这样上边一个,左边一个够用了吧,HOHO~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值