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

Post your working scripts, libraries and tools for AHK v1.1 and older
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

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

16 Jan 2016, 02:33

TheDewd wrote:My earlier version is more based on a combination of PeaZip's main interface and options window, borrowing elements from both... My recent iteration does look very similar to Chrome's settings page. I haven't used Chrome in a very long time so I didn't realize the similarities. :-)
PeaZip Options Screenshot.png
It look very nice :)
Can you please post code for that gui?
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

16 Jan 2016, 10:28

vasili111 wrote:Can you please post code for that gui?
https://autohotkey.com/boards/viewtopic ... 003#p58003
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

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

18 Jan 2016, 03:08

Nice example TheDewd =)
But for the Buttons on white (or any other color than the normal grey) background you should add this: Borderless Buttons

small example:

Code: Select all

#NoEnv

Gui, +LastFound
Gui, Margin, 100, 50
Gui, Color, FFFFFF
Gui, Add, Radio, w100 vRB1, Radio1
Gui, Add, Radio, xm y+10 w100 vRB2, Radio2
Gui, Add, CheckBox, w100 vCB, CheckBox
Gui, Add, Edit, xm w100 h30
Gui, Add, Button, xm y+2 w100 vPB, Button
Gui, Show,, Test
WinSet, Redraw
Return
 
GuiClose:
GuiEscape:
ExitApp

CtlColorBtns()
{
    static init := OnMessage(0x0135, "CtlColorBtns")
    return DllCall("gdi32.dll\CreateSolidBrush", "UInt", 0xFFFFFF, "UPtr")
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

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

26 Jan 2016, 16:22

I think I mentioned this before in this thread, but I have now started making alpha releases of my new application, and none of us on the project have the time or ability to do it justice in terms of the GUI styling.
Here is how it currently looks (It's fixed-width, variable-height):
Image
Each of the plugin blocks is a separate AHK script with it's own GUI - you can add as many as you like and have different profiles etc.
There are lots of GUI elements to style, as well as a quite "deep" structure (There are over 10 GUIs within GUIs in that picture). The App > Profile > Plugins architecture will dictate the layout to a large degree, but that aside I am open to anything.
Plugins are intended to be able to be written by end-users, so whatever GUI styling techniques are used, they would have to be easy to implement in plugins, or part of the main app (ie the main app automatically styles child GUIs).

There is also a need for custom buttons / icons etc - so if any of you arty types are interested in contributing anything (eg design ideas/assets/code), please let me know on the UCR thread.
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

03 Feb 2016, 14:45

Microsoft Office 2016 Inspired GUI Interface

Here's a custom UI inspired by Microsoft Office 2016 that I made today... I appreciate any feedback :-)

Tested on Windows 7 with Aero enabled.
Office16.zip
Script with Images
(8.76 KiB) Downloaded 495 times
Screenshot-Main.png
Main Window
Screenshot-Main.png (4.01 KiB) Viewed 8326 times
Screenshot-Menu.png
Displaying Menu
Screenshot-Menu.png (5.88 KiB) Viewed 8326 times
EDIT:
I modified the script so that it would not require the use of external images anymore:

Code: Select all

; Header =======================================================================
; Name .........: Microsoft Office 2016 Inspired UI
; Description ..: A custom UI design based on Microsoft Office 2016
; AHK Version ..: 1.1.23.01 (Unicode 32-bit) - January 24, 2016
; OS Version ...: Windows 2000+
; Language .....: English (en-US)
; Author .......: (TheDewd) Weston Campbell <[email protected]>
; Filename .....: Office16.ahk
; Link .........: https://autohotkey.com/boards/viewtopic.php?f=6&t=3851&p=70009#p70009
; ==============================================================================

; Globals ======================================================================
#SingleInstance, Force ; Allow only one running instance of the 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
SendMode, Input ; Method for sending keystrokes and mouse clicks
SetWorkingDir, %A_ScriptDir% ; Set the working directory of the script
SetBatchLines, -1 ; Run the script at maximum speed
SetWinDelay, -1 ; The delay to occur after modifying a window
SetControlDelay, -1 ; The delay to occur after modifying a control

Application := {} ; Create Application Object
Application.Name := "New AutoHotkey Script"
Application.Version := "0.1"

Window := {} ; Create Window Object
Window.Width := 600
Window.Height := 400
Window.Title := Application.Name
; ==============================================================================

; Script =======================================================================
Menu, FileMenu, Add, File (Item 1), MenuHandler
Menu, FileMenu, Add, File (Item 2), MenuHandler
Menu, FileMenu, Add, File (Item 3), MenuHandler
Menu, FileMenu, Add ; Separator
Menu, FileMenu, Add, Exit, ExitSub
Menu, EditMenu, Add, Edit (Item 1), MenuHandler
Menu, EditMenu, Add, Edit (Item 2), MenuHandler
Menu, EditMenu, Add, Edit (Item 3), MenuHandler
Menu, ViewMenu, Add, View (Item 1), MenuHandler
Menu, ViewMenu, Add, View (Item 2), MenuHandler
Menu, ViewMenu, Add, View (Item 3), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 1), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 2), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 3), MenuHandler
Menu, HelpMenu, Add, Help (Item 1), MenuHandler
Menu, HelpMenu, Add, Help (Item 2), MenuHandler
Menu, HelpMenu, Add, Help (Item 3), MenuHandler

Gui, +LastFound -Resize -Caption -Border +HWNDhGui1
Gui, Color, FFFFFF
Gui, Margin, 10, 10

; Window Border
Gui, Add, Text, % " x" 0 " y" 0 " w" 1 " h" Window.Height " +0x4E +HWNDhBorderLeft"
Gui, Add, Text, % " x" Window.Width-1 " y" 0 " w" 1 " h" Window.Height " +0x4E +HWNDhBorderRight"
Gui, Add, Text, % "x" 1 " y" Window.Height-1 " w" Window.Width-2 " h" 1 " +0x4E +HWNDhBorderBottom"
DllCall("SendMessage", "Ptr", hBorderLeft, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0072C6", 1, 1))
DllCall("SendMessage", "Ptr", hBorderRight, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0072C6", 1, 1))
DllCall("SendMessage", "Ptr", hBorderBottom, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0072C6", 1, 1))

; Window Header
Gui, Add, Text, % "x" 1 " y" 0 " w" Window.Width-2 " h" 67 " +0x4E +HWNDhTitleHeader"
DllCall("SendMessage", "Ptr", hTitleHeader, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))

; Window Title
Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
Gui, Add, Text, % " x" 140 " y" 12 " w" Window.Width-280 " +BackgroundTrans +0x101 +HWNDhTitle", % Window.Title
Gui, Font ; Reset font options

; Window StatusBar
Gui, Add, Picture, % " x" 1 " y" Window.Height-23 " w" Window.Width-2 " h" 22 " +0x4E +HWNDhStatusBar"
StatusBar := "#@@@@@@@@@@@@@@@@@@@@@"
StringReplace, StatusBar, StatusBar, #, BFBFBF|, All
StringReplace, StatusBar, StatusBar, @, F1F1F1|, All
StringTrimRight, StatusBar, StatusBar, 1
DllCall("SendMessage", "Ptr", hStatusBar, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(StatusBar, 1, 22))
Gui, Font, s8 c515050, Segoe UI ; Set font options
Gui, Add, Text, % " x" 8 " y" Window.Height-19 " w" Window.Width-16 " +HWNDhStatusBarText +BackgroundTrans", % "Sample Text"
Gui, Font ; Reset font options

; Window Minimize Button
Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMinimizeN Hidden0"
Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMinimizeH Hidden1"
Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMinimizeP Hidden1"

ButtonMinimize := "####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################@@@@@@@@@@####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

StringReplace, ButtonMinimizeN, ButtonMinimize, #, 0173C7|, All
StringReplace, ButtonMinimizeN, ButtonMinimizeN, @, FFFFFF|, All
StringTrimRight, ButtonMinimizeN, ButtonMinimizeN, 1

StringReplace, ButtonMinimizeH, ButtonMinimize, #, 2A8AD4|, All
StringReplace, ButtonMinimizeH, ButtonMinimizeH, @, FFFFFF|, All
StringTrimRight, ButtonMinimizeH, ButtonMinimizeH, 1

StringReplace, ButtonMinimizeP, ButtonMinimize, #, 015C9F|, All
StringReplace, ButtonMinimizeP, ButtonMinimizeP, @, FFFFFF|, All
StringTrimRight, ButtonMinimizeP, ButtonMinimizeP, 1

DllCall("SendMessage", "Ptr", hButtonMinimizeN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMinimizeN, 46, 31))
DllCall("SendMessage", "Ptr", hButtonMinimizeH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMinimizeH, 46, 31))
DllCall("SendMessage", "Ptr", hButtonMinimizeP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMinimizeP, 46, 31))

; Window Maximize Button
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMaximizeN Hidden0"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMaximizeH Hidden1"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMaximizeP Hidden1"

ButtonMaximize := "##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################@@@@@@@@@@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@@@@@@@@@@############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

StringReplace, ButtonMaximizeN, ButtonMaximize, #, 0173C7|, All
StringReplace, ButtonMaximizeN, ButtonMaximizeN, @, FFFFFF|, All
StringTrimRight, ButtonMaximizeN, ButtonMaximizeN, 1

StringReplace, ButtonMaximizeH, ButtonMaximize, #, 2A8AD4|, All
StringReplace, ButtonMaximizeH, ButtonMaximizeH, @, FFFFFF|, All
StringTrimRight, ButtonMaximizeH, ButtonMaximizeH, 1

StringReplace, ButtonMaximizeP, ButtonMaximize, #, 015C9F|, All
StringReplace, ButtonMaximizeP, ButtonMaximizeP, @, FFFFFF|, All
StringTrimRight, ButtonMaximizeP, ButtonMaximizeP, 1

DllCall("SendMessage", "Ptr", hButtonMaximizeN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMaximizeN, 46, 31))
DllCall("SendMessage", "Ptr", hButtonMaximizeH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMaximizeH, 46, 31))
DllCall("SendMessage", "Ptr", hButtonMaximizeP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMaximizeP, 46, 31))

; Window Restore Button
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonRestoreN Hidden1"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonRestoreH Hidden1"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonRestoreP Hidden1"

ButtonRestore := "################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################@@@@@@@@######################################@######@####################################@@@@@@@@#@####################################@######@#@####################################@######@#@####################################@######@#@####################################@######@#@####################################@######@@@####################################@######@######################################@@@@@@@@##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

StringReplace, ButtonRestoreN, ButtonRestore, #, 0173C7|, All
StringReplace, ButtonRestoreN, ButtonRestoreN, @, FFFFFF|, All
StringTrimRight, ButtonRestoreN, ButtonRestoreN, 1

StringReplace, ButtonRestoreH, ButtonRestore, #, 2A8AD4|, All
StringReplace, ButtonRestoreH, ButtonRestoreH, @, FFFFFF|, All
StringTrimRight, ButtonRestoreH, ButtonRestoreH, 1

StringReplace, ButtonRestoreP, ButtonRestore, #, 015C9F|, All
StringReplace, ButtonRestoreP, ButtonRestoreP, @, FFFFFF|, All
StringTrimRight, ButtonRestoreP, ButtonRestoreP, 1

DllCall("SendMessage", "Ptr", hButtonRestoreN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonRestoreN, 46, 31))
DllCall("SendMessage", "Ptr", hButtonRestoreH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonRestoreH, 46, 31))
DllCall("SendMessage", "Ptr", hButtonRestoreP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonRestoreP, 46, 31))

; Window Close Button
Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonCloseN Hidden0"
Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonCloseH Hidden1"
Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonCloseP Hidden1"

ButtonClose := "##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################-$######$-####################################$-$####$-$#####################################$-$##$-$#######################################$-$$-$#########################################$--$##########################################$--$#########################################$-$$-$#######################################$-$##$-$#####################################$-$####$-$####################################-$######$-############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

StringReplace, ButtonCloseN, ButtonClose, #, 0173C7|, All
StringReplace, ButtonCloseN, ButtonCloseN, $, 4096D5|, All
StringReplace, ButtonCloseN, ButtonCloseN, -, FFFFFF|, All
StringTrimRight, ButtonCloseN, ButtonCloseN, 1

StringReplace, ButtonCloseH, ButtonClose, #, E81123|, All
StringReplace, ButtonCloseH, ButtonCloseH, $, EE4C59|, All
StringReplace, ButtonCloseH, ButtonCloseH, -, FFFFFF|, All
StringTrimRight, ButtonCloseH, ButtonCloseH, 1

StringReplace, ButtonCloseP, ButtonClose, #, F1707A|, All
StringReplace, ButtonCloseP, ButtonCloseP, $, F4939B|, All
StringReplace, ButtonCloseP, ButtonCloseP, -, FFFFFF|, All
StringTrimRight, ButtonCloseP, ButtonCloseP, 1

DllCall("SendMessage", "Ptr", hButtonCloseN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonCloseN, 46, 31))
DllCall("SendMessage", "Ptr", hButtonCloseH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonCloseH, 46, 31))
DllCall("SendMessage", "Ptr", hButtonCloseP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonCloseP, 46, 31))

; Window Menu Button
Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
Gui, Add, Picture, % " x" 2 " y" 36 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuFileN Hidden0"
Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuFileH Hidden1"
Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuFileText +BackgroundTrans +0x201", % "File"
DllCall("SendMessage", "Ptr", hButtonMenuFileN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
DllCall("SendMessage", "Ptr", hButtonMenuFileH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuEditN Hidden0"
Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuEditH Hidden1"
Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuEditText +BackgroundTrans +0x201", % "Edit"
DllCall("SendMessage", "Ptr", hButtonMenuEditN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
DllCall("SendMessage", "Ptr", hButtonMenuEditH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuViewN Hidden0"
Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuViewH Hidden1"
Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuViewText +BackgroundTrans +0x201", % "View"
DllCall("SendMessage", "Ptr", hButtonMenuViewN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
DllCall("SendMessage", "Ptr", hButtonMenuViewH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuToolsN Hidden0"
Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuToolsH Hidden1"
Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuToolsText +BackgroundTrans +0x201", % "Tools"
DllCall("SendMessage", "Ptr", hButtonMenuToolsN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
DllCall("SendMessage", "Ptr", hButtonMenuToolsH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuHelpN Hidden0"
Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuHelpH Hidden1"
Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuHelpText +BackgroundTrans +0x201", % "Help"
DllCall("SendMessage", "Ptr", hButtonMenuHelpN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
DllCall("SendMessage", "Ptr", hButtonMenuHelpH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))
Gui, Font ; Reset font options

Gui, Show, % " w" Window.Width " h" Window.Height, % Window.Title

OnMessage(0x200, "WM_MOUSEMOVE")
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x202, "WM_LBUTTONUP")
OnMessage(0x2A3, "WM_MOUSELEAVE")

VarSetCapacity(TME, 16, 0), NumPut(16, TME, 0), NumPut(2, TME, 4), NumPut(hGui1, TME, 8)
return ; End automatic execution
; ==============================================================================

; Labels =======================================================================
GuiSize:
	If (ErrorLevel = 1) {
		return ; The window has been minimized.  No action needed.
	}

	GuiControl, MoveDraw, % hTitleHeader, % " w" A_GuiWidth-2
	GuiControl, MoveDraw, % hBorderLeft, % " h" A_GuiHeight
	GuiControl, MoveDraw, % hBorderRight, % " x"  A_GuiWidth-1 " h" A_GuiHeight
	GuiControl, MoveDraw, % hBorderBottom, % " y" A_GuiHeight-1 " w" A_GuiWidth-2
	GuiControl, MoveDraw, % hTitle, % " w" A_GuiWidth-280
	GuiControl, MoveDraw, % hStatusBar, % " w" A_GuiWidth-2 " y" A_GuiHeight-23
	GuiControl, MoveDraw, % hStatusBarText, % " w" A_GuiWidth-16 " y" A_GuiHeight-19
	GuiControl, MoveDraw, % hButtonMinimizeN, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMinimizeH, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMinimizeP, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMaximizeN, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonMaximizeH, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonMaximizeP, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestoreN, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestoreH, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestoreP, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonCloseN, % " x" A_GuiWidth-47
	GuiControl, MoveDraw, % hButtonCloseH, % " x" A_GuiWidth-47
	GuiControl, MoveDraw, % hButtonCloseP, % " x" A_GuiWidth-47
return

MenuHandler:
	MsgBox,, MenuHandler, % "Menu Item: " A_ThisMenuItem "`nMenu: " A_ThisMenu
return

GuiEscape:
GuiClose:
ExitSub:
	ExitApp ; Terminate the script unconditionally
return
; ==============================================================================

; Functions ====================================================================
WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
	Global

	DllCall("TrackMouseEvent", "UInt", &TME)

	MouseGetPos,,,, MouseCtrl, 2

	GuiControl, % (MouseCtrl = hButtonMinimizeN || MouseCtrl = hButtonMinimizeH) ? "Show" : "Hide", % hButtonMinimizeH
	GuiControl, % (MouseCtrl = hButtonMaximizeN || MouseCtrl = hButtonMaximizeH) ? "Show" : "Hide", % hButtonMaximizeH
	GuiControl, % (MouseCtrl = hButtonRestoreN || MouseCtrl = hButtonRestoreH) ? "Show" : "Hide", % hButtonRestoreH
	GuiControl, % (MouseCtrl = hButtonCloseN || MouseCtrl = hButtonCloseH) ? "Show" : "Hide", % hButtonCloseH

	GuiControl, % (MouseCtrl = hButtonMenuFileText) ? "Show" : "Hide", % hButtonMenuFileH
	GuiControl, % (MouseCtrl = hButtonMenuEditText) ? "Show" : "Hide", % hButtonMenuEditH
	GuiControl, % (MouseCtrl = hButtonMenuViewText) ? "Show" : "Hide", % hButtonMenuViewH
	GuiControl, % (MouseCtrl = hButtonMenuToolsText) ? "Show" : "Hide", % hButtonMenuToolsH
	GuiControl, % (MouseCtrl = hButtonMenuHelpText) ? "Show" : "Hide", % hButtonMenuHelpH
}

WM_LBUTTONDOWN(wParam, lParam, Msg, Hwnd) {
	Global

	If (MouseCtrl = hTitleHeader || MouseCtrl = hTitle) {
		PostMessage, 0xA1, 2
	}

	GuiControl, % (MouseCtrl = hButtonMinimizeH) ? "Show" : "Hide", % hButtonMinimizeP
	GuiControl, % (MouseCtrl = hButtonMaximizeH) ? "Show" : "Hide", % hButtonMaximizeP
	GuiControl, % (MouseCtrl = hButtonRestoreH) ? "Show" : "Hide", % hButtonRestoreP
	GuiControl, % (MouseCtrl = hButtonCloseH) ? "Show" : "Hide", % hButtonCloseP
}

WM_LBUTTONUP(wParam, lParam, Msg, Hwnd) {
	Global

	If (MouseCtrl = hButtonMinimizeP) {
		WinMinimize
	} Else If (MouseCtrl = hButtonMaximizeP || MouseCtrl = hButtonRestoreP) {
		WinGet, MinMaxStatus, MinMax

		If (MinMaxStatus = 1) {
			WinRestore
			GuiControl, Hide, % hButtonRestoreN
		} Else {
			WinMaximize
			GuiControl, Show, % hButtonRestoreN
		}
	} Else If (MouseCtrl = hButtonCloseP) {
		ExitApp
	} Else If (MouseCtrl = hButtonMenuFileText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuFileText%
		Menu, FileMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuEditText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuEditText%
		Menu, EditMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuViewText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuViewText%
		Menu, ViewMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuToolsText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuToolsText%
		Menu, ToolsMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuHelpText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuHelpText%
		Menu, HelpMenu, Show, %ctlX%, % ctlY + ctlH
	}

	GuiControl, Hide, % hButtonMinimizeP
	GuiControl, Hide, % hButtonMaximizeP
	GuiControl, Hide, % hButtonRestoreP
	GuiControl, Hide, % hButtonCloseP
	GuiControl, Hide, % hButtonMenuFileH
	GuiControl, Hide, % hButtonMenuEditH
	GuiControl, Hide, % hButtonMenuViewH
	GuiControl, Hide, % hButtonMenuToolsH
	GuiControl, Hide, % hButtonMenuHelpH
}

WM_MOUSELEAVE(wParam, lParam, Msg, Hwnd) {
	Global

	GuiControl, Hide, % hButtonMinimizeH
	GuiControl, Hide, % hButtonMaximizeH
	GuiControl, Hide, % hButtonRestoreH
	GuiControl, Hide, % hButtonCloseH
	GuiControl, Hide, % hButtonMinimizeP
	GuiControl, Hide, % hButtonMaximizeP
	GuiControl, Hide, % hButtonRestoreP
	GuiControl, Hide, % hButtonCloseP
	GuiControl, Hide, % hButtonMenuFileH
	GuiControl, Hide, % hButtonMenuEditH
	GuiControl, Hide, % hButtonMenuViewH
	GuiControl, Hide, % hButtonMenuToolsH
	GuiControl, Hide, % hButtonMenuHelpH
}

CreateDIB(Input, W, H, ResizeW := 0, ResizeH := 0, Gradient := 1 ) {
	WB := Ceil((W * 3) / 2) * 2, VarSetCapacity(BMBITS, (WB * H) + 1, 0), P := &BMBITS

	Loop, Parse, Input, |
	{
		P := Numput("0x" . A_LoopField, P + 0, 0, "UInt") - (W & 1 && Mod(A_Index * 3, W * 3) = 0 ? 0 : 1)
	}

	hBM := DllCall("CreateBitmap", "Int", W, "Int", H, "UInt", 1, "UInt", 24, "Ptr", 0, "Ptr")
	hBM := DllCall("CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "Ptr")
	DllCall("SetBitmapBits", "Ptr", hBM, "UInt", WB * H, "Ptr", &BMBITS)

	If (Gradient != 1) {
		hBM := DllCall("CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x0008, "Ptr")
	}

	return DllCall("CopyImage", "Ptr", hBM, "Int", 0, "Int", ResizeW, "Int", ResizeH, "Int", 0x200C, "UPtr")
}
; ==============================================================================
Last edited by TheDewd on 04 Feb 2016, 12:33, edited 1 time in total.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

03 Feb 2016, 19:26

TheDewd wrote:Microsoft Office 2016 Inspired GUI Interface

Here's a custom UI inspired by Microsoft Office 2016 that I made today... I appreciate any feedback :-)
I tried my hands at messing around with this. I thought I'd compose the file menu a different way using just me's Class_CtlColors.ahk.

I positioned the menus at the bottom of their respective headers too. I'd like to change it to know if a menu is shown, and the cursor moves to a different menu, to hide the previously shown one and show the newly hovered menu. What do you think?

Code: Select all

; Header =======================================================================
; Name .........: Microsoft Office 2016 Inspired UI
; Description ..: A custom UI design based on Microsoft Office 2016
; AHK Version ..: 1.1.23.01 (Unicode 32-bit) - January 24, 2016
; OS Version ...: Windows 2000+
; Language .....: English (en-US)
; Author .......: (TheDewd) Weston Campbell <[email protected]>
; Filename .....: Office16.ahk
; Link .........: https://autohotkey.com/boards/viewtopic.php?f=6&t=3851&p=70009#p70009
; ==============================================================================

; Globals ======================================================================
#SingleInstance, Force ; Allow only one running instance of the 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
#Include Class_CtlColors-master\Sources\Class_CtlColors.ahk
SendMode, Input ; Method for sending keystrokes and mouse clicks
SetWorkingDir, %A_ScriptDir% ; Set the working directory of the script
SetBatchLines, -1 ; Run the script at maximum speed
SetControlDelay, -1 ; The delay to occur after modifying a control

Application := {} ; Create Application Object
Application.Name := "New AutoHotkey Script"
Application.Version := "0.1"

Window := {} ; Create Window Object
Window.Width := 600
Window.Height := 400
Window.Title := Application.Name

AppMenu := {1 : {"handlename" : "hButtonMenuFileText"  , "title" : "File"}
            ,2 : {"handlename" : "hButtonMenuEditText" , "title" : "Edit"}
            ,3 : {"handlename" : "hButtonMenuViewText" , "title" : "View"}
            ,4 : {"handlename" : "hButtonMenuToolsText", "title" : "Tools"}
            ,5 : {"handlename" : "hButtonMenuHelpText" , "title" : "Help"}}
; ==============================================================================

; Script =======================================================================
Menu, FileMenu, Add, File (Item 1), MenuHandler
Menu, FileMenu, Add, File (Item 2), MenuHandler
Menu, FileMenu, Add, File (Item 3), MenuHandler
Menu, FileMenu, Add ; Separator
Menu, FileMenu, Add, Exit, ExitSub
Menu, EditMenu, Add, Edit (Item 1), MenuHandler
Menu, EditMenu, Add, Edit (Item 2), MenuHandler
Menu, EditMenu, Add, Edit (Item 3), MenuHandler
Menu, ViewMenu, Add, View (Item 1), MenuHandler
Menu, ViewMenu, Add, View (Item 2), MenuHandler
Menu, ViewMenu, Add, View (Item 3), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 1), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 2), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 3), MenuHandler
Menu, HelpMenu, Add, Help (Item 1), MenuHandler
Menu, HelpMenu, Add, Help (Item 2), MenuHandler
Menu, HelpMenu, Add, Help (Item 3), MenuHandler

Gui, +LastFound -Resize -Caption -Border +HwndhGui1
Gui, Color, FFFFFF
Gui, Margin, 10, 10

; Window Border
Gui, Add, Picture, % " x" 0 " y" 0 " w" 1 " h" Window.Height " +HWNDhWindowBorderLeft", % "resources\window-border.png"
Gui, Add, Picture, % " x" Window.Width-1 " y" 0 " w" 1 " h" Window.Height " +HWNDhWindowBorderRight", % "resources\window-border.png"
Gui, Add, Picture, % " x" 1 " y" Window.Height-1 " w" Window.Width-2 " h" 1 " +HWNDhWindowBorderBottom", % "resources\window-border.png"

; Window Header
Gui, Add, Picture, % " x" 1 " y" 0 " w" Window.Width-2 " h" 67 " +HWNDhWindowHeader", % "resources\window-header.png"

; Window Title
Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
Gui, Add, Text, % " x" 140 " y" 12 " w" Window.Width-280 " +BackgroundTrans +0x101 +HWNDhTitle", % Window.Title

; Window Menu Button
for item in appMenu
{
	If (item = 1)
		Gui, Add, Text, % "x2 yp+25 w40 h24 Center +HWND" appMenu[item, "handlename"] " v" item " +0x201", % appMenu[item, "title"]
	Else
		Gui, Add, Text, % "xp+40 yp w40 h24 +HWND" appMenu[item, "handlename"] " v" item " +0x201", % appMenu[item, "title"]
	currhandle := appMenu[item, "handlename"]
	appMenu[item].handle := %currhandle%
	ctlColors.Attach(%currhandle%, "0173c7", "FFFFFF")
}

; Window Minimize Button
Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +HWNDhButtonMinimizeN Hidden0", % "resources\button-minimize-normal.png"
Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +HWNDhButtonMinimizeH Hidden1", % "resources\button-minimize-hover.png"
Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +HWNDhButtonMinimizeP Hidden1", % "resources\button-minimize-pressed.png"

; Window Maximize Button
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +HWNDhButtonMaximizeN Hidden0", % "resources\button-maximize-normal.png"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +HWNDhButtonMaximizeH Hidden1", % "resources\button-maximize-hover.png"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +HWNDhButtonMaximizeP Hidden1", % "resources\button-maximize-pressed.png"

; Window Restore Button
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +HWNDhButtonRestoreN Hidden1", % "resources\button-restore-normal.png"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +HWNDhButtonRestoreH Hidden1", % "resources\button-restore-hover.png"
Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +HWNDhButtonRestoreP Hidden1", % "resources\button-restore-pressed.png"

; Window Close Button
Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +HWNDhButtonCloseN Hidden0", % "resources\button-close-normal.png"
Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +HWNDhButtonCloseH Hidden1", % "resources\button-close-hover.png"
Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +HWNDhButtonCloseP Hidden1", % "resources\button-close-pressed.png"

; Window StatusBar
Gui, Font, s8 c515050, Segoe UI ; Set font options
Gui, Add, Picture, % " x" 1 " y" Window.Height-23 " w" Window.Width-2 " h" 22 " +HWNDhStatusBar", % "resources\window-statusbar.png"
Gui, Add, Text, % " x" 8 " y" Window.Height-19 " w" Window.Width-16 " +HWNDhStatusBarText +BackgroundTrans", % "Sample Text"
Gui, Font ; Reset font options

Gui, Show, % " w" Window.Width " h" Window.Height, % Window.Title

OnMessage(0x200, "WM_MOUSEMOVE")
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x202, "WM_LBUTTONUP")
OnMessage(0x2A3, "WM_MOUSELEAVE")

VarSetCapacity(TME, 16, 0), NumPut(16, TME, 0), NumPut(2, TME, 4), NumPut(hGui1, TME, 8)
return ; End automatic execution
; ==============================================================================

; Labels =======================================================================
GuiSize:
	If (ErrorLevel = 1) {
		return ; The window has been minimized.  No action needed.
	}

	GuiControl, MoveDraw, % hWindowHeader, % " w" A_GuiWidth-2
	GuiControl, MoveDraw, % hWindowBorderLeft, % " h" A_GuiHeight
	GuiControl, MoveDraw, % hWindowBorderRight, % " x"  A_GuiWidth-1 " h" A_GuiHeight
	GuiControl, MoveDraw, % hWindowBorderBottom, % " y" A_GuiHeight-1 " w" A_GuiWidth-2
	GuiControl, MoveDraw, % hTitle, % " w" A_GuiWidth-280
	GuiControl, MoveDraw, % hStatusBar, % " w" A_GuiWidth-2 " y" A_GuiHeight-23
	GuiControl, MoveDraw, % hStatusBarText, % " w" A_GuiWidth-16 " y" A_GuiHeight-19
	GuiControl, MoveDraw, % hButtonMinimizeN, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMinimizeH, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMinimizeP, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMaximizeN, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonMaximizeH, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonMaximizeP, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestoreN, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestoreH, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestoreP, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonCloseN, % " x" A_GuiWidth-47
	GuiControl, MoveDraw, % hButtonCloseH, % " x" A_GuiWidth-47
	GuiControl, MoveDraw, % hButtonCloseP, % " x" A_GuiWidth-47
return

MenuHandler:
	MsgBox,, MenuHandler, % "Menu Item: " A_ThisMenuItem "`nMenu: " A_ThisMenu
return

GuiEscape:
GuiClose:
ExitSub:
	ExitApp ; Terminate the script unconditionally
return
; ==============================================================================

; Functions ====================================================================
WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
	Global

	DllCall("TrackMouseEvent", "UInt", &TME)

	MouseGetPos,,,, MouseCtrl, 2

	GuiControl, % (MouseCtrl = hButtonMinimizeN || MouseCtrl = hButtonMinimizeH) ? "Show" : "Hide", % hButtonMinimizeH
	GuiControl, % (MouseCtrl = hButtonMaximizeN || MouseCtrl = hButtonMaximizeH) ? "Show" : "Hide", % hButtonMaximizeH
	GuiControl, % (MouseCtrl = hButtonRestoreN || MouseCtrl = hButtonRestoreH) ? "Show" : "Hide", % hButtonRestoreH
	GuiControl, % (MouseCtrl = hButtonCloseN || MouseCtrl = hButtonCloseH) ? "Show" : "Hide", % hButtonCloseH

	If (MouseCtrl = hButtonMenuFileText || MouseCtrl = hButtonMenuEditText || MouseCtrl = hButtonMenuViewText || MouseCtrl = hButtonMenuToolsText || MouseCtrl = hButtonMenuHelpText)
	{
		for item in appMenu
		{
			If (appMenu[item, "handle"] = MouseCtrl)
				CtlColors.Change(MouseCtrl, "2a8ad4", "FFFFFF")
			Else
				CtlColors.Change(appMenu[item, "handle"], "0173c7", "FFFFFF")
		}
	}
	Else
	{
		for item in appMenu
			CtlColors.Change(appMenu[item, "handle"], "0173c7", "FFFFFF")
	}
}

WM_LBUTTONDOWN(wParam, lParam, Msg, Hwnd) {
	Global

	If (MouseCtrl = hWindowHeader || MouseCtrl = hTitle) {
		PostMessage, 0xA1, 2
	}

	GuiControl, % (MouseCtrl = hButtonMinimizeH) ? "Show" : "Hide", % hButtonMinimizeP
	GuiControl, % (MouseCtrl = hButtonMaximizeH) ? "Show" : "Hide", % hButtonMaximizeP
	GuiControl, % (MouseCtrl = hButtonRestoreH) ? "Show" : "Hide", % hButtonRestoreP
	GuiControl, % (MouseCtrl = hButtonCloseH) ? "Show" : "Hide", % hButtonCloseP
}

WM_LBUTTONUP(wParam, lParam, Msg, Hwnd) {
	Global

	If (MouseCtrl = hButtonMinimizeP) {
		WinMinimize
	} Else If (MouseCtrl = hButtonMaximizeP || MouseCtrl = hButtonRestoreP) {
		WinGet, MinMaxStatus, MinMax

		If (MinMaxStatus = 1) {
			WinRestore
			GuiControl, Hide, % hButtonRestoreN
		} Else {
			WinMaximize
			GuiControl, Show, % hButtonRestoreN
		}
	} Else If (MouseCtrl = hButtonCloseP) {
		ExitApp
	} Else If (MouseCtrl = hButtonMenuFileText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuFileText%
		Menu, FileMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuEditText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuEditText%
		Menu, EditMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuViewText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuViewText%
		Menu, ViewMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuToolsText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuToolsText%
		Menu, ToolsMenu, Show, %ctlX%, % ctlY + ctlH
	} Else If (MouseCtrl = hButtonMenuHelpText) {
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuHelpText%
		Menu, HelpMenu, Show, %ctlX%, % ctlY + ctlH
	}

	GuiControl, Hide, % hButtonMinimizeP
	GuiControl, Hide, % hButtonMaximizeP
	GuiControl, Hide, % hButtonRestoreP
	GuiControl, Hide, % hButtonCloseP
}

WM_MOUSELEAVE(wParam, lParam, Msg, Hwnd) {
	Global

	GuiControl, Hide, % hButtonMinimizeH
	GuiControl, Hide, % hButtonMaximizeH
	GuiControl, Hide, % hButtonRestoreH
	GuiControl, Hide, % hButtonCloseH
	GuiControl, Hide, % hButtonMinimizeP
	GuiControl, Hide, % hButtonMaximizeP
	GuiControl, Hide, % hButtonRestoreP
	GuiControl, Hide, % hButtonCloseP
}
; ==============================================================================
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

03 Feb 2016, 19:46

I like the idea of placing the menu pop-up under the buttons... Great idea. :-)

However, with Class_CtlColors, the Menu button's text is flickering while the mouse is moving on the GUI (Windows 10 Home). Might need some modifications to fix that.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

03 Feb 2016, 19:51

Yeah I did notice that too just a bit. I think it's because with my changes, you have to loop over the object and that's done every time the mouse moves over either of those five controls. Anyone else have ideas as to remediation that?
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

04 Feb 2016, 12:35

kczx3, the script doesn't need images anymore. I posted the code at the bottom of my previous post of the script. I also used your menu positioning. Didn't change the method for highlighting the menu buttons yet because of the flickering.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

04 Feb 2016, 13:43

TheDewd wrote:kczx3, the script doesn't need images anymore. I posted the code at the bottom of my previous post of the script. I also used your menu positioning. Didn't change the method for highlighting the menu buttons yet because of the flickering.
I have been playing around with this more as well. I'm still utilizing your images but using class_imagebutton by just me, I was able to drastically shorten the code as well as the complexity of it (IMO). Though the menu buttons don't stay highlighted with the pressed image when the menu is shown which I don't like.

Code: Select all

; Header =======================================================================
; Name .........: Microsoft Office 2016 Inspired UI
; Description ..: A custom UI design based on Microsoft Office 2016
; AHK Version ..: 1.1.23.01 (Unicode 32-bit) - January 24, 2016
; OS Version ...: Windows 2000+
; Language .....: English (en-US)
; Author .......: (TheDewd) Weston Campbell <[email protected]>
; Filename .....: Office16.ahk
; Link .........: https://autohotkey.com/boards/viewtopic.php?f=6&t=3851&p=70009#p70009
; ==============================================================================

; Globals ======================================================================
#SingleInstance, Force ; Allow only one running instance of the 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
#Include Class_ImageButton-master\Sources\Class_ImageButton.ahk
SendMode, Input ; Method for sending keystrokes and mouse clicks
SetWorkingDir, %A_ScriptDir% ; Set the working directory of the script
SetBatchLines, -1 ; Run the script at maximum speed
SetControlDelay, -1 ; The delay to occur after modifying a control

Application := {} ; Create Application Object
Application.Name := "New AutoHotkey Script"
Application.Version := "0.1"

Window := {} ; Create Window Object
Window.Width := 600
Window.Height := 400
Window.Title := Application.Name
; ==============================================================================

; Script =======================================================================
Menu, FileMenu, Add, File (Item 1), MenuHandler
Menu, FileMenu, Add, File (Item 2), MenuHandler
Menu, FileMenu, Add, File (Item 3), MenuHandler
Menu, FileMenu, Add ; Separator
Menu, FileMenu, Add, Exit, ExitSub
Menu, EditMenu, Add, Edit (Item 1), MenuHandler
Menu, EditMenu, Add, Edit (Item 2), MenuHandler
Menu, EditMenu, Add, Edit (Item 3), MenuHandler
Menu, ViewMenu, Add, View (Item 1), MenuHandler
Menu, ViewMenu, Add, View (Item 2), MenuHandler
Menu, ViewMenu, Add, View (Item 3), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 1), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 2), MenuHandler
Menu, ToolsMenu, Add, Tools (Item 3), MenuHandler
Menu, HelpMenu, Add, Help (Item 1), MenuHandler
Menu, HelpMenu, Add, Help (Item 2), MenuHandler
Menu, HelpMenu, Add, Help (Item 3), MenuHandler

Gui, +LastFound -Resize -Caption -Border +HwndhGui1
Gui, Color, FFFFFF
Gui, Margin, 10, 10

; Window Border
Gui, Add, Picture, % " x" 0 " y" 0 " w" 1 " h" Window.Height " +HWNDhWindowBorderLeft", % "resources\window-border.png"
Gui, Add, Picture, % " x" Window.Width-1 " y" 0 " w" 1 " h" Window.Height " +HWNDhWindowBorderRight", % "resources\window-border.png"
Gui, Add, Picture, % " x" 1 " y" Window.Height-1 " w" Window.Width-2 " h" 1 " +HWNDhWindowBorderBottom", % "resources\window-border.png"

; Window Header
Gui, Add, Picture, % " x" 1 " y" 0 " w" Window.Width-139 " h" 31 " +HWNDhWindowHeader1 gclickDrag", % "resources\window-header.png"
Gui, Add, Picture, % "x" 1 " y" 31 " w" Window.Width-2 " h" 29 " +HWNDhWindowHeader2", % "resources\window-header.png"

; Window Title
Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
Gui, Add, Text, % " x" 140 " y" 12 " w" Window.Width/6 " +BackgroundTrans +0x101 +HWNDhTitle", % Window.Title
Gui, Font ; Reset font options

; Window Menu Button
Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
Gui, Add, Button, x2 yp+24 w60 h24 gOnButtonClick +HWNDhButtonMenuFileText, File
opt1 := [0, 0x0173c7, , 0xFFFFFF]
opt2 := [0, 0x2a8ad4, , 0xFFFFFF]
ImageButton.Create(hButtonMenuFileText, Opt1, Opt2)
Gui, Add, Button, xp+60 yp wp hp gOnButtonClick +HWNDhButtonMenuEditText, Edit
ImageButton.Create(hButtonMenuEditText, Opt1, Opt2)
Gui, Add, Button, xp+60 yp wp hp gOnButtonClick +HWNDhButtonMenuViewText, View
ImageButton.Create(hButtonMenuViewText, Opt1, Opt2)
Gui, Add, Button, xp+60 yp wp hp gOnButtonClick +HWNDhButtonMenuToolsText, Tools
ImageButton.Create(hButtonMenuToolsText, Opt1, Opt2)
Gui, Add, Button, xp+60 yp wp hp gOnButtonClick +HWNDhButtonMenuHelpText, Help
ImageButton.Create(hButtonMenuHelpText, Opt1, Opt2)
Gui, Font ; Reset font options

; Window Minimize Button
Gui, Add, Button, % "x" Window.Width-139 " y0 w46 h31 +HWNDhButtonMinimize gMinimize"
Opt1 := [0, "resources\button-minimize-normal.png"]
Opt2 := [0, "resources\button-minimize-hover.png"]
Opt3 := [0, "resources\button-minimize-pressed.png"]
ImageButton.Create(hButtonMinimize, Opt1, Opt2, Opt3)

; Window Maximize Button
Gui, Add, Button, % "x" Window.Width-93 " y0 w46 h31 +HWNDhButtonMaximize gMaximize"
Opt1 := [0, "resources\button-maximize-normal.png"]
Opt2 := [0, "resources\button-maximize-hover.png"]
Opt3 := [0, "resources\button-maximize-pressed.png"]
ImageButton.Create(hButtonMaximize, Opt1, Opt2, Opt3)

; Window Restore Button
Gui, Add, Button, % "x" Window.Width-93 " y0 w46 h31 +HWNDhButtonRestore gRestore Hidden1"
Opt1 := [0, "resources\button-restore-normal.png"]
Opt2 := [0, "resources\button-restore-hover.png"]
Opt3 := [0, "resources\button-restore-pressed.png"]
ImageButton.Create(hButtonRestore, Opt1, Opt2, Opt3)

; Window Close Button
Gui, Add, Button, % "x" Window.Width-47 " y0 w46 h31 +HWNDhButtonClose gGuiClose"
Opt1 := [0, "resources\button-close-normal.png"]
Opt2 := [0, "resources\button-close-hover.png"]
Opt3 := [0, "resources\button-close-pressed.png"]
ImageButton.Create(hButtonClose, Opt1, Opt2, Opt3)

; Window StatusBar
Gui, Font, s8 c515050, Segoe UI ; Set font options
Gui, Add, Picture, % " x" 1 " y" Window.Height-23 " w" Window.Width-2 " h" 22 " +HWNDhStatusBar", % "resources\window-statusbar.png"
Gui, Add, Text, % " x" 8 " y" Window.Height-19 " w" Window.Width-16 " vsBar +HWNDhStatusBarText +BackgroundTrans", % "Sample Text"
Gui, Font ; Reset font options

Gui, Show, % " w" Window.Width " h" Window.Height, % Window.Title
GuiControl, Focus, sBar

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

; Labels =======================================================================
OnButtonClick:
	GuiControl, Focus, sBar
	MouseGetPos,,,, MouseCtrl, 2
	If (MouseCtrl = hButtonMenuFileText)
	{
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %MouseCtrl%
		Menu, FileMenu, Show, %ctlX%, % ctlY + ctlH
	}
	Else If (MouseCtrl = hButtonMenuEditText)
	{
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %MouseCtrl%
		Menu, EditMenu, Show, %ctlX%, % ctlY + ctlH
	}
	Else If (MouseCtrl = hButtonMenuViewText)
	{
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %MouseCtrl%
		Menu, ViewMenu, Show, %ctlX%, % ctlY + ctlH
	}
	Else If (MouseCtrl = hButtonMenuToolsText)
	{
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %MouseCtrl%
		Menu, ToolsMenu, Show, %ctlX%, % ctlY + ctlH
	}
	Else If (MouseCtrl = hButtonMenuHelpText)
	{
		ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %MouseCtrl%
		Menu, HelpMenu, Show, %ctlX%, % ctlY + ctlH
	}
Return

Minimize:
	WinMinimize
Return

Maximize:
Restore:
	WinGet, MinMaxStatus, MinMax
	If (MinMaxStatus = 1)
	{
		WinRestore
		GuiControl, Show, % hButtonMaximize
		GuiControl, Hide, % hButtonRestore
	}
	Else
	{
		WinMaximize
		GuiControl, Hide, % hButtonMaximize
		GuiControl, Show, % hButtonRestore
	}
Return

GuiSize:
	If (ErrorLevel = 1) {
		return ; The window has been minimized.  No action needed.
	}

	GuiControl, MoveDraw, % hWindowHeader1, % " w" A_GuiWidth-139
	GuiControl, MoveDraw, % hWindowHeader2, % " w" A_GuiWidth-2
	GuiControl, MoveDraw, % hWindowBorderLeft, % " h" A_GuiHeight
	GuiControl, MoveDraw, % hWindowBorderRight, % " x"  A_GuiWidth-1 " h" A_GuiHeight
	GuiControl, MoveDraw, % hWindowBorderBottom, % " y" A_GuiHeight-1 " w" A_GuiWidth-2
	GuiControl, MoveDraw, % hTitle, % " w" A_GuiWidth-280
	GuiControl, MoveDraw, % hStatusBar, % " w" A_GuiWidth-2 " y" A_GuiHeight-23
	GuiControl, MoveDraw, % hStatusBarText, % " w" A_GuiWidth-16 " y" A_GuiHeight-19
	GuiControl, MoveDraw, % hButtonMinimize, % " x" A_GuiWidth-139
	GuiControl, MoveDraw, % hButtonMaximize, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonRestore, % " x" A_GuiWidth-93
	GuiControl, MoveDraw, % hButtonClose, % " x" A_GuiWidth-47
return

MenuHandler:
	MsgBox,, MenuHandler, % "Menu Item: " A_ThisMenuItem "`nMenu: " A_ThisMenu
return

GuiEscape:
GuiClose:
ExitSub:
	ExitApp ; Terminate the script unconditionally
return

clickDrag:
	PostMessage, 0xA1, 2
Return

; ==============================================================================
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

04 Feb 2016, 13:48

Also, I think it would look better if the fade out time on the buttons was quicker. Not sure if that's something that could be tweaked in just me's code or not.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

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

05 Feb 2016, 01:43

Now a ribbon menu or self drawn menu (like the blue color) and it would be perfect =)
Good job TheDewd & kczx3
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

05 Feb 2016, 10:45

@jNizM

Here's my attempt at somewhat of a ribbon menu. Two things:
1) It flickers again when you change the selected menu (change tabs in the tab control). It appears that the ImageButtons in the upper-right corner don't like it when the tab changes.
2) I can't seem to get the buttons text in the menuHandler g-label. I gave them variables and A_GuiControl is getting populated but GuiControlGet won't retrieve the button's text.
Attachments
Office16.zip
(39.26 KiB) Downloaded 292 times
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

05 Feb 2016, 10:52

kczx3 wrote:Here's my attempt at somewhat of a ribbon menu.
Here's an actual screenshot of the real ribbon, if you'd like to use it for inspiration:
Image
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

05 Feb 2016, 11:04

Do you know if the icons are accessible from an EXE or DLL? If so, which one?
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

05 Feb 2016, 11:23

I had luck using Microsoft Office Icons (ImageMSO) Gallery & Extraction.

I've uploaded the icons extracted from my installation of Office 2016.

The zip archive contains 8,893 ico files in the following sizes:

16x16
24x24
32x32
48x48
64x64
128x128

https://www.dropbox.com/s/j7sckawfh30n3 ... 6.zip?dl=0
53.6 MB compressed
866 MB extracted

You should be able to extract the image size you need from the ico files. I use IconViewer which even lets me save a PNG from an ICO file.
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

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

05 Feb 2016, 12:01

Haha nice, it would be cool to have a MS Ribbon menu library ;)
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]
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

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

05 Feb 2016, 15:03

Best I could do for now. Class_ImageButtons sctretches the image to cover the whole button and you can't just simply change the background of the button with the same image overlay. so that requires you to have all the icons of different shades for Normal/Hover/Pressed which is a nuisance. I'm sure there are other ways but I'm just not aware of them or they are too complex for me right now.
office16_w_icons.png
office16_w_icons.png (8.13 KiB) Viewed 8108 times
lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

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

05 Feb 2016, 17:08

joedf wrote:Haha nice, it would be cool to have a MS Ribbon menu library ;)
There is one...
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

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

05 Feb 2016, 22:19

yes :b i meant ahk library, naturally it seems to work with COM... but anyhow thanks for the link :)
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]

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 124 guests