Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by Hellbent » 03 Jun 2019, 12:37

@burque505
Thank you.

Here is a new one I just finished up. Once again, it's just a very simple gui created using Gdip and my Gdip editor.

SnapShot_497.png
SnapShot_497.png (265.4 KiB) Viewed 8623 times

User avatar
DataLife
Posts: 445
Joined: 29 Sep 2013, 19:52

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by DataLife » 03 Jun 2019, 14:00

Where can I get your GDIP editor?
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by Hellbent » 03 Jun 2019, 14:40

DataLife wrote:
03 Jun 2019, 14:00
Where can I get your GDIP editor?
It's in the scripts and functions section, I posted it in early to mid March so just go back a few pages and you should find it no problem.

I don't remember the exact title but it was something like [Editor]Gdip Bitmap maker .

Somethings to keep in mind when using it is that it's a Alpha release so be sure to save often (saving takes a fair bit of time, so don't save too often lol).
Also, if you're making a bitmap with loads and loads of elements, it is a good idea to save and reload the editor every now and then. There is a bug that can randomly cause the bitmap to suddenly go all black and everything will be lost. It doesn't happen often (I have done 100+ bitmaps with it and it's only happened 3-4 times).

When you are re-saving a bitmap, save it as a new bitmap, for example if i'm making a window background the first time I save it I'll call it something like BG 1, then the next time I save it I'll save it as BG 2 etc.

Saving takes a fair bit of time (1-3 mins for bitmaps that have loads of elements) Atm the only way to know when it's done saving is that a traytip will pop up saying "Done" and you'll hear a SoundBeep. I've never tried doing anything with the editor while it's saving so I can only say that while it's saving, don't do anything in the editor.

When you clone a element, Select the clone in the List box to update it's info.
If you minimize the editor, the bitmaps will look like they are gone when you reactivate the window, just right click one of the side panels and it will redraw your bitmaps.

If you have any questions, feel free to ask.


***Edit***
Here is a little demo of the editor.
The current version has a number of new features, but this demo shows the basic idea of it's use.


burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by burque505 » 04 Jun 2019, 09:54

@DataLife, that link is here.

User avatar
DataLife
Posts: 445
Joined: 29 Sep 2013, 19:52

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by DataLife » 04 Jun 2019, 13:26

burque505 wrote:
04 Jun 2019, 09:54
@DataLife, that link is here.
thanks, got it.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by Hellbent » 27 Jun 2019, 19:51

Gdip Gui.

Tips enabled and disabled
SnapShot_30.png
SnapShot_30.png (153.21 KiB) Viewed 8364 times

A few different color variations
SnapShot_29.png
SnapShot_29.png (217.33 KiB) Viewed 8364 times

User avatar
Delta Pythagorean
Posts: 626
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by Delta Pythagorean » 27 Jun 2019, 22:42

It doesn't even look like you made it in AHK!
Holy crap!

[AHK]......: v2.0.6 | 64-bit
[OS].......: Windows 11 | 22H2 (OS Build: 22621.1555)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


You should consider migrating to v2. Practice with small features first such as learning how to do Guis!
Remember to use [code] ... [/code] for your multi-line scripts for the forums.

User avatar
Klark92
Posts: 161
Joined: 18 Jan 2015, 19:33

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by Klark92 » 28 Jun 2019, 10:50

Hellbent wrote:
27 Jun 2019, 19:51
Gdip Gui.

Tips enabled and disabled

SnapShot_30.png


A few different color variations

SnapShot_29.png
You should share that with us. :)
Smart Kombo 1.0 | One of the best Knight Online's key combo program...

burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by burque505 » 30 Jun 2019, 17:57

:bravo: @Hellbent, you never cease to amaze. :bravo:
Regards,
burque505

User avatar
elModo7
Posts: 217
Joined: 01 Sep 2017, 02:38
Location: Spain
Contact:

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by elModo7 » 18 Jul 2019, 05:51

burque505 wrote:
30 Jun 2019, 17:57
:bravo: @Hellbent, you never cease to amaze. :bravo:
Regards,
burque505
+9999

tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by tmplinshi » 18 Aug 2019, 13:44

Image

It's an example of using Scale9.

Source on GitHub
Last edited by tmplinshi on 24 Aug 2019, 13:06, edited 1 time in total.

m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by m3user » 24 Aug 2019, 10:50

Tmplinshi, that's impressive. Could you share the code?

burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by burque505 » 24 Aug 2019, 11:17

@m3user, try the link at the bottom of the post.

tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by tmplinshi » 24 Aug 2019, 13:11

@m3user I've edited the description to make it more clear. :)

m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by m3user » 24 Aug 2019, 13:59

Thanks, this is really great. Do you think it be possible to simulate other controls, like buttons, dropdowns and tabs?

tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by tmplinshi » 26 Aug 2019, 15:42

m3user wrote:
24 Aug 2019, 13:59
Do you think it be possible to simulate other controls, like buttons, dropdowns and tabs?
Not in the same way as the Edit control.

For buttons, before executing Gui Show, you can retrieve all buttons, then apply skin to them with Class_ImageButton.
For tabs, you can create an invisible tab control with w0 h0 option, and then use radio buttons as the tab buttons. See topic AHK Gui tab styling for example.
For dropdowns, it's a little difficult, you can combine with a button and a popup GUI.. See these images for example, I can't post the code though, I wrote it for someone.

User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by Hellbent » 13 Oct 2019, 05:49

Klark92 wrote:
28 Jun 2019, 10:50
You should share that with us. :)
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=68814

User avatar
TheDewd
Posts: 1503
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by TheDewd » 18 Nov 2019, 14:50

I made another attempt to style a Gui similar to Google's Material Design.

It's only the styled Gui at the moment, with functional window control buttons (minimize, maximize, close). No other functionality added yet.

Started with a captionless and borderless Gui, and added custom images to emulate the appearance of actual Gui controls.

Tested with AHK 1.1.31.01 on Windows 10.

Image

Code: Select all

; Script Information ===========================================================
; Name:        Material Design
; Description: Material Design inspired Gui
; AHK Version: 1.1.31.01 (Unicode 32-bit)
; OS Version:  Windows 10
; Language:    English (United States)
; Author:      Weston Campbell (TheDewd) <[email protected]>
; Filename:    Material Design.ahk
; ==============================================================================

; Revision History =============================================================
; Revision 1 (2019-11-18)
; * Initial release
; ==============================================================================

; Auto-Execute =================================================================
#SingleInstance, Force ; Allow only one running instance of script
#Persistent ; Keep the script permanently running until terminated
#NoEnv ; Avoid checking empty variables for environment variables
;#Warn ; Enable warnings to assist with detecting common errors
;#NoTrayIcon ; Disable the tray icon of the script
#KeyHistory, 0 ; Keystroke and mouse click history
ListLines, Off ; The script lines most recently executed
SetWorkingDir, % A_ScriptDir ; Set the working directory of the script
SetBatchLines, -1 ; The speed at which the lines of the script are executed
SendMode, Input ; The method for sending keystrokes and mouse clicks
;DetectHiddenWindows, On ; The visibility of hidden windows by the script
SetWinDelay, 0 ; The delay to occur after modifying a window
SetControlDelay, 0 ; The delay to occur after modifying a control
OnExit("OnUnload") ; Run a subroutine or function when exiting the script

return ; End automatic execution
; ==============================================================================

; Labels =======================================================================
; TBD
; ==============================================================================

; Functions ====================================================================
OnLoad() {
	Global ; Assume-global mode
	Static Init := OnLoad() ; Call function

	Menu, Tray, Tip, New AutoHotkey Script

	; GDI+ Startup
	hGdip := DllCall("Kernel32.dll\LoadLibrary", "Str", "Gdiplus.dll") ; Load module
	VarSetCapacity(GdiplusStartupInput, (A_PtrSize = 8 ? 24 : 16), 0) ; GdiplusStartupInput structure
	NumPut(1, GdiplusStartupInput, 0, "UInt") ; GdiplusVersion
	DllCall("Gdiplus.dll\GdiplusStartup", "PtrP", pToken, "Ptr", &GdiplusStartupInput, "Ptr", 0) ; Initialize GDI+

	TitleIcon := "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVHcEz///+flKJDAAAAAXRSTlMAQObYZgAAAB9JREFUeAFj+FfP0OSIhIBcBhD5z5GBwRFIIssCFQMAWZEOVjbFLUEAAAAASUVORK5CYII="
	ButtonMinimize := "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAdAQMAAAAErnd0AAAABlBMVEVHcEz///+flKJDAAAAAXRSTlMAQObYZgAAAA9JREFUeAFjoAeof0APWwCLxQFgXVzsZwAAAABJRU5ErkJggg=="
	ButtonMaximize := "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAdAQMAAAAErnd0AAAABlBMVEVHcEz///+flKJDAAAAAXRSTlMAQObYZgAAABZJREFUeAFjoBjUPwBTDgokUzDtVAIAW/YFvwYcJbMAAAAASUVORK5CYII="
	ButtonRestore := "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAdAQMAAAAErnd0AAAABlBMVEVHcEz///+flKJDAAAAAXRSTlMAQObYZgAAACJJREFUeAFjoBjIPwBTAgpgqn4BmHLARz2AUA0QDUCKOgAAgGoIrt5ErioAAAAASUVORK5CYII="
	ButtonClose := "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAdAgMAAABDDg2kAAAACVBMVEVHcEz////////mcEUwAAAAAnRSTlMATAn5wIMAAAAtSURBVHgBYxgwoMIggeBIMqQgOGyOExAcxmkOSJoyGTA5CGWYBiCMRlg6OAAAS1UFoW2zwNkAAAAASUVORK5CYII="
	ButtonHoverLight := "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAdAQMAAAAErnd0AAAABlBMVEX///9HcExwQjx2AAAAAnRSTlMPAPEL0fcAAAA/SURBVHgBY/gPAj8wqAf1YIqBH0T9Y2AHUX8YmIEUEDGCqA8MDJjUAwaGeqIoTO1Qo6EWQa2FOQLhJCDAQQEA9kh/fLXD4JsAAAAASUVORK5CYII="
	ButtonHoverDark := "iVBORw0KGgoAAAANSUhEUgAAAC0AAAAdCAYAAAA+YOU3AAAAW0lEQVR4Ae3XtxGAMADAQAZgLvIw7F9BRXQrR3Gn/gHHbty34hJdJPp8+lAMGoCSL8CDATgPBuA8GIAnAt+JLhLNg+8KQYsWLdp1WrQHJgDuJYCGe7FNkGgi0QdIuLX5HAI62QAAAABJRU5ErkJggg=="

	hBMPTitleIcon := GdipCreateHBITMAPFromBase64(TitleIcon)
	hBMPButtonMinimize := GdipCreateHBITMAPFromBase64(ButtonMinimize)
	hBMPButtonMaximize := GdipCreateHBITMAPFromBase64(ButtonMaximize)
	hBMPButtonRestore := GdipCreateHBITMAPFromBase64(ButtonRestore)
	hBMPButtonClose := GdipCreateHBITMAPFromBase64(ButtonClose)

	BMPButtonHoverLight := GdipCreateBitmapFromBase64(ButtonHoverLight)
	BMPButtonHoverDark := GdipCreateBitmapFromBase64(ButtonHoverDark)
	BMPButtonMinimize := GdipCreateBitmapFromBase64(ButtonMinimize)
	BMPButtonMaximize := GdipCreateBitmapFromBase64(ButtonMaximize)
	BMPButtonRestore := GdipCreateBitmapFromBase64(ButtonRestore)
	BMPButtonClose := GdipCreateBitmapFromBase64(ButtonClose)

	hBMPMinimizeHover := GdipCreateHBITMAPFromBitmap(GdiBitmapMerge(BMPButtonHoverLight, BMPButtonMinimize))
	hBMPMaximizeHover := GdipCreateHBITMAPFromBitmap(GdiBitmapMerge(BMPButtonHoverLight, BMPButtonMaximize))
	hBMPRestoreHover := GdipCreateHBITMAPFromBitmap(GdiBitmapMerge(BMPButtonHoverLight, BMPButtonRestore))
	hBMPCloseHover := GdipCreateHBITMAPFromBitmap(GdiBitmapMerge(BMPButtonHoverLight, BMPButtonClose))

	ButtonState := []
	ButtonState["Minimize"] := 0
	ButtonState["Maximize"] := 0
	ButtonState["Restore"] := 0
	ButtonState["Close"] := 0
}

OnUnload(ExitReason, ExitCode) {
	Global ; Assume-global mode

	; Clean up resources used by GDI+
	DllCall("Gdiplus.dll\GdiplusShutdown", "Ptr", pToken)
}

GdipCreateBitmapFromBase64(B64) {
	VarSetCapacity(B64Len, 0)
	DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &B64, "UInt", StrLen(B64), "UInt", 0x01, "Ptr", 0, "UIntP", B64Len, "Ptr", 0, "Ptr", 0)
	VarSetCapacity(B64Dec, B64Len, 0) ; pbBinary size
	DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &B64, "UInt", StrLen(B64), "UInt", 0x01, "Ptr", &B64Dec, "UIntP", B64Len, "Ptr", 0, "Ptr", 0)
	pStream := DllCall("Shlwapi.dll\SHCreateMemStream", "Ptr", &B64Dec, "UInt", B64Len, "UPtr")
	VarSetCapacity(pBitmap, 0)
	DllCall("Gdiplus.dll\GdipCreateBitmapFromStreamICM", "Ptr", pStream, "PtrP", pBitmap)
	ObjRelease(pStream)
	return pBitmap
}

GdipCreateHBITMAPFromBitmap(pBitmap) {
	VarSetCapacity(hBitmap, 0)
	DllCall("Gdiplus.dll\GdipCreateHBITMAPFromBitmap", "UInt", pBitmap, "UInt*", hBitmap, "Int", 0XFFFFFFFF)
	return hBitmap
}

GdipCreateHICONFromBitmap(pBitmap) {
	VarSetCapacity(hIcon, 0)
	DllCall("Gdiplus.dll\GdipCreateHICONFromBitmap", "Ptr", pBitmap, "PtrP", hIcon, "UInt", 0)
	return hIcon
}

GdipCreateHBITMAPFromBase64(B64) {
	pBitmap := GdipCreateBitmapFromBase64(B64)
	return GdipCreateHBITMAPFromBitmap(pBitmap)
}

GuiCreate() {
	Global ; Assume-global mode
	Static Init := GuiCreate() ; Call function

	; Window Options -----------------------------------------------------------
	Gui, +LastFound -Resize -Caption -Border +HWNDhMaterialDesign +MinSize800x600
	Gui, Margin, 0, 0

	; Window Border ------------------------------------------------------------
	Gui, Add, Text, x0 y0 w800 h1 +0x4E HWNDhBorderTop
	Gui, Add, Text, x0 y599 w800 h1 +0x4E HWNDhBorderBottom
	Gui, Add, Text, x0 y1 w1 h598 +0x4E HWNDhBorderLeft
	Gui, Add, Text, x799 y1 w1 h598 +0x4E HWNDhBorderRight

	; Titlebar -----------------------------------------------------------------
	Gui, Add, Text, x1 y1 w798 h30 +0x4E HWNDhTitlebar
	Gui, Add, Picture, x8 y8 w16 h16 HWNDhTitleIcon +BackgroundTrans, % "HBITMAP:*" hBMPTitleIcon
	Gui, Add, Text, x1 y31 w798 h1 +0x4E HWNDhTitlebarLine
	Gui, Font, s9 cFFFFFF, Segoe UI
	Gui, Add, Text, x30 y1 h30 w400 0x200 HWNDhTitlebarText +BackgroundTrans, Application

	; Window Controls ----------------------------------------------------------
	Gui, Add, Picture, x662 y1 w45 h29 HWNDhButtonMinimize +BackgroundTrans, % "HBITMAP:*" hBMPButtonMinimize
	Gui, Add, Picture, x708 y1 w45 h29 HWNDhButtonMaximize +BackgroundTrans, % "HBITMAP:*" hBMPButtonMaximize
	Gui, Add, Picture, x754 y1 w45 h29 HWNDhButtonClose +BackgroundTrans, % "HBITMAP:*" hBMPButtonClose

	; Appbar -------------------------------------------------------------------
	Gui, Add, Text, x1 y32 w798 h64 +0x4E HWNDhAppbar

	; Body ---------------------------------------------------------------------
	Gui, Add, Text, x1 y96 w200 h504 +0x4E HWNDhPanelLeft
	Gui, Add, Text, x201 y96 w1 h504 +0x4E HWNDhDividerVert
	Gui, Add, Text, x202 y96 w597 h504 +0x4E HWNDhPanelRight

	;Gui, Font, s18 c000000
	;Gui, Add, Text, x1 y700 +BackgroundTrans, TEST

	CreatePixel(hBorderTop, "2E81D3")
	CreatePixel(hBorderBottom, "2E81D3")
	CreatePixel(hBorderLeft, "2E81D3")
	CreatePixel(hBorderRight, "2E81D3")
	CreatePixel(hTitlebar, "0069C0")
	CreatePixel(hTitlebarLine, "48A8F4")
	CreatePixel(hAppbar, "2196F3")
	CreatePixel(hPanelLeft, "FAFAFA")
	CreatePixel(hDividerVert, "D2D2D2")
	CreatePixel(hPanelRight, "F5F5F5")

	Gui, Show, w800 h600, Example
}

GuiSize(GuiHwnd, EventInfo, Width, Height) {
	Global ; Assume-global mode

	If (ErrorLevel = 1) { ; Window minimized
		return
	}

	GuiControl, Move, % hBorderTop, % "w" Width " h1"
	GuiControl, Move, % hBorderBottom, % "y" Height - 1 " w" Width
	GuiControl, Move, % hBorderLeft, % "h" Height - 2
	GuiControl, Move, % hBorderRight, % "x" Width - 1 " h" Height - 2
	GuiControl, Move, % hTitlebar, % "w" Width - 2
	GuiControl, Move, % hTitlebarText, % "w" Width - 170
	GuiControl, Move, % hTitlebarLine, % "w" Width - 2
	GuiControl, Move, % hAppbar, % "w" Width - 2
	GuiControl, Move, % hPanelLeft, % "h" Height - 97
	GuiControl, Move, % hPanelRight, % "w" Width - 204 " h" Height - 97
	GuiControl, Move, % hDividerVert, % "h" Height - 97

	GuiControl, MoveDraw, % hButtonClose, % "x" Width - 46
	GuiControl, MoveDraw, % hButtonMaximize, % "x" Width - 92
	GuiControl, MoveDraw, % hButtonMinimize, % "x" Width - 138
}

GuiEscape(GuiHwnd) {
	ExitApp ; Terminate the script unconditionally
}

GuiClose(GuiHwnd) {
	ExitApp ; Terminate the script unconditionally
}

WM_SIZE(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x0005, "WM_SIZE") ; Call function

	If (A_Gui = 1) {
		Width := lParam & 0xFFFF, Height := lParam >> 16

		WinGet, WinMax, MinMax

		If (WinMax = 1) {
			GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPButtonRestore
		} Else If (WinMax = 0) {
			GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPButtonMaximize
		}
	}
}

WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x0200, "WM_MOUSEMOVE")

	MouseGetPos, MouseX, MouseY, MouseWin, MouseCtl, 2

	VarSetCapacity(TME, 16, 0)
	NumPut(16, TME, 0)
	NumPut(2, TME, 4) ; TME_LEAVE
	NumPut(MouseWin, TME, 8)

	DllCall("User32.dll\TrackMouseEvent", "UInt", &TME)

	If (MouseCtl = hButtonMinimize && ButtonState["Minimize"] <> 1) {
		GuiControl,, % hButtonMinimize, % "HBITMAP:*" hBMPMinimizeHover
		ButtonState["Minimize"] := 1
	} Else If (MouseCtl <> hButtonMinimize && ButtonState["Minimize"] = 1) {
		GuiControl,, % hButtonMinimize, % "HBITMAP:*" hBMPButtonMinimize
		ButtonState["Minimize"] := 0
	}

	If (MouseCtl = hButtonMaximize) {
		WinGet, WinMax, MinMax

		If (WinMax = 1 && ButtonState["Restore"] <> 1) {
			GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPRestoreHover
			ButtonState["Restore"] := 1
		} Else If (WinMax <> 1 && ButtonState["Maximize"] <> 1) {
			GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPMaximizeHover
			ButtonState["Maximize"] := 1
		}
	} Else If (MouseCtl <> hButtonMaximize) {
		WinGet, WinMax, MinMax

		If (WinMax = 1 && ButtonState["Restore"] = 1) {
			GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPButtonRestore
			ButtonState["Restore"] := 0
		} Else If (WinMax <> 1 && ButtonState["Maximize"] = 1) {
			GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPButtonMaximize
			ButtonState["Maximize"] := 0
		}
	}

	If (MouseCtl = hButtonClose && ButtonState["Close"] <> 1) {
		GuiControl,, % hButtonClose, % "HBITMAP:*" hBMPCloseHover
		ButtonState["Close"] := 1
	} Else If (MouseCtl <> hButtonClose && ButtonState["Close"] = 1) {
		GuiControl,, % hButtonClose, % "HBITMAP:*" hBMPButtonClose
		ButtonState["Close"] := 0
	}
}

WM_MOUSELEAVE(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x02A3, "WM_MOUSELEAVE")

	If (ButtonState["Minimize"] <> 0) {
		GuiControl,, % hButtonMinimize, % "HBITMAP:*" hBMPButtonMinimize
		ButtonState["Minimize"] := 0
	} Else If (ButtonState["Maximize"] <> 0) {
		GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPButtonMaximize
		ButtonState["Maximize"] := 0
	} Else If (ButtonState["Restore"] <> 0) {
		GuiControl,, % hButtonMaximize, % "HBITMAP:*" hBMPButtonRestore
		ButtonState["Restore"] := 0
	} Else If (ButtonState["Close"] <> 0) {
		GuiControl,, % hButtonClose, % "HBITMAP:*" hBMPButtonClose
		ButtonState["Close"] := 0
	}
}

WM_LBUTTONDOWN(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x0201, "WM_LBUTTONDOWN") ; Call function

	If (A_Gui = 1) {
		If (MouseCtl = hTitleIcon) {
			PostMessage, 0x112, 0xF100, 0x20 ; WM_SYSCOMMAND := 0x112 ;SC_KEYMENU := 0xF100
		} Else If (MouseCtl = hTitlebarText) {
			PostMessage, 0xA1, 2 ; 0xA1 := WM_NCLBUTTONDOWN / 2 := HTCAPTION
		}
	}
}

WM_LBUTTONUP(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x0202, "WM_LBUTTONUP")

	If (A_Gui = 1) {
		If (MouseCtl = hButtonClose) {
			ExitApp
		} Else If (MouseCtl = hButtonMaximize) {
			WinGet, WinMax, MinMax

			If (WinMax = 1) {
				WinRestore
			} Else If (WinMax = 0) {
				Gui, +Caption
				WinMaximize
				Gui, -Caption
			}
		} Else If (MouseCtl = hButtonMinimize) {
			WinMinimize
		}
	}
}

WM_RBUTTONUP(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x0205, "WM_RBUTTONUP") ; Call function

	If (A_Gui = 1) {
		If (MouseCtl = hTitleIcon) {
			PostMessage, 0x112, 0xF100, 0x20 ; SysMenu
		}
	}
}

WM_LBUTTONDBLCLK(wParam, lParam, Msg, Hwnd) {
	Global ; Assume-global mode
	Static Init := OnMessage(0x0203, "WM_LBUTTONDBLCLK")

	If (A_Gui = 1) {
		If (MouseCtl = hTitlebarText) {
			WinGet, WinMax, MinMax

			If (WinMax = 1) {
				WinRestore
			} Else If (WinMax = 0) {
				Gui, +Caption
				WinMaximize
				Gui, -Caption
			}
		}
	}
}

WM_NCHITTEST(wParam, lParam, Msg, Hwnd) { ; Define sizing borders
	Static Init := OnMessage(0x0084, "WM_NCHITTEST") ; Call function
	Static BSZ := 6 ; Border Size

	If (A_Gui = 1)	{
		WinGetPos, gX, gY, gW, gH

		X := (lParam << 48 >> 48)
		Y := (lParam << 32 >> 48)

		HL := (X < (gX + BSZ))
		HR := (X >= ((gX + gW) - BSZ))
		HT := (Y < (gY + BSZ))
		HB := (Y >= ((gY + gH) - BSZ))

		; Enable window resizing
		If (HL || HR || HT || HB)
		|| (HT & HL || HT & HR || HB & HL || HB & HR) {
			WinGet, Style, Style

			If !(Style & 0x40000) {
				Gui, +Resize
			}
		}

		If (HT) {
			return (HL ? 0xD : HR ? 0xE : 0xC)
		} Else If (HB) {
			return (HL ? 0x10 : HR ? 0x11 : 0xF)
		} Else If (HL) {
			return 0xA
		} Else If (HR) {
			return 0xB
		}
	}
}

WM_NCCALCSIZE(wParam, lParam, Msg, Hwnd) { ; Size the client area to fill entire window
	Static Init := OnMessage(0x0083, "WM_NCCALCSIZE") ; Call function

	If (A_Gui = 1) {
		return 0
	}
}

WM_NCACTIVATE(wParam, lParam, Msg, Hwnd) { ; Prevent drawing border when activating window
	Static Init := OnMessage(0x0086, "WM_NCACTIVATE") ; Call function

	If (A_Gui = 1) {
		return 1
	}
}

CreatePixel(HWND, HexColor) {
	hBitmap := DllCall("Gdi32.dll\CreateBitmap", "Int", 1, "Int", 1, "UInt", 1, "UInt", 24, "Ptr", 0, "Ptr")
	hBM := DllCall("User32.dll\CopyImage", "Ptr", hBitmap, "UInt", 0, "Int", 0, "Int", 0, "UInt", 8, "Ptr")
	VarSetCapacity(BMBITS, 5, 0)
	Numput("0x" HexColor, &BMBITS, 0, "UInt")
	DllCall("Gdi32.dll\SetBitmapBits", "Ptr", hBM, "UInt", 4, "Ptr", &BMBITS)
	DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x0172, "Ptr", 0, "Ptr", hBM, "Ptr")
	DllCall("Gdi32.dll\DeleteObject", "Ptr", hBitmap)
}

GdiBitmapMerge(Bitmap1, Bitmap2) {
	DllCall("Gdiplus.dll\GdipGetImageWidth", "UPtr", Bitmap1, "UInt*", Width)
	DllCall("Gdiplus.dll\GdipGetImageHeight", "UPtr", Bitmap1, "UInt*", Height)
	DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", Width, "Int", Height, "Int", 0, "Int", 0x26200A, "UPtr", 0, "UPtr*", BitmapNew)
	DllCall("Gdiplus.dll\GdipGetImageGraphicsContext", "UPtr", BitmapNew, "UPtr*", pGraphics)
	DllCall("Gdiplus.dll\GdipDrawImageRectRect", "Ptr", pGraphics, "Ptr", Bitmap1, "Float", 0, "Float", 0, "Float", Width, "Float", Height, "Float", 0, "Float", 0, "Float", Width, "Float", Height, "Int", 2, "Ptr", 0, "Ptr", 0, "Ptr", 0)
	DllCall("Gdiplus.dll\GdipDrawImageRectRect", "Ptr", pGraphics, "Ptr", Bitmap2, "Float", 0, "Float", 0, "Float", Width, "Float", Height, "Float", 0, "Float", 0, "Float", Width, "Float", Height, "Int", 2, "Ptr", 0, "Ptr", 0, "Ptr", 0)
	DllCall("Gdiplus.dll\GdipDeleteGraphics", "UPtr", pGraphics)
	return BitmapNew
}
; ==============================================================================
Last edited by TheDewd on 18 Nov 2019, 15:26, edited 1 time in total.

burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by burque505 » 18 Nov 2019, 15:11

@TheDewd, that really looks nice on Win7 64-bit too.
Regards,
burque505

User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Examples of Non-Standard GUIs (ActiveX, GDI, etc.)

Post by joedf » 18 Nov 2019, 17:49

Nice work! :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

Post Reply

Return to “Scripts and Functions (v1)”