Skip to content

Instantly share code, notes, and snippets.

@jNizM
Last active May 16, 2019 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jNizM/53a3cea19463f1074cb1ad349e6cf238 to your computer and use it in GitHub Desktop.
Save jNizM/53a3cea19463f1074cb1ad349e6cf238 to your computer and use it in GitHub Desktop.
[AHK] Create Gardient in GUI
; GLOBAL SETTINGS ===============================================================================================================
#NoEnv
#SingleInstance Force
SetBatchLines -1
; GUI ===========================================================================================================================
Gui, +LastFound +hwndhMyGUI
Gui, Margin, 0, 0
Gui, Add, Pic, x0 y0 w800 h600 0x4E hwndhPic01
CreateGradient(hPic01, 800, 600, ["0x3399FF", "0xFF3399"]*)
Gui, Show, AutoSize
return
; FUNCTIONS =====================================================================================================================
CreateGradient(handle, width, height, colors*)
{
size := VarSetCapacity(bits, (ClrCnt := colors.MaxIndex()) * 2 * 4, 0)
addr := &bits
for each, color in colors
addr := NumPut(color, NumPut(color, addr + 0, "uint"), "uint")
hBitmap := DllCall("CreateBitmap", "int", 2, "int", ClrCnt, "uint", 1, "uint", 32, "ptr", 0, "ptr")
hBitmap := DllCall("CopyImage", "ptr", hBitmap, "uint", 0, "int", 0, "int", 0, "uint", 0x2008, "ptr")
DllCall("SetBitmapBits", "ptr", hBitmap, "uint", size, "ptr", &bits)
hBitmap := DllCall("CopyImage", "ptr", hBitmap, "uint", 0, "int", width, "int", height, "uint", 0x2008, "ptr")
DllCall("SendMessage", "ptr", handle, "uint", 0x0172, "ptr", 0, "ptr", hBitmap, "ptr")
return true
}
; EXIT ==========================================================================================================================
GuiClose:
GuiEscape:
ExitApp
; ===============================================================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment