⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uo_supperbutton.sru

📁 一人很好的PB做的招生管理系统,是PB初学者良好的参考资料 在原口令编辑域中输入初始密码(第一使用时密码为:1234)
💻 SRU
📖 第 1 页 / 共 4 页
字号:

end variables

forward prototypes
public function long of_getstockicon (string as_stockbitmap, ref integer ai_imagetype)
public function long of_getmaskcolor (long al_bitmaphandle)
public function long of_geticonhandle (string as_iconname, integer ai_size)
public subroutine of_destroyrc ()
public subroutine of_getrect (toolbaralignment aa_align, ref tagrect ast_cbrect, ref tagrect ast_picrect, ref tagrect ast_textrect, integer ai_picsize)
public subroutine of_init_draw ()
public subroutine of_drawtransbk (long hdc)
public function integer of_getpicsize ()
public function boolean of_containselement (long al_src, long al_exponent)
public subroutine of_paint ()
public function integer of_makeregion (unsignedlong al_hwnd)
public subroutine of_drawgradient (unsignedlong al_hdc, tagrect rct, long al_endcolour, long al_startcolour, boolean ab_vertical)
public subroutine of_drawgradient (unsignedlong al_hwnd, long al_startcolour, long al_endcolour, boolean ab_vertical)
public function long of_drawline (long al_hdc, long al_x1, long al_y1, long al_x2, long al_y2, long al_color)
public function long combinergn (long al_hdc, long al_x1, long al_y1, long al_x2, long al_y2, long al_color)
public function long of_shiftcolor (long al_color, long al_value, boolean ab_isxp)
public subroutine of_drawrectangle (long al_hdc, long al_x, long al_y, long al_width, long al_height, long al_color, boolean ab_onlyborder)
public subroutine of_drawbkandborder (long hdc, ref tagrect ast_rect, boolean ab_focus)
public subroutine of_drawxp (long hdc, boolean normal, boolean mousemove, boolean ab_focus, boolean mousedown, tagrect rcsep)
public function integer controlregister (dragobject controlobject, string tip, integer flag)
public function integer localalloc (dragobject controlobject, string tip, integer flag)
public subroutine showtip (dragobject controlobject)
end prototypes

event ue_paint;
DefWindowProc(handle(this),message.Number,message.WordParm,message.LongParm	)

of_paint()

return 1

end event

event ue_lbuttondown;//draw pushdown state
ib_pushDown = true 
of_paint()

return 1
end event

event ue_mousemove;if (XPos<0 or YPos<0) or (XPos>=this.Width or YPos>this.Height) then
	IF ib_Captured THEN
		ib_Captured = false
		ib_PushDown= false
		ReleaseCapture()
		//draw normal state
		if not XP风格 then
		   of_paint()
		end if
	END IF
elseif GetCapture()<>handle(this) THEN
	SetCapture(handle(this))
	ib_Captured = true
	if KeyDown(KeyLeftButton!) THEN
		ib_PushDown= true
	end if
	//draw movein state
	if not XP风格 then
		of_paint()
	end if
end if

//显示提示信息
if 显示提示信息 then 
   ControlRegister(this,提示信息,0)
   Showtip(this)
end if

//判断鼠标是否在按钮上
If xPos < 0 Or yPos < 0  Or xPos > Width Or yPos > Height Then
	ib_MouseOnButton = FALSE
Else
	ib_MouseOnButton = TRUE
End If
end event

event ue_lbuttonup;//draw pushup(normal) state
if ib_pushDown then postevent("clicked")
ib_pushDown = false
ReleaseCapture()

of_paint()

This.SetFocus()

end event

event ue_size;
of_destroyrc() //尺寸变化了,重新初始化
of_init_draw()

end event

event ue_dbclk;
return 1
end event

event ue_keyup;ib_blup = true

IF Key = KeySpaceBar! OR Key = KeyEnter! THEN
	ib_pushdown = false
	post of_paint()
END IF

end event

event ue_keydown;ib_blup = false
 
IF Keydown( KeySpaceBar!) OR keydown(KeyEnter!) THEN
  IF NOT ib_pushdown THEN
   ib_pushdown = true
   post of_paint()
  
    elseif (Keydown( KeySpaceBar!) and Key <> KeySpaceBar!) or( Key <> KeyEnter! and keydown(KeyEnter!)) then 
    post of_paint()
  end if
 END IF

end event

event ue_enable;post of_paint()
end event

event readme();/*========================================================================*/
// 事件名称: readme in uo_imflatbutton * (pdm) inherited from commandbutton 
/*------------------------------------------------------------------------*/
// 声明:本按钮原型为“扁平按钮”,扁平按钮功能部分归原始作者所有
/*-------------------------------------------------------------------------*/
// 描述: 本对象为自定义按钮对象,修改自扁平按钮
//       主要功能为:扁平按钮形式 〔包括原扁平按钮的所有功能〕
//                   渐进色状态    〔具有渐近色的按钮〕
//                   正常按钮状态   〔修饰了的原始PB按钮〕
//                   新增两种XP风格按钮 〔焦点状态颜色不同〕
//                   图片按钮状态〔可用pb自己的图片〕
//                   椭圆形按钮状态    〔在以上几种按钮形态下把按钮转换为椭圆形〕
//                   提示信息显示 〔显示按钮的提示信息〕
//       用户可自定义各种属性,包括各种颜色、图片、状态等
//       具体属性请看按钮的属性值,注:按钮的属性为中文属性
//   
//   增加PB自带图片锁定功能〔如果图片为PB自带图片,只要选择按钮的PB自带图片
//                           属性即可锁定图片大小为原始尺寸〕
//   增加了所有状态的属性开关,包括:
//
//         椭圆形状〔确定按钮是否为椭圆形状〕
//         边框     〔确定按钮是否有边框〕
//         凸起效果  〔确定按钮是否有凸起效果〕
//         凸起效果渐进色背景 〔确定按钮是否有凸起效果渐进色背景〕
//         渐进色背景  〔确定按钮是否有渐进色背景〕
//         水平渐进    〔确定按钮渐进色背景为水平渐进还是竖直渐近〕
//         PB自带图片   〔锁定PB自带图片时的图片大小〕
//         提示信息显示  〔是否显示提示信息〕
//         按钮背景颜色设置 〔设置按钮的背景颜色〕
/*------------------------------------------------------------------------*/
// 说明:只包括一个按钮对象
/*------------------------------------------------------------------------*/
// 作者: pcm          日期: 2003-11-11
/*------------------------------------------------------------------------*/
// 联系方式:http://ourmis.com  pcm@ourmis.com
/*========================================================================*/

end event

public function long of_getstockicon (string as_stockbitmap, ref integer ai_imagetype);//////////////////////////////////////////////////////////////////////////////
//
//	函数名称:      Of_getstockicon
//	访问级别:  		Public
//	参数:          as_stockbitmap             stock位图名称
//                ai_imagetype               位图 or 图标标示 
//	返回值:        Long
//	功能描述:      得到系统stock位图相应的标识符
//////////////////////////////////////////////////////////////////////////////

Long  ll_Identifier

//检查参数
If IsNull(as_StockBitmap) Or as_StockBitmap="" Then Return -1

 ll_Identifier = FN_ResGetBitmapID(as_stockbitmap)
 
 if ll_Identifier<=0 then 
 	ll_Identifier = FN_ResGetIconID(as_stockbitmap)
	ai_imagetype= IMAGE_ICON
 else  //位图 
	ai_imagetype = IMAGE_BITMAP
 end if
 return ll_Identifier

end function

public function long of_getmaskcolor (long al_bitmaphandle);//////////////////////////////////////////////////////////////////////////////
//	函数名称:      Of_GetMaskColor
//	访问级别:  		Public
//	参数:          al_BitmapHandle          位图句柄
//	返回值:        Long
//	功能描述:      获得指定位图文件的Mask颜色,返回值为Mask颜色
// 补充说明:
//////////////////////////////////////////////////////////////////////////////
//	修改记录:2001-11-15
// 修改:pcm
////////////////////////////////////////////////////////////////////////////
String ls_Null
Long ll_Hdc,ll_HDCTemp,ll_HbmpTemp
Long ll_MaskColor = -1

ll_HDC = CreateDC("DISPLAY",ls_Null,ls_Null,0)

If ll_HDC<>0 Then
   //创建一个与指定设备兼容的内存上下文环境
   ll_HDCTemp = CreateCompatibleDC(ll_HDC)
   If ll_HDCTemp<>0 Then
      //选择一个对象到指定的设备上下文环境
      ll_HbmpTemp = SelectObject(ll_HDCTemp, al_BitMapHandle)
		//获得位图坐标(0,0)颜色值
      ll_MaskColor = GetPixel(ll_HDCTemp,0,0)

      SelectObject(ll_HDCTemp,ll_HbmpTemp)

		DeleteDC(ll_HDCTemp)
   End If
	
   DeleteDC(ll_HDC)
End If

Return ll_MaskColor
end function

public function long of_geticonhandle (string as_iconname, integer ai_size);//====================================================================
// Function: of_geticonhandle()
//--------------------------------------------------------------------
// Description: Get the handle of icon from the toolbaritemname of the menu
//--------------------------------------------------------------------
// Arguments: 
//		value	string	as_iconname		
//--------------------------------------------------------------------
// Returns:  long  IconHandle
//--------------------------------------------------------------------
// Modify History: 	pcm		Date: 2003.05.07
//	
//====================================================================

Long ll_BitmapHandle , ll_IconHandle , ll_Library , ll_Index=-1
Environment env
Integer rtn,li_imagetype
String ls_File
Long ll_identier
long ll_hIml

if pos(lower(as_iconname),'.ico')>0 then 
	ll_IconHandle= LoadImage(0,as_iconname,IMAGE_ICON,ai_size,ai_size,LR_LOADFROMFILE )
elseif pos(lower(as_iconname),'.bmp')>0 then 	
	ll_BitmapHandle =LoadImage(0,as_iconname,IMAGE_BITMAP,ai_size,ai_size,LR_LOADFROMFILE + LR_DEFAULTSIZE)

	ll_hIml = ImageList_Create (ai_size , ai_size , 33, 4, 4)
 	ll_Index = ImageList_AddMasked(ll_hIml , ll_BitmapHandle ,  Of_GetMaskColor(ll_BitmapHandle))
 	ll_IconHandle= ImageList_GetIcon( ll_hIml , ll_Index , 1)
  	//DeleteObject(ll_hIml)
	ImageList_Destroy(ll_hIml)
	DeleteObject(ll_BitmapHandle)
elseif pos(as_iconname,'!')>0 then 
	rtn = GetEnvironment(env)
   IF rtn <> 1 THEN
		MessageBox("TIP","Get the value is wrrong in the PowerBuilder Environment.",StopSign!,Ok!)
		Return -1
	End If
		
	ls_File = "PBVM" + String(env.PBMajorRevision) + "0.DLL"
	ll_Library = LoadLibrary(ls_File)
	ll_identier = Of_GetStockicon(as_iconname,li_imagetype)
	If ll_identier >0 and li_imagetype = IMAGE_BITMAP Then
	  		ll_BitmapHandle =  LoadBitmap ( ll_Library , ll_identier)
     		ll_hIml = ImageList_Create (16 , 16 , 33, 4, 4)
			ll_Index = ImageList_AddMasked(ll_hIml , ll_BitmapHandle ,  Of_GetMaskColor(ll_BitmapHandle))
			ll_IconHandle= ImageList_GetIcon( ll_hIml , ll_Index , 1)
 			//DeleteObject(ll_hIml)
			ImageList_Destroy(ll_hIml)
			DeleteObject(ll_BitmapHandle)
	elseIf ll_identier >0 and li_imagetype = IMAGE_ICON Then	
			ll_IconHandle= LoadImage(ll_Library,ll_identier,IMAGE_ICON,0,0, LR_DEFAULTSIZE )
	Else
			ll_index = -1
	End If
		
	FreeLibrary ( ll_Library )
else
	return 0
end if

return ll_IconHandle

end function

public subroutine of_destroyrc ();destroyicon(h_normalPic)
destroyicon(h_MovePic)
end subroutine

public subroutine of_getrect (toolbaralignment aa_align, ref tagrect ast_cbrect, ref tagrect ast_picrect, ref tagrect ast_textrect, integer ai_picsize);ast_textrect = ast_cbrect
ast_picrect = ast_cbrect
choose case aa_align
	case  alignatbottom!
        ast_textrect.bottom = ast_cbrect.bottom - ai_picsize -1
		  ast_picrect.top = ast_cbrect.bottom - ai_picsize
	case  alignatleft!
		  ast_textrect.left = ast_cbrect.left + ai_picsize +1
		  ast_picrect.right = ast_cbrect.left + ai_picsize
	case  alignatright!
		  ast_textrect.right = ast_cbrect.right - ai_picsize -1
		  ast_picrect.left = ast_cbrect.right - ai_picsize
	case  alignattop! 
        ast_textrect.top = ast_cbrect.top + ai_picsize +1
		  ast_picrect.bottom = ast_cbrect.top + ai_picsize
	case  floating! 
		//return this.Width
		
end choose



end subroutine

public subroutine of_init_draw ();//初始化一些变量

ii_picsize = of_getpicsize()

if 正常状态图片<>"" then h_normalPic = of_geticonhandle(正常状态图片,ii_picsize)
if 鼠标移入图片<>"" then h_MovePic = of_geticonhandle(鼠标移入图片,ii_picsize)
GetClientRect(handle(this),winRect) 


of_paint()




end subroutine

public subroutine of_drawtransbk (long hdc);//long clDC,bmpDC,hbmp,hbmpOldBk
//integer li_cbwidth,li_cbHeight,li_cbX,li_cbY
//
//li_cbwidth = UnitsToPixels ( width, XUnitsToPixels!)
//li_cbHeight = UnitsToPixels ( height, YUnitsToPixels!)
//li_cbX = UnitsToPixels ( X, XUnitsToPixels!)
//li_cbY = UnitsToPixels ( Y, YUnitsToPixels!)
//
//clDC=GetDC(handle(parent))
//tagRect rect
//GetClientRect(handle(this),rect)
//bmpDC = CreateCompatibleDC(clDC)
//hbmp=CreateCompatibleBitmap(clDC, li_cbwidth, li_cbHeight);
//hbmpOldBk = SelectObject(hdc,m_bmpBk);
//		m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
//	} // if
//
//	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0, SRCCOPY);
end subroutine

public function integer of_getpicsize ();integer li_refer,li_cbwidth,li_cbHeight

li_cbwidth = UnitsToPixels ( width, XUnitsToPixels!)
li_cbHeight = UnitsToPixels ( height, YUnitsToPixels!)

li_refer = min(li_cbwidth,li_cbHeight) *0.9 
li_refer = li_refer /8 
li_refer = li_refer*8
return li_refer




end function

public function boolean of_containselement (long al_src, long al_exponent);//判断一个数中的某个二进制位是否是1,也就是两个数求逻辑or后是否仍然是第一个数

//al_dst必须为2的整数次方(这个整数次方就是al_src的某一位,出于效率不作判断),否则结果不能预料


al_src = al_src/al_exponent

if mod(al_src,2) = 1 then
	return true
else
	return false
end if	
end function

public subroutine of_paint ();
long hdc
tagRect picRect,textRect
int li_x,li_y
long ll_hFont,ll_oldFont

Long   ll_IconWidth , ll_IconHeight 
//图标高度、宽度
ll_IconWidth = GetSystemMetrics(SM_CXICON)/2
ll_IconHeight = GetSystemMetrics(SM_CYICON)/2

hdc = getdc(handle(this))

if h_normalPic>0 then
 of_getrect(图片排列方式,winRect,picRect,textRect,ii_picsize)
else
 textRect = winRect
end if

if 图片排列方式 = alignatleft! then
	if PB自带图片 = false then
		li_y = (picRect.bottom - picRect.top - ii_picsize) /2
		li_x = li_y
	else
		li_y = (picRect.bottom - picRect.top - ll_IconHeight) /2
		li_x = li_y

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -