Skip to content

Instantly share code, notes, and snippets.

@jNizM
Last active August 10, 2024 01:04
Show Gist options
  • 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
; ===============================================================================================================================
@jNizM
Copy link
Author

jNizM commented Aug 9, 2024

Wow looks useful 👍 though I wish it was v2.

here you go:
https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Gui/CreateGradient.ahk

@Chuckalttponline
Copy link

Chuckalttponline commented Aug 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment