Advertisement
Guest User

HB pB v2

a guest
Jun 10th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance,Force
  2. SetBatchLines,-1
  3. #NoEnv
  4. ListLines,Off
  5. Gdip_Startup()
  6. global HB_Button:=[]
  7.  
  8. Gui,1:+AlwaysOnTop
  9. Gui,1:Color,% Button_Background_Color:="003399"
  10. Gui,1:Font,cWhite s10
  11.  
  12. ;###############################################################################################################################################
  13. ;###############################################################################################################################################
  14. ; Prototype
  15. ; HB_Button.Push(New pButton_V2(x:=10, y:=10, w:=100, h:=30, Window:="1", Label:="", Text:="HB pButton", Font:="Arial", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color:="222222", Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="FFFF00", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:="", Text_YOffset:=""))
  16. ;###############################################################################################################################################
  17. ;###############################################################################################################################################
  18.  
  19. HB_Button.Push(New pButton_V2(x:=10
  20.                             , y:=10
  21.                             , w:=146
  22.                             , h:=50
  23.                             , Window:="1"
  24.                             , Label:="test_Label"
  25.                             , Text:="HB pButtons v2"
  26.                             , Font:="Arial"
  27.                             , Font_Size:="12 Bold"
  28.                             , Font_Color_Top:="FFFFFF"
  29.                             , Font_Color_Bottom:="000000"
  30.                             , Button_Background_Color
  31.                             , Button_Top_Color_Default:="333333"
  32.                             , Button_Top_Color_Hover:="77ff77"
  33.                             , Button_Top_Color_Pressed:="338833"
  34.                             , Button_Top_Trim_Color_Default:="555555"
  35.                             , Button_Top_Trim_Color_Hover:="00ff00"
  36.                             , Button_Top_Trim_Color_Pressed:="222222"
  37.                             , Button_Bottom_Trim_Color_Default:="000000"
  38.                             , Button_Bottom_Trim_Color_Hover:="00ff00"
  39.                             , Button_Bottom_Trim_Color_Pressed:="555555"
  40.                             , Button_Shadow_Color:="000000"
  41.                             , Font_Color_Top_Hover:="000000"
  42.                             , Font_Color_Bottom_Hover:="00ff00"
  43.                             , Font_Color_Top_Pressed:="00ff00"
  44.                             , Font_Color_Bottom_Pressed:="222222"
  45.                             , Text_YOffset:=-2))
  46.                            
  47. ;###############################################################################################################################################
  48. ;###############################################################################################################################################
  49.  
  50. HB_Button.Push(New pButton_V2(x+=w+10, y:=10, w:=100, h:=30, Window:="1", Label:="Test_Label", Text:="HB pButton", Font:="Segoe Ui", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="FFFF00", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:="", Text_YOffset:=-4))
  51. HB_Button.Push(New pButton_V2(x+=w+10, y:=10, w:=100, h:=40, Window:="1", Label:="Test_Function", Text:="HB pButton", Font:="Arial Black", Font_Size:="10", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="FFFF00", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:=""))
  52.  
  53. HB_Button.Push(New pButton_V2(x:=10, y+=h+20, w:=380, h:=40, Window:="1", Label:="Test_Label", Text:="HB pButton`n`n", Font:="Segoe UI Black", Font_Size:="12", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="FFFFFF", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:=""))
  54. HB_Button.Push(New pButton_V2(x:=10, y+=h+5, w:=380, h:=40, Window:="1", Label:="Test_Function", Text:="Some Random Button Text", Font:="Arial", Font_Size:="12 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="006699", Button_Top_Color_Hover:="0099bb", Button_Top_Color_Pressed:="002255", Button_Top_Trim_Color_Default:="888888", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:=""))
  55. HB_Button.Push(New pButton_V2(x:=10, y+=h+5, w:=380, h:=40, Window:="1", Label:="Test_Label", Text:="HB pButton", Font:="Arial", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="880000", Button_Top_Color_Hover:="aa0000", Button_Top_Color_Pressed:="660000", Button_Top_Trim_Color_Default:="ff0000", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="000000", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:=""))
  56. HB_Button.Push(New pButton_V2(x:=10, y+=h+5, w:=380, h:=40, Window:="1", Label:="Test_Label", Text:="HB pButton", Font:="Arial", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="ED5B0B", Button_Top_Color_Hover:="FF932D", Button_Top_Color_Pressed:="FE370A", Button_Top_Trim_Color_Default:="555555", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="555555", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="44", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:=""))
  57. HB_Button.Push(New pButton_V2(x:=10, y+=h+5, w:=380, h:=40, Window:="1", Label:="Test_Label", Text:="HB pButton", Font:="Arial", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color, Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="555555", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="555555", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="44", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:=""))
  58.  
  59. Gui,1:Show,% "x" A_ScreenWidth-450 " y100 w400 h300 NA",HB pButton Class v2
  60.  
  61. SetTimer,HB_Button_Hover,50
  62.  
  63. return
  64.  
  65. GuiClose:
  66. GuiContextMenu:
  67. *ESC::
  68.     ExitApp
  69.  
  70. Test_Label:
  71.     hz:=400
  72.     loop, 3
  73.         SoundBeep,% hz+=100
  74.     return
  75.  
  76. Test_Function(){
  77.     hz:=900
  78.     loop, 3
  79.         SoundBeep,% hz+=100
  80. }
  81.  
  82. HB_Button_Hover(){
  83.     static Hover_On,Index
  84.     MouseGetPos,,,,ctrl,2
  85.     if(!Hover_On&&ctrl){
  86.         Loop,% HB_Button.Length()
  87.             if(ctrl=HB_Button[A_Index].Hwnd)
  88.                 HB_Button[A_Index].Draw_Hover(),Index:=A_Index,Hover_On:=1
  89.     }else if(Hover_On)
  90.         if(ctrl!=HB_Button[Index].Hwnd)
  91.             HB_Button[Index].Draw_Default(),Hover_On:=0
  92. }
  93.  
  94. class pButton_V2    {
  95.     __New(x:=10, y:=10, w:=100, h:=30, Window:="1", Label:="", Text:="HB pButton", Font:="Arial", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color:="222222", Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="FFFF00", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:="", Text_YOffset:=""){
  96.         ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  97.         ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  98.         ; Prototype Button Creation Example
  99.         ; HB_Button.Push(New pButton_V2(x:=10, y:=10, w:=100, h:=30, Window:="1", Label:="", Text:="HB pButton", Font:="Arial", Font_Size:="10 Bold", Font_Color_Top:="FFFFFF", Font_Color_Bottom:="000000", Button_Background_Color:="222222", Button_Top_Color_Default:="333333", Button_Top_Color_Hover:="444444", Button_Top_Color_Pressed:="222222", Button_Top_Trim_Color_Default:="FFFF00", Button_Top_Trim_Color_Hover:="", Button_Top_Trim_Color_Pressed:="", Button_Bottom_Trim_Color_Default:="000000", Button_Bottom_Trim_Color_Hover:="", Button_Bottom_Trim_Color_Pressed:="", Button_Shadow_Color:="", Font_Color_Top_Hover:="", Font_Color_Bottom_Hover:="", Font_Color_Top_Pressed:="", Font_Color_Bottom_Pressed:="", Text_YOffset:=""))
  100.         ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  101.         ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  102.        
  103.         This.X:=x
  104.         This.Y:=y
  105.         This.W:=w
  106.         This.H:=h
  107.        
  108.         This.Window:=Window
  109.         This.Label:=Label
  110.        
  111.         This.Text:=Text
  112.         This.Font:=Font
  113.         This.Font_Size:=Font_Size
  114.         This.Font_Color_Top:="0xFF" Font_Color_Top
  115.         This.Font_Color_Bottom:="0xFF" Font_Color_Bottom
  116.        
  117.         This.Button_Background_Color:="0xFF" Button_Background_Color
  118.        
  119.         This.Button_Top_Color_Default:="0xFF" Button_Top_Color_Default
  120.         This.Button_Top_Color_Hover:="0xFF" Button_Top_Color_Hover
  121.         This.Button_Top_Color_Pressed:="0xFF" Button_Top_Color_Pressed
  122.        
  123.         This.Button_Top_Trim_Color_Default:="0xFF" Button_Top_Trim_Color_Default
  124.         This.Button_Top_Trim_Color_Hover:=(Button_Top_Trim_Color_Hover!=null)?("0xFF" Button_Top_Trim_Color_Hover):(This.Button_Top_Trim_Color_Default)
  125.         This.Button_Top_Trim_Color_Pressed:=(Button_Top_Trim_Color_Pressed!=null)?("0xFF" Button_Top_Trim_Color_Pressed):(This.Button_Top_Trim_Color_Default)
  126.        
  127.         This.Button_Bottom_Trim_Color_Default:="0xFF" Button_Bottom_Trim_Color_Default
  128.         This.Button_Bottom_Trim_Color_Hover:=(Button_Bottom_Trim_Color_Hover!=null)?("0xFF" Button_Bottom_Trim_Color_Hover):(This.Button_Bottom_Trim_Color_Default)
  129.         This.Button_Bottom_Trim_Color_Pressed:=(Button_Bottom_Trim_Color_Pressed!=null)?("0xFF" Button_Bottom_Trim_Color_Pressed):(This.Button_Bottom_Trim_Color_Default)
  130.        
  131.         This.Button_Shadow_Color:=(Button_Shadow_Color!=null)?("0x66" Button_Shadow_Color):("0x66000000")
  132.        
  133.         This.Font_Color_Top_Hover:=(Font_Color_Top_Hover!=null)?("0xFF" Font_Color_Top_Hover):(This.Font_Color_Top)
  134.         This.Font_Color_Bottom_Hover:=(Font_Color_Bottom_Hover!=null)?("0xFF" Font_Color_Bottom_Hover):(This.Font_Color_Bottom)
  135.        
  136.         This.Font_Color_Top_Pressed:=(Font_Color_Top_Pressed!=null)?("0xFF" Font_Color_Top_Pressed):(This.Font_Color_Top)
  137.         This.Font_Color_Bottom_Pressed:=(Font_Color_Bottom_Pressed!=null)?("0xFF" Font_Color_Bottom_Pressed):(This.Font_Color_Bottom)
  138.        
  139.         This.Text_YOffset:=(Text_YOffset!=Null)?(Text_YOffSet):(0)
  140.        
  141.         This.Create_Trigger()
  142.         This.Create_Default_Bitmap()
  143.         This.Create_Hover_Bitmap()
  144.         This.Create_Pressed_Bitmap()
  145.         Sleep,20
  146.         This.Draw_Default()
  147.     }
  148.     Create_Trigger(){
  149.         local hwnd
  150.         Gui,% This.Window ":Add",Picture,% "x" This.X " y" This.Y " w" This.W " h" This.H " hwndhwnd 0xE"
  151.         This.Hwnd:=hwnd
  152.         BP:=This.Draw_Pressed.Bind(This)
  153.         GuiControl,+G,% This.Hwnd,% BP
  154.         if(This.Label)
  155.             (IsFunc(This.Label))?(This.Function:=Func(This.Label))
  156.     }
  157.     Create_Default_Bitmap(){
  158.         ;Bitmap Created Using: HB Bitmap Maker
  159.         pBitmap:=Gdip_CreateBitmap( This.W, This.H )
  160.         G := Gdip_GraphicsFromImage( pBitmap )
  161.         Gdip_SetSmoothingMode( G , 1 )
  162.         Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
  163.         Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+8, This.H+8)
  164.         Gdip_DeleteBrush( Brush )
  165.         Brush := Gdip_BrushCreateSolid( This.Button_Shadow_Color )
  166.         Gdip_FillRectangle( G , Brush , 2 , 2 , This.W-4, This.H-4 )
  167.         Gdip_DeleteBrush( Brush )
  168.         Brush := Gdip_BrushCreateSolid( This.Button_Top_Color_Default )
  169.         Gdip_FillRectangle( G , Brush , 0 , 0 , This.W-4, This.H-5 )
  170.         Gdip_DeleteBrush( Brush )
  171.         Pen := Gdip_CreatePen( This.Button_Bottom_Trim_Color_Default , 1 )
  172.         Gdip_DrawRectangle( G , Pen , 0 , 0 , This.W-4, This.H-5 )
  173.         Gdip_DeletePen( Pen )
  174.         Pen := Gdip_CreatePen( This.Button_Top_Trim_Color_Default , 1 )
  175.         Gdip_DrawLine( G , Pen , 0 , 0 , 0 , This.H-6 )
  176.         Gdip_DeletePen( Pen )
  177.         Pen := Gdip_CreatePen( This.Button_Top_Trim_Color_Default , 1 )
  178.         Gdip_DrawLine( G , Pen , 0 , 0 , This.W-5 , 0 )
  179.         Gdip_DeletePen( Pen )
  180.         Brush := Gdip_BrushCreateSolid( This.Font_Color_Bottom )
  181.         Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x2 y" 3+This.Text_YOffset , This.Font, This.W, This.H )
  182.         Gdip_DeleteBrush( Brush )
  183.         Brush := Gdip_BrushCreateSolid( This.Font_Color_Top )
  184.         Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x1 y" 2+This.Text_YOffset , This.Font, This.W, This.H )
  185.         Gdip_DeleteBrush( Brush )
  186.         Gdip_DeleteGraphics( G )
  187.         This.Default_Bitmap:=Gdip_CreateHBITMAPFromBitmap(pBitmap)
  188.         Gdip_DisposeImage(pBitmap)
  189.     }
  190.     Create_Hover_Bitmap(){
  191.         ;Bitmap Created Using: HB Bitmap Maker
  192.         pBitmap:=Gdip_CreateBitmap( This.W, This.H )
  193.         G := Gdip_GraphicsFromImage( pBitmap )
  194.         Gdip_SetSmoothingMode( G , 1 )
  195.         Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
  196.         Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+8, This.H+8)
  197.         Gdip_DeleteBrush( Brush )
  198.         Brush := Gdip_BrushCreateSolid( This.Button_Shadow_Color )
  199.         Gdip_FillRectangle( G , Brush , 2 , 2 , This.W-4, This.H-4 )
  200.         Gdip_DeleteBrush( Brush )
  201.         Brush := Gdip_BrushCreateSolid( This.Button_Top_Color_Hover )
  202.         Gdip_FillRectangle( G , Brush , 0 , 0 , This.W-4, This.H-5 )
  203.         Gdip_DeleteBrush( Brush )
  204.         Pen := Gdip_CreatePen( This.Button_Bottom_Trim_Color_Hover , 1 )
  205.         Gdip_DrawRectangle( G , Pen , 0 , 0 , This.W-4, This.H-5 )
  206.         Gdip_DeletePen( Pen )
  207.         Pen := Gdip_CreatePen( This.Button_Top_Trim_Color_Hover , 1 )
  208.         Gdip_DrawLine( G , Pen , 0 , 0 , 0 , This.H-6 )
  209.         Gdip_DeletePen( Pen )
  210.         Pen := Gdip_CreatePen( This.Button_Top_Trim_Color_Hover , 1 )
  211.         Gdip_DrawLine( G , Pen , 0 , 0 , This.W-5 , 0 )
  212.         Gdip_DeletePen( Pen )
  213.         Brush := Gdip_BrushCreateSolid( This.Font_Color_Bottom_Hover )
  214.         Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x2 y" 3+This.Text_YOffset , This.Font, This.W, This.H )
  215.         Gdip_DeleteBrush( Brush )
  216.         Brush := Gdip_BrushCreateSolid( This.Font_Color_Top_Hover )
  217.         Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x1 y" 2+This.Text_YOffset , This.Font, This.W, This.H )
  218.         Gdip_DeleteBrush( Brush )
  219.         Gdip_DeleteGraphics( G )
  220.         This.Hover_Bitmap:=Gdip_CreateHBITMAPFromBitmap(pBitmap)
  221.         Gdip_DisposeImage(pBitmap)
  222.     }
  223.     Create_Pressed_Bitmap(){
  224.         ;Bitmap Created Using: HB Bitmap Maker
  225.         pBitmap:=Gdip_CreateBitmap( This.W, This.H )
  226.         G := Gdip_GraphicsFromImage( pBitmap )
  227.         Gdip_SetSmoothingMode( G , 1 )
  228.         Brush := Gdip_BrushCreateSolid( This.Button_Background_Color )
  229.         Gdip_FillRectangle( G , Brush , -1 , -1 , This.W+8 , This.H+8 )
  230.         Gdip_DeleteBrush( Brush )
  231.         Brush := Gdip_BrushCreateSolid( This.Button_Shadow_Color )
  232.         Gdip_FillRectangle( G , Brush , 0 , 0 , This.W-2 , This.H-2 )
  233.         Gdip_DeleteBrush( Brush )
  234.         Brush := Gdip_BrushCreateSolid( This.Button_Top_Color_Pressed )
  235.         Gdip_FillRectangle( G , Brush , 1 , 1 , This.W-4 , This.H-5 )
  236.         Gdip_DeleteBrush( Brush )
  237.         Pen := Gdip_CreatePen( This.Button_Bottom_Trim_Color_Pressed , 1 )
  238.         Gdip_DrawRectangle( G , Pen , 1 , 1 , This.W-4 , This.H-5 )
  239.         Gdip_DeletePen( Pen )
  240.         Pen := Gdip_CreatePen( This.Button_Top_Trim_Color_Pressed , 1 )
  241.         Gdip_DrawLine( G , Pen , 1 , 1 , 1 , This.H-5 )
  242.         Gdip_DeletePen( Pen )
  243.         Pen := Gdip_CreatePen( This.Button_Top_Trim_Color_Pressed , 1 )
  244.         Gdip_DrawLine( G , Pen , 1 , 1 , This.W-4 , 1 )
  245.         Gdip_DeletePen( Pen )
  246.         Brush := Gdip_BrushCreateSolid( This.Font_Color_Bottom_Pressed )
  247.         Gdip_TextToGraphics( G , This.Text , "s" This.Font_Size " Center vCenter c" Brush " x3 y" 4+This.Text_YOffset , This.Font, This.W, This.H )
  248.         Gdip_DeleteBrush( Brush )
  249.         Brush := Gdip_BrushCreateSolid( This.Font_Color_Top_Pressed )
  250.         Gdip_TextToGraphics( G , This.Text, "s" This.Font_Size " Center vCenter c" Brush " x2 y" 3+This.Text_YOffset , This.Font, This.W, This.H )
  251.         Gdip_DeleteBrush( Brush )
  252.         Gdip_DeleteGraphics( G )
  253.         This.Pressed_Bitmap:=Gdip_CreateHBITMAPFromBitmap(pBitmap)
  254.         Gdip_DisposeImage(pBitmap)
  255.     }
  256.     Draw_Pressed(){
  257.         GuiControl,Focus,% This.Hwnd
  258.         SetTimer,HB_Button_Hover,Off
  259.         SetImage(This.Hwnd,This.Pressed_Bitmap)
  260.         While(GetKeyState("LButton"))
  261.             Sleep,10
  262.         SetTimer,HB_Button_Hover,On
  263.         MouseGetPos,,,,ctrl,2
  264.         if(This.Hwnd=ctrl){
  265.             This.Draw_Hover()
  266.             if(This.Label){
  267.                 if(This.Function)
  268.                     This.Function.Call()
  269.                 else
  270.                     gosub,% This.Label
  271.             }
  272.         }else  
  273.             This.Draw_Default()
  274.     }
  275.     Draw_Hover(){
  276.         SetImage(This.Hwnd,This.Hover_Bitmap)
  277.     }
  278.     Draw_Default(){
  279.         SetImage(This.Hwnd,This.Default_Bitmap)
  280.     }
  281. }
  282.  
  283. ;######################################################################################################################################
  284. ;#####################################################                          #######################################################
  285. ;#####################################################        Gdip LITE         #######################################################
  286. ;#####################################################                          #######################################################
  287. ;######################################################################################################################################
  288. ; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
  289. ; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
  290. BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster=""){
  291.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  292.     return DllCall("gdi32\BitBlt", Ptr, dDC, "int", dx, "int", dy, "int", dw, "int", dh, Ptr, sDC, "int", sx, "int", sy, "uint", Raster ? Raster : 0x00CC0020)
  293. }
  294. Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1){
  295.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  296.     if (Matrix&1 = "")
  297.         ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
  298.     else if (Matrix != 1)
  299.         ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
  300.     if(sx = "" && sy = "" && sw = "" && sh = ""){
  301.         if(dx = "" && dy = "" && dw = "" && dh = ""){
  302.             sx := dx := 0, sy := dy := 0
  303.             sw := dw := Gdip_GetImageWidth(pBitmap)
  304.             sh := dh := Gdip_GetImageHeight(pBitmap)
  305.         }else   {
  306.             sx := sy := 0,sw := Gdip_GetImageWidth(pBitmap),sh := Gdip_GetImageHeight(pBitmap)
  307.         }
  308.     }
  309.     E := DllCall("gdiplus\GdipDrawImageRectRect", Ptr, pGraphics, Ptr, pBitmap, "float", dx, "float", dy, "float", dw, "float", dh, "float", sx, "float", sy, "float", sw, "float", sh, "int", 2, Ptr, ImageAttr, Ptr, 0, Ptr, 0)
  310.     if ImageAttr
  311.         Gdip_DisposeImageAttributes(ImageAttr)
  312.     return E
  313. }
  314. Gdip_SetImageAttributesColorMatrix(Matrix){
  315.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  316.     VarSetCapacity(ColourMatrix, 100, 0)
  317.     Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|")
  318.     StringSplit, Matrix, Matrix, |
  319.     Loop, 25
  320.     {
  321.         Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
  322.         NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float")
  323.     }
  324.     DllCall("gdiplus\GdipCreateImageAttributes", A_PtrSize ? "UPtr*" : "uint*", ImageAttr)
  325.     DllCall("gdiplus\GdipSetImageAttributesColorMatrix", Ptr, ImageAttr, "int", 1, "int", 1, Ptr, &ColourMatrix, Ptr, 0, "int", 0)
  326.     return ImageAttr
  327. }
  328. Gdip_GetImageWidth(pBitmap){
  329.    DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
  330.    return Width
  331. }
  332. Gdip_GetImageHeight(pBitmap){
  333.    DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
  334.    return Height
  335. }
  336. Gdip_DeletePen(pPen){
  337.    return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
  338. }
  339. Gdip_DeleteBrush(pBrush){
  340.    return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
  341. }
  342. Gdip_DisposeImage(pBitmap){
  343.    return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
  344. }
  345. Gdip_DeleteGraphics(pGraphics){
  346.    return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
  347. }
  348. Gdip_DisposeImageAttributes(ImageAttr){
  349.     return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
  350. }
  351. Gdip_DeleteFont(hFont){
  352.    return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
  353. }
  354. Gdip_DeleteStringFormat(hFormat){
  355.    return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
  356. }
  357. Gdip_DeleteFontFamily(hFamily){
  358.    return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
  359. }
  360. CreateCompatibleDC(hdc=0){
  361.    return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
  362. }
  363. SelectObject(hdc, hgdiobj){
  364.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  365.     return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
  366. }
  367. DeleteObject(hObject){
  368.    return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
  369. }
  370. GetDC(hwnd=0){
  371.     return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
  372. }
  373. GetDCEx(hwnd, flags=0, hrgnClip=0){
  374.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  375.     return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
  376. }
  377. ReleaseDC(hdc, hwnd=0){
  378.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  379.     return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
  380. }
  381. DeleteDC(hdc){
  382.    return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
  383. }
  384. Gdip_SetClipRegion(pGraphics, Region, CombineMode=0){
  385.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  386.     return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
  387. }
  388. CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0){
  389.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  390.     hdc2 := hdc ? hdc : GetDC()
  391.     VarSetCapacity(bi, 40, 0)
  392.     NumPut(w, bi, 4, "uint"), NumPut(h, bi, 8, "uint"), NumPut(40, bi, 0, "uint"), NumPut(1, bi, 12, "ushort"), NumPut(0, bi, 16, "uInt"), NumPut(bpp, bi, 14, "ushort")
  393.     hbm := DllCall("CreateDIBSection", Ptr, hdc2, Ptr, &bi, "uint", 0, A_PtrSize ? "UPtr*" : "uint*", ppvBits, Ptr, 0, "uint", 0, Ptr)
  394.     if !hdc
  395.         ReleaseDC(hdc2)
  396.     return hbm
  397. }
  398. Gdip_GraphicsFromImage(pBitmap){
  399.     DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
  400.     return pGraphics
  401. }
  402. Gdip_GraphicsFromHDC(hdc){
  403.     DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
  404.     return pGraphics
  405. }
  406. Gdip_GetDC(pGraphics){
  407.     DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
  408.     return hdc
  409. }
  410.  
  411.  
  412. Gdip_Startup(){
  413.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  414.     if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
  415.         DllCall("LoadLibrary", "str", "gdiplus")
  416.     VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
  417.     DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
  418.     return pToken
  419. }
  420. Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0){
  421.     IWidth := Width, IHeight:= Height
  422.     RegExMatch(Options, "i)X([\-\d\.]+)(p*)", xpos)
  423.     RegExMatch(Options, "i)Y([\-\d\.]+)(p*)", ypos)
  424.     RegExMatch(Options, "i)W([\-\d\.]+)(p*)", Width)
  425.     RegExMatch(Options, "i)H([\-\d\.]+)(p*)", Height)
  426.     RegExMatch(Options, "i)C(?!(entre|enter))([a-f\d]+)", Colour)
  427.     RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos)
  428.     RegExMatch(Options, "i)NoWrap", NoWrap)
  429.     RegExMatch(Options, "i)R(\d)", Rendering)
  430.     RegExMatch(Options, "i)S(\d+)(p*)", Size)
  431.     if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2))
  432.         PassBrush := 1, pBrush := Colour2
  433.     if !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2)
  434.         return -1
  435.     Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout"
  436.     Loop, Parse, Styles, |
  437.     {
  438.         if RegExMatch(Options, "\b" A_loopField)
  439.         Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8
  440.     }
  441.     Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right"
  442.     Loop, Parse, Alignments, |
  443.     {
  444.         if RegExMatch(Options, "\b" A_loopField)
  445.             Align |= A_Index//2.1      ; 0|0|1|1|2|2
  446.     }
  447.     xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0
  448.     ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0
  449.     Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth
  450.     Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight
  451.     if !PassBrush
  452.         Colour := "0x" (Colour2 ? Colour2 : "ff000000")
  453.     Rendering := ((Rendering1 >= 0) && (Rendering1 <= 5)) ? Rendering1 : 4
  454.     Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12
  455.     hFamily := Gdip_FontFamilyCreate(Font)
  456.     hFont := Gdip_FontCreate(hFamily, Size, Style)
  457.     FormatStyle := NoWrap ? 0x4000 | 0x1000 : 0x4000
  458.     hFormat := Gdip_StringFormatCreate(FormatStyle)
  459.     pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour)
  460.     if !(hFamily && hFont && hFormat && pBrush && pGraphics)
  461.         return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0
  462.     CreateRectF(RC, xpos, ypos, Width, Height)
  463.     Gdip_SetStringFormatAlign(hFormat, Align)
  464.     Gdip_SetTextRenderingHint(pGraphics, Rendering)
  465.     ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
  466.     if vPos
  467.     {
  468.         StringSplit, ReturnRC, ReturnRC, |
  469.         if (vPos = "vCentre") || (vPos = "vCenter")
  470.             ypos += (Height-ReturnRC4)//2
  471.         else if (vPos = "Top") || (vPos = "Up")
  472.             ypos := 0
  473.         else if (vPos = "Bottom") || (vPos = "Down")
  474.             ypos := Height-ReturnRC4
  475.         CreateRectF(RC, xpos, ypos, Width, ReturnRC4)
  476.         ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
  477.     }
  478.     if !Measure
  479.         E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC)
  480.     if !PassBrush
  481.         Gdip_DeleteBrush(pBrush)
  482.     Gdip_DeleteStringFormat(hFormat)
  483.     Gdip_DeleteFont(hFont)
  484.     Gdip_DeleteFontFamily(hFamily)
  485.     return E ? E : ReturnRC
  486. }
  487. Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF){
  488.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  489.     if (!A_IsUnicode)
  490.     {
  491.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, 0, "int", 0)
  492.         VarSetCapacity(wString, nSize*2)
  493.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
  494.     }
  495.     return DllCall("gdiplus\GdipDrawString", Ptr, pGraphics, Ptr, A_IsUnicode ? &sString : &wString, "int", -1, Ptr, hFont, Ptr, &RectF, Ptr, hFormat, Ptr, pBrush)
  496. }
  497. Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1){
  498.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  499.     CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
  500.     DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
  501.     return LGpBrush
  502. }
  503. Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1){
  504.     CreateRectF(RectF, x, y, w, h)
  505.     DllCall("gdiplus\GdipCreateLineBrushFromRect", A_PtrSize ? "UPtr" : "UInt", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
  506.     return LGpBrush
  507. }
  508. Gdip_CloneBrush(pBrush){
  509.     DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
  510.     return pBrushClone
  511. }
  512. Gdip_FontFamilyCreate(Font){
  513.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  514.     if (!A_IsUnicode)
  515.     {
  516.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, "uint", 0, "int", 0)
  517.         VarSetCapacity(wFont, nSize*2)
  518.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, Ptr, &wFont, "int", nSize)
  519.     }
  520.     DllCall("gdiplus\GdipCreateFontFamilyFromName", Ptr, A_IsUnicode ? &Font : &wFont, "uint", 0, A_PtrSize ? "UPtr*" : "UInt*", hFamily)
  521.     return hFamily
  522. }
  523. Gdip_SetStringFormatAlign(hFormat, Align){
  524.    return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
  525. }
  526. Gdip_StringFormatCreate(Format=0, Lang=0){
  527.    DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
  528.    return hFormat
  529. }
  530. Gdip_FontCreate(hFamily, Size, Style=0){
  531.    DllCall("gdiplus\GdipCreateFont", A_PtrSize ? "UPtr" : "UInt", hFamily, "float", Size, "int", Style, "int", 0, A_PtrSize ? "UPtr*" : "UInt*", hFont)
  532.    return hFont
  533. }
  534. Gdip_CreatePen(ARGB, w){
  535.    DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
  536.    return pPen
  537. }
  538. Gdip_CreatePenFromBrush(pBrush, w){
  539.     DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
  540.     return pPen
  541. }
  542. Gdip_BrushCreateSolid(ARGB=0xff000000){
  543.     DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
  544.     return pBrush
  545. }
  546. Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0){
  547.     DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
  548.     return pBrush
  549. }
  550. CreateRectF(ByRef RectF, x, y, w, h){
  551.    VarSetCapacity(RectF, 16)
  552.    NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float")
  553. }
  554. Gdip_SetTextRenderingHint(pGraphics, RenderingHint){
  555.     return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
  556. }
  557. Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF){
  558.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  559.     VarSetCapacity(RC, 16)
  560.     if !A_IsUnicode
  561.     {
  562.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, "uint", 0, "int", 0)
  563.         VarSetCapacity(wString, nSize*2)
  564.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
  565.     }
  566.     DllCall("gdiplus\GdipMeasureString", Ptr, pGraphics, Ptr, A_IsUnicode ? &sString : &wString, "int", -1, Ptr, hFont, Ptr, &RectF, Ptr, hFormat, Ptr, &RC, "uint*", Chars, "uint*", Lines)
  567.     return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0
  568. }
  569. CreateRect(ByRef Rect, x, y, w, h){
  570.     VarSetCapacity(Rect, 16)
  571.     NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
  572. }
  573. CreateSizeF(ByRef SizeF, w, h){
  574.    VarSetCapacity(SizeF, 8)
  575.    NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
  576. }
  577. CreatePointF(ByRef PointF, x, y){
  578.    VarSetCapacity(PointF, 8)
  579.    NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
  580. }
  581. Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle){
  582.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  583.     return DllCall("gdiplus\GdipDrawArc", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
  584. }
  585. Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle){
  586.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  587.     return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
  588. }
  589. Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2){
  590.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  591.     return DllCall("gdiplus\GdipDrawLine", Ptr, pGraphics, Ptr, pPen, "float", x1, "float", y1, "float", x2, "float", y2)
  592. }
  593. Gdip_DrawLines(pGraphics, pPen, Points){
  594.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  595.     StringSplit, Points, Points, |
  596.     VarSetCapacity(PointF, 8*Points0)
  597.     Loop, %Points0%
  598.     {
  599.         StringSplit, Coord, Points%A_Index%, `,
  600.         NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  601.     }
  602.     return DllCall("gdiplus\GdipDrawLines", Ptr, pGraphics, Ptr, pPen, Ptr, &PointF, "int", Points0)
  603. }
  604. Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h){
  605.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  606.     return DllCall("gdiplus\GdipFillRectangle", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
  607. }
  608. Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r){
  609.     Region := Gdip_GetClipRegion(pGraphics)
  610.     Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
  611.     Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
  612.     Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
  613.     Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
  614.     E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
  615.     Gdip_SetClipRegion(pGraphics, Region, 0)
  616.     Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
  617.     Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
  618.     Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
  619.     Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
  620.     Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
  621.     Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
  622.     Gdip_SetClipRegion(pGraphics, Region, 0)
  623.     Gdip_DeleteRegion(Region)
  624.     return E
  625. }
  626. Gdip_GetClipRegion(pGraphics){
  627.     Region := Gdip_CreateRegion()
  628.     DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
  629.     return Region
  630. }
  631. Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0){
  632.    return DllCall("gdiplus\GdipSetClipRect",  A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode)
  633. }
  634. Gdip_SetClipPath(pGraphics, Path, CombineMode=0){
  635.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  636.     return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
  637. }
  638. Gdip_ResetClip(pGraphics){
  639.    return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
  640. }
  641. Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h){
  642.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  643.     return DllCall("gdiplus\GdipFillEllipse", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
  644. }
  645. Gdip_FillRegion(pGraphics, pBrush, Region){
  646.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  647.     return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
  648. }
  649. Gdip_FillPath(pGraphics, pBrush, Path){
  650.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  651.     return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
  652. }
  653. Gdip_CreateRegion(){
  654.     DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
  655.     return Region
  656. }
  657. Gdip_DeleteRegion(Region){
  658.     return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
  659. }
  660. Gdip_CreateBitmap(Width, Height, Format=0x26200A){
  661.     DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, A_PtrSize ? "UPtr" : "UInt", 0, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
  662.     Return pBitmap
  663. }
  664. Gdip_SetSmoothingMode(pGraphics, SmoothingMode){
  665.    return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
  666. }
  667. Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h){
  668.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  669.     return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
  670. }
  671. Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r){
  672.     Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
  673.     Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
  674.     Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
  675.     Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
  676.     E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
  677.     Gdip_ResetClip(pGraphics)
  678.     Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
  679.     Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
  680.     Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r)
  681.     Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r)
  682.     Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r)
  683.     Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
  684.     Gdip_ResetClip(pGraphics)
  685.     return E
  686. }
  687. Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h){
  688.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  689.     return DllCall("gdiplus\GdipDrawEllipse", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
  690. }
  691. Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff){
  692.     DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
  693.     return hbm
  694. }
  695. SetImage(hwnd, hBitmap){
  696.     SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
  697.     E := ErrorLevel
  698.     DeleteObject(E)
  699.     return E
  700. }
  701. Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0){
  702.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  703.     StringSplit, Points, Points, |
  704.     VarSetCapacity(PointF, 8*Points0)
  705.     Loop, %Points0%
  706.     {
  707.         StringSplit, Coord, Points%A_Index%, `,
  708.         NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  709.     }
  710.     return DllCall("gdiplus\GdipFillPolygon", Ptr, pGraphics, Ptr, pBrush, Ptr, &PointF, "int", Points0, "int", FillMode)
  711. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement