📄 uo_xpbutton.sru
字号:
event ue_paint;//窗口的客户区需要被画出
ValidateRect(handle(this),usrRect)
of_paint(0)
return 1
end event
event ue_keydown;If Key = keyenter! And enabled=true Then
of_paint(1)
End If
end event
event ue_keyup;If Key = keyenter! And enabled=true Then
of_paint(0)
End If
end event
event ue_mousedown; this.setFocus()
of_paint(2)
return 1
end event
event ue_mousemove; if (XPos<0 or YPos<0) or (XPos>=this.Width or YPos>this.Height) then //not in region
ReleaseCapture()
of_paint(0)
elseif GetCapture()<>handle(this) THEN
SetCapture(handle(this))
of_paint(1)
end if
end event
event uo_mouseup;postevent("clicked")
ReleaseCapture()
of_paint(0)
end event
event ue_enable;/*========================================================================*/
//控件的Enabled改变时所触发
/*========================================================================*/
post of_paint(0)
end event
event ue_resize;of_destroy()
of_init()
end event
event readme();/*========================================================================*/
// 事件名称: readme in uo_xpbutton * (xpbutton) (xpbutton.pbl) inherited from commandbutton
/*------------------------------------------------------------------------*/
// 描述: 属性说明
/*------------------------------------------------------------------------*/
// 作者: 张学禹 武汉科技学院 计007班 日期: 2003-9-27
/*========================================================================*//*========================================================================*/
///*========================================================================*/
//
//chimb 是否实现凹凸效果,建议:有背景图片或只有文本时选择此项
//alignment CaptionAlign 文本对齐方式
//IconOK =true 是否有按钮图片,不选此项是只显示文本,按钮呈正方形时可隐藏文本
//normalPicName
//MovePicName
//BKPicName
//IconSizeWidth = 16
//IconSizeHeight = 16
//ToolBarAlignment PIC_Align 图片对齐方式
//Borderok 是否显示边框
//BorderColor
//BorderColorOver
//lBorderColorDown
//文本区颜色设置
//BackColor
//BackColorOver
//BackColorDown
//图片区颜色设置
//BackColorIcon
//lackColorIconOver
//BackColorIconDown
//文本颜色设置
//FontColor
//FontColorOver
//FontColorDown
//FontShadow 文本是否有阴影
//ShadowColor 文本阴影颜色设置
//ShadowSize 阴影大小
//MultiLine 文本是否多行显示,提示:在转行位置插入~n即可,不限个数
//ShowFocus 是否显示焦点
//rowfocusind TOOLTIPTYPE 提示的窗口类型
//TooltipTitle 提示窗口是否有标题
//icon title 标题上的内容
//TooltipMaxWidth 提示窗口中一行文本的长度,大于此值时将多行显示
//TooltipBKColor提示窗口的背景颜色
//TooltipTextColor提示窗口种文本的颜色
////按钮提示对象
//n_tooltip tooltip
/*========================================================================*/
end event
public subroutine of_paint (integer buttontype);/*========================================================================*/
//绘制按钮函数
/*========================================================================*/
Long Brsh, Clr
long hdc
rect lr_temp
if enabled=false then
buttontype=0
end if
If Focus = true and ShowFocus And enabled=true Then
buttontype=2
End If
hdc = getdc(handle(this))
choose Case buttontype
//Button Normal
Case 0
if h_bkpic<>0 then
FillRect(hdc,usrRect,h_bkpic)
else
OleTranslateColor(BackColor, 0, clr)
Brsh = CreateSolidBrush(Clr)
FillRect(hDC, TextRect, Brsh)
DeleteObject (Brsh)
if iconok=true then
OleTranslateColor(BackColorIcon, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FillRect(hDC, picRect, Brsh)
DeleteObject (Brsh)
end if
if borderok=true then
OleTranslateColor(BorderColor, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FrameRect(hDC, UsrRect, Brsh)
DeleteObject( Brsh)
else
OleTranslateColor(BackColor, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FrameRect(hDC, UsrRect, Brsh)
DeleteObject( Brsh)
end if
end if
if not enabled then
DrawState (hDC, 0, 0, h_normalPic, 0, picrect.left+int((picrect.right -picrect.left -IconSizeWidth)/2),picrect.top+int((picrect.bottom -picrect.top -IconSizeHeight)/2), 0, 0, (DST_ICON + DSS_DISABLED))
else
DrawIconEx(hdc,picrect.left+int((picrect.right -picrect.left -IconSizeWidth)/2),picrect.top+int((picrect.bottom -picrect.top -IconSizeHeight)/2),h_normalPic,IconSizeWidth,IconSizeHeight,0,0,DST_ICON )
end if
//Button Over
Case 1
if h_bkpic<>0 then
FillRect(hdc,usrRect,h_bkpic)
else
OleTranslateColor(BackColorOver, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FillRect(hDC, TextRect, Brsh)
DeleteObject (Brsh)
if iconok=true then
OleTranslateColor(BackColorIconOver, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FillRect(hDC, PicRect, Brsh)
DeleteObject (Brsh)
end if
if borderok=true then
OleTranslateColor(BorderColorOver, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FrameRect(hDC, UsrRect, Brsh)
DeleteObject (Brsh)
end if
end if
if h_movepic<>0 then
DrawIconEx(hdc,picrect.left+int((picrect.right -picrect.left -IconSizeWidth)/2 ),picrect.top+int((picrect.bottom -picrect.top -IconSizeHeight)/2 ),h_movePic,IconSizeWidth,IconSizeHeight,0,0,DST_ICON )
elseif h_bkpic=0 then
DrawState (hDC, 0, 0, h_normalPic, 0, picrect.left+int((picrect.right -picrect.left -IconSizeWidth)/2+1),picrect.top+int((picrect.bottom -picrect.top -IconSizeHeight)/2+1), 0, 0, (DST_ICON + DSS_DISABLED))
DrawIconEx(hdc,picrect.left+int((picrect.right -picrect.left -IconSizeWidth)/2 -1),picrect.top+int((picrect.bottom -picrect.top -IconSizeHeight)/2 -1),h_normalPic,IconSizeWidth,IconSizeHeight,0,0,DST_ICON )
end if
if chimb=true then
drawEdge(hdc,usrrect, BDR_RAISEDINNER, BF_LEFT+BF_RIGHT+BF_TOP+BF_BOTTOM)
end if
// Button Down
Case 2
if h_bkpic<>0 then
FillRect(hdc,usrRect,h_bkpic)
else
OleTranslateColor(BackColorDown, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FillRect(hDC, TextRect, Brsh)
DeleteObject (Brsh)
if iconok=true then
OleTranslateColor(BackColorIconDown, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FillRect(hDC, PicRect, Brsh)
DeleteObject (Brsh)
end if
if borderok=true then
OleTranslateColor(BorderColorDown, 0, Clr)
Brsh = CreateSolidBrush(Clr)
FrameRect(hDC, UsrRect, Brsh)
DeleteObject (Brsh)
end if
end if
DrawIconEx(hdc,picrect.left+int((picrect.right -picrect.left -IconSizeWidth)/2 ),picrect.top+int((picrect.bottom -picrect.top -IconSizeHeight)/2 ),h_normalPic,IconSizeWidth,IconSizeHeight,0,0,DST_ICON )
if chimb=true then
DrawEdge(hdc,usrrect, BDR_SUNKENOUTER, BF_LEFT+BF_RIGHT+BF_TOP+BF_BOTTOM)
end if
End choose
of_drawtext( hdc,buttontype)
If Focus = true and ShowFocus And enabled=true Then
// SetRect(lr_temp, 2, 2, UsrRect.right - 2, UsrRect.bottom - 2)
// DrawFocusRect(hDC, lr_temp)
End If
releaseDC(handle(this),hdc)
end subroutine
public subroutine of_refresh ();/*========================================================================*/
//按钮刷新函数,动态改变按钮的属性时,可调用此函数进行刷新
/*========================================================================*/
of_destroy()
of_init()
of_paint(0)
end subroutine
public subroutine of_init ();/*========================================================================*/
// 函数名: of_init in uo_xpbutton * (xpbutton) (E:\powerbuilder\xpbutton\xpbutton.pbl) inherited from commandbutton
//
// 作用范围: public
/*------------------------------------------------------------------------*/
// 描述: 按钮初始化函数,获得按钮空间的分配情况以及初始化TOOLTIP
/*------------------------------------------------------------------------*/
// 参数:
//
// <None>
/*------------------------------------------------------------------------*/
// 返回值: (NONE)
/*------------------------------------------------------------------------*/
// 作者: 张学禹 武汉科技学院 计007班 日期: 2003-9-25
/*========================================================================*/
int li_title,li_stype
string ls_titlename
of_getpichandle( )
of_setrect( )
if TOOLTIPTYPE <> OFF! then
if TOOLTIPTYPE=Hand! then
li_stype=0
else
li_stype=1
end if
choose case title
case information!
li_title=1
ls_titlename="信息"
case none!
li_title=0
ls_titlename="提示"
case question!
li_title=3
ls_titlename="警告"
case stopsign!
li_title=2
ls_titlename="错误"
case exclamation!
li_title=1
ls_titlename="提示"
end choose
if TooltipTitle=true then
tooltip.of_controlregister(this,li_stype,this.tag,li_title,ls_titlename,TooltipMaxWidth,TooltipBKColor,TooltipTextColor)
else
ls_titlename=''
tooltip.of_controlregister(this,li_stype,this.tag,li_title,ls_titlename,TooltipMaxWidth,TooltipBKColor,TooltipTextColor)
end if
end if
end subroutine
public subroutine of_setrect ();/*========================================================================*/
// 函数名: of_setrect in uo_xpbutton * (xpbutton) (xpbutton.pbl) inherited from commandbutton
//
// 作用范围: public
/*------------------------------------------------------------------------*/
// 描述: 根据图片的位置分配按钮空间
/*------------------------------------------------------------------------*/
// 参数:
//
// <None>
/*------------------------------------------------------------------------*/
// 返回值: (NONE)
/*------------------------------------------------------------------------*/
// 作者: 张学禹 武汉科技学院 计007班 日期: 2003-9-25
/*========================================================================*/
if IconOK=true then
choose case PIC_Align
case Alignatleft!
setrect(PicRect, UsrRect.left+1, UsrRect.top+1,UsrRect.bottom , UsrRect.bottom -1)
setrect(TextRect, UsrRect.bottom, UsrRect.top+1, UsrRect.right -1,UsrRect.bottom -1)
case Alignattop!
setrect(PicRect, UsrRect.left+1, UsrRect.top+1,UsrRect.right -1, int(UsrRect.bottom/2 ))
setrect(TextRect, UsrRect.left+1, int(UsrRect.bottom/2), UsrRect.right -1,UsrRect.bottom -1)
case Alignatbottom!
setrect(PicRect, UsrRect.left+1, int(UsrRect.bottom/2), UsrRect.right -1,UsrRect.bottom -1)
setrect(TextRect, UsrRect.left+1, UsrRect.top+1,UsrRect.right -1, int(UsrRect.bottom/2 ))
case Alignatright!
setrect(TextRect, UsrRect.left+1, UsrRect.top+1,UsrRect.right -1 -UsrRect.bottom, UsrRect.bottom -1)
setrect(PicRect, UsrRect.right -1 -UsrRect.bottom, UsrRect.top+1, UsrRect.right -1,UsrRect.bottom -1)
case Floating!
TextRect=usrrect
PicRect=usrrect
end choose
else
TextRect=usrrect
end if
end subroutine
public subroutine of_getpichandle ();/*========================================================================*/
// 函数名: of_getpichandle in uo_xpbutton * (xpbutton) (E:\powerbuilder\xpbutton\xpbutton.pbl) inherited from commandbutton
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -