📄 uo_xpbutton.sru
字号:
// 作用范围: public
/*------------------------------------------------------------------------*/
// 描述: 得到控件中所要绘制的图像的句柄
/*------------------------------------------------------------------------*/
// 参数:
//
// <None>
/*------------------------------------------------------------------------*/
// 返回值: (NONE)
ulong ll_bmp
if IconOK =true then
if normalPicname<>'' then
if pos(lower(normalPicname),'.ico')>0 then
h_normalPic= LoadImage(0,normalPicname,IMAGE_ICON,IconSizeWidth,IconSizeHeight,LR_LOADFROMFILE )
else
h_normalPic=0
end if
end if
if MovePicName<>'' then
if pos(lower(MovePicName),'.ico')>0 then
h_MovePic= LoadImage(0,MovePicName,IMAGE_ICON,IconSizeWidth,IconSizeHeight,LR_LOADFROMFILE )
else
h_MovePic=0
end if
end if
end if
if BKpicName<>'' then
if pos(lower(BKpicName),'.bmp')>0 then
ll_bmp =LoadImage(0,BKpicName,IMAGE_BITMAP,usrrect.right,usrrect.bottom,16)
h_bkpic =CreatePatternBrush(ll_bmp)
Deleteobject(ll_bmp)
else
h_bkpic=0
end if
end if
end subroutine
public function long of_gettextpro ();/*========================================================================*/
// 函数名: of_gettextpro in uo_xpbutton * (xpbutton) (xpbutton.pbl) inherited from commandbutton
//
// 作用范围: public
/*------------------------------------------------------------------------*/
// 描述: 得到文本的绘制方式:单行或多行
/*------------------------------------------------------------------------*/
// 参数:
//
// <None>
/*------------------------------------------------------------------------*/
// 返回值: LONG
/*------------------------------------------------------------------------*/
// 作者: 张学禹 武汉科技学院 计007班 日期: 2003-9-25
/*========================================================================*/
Long ll_textline
Long ll_align
int li_number
choose Case CaptionAlign
Case Center!
ll_align = DT_CENTER
Case Left!
ll_align = DT_LEFT
Case Right!
ll_align = DT_RIGHT
End choose
If MultiLine Then
ll_textline = ll_align + DT_VCENTER
do while Pos ( text, "~~n" )<>0
text=Replace ( text, Pos ( text, '~~n' ), 2, '~n' )
loop
Else
ll_textline = DT_SINGLELINE + ll_align + DT_VCENTER
End If
return ll_textline
end function
public subroutine of_drawtext (long hd, integer buttontype);/*========================================================================*/
// 函数名: of_drawtext in uo_xpbutton * (xpbutton) xpbutton.pbl inherited from commandbutton
//
// 作用范围: public
/*------------------------------------------------------------------------*/
// 描述: 在控件上绘出文本
/*------------------------------------------------------------------------*/
// 参数:
//
// [value] long hd
// 窗口的设备场景句柄
// [value] integer buttontype
// 按钮状态
/*------------------------------------------------------------------------*/
// 返回值: (NONE)
/*------------------------------------------------------------------------*/
// 作者: 张学禹 武汉科技学院 计007班 日期: 2003-9-25
/*========================================================================*/
//'text Shadow
int li_sh,li_xx
rect lr_temp
long ll_textline
long ll_hFont,ll_oldFont,ll_oldFcolor,ll_fontcolor
SetBkMode(hd,1)
If text<> "" Then
choose Case buttontype
Case 0
ll_fontColor = FontColor
Case 1
ll_fontColor = FontColorOver
Case 2
ll_fontColor = FontColorDown
Case Else
ll_fontColor = FontColor
End choose
ll_textline=of_gettextpro( )
ll_hFont = Send(Handle(this), WM_GETFONT, 0, 0)
ll_oldFont = SelectObject(Hd, ll_hFont)
ll_oldFcolor = SetTextColor(hd,ShadowColor)
if FontShadow = true then
if enabled<>false then
If ShadowSize > 0 Then
For li_xx = 1 To ShadowSize
SetRect(lr_temp, textrect.left+li_xx + 1, textrect.top+li_xx + 1, textrect.right+ li_xx - 1, textrect.bottom + li_xx - 1)
DrawText(hD, text, -1, lr_temp, ll_textline)
Next
end if
end if
end if
if enabled=false then
SetTextColor(hd,8421504)
DrawText(hD, text, -1, textrect, ll_textline)
else
SetTextColor(hd,ll_fontcolor)
DrawText(hD, text, -1, textrect, ll_textline)
end if
SetTextColor(hd,ll_oldFcolor)
SelectObject(Hd, ll_oldFont)
end if
end subroutine
public subroutine of_destroy ();/*========================================================================*/
//销毁图像
/*========================================================================*/
destroyicon(h_normalPic)
destroyicon(h_MovePic)
if h_bkPic<> 0 then
deleteDC(h_bkPic)
h_bkPic= 0
end if
end subroutine
public subroutine of_gradientfilld (long hdc, rect rect, long ai_colorfrom, long ai_colorto, integer ai_style);int li_height, li_width, li, li_steps,li_halfwidth
//int li_left, li_right,li_top,li_bottom
//ulong hBrush, hOldBrush
//int r1,r2,g1,g2,b1,b2,vr,vg,vb
//
//CHOOSE CASE ai_style
// CASE STYLE_HGRADIENT
// li_steps = rect.Right - Rect.left
// li_width = 1
// of_color2rgb(ai_colorfrom,r1,g1,b1)
// of_color2rgb(ai_colorto,r2,g2,b2)
// vr = abs(r1 - r2) / li_steps
// vg = abs(g1 - g2) / li_steps
// vb = abs(b1 - b2) / li_steps
// IF r2<r1 THEN vr = vr * -1
// IF g2<g1 THEN vg = vg * -1
// IF b2<b1 THEN vb = vb * -1
// SetBkMode(hdc,TRANSPARENT)
// li_left = rect.left
// li_right = rect.right
// FOR li = 1 TO li_steps +1
// r2 = r1 + vr * li
// g2 = g1 + vg * li
// b2 = b1 + vb * li
// rect.left = li_left + (li - 1) *li_width
// rect.right = rect.left + li_width
// hBrush = CreateSolidBrush(RGB( r2, g2, b2))
// FillRect(hdc,rect,hBrush)
// DeleteObject(hBrush)
// NEXT
// Case STYLE_VGRADIENT
// li_steps = rect.bottom - rect.top
// li_width = 1
// of_color2rgb(ai_colorfrom,r1,g1,b1)
// of_color2rgb(ai_colorto,r2,g2,b2)
// vr = abs(r1 - r2) / li_steps
// vg = abs(g1 - g2) / li_steps
// vb = abs(b1 - b2) / li_steps
// IF r2<r1 THEN vr = vr * -1
// IF g2<g1 THEN vg = vg * -1
// IF b2<b1 THEN vb = vb * -1
// SetBkMode(hdc,TRANSPARENT)
// li_left = rect.top
// li_right = rect.bottom
// FOR li = 1 TO li_steps +1
// r2 = r1 + vr * li
// g2 = g1 + vg * li
// b2 = b1 + vb * li
// rect.top = li_left + (li - 1) * li_width
// rect.bottom = rect.top + li_width
// hBrush = CreateSolidBrush(RGB( r2, g2, b2))
// FillRect(hdc,rect,hBrush)
// DeleteObject(hBrush)
// NEXT
// Case STYLE_VEDGEGRADIENT
// tagrect rect2
// rect2=rect
// li_steps = (rect.bottom - rect.top) /2
// li_halfwidth= (rect.bottom - rect.top) /2
// li_top= rect.top
// li_bottom = rect.bottom
// rect.bottom = li_halfwidth + rect.top
// rect2.top=rect2.bottom - li_halfwidth
// li_width = 1
// of_color2rgb(ai_colorto,r1,g1,b1)
// of_color2rgb(ai_colorfrom,r2,g2,b2)
// vr = abs(r1 - r2) / li_steps
// vg = abs(g1 - g2) / li_steps
// vb = abs(b1 - b2) / li_steps
// IF r2<r1 THEN vr = vr * -1
// IF g2<g1 THEN vg = vg * -1
// IF b2<b1 THEN vb = vb * -1
// SetBkMode(hdc,TRANSPARENT)
// FOR li = 1 TO li_steps
// r2 = r1 + vr * li
// g2 = g1 + vg * li
// b2 = b1 + vb * li
// rect.top = li_top + (li - 1) * li_width
// rect.bottom = rect.top + li_width
// rect2.top = li_bottom - (li - 1) * li_width
// rect2.bottom = rect.bottom - li_width
// hBrush = CreateSolidBrush(RGB( r2, g2, b2))
// FillRect(hdc,rect,hBrush)
// FillRect(hdc,rect2,hBrush)
// DeleteObject(hBrush)
// NEXT
// CASE STYLE_VHEADERGRADIENT
// li_steps = (rect.bottom - rect.top) /2
// li_halfwidth= (rect.bottom - rect.top) /2
// li_left = rect.top
// li_right = rect.bottom
// rect.bottom = li_halfwidth + rect.top
// rect2.top=rect2.bottom - li_halfwidth
// li_width = 1
// of_color2rgb(ai_colorto,r1,g1,b1)
// of_color2rgb(ai_colorfrom,r2,g2,b2)
// vr = abs(r1 - r2) / li_steps
// vg = abs(g1 - g2) / li_steps
// vb = abs(b1 - b2) / li_steps
// IF r2<r1 THEN vr = vr * -1
// IF g2<g1 THEN vg = vg * -1
// IF b2<b1 THEN vb = vb * -1
// SetBkMode(hdc,TRANSPARENT)
// FOR li = 1 TO li_steps
// r2 = r1 + vr * li
// g2 = g1 + vg * li
// b2 = b1 + vb * li
// rect.top = li_left + (li - 1) * li_width
// rect.bottom = rect.top + li_width
// hBrush = CreateSolidBrush(RGB( r2, g2, b2))
// FillRect(hdc,rect,hBrush)
// DeleteObject(hBrush)
// NEXT
// rect.top = li_left + (li - 1) * li_width
// rect.bottom = li_right
// hBrush = CreateSolidBrush(RGB( r2, g2, b2))
// FillRect(hdc,rect,hBrush)
// DeleteObject(hBrush)
// CASE ELSE
// hBrush = CreateSolidBrush(ColorFrom)
// FillRect(hdc,rect,hBrush)
// DeleteObject(hBrush)
//END CHOOSE
//
end subroutine
on uo_xpbutton.create
end on
on uo_xpbutton.destroy
end on
event constructor;/*========================================================================*/
// 事件名称: constructor in uo_xpbutton * (xpbutton) xpbutton.pbl inherited from commandbutton
/*------------------------------------------------------------------------*/
// 描述: 修改按钮的风格为自绘式
/*------------------------------------------------------------------------*/
// 作者: 张学禹 武汉科技学院 计007班 日期: 2003-9-25
/*========================================================================*/
constant long BS_OWNERDRAW = 11//指定一个自绘式按钮
constant long GWL_STYLE = -16//设置新的窗口风格
constant long BS_PUSHBUTTON = 0//指定一个命令按钮
long ll_nStyle
ll_nStyle = GetWindowuLong(handle(this), GWL_STYLE)
ll_nStyle = ll_nStyle + BS_OWNERDRAW
SetWindowuLong(handle(this), GWL_STYLE, ll_nStyle)
GetClientRect(handle(this),UsrRect)
of_init()
SetRedraw(true)
end event
event getfocus;Focus = true
of_paint( 0)
end event
event losefocus;Focus = False
of_paint( 0)
end event
event destructor;//
of_destroy()
end event
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -