Advertisement
Guest User

swapping text

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