iPhilip wrote: ↑28 Nov 2021, 17:15
Hellbent wrote: ↑27 Nov 2021, 18:05
Resizable Layered window template. ( +E0x80000 / +E0x080000 )
Interesting! I would appreciate it if you would share the code you used to generate that. Thank you.
It isn't ready for release yet but enough of it is done to convey the basics.
***This requires the GDIP.AHK LIB and Windows 8 or higher ( uses embedded controls and child windows )
When you use this, you basically use a grandchild window as your main window.
The parent has the design for the background and window frame and is redrawn as the window is resized using this.
Code: Select all
_DrawGraphics(){
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , This.W , This.H , "0x01000000" , "0x66000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , 13 , 1 , This.W - 15 , This.H - 4 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 6 , 6 , This.W - 12 , This.H - 12 , "0xff808080" , "0xFF474747" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , 6 , 6 , This.W - 12 , This.H - 12 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 6 , 6 , This.W - 12 , This.H - 12 , "0xFF171717" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , 6 , 6 , This.W - 12 , This.H - 12 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xff252525" ) , Gdip_FillRoundedRectangle( This.G , Brush , 8 , 8 , This.W - 16 , This.H - 16 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xff2E2E2E" ) , Gdip_FillRoundedRectangle( This.G , Brush , 8 , 28 , This.W - 16 , This.H - 36 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF2E2E2E" ) , Gdip_FillRectangle( This.G , Brush , 8 , 28 , This.W - 16 , This.H - 142 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF383838" , 1 ) , Gdip_DrawLine( This.G , Pen , 9 , 28 , This.W - 9 , 28 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 5 , 10 , This.W - 12 , This.H - 22 , "0x66171717" , "0x66000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , 8 , 8 , This.W - 16 , This.H - 16 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFFB6B6B6" ) , Gdip_FillEllipse( This.G , Brush , 11 , 10 , 15 , 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF323232" ) , Gdip_TextToGraphics( This.G , "r" , "s11 Center vCenter Bold c" Brush " x11 y12" , "Webdings" , 15 , 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFB3B3B3" ) , Gdip_TextToGraphics( This.G , This.Text , "s12 Center vCenter Bold c" Brush " x0 y8" , "Verdana" , This.W , 25 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFacacac" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawLine( This.G , Pen , This.W - 24 , This.H - 12 , This.W - 12 , This.H - 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFFacacac" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawLine( This.G , Pen , This.W - 20 , This.H - 12 , This.W - 12 , This.H - 20 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFFacacac" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawLine( This.G , Pen , This.W - 16 , This.H - 12 , This.W - 12 , This.H - 16 ) , Gdip_DeletePen( Pen )
}
inside that window is another window that acts as the housing for your window. This window is resized but not redrawn as the window is resized.
Last is your window which sits inside a window inside another window.
I don't have the child window added in to the class yet so I had to just rig things up bit.
This here ( found in the auto-execute section at the top)
Code: Select all
Gui2 := New PopUpWindow( { X: 20 , Y: 30 , W: Gui1.W - 40 , H: Gui1.H - 50 , Options: " -DPIScale +AlwaysOnTop +Parent" Gui1.Hwnd } )
Gui2.ShowWindow()
Gui2.PaintBackground( color := "0xFF000000" , 1 ) ;{ Color: "0xFF000000" , X: 2 , Y: 2 , W: Gui2.W - 4 , H: Gui2.H - 4 , Round: 10 }
;and this
ResizeIt:
Gui2.UpdateSettings( { W: Gui1.W - 40 , H: Gui1.H - 50 } , UpdateGraphics := 0 )
Gui2.ShowWindow()
return
would be part of the windows class.
And this
Code: Select all
Gui3 := New PopUpWindow( { X: 0 , Y: 0 , W: 700 , H: 400 , Options: " -DPIScale +AlwaysOnTop +Parent" Gui2.Hwnd } )
Gui3.ShowWindow()
Gui3.PaintBackground( { Color: "0xFF22262a" , X: 2 , Y: 2 , W: Gui3.W - 4 , H: Gui3.H - 4 , Round: 10 } , 1 ) ;{ Color: "0xFF000000" , X: 2 , Y: 2 , W: Gui3.W - 4 , H: Gui3.H - 4 , Round: 10 }
Gui3.DrawBitmap( HB_BITMAP_MAKER() , { X: 100 , Y: 100 , W: 300 , H: 220 } , 1 , 1 )
Is more or less how you use the main window (your window).
I made the inner window a different color in this gif so that it is easier to see how it works. (the parent of your window)
- Temp (1).gif (691.85 KiB) Viewed 7269 times
This here is the class that I am using for my main window ( the window with my controls on it etc.)
I am also using it for the inner window in this case since it hasn't been added to the class yet.
PopUpWindow Class (v2) ( general purpose Layered Window class)
Code: Select all
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
class PopUpWindow {
;PopUpWindow v2
;Date Written: Oct 28th, 2021
;Written By: Hellbent aka CivReborn
;SpcThanks: teadrinker , malcev
static Index := 0 , Windows := [] , Handles := [] , EditHwnd , HelperHwnd
__New( obj := "" ){
This._SetDefaults()
This.UpdateSettings( obj )
This._CreateWindow()
This._CreateWindowGraphics()
if( This.AutoShow )
This.ShowWindow( This.Title )
}
_SetDefaults(){
This.X := 10
This.Y := 10
This.W := 10
This.H := 10
This.Smoothing := 2
This.Options := " -DPIScale +AlwaysOnTop "
This.AutoShow := 0
This.GdipStartUp := 0
This.Title := ""
This.Controls := []
This.Handles := []
This.Index := 0
}
AddTrigger( obj ){
local k , v , cc , bd
This.Controls[ ++This.Index ] := { X: 10
, Y: 10
, W: 10
, H: 10 }
for k, v in obj
This.Controls[ This.Index ][ k ] := obj[ k ]
cc := This.Controls[ This.Index ]
Gui, % This.Hwnd ":Add", Text, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd"
This.Handles[ hwnd ] := This.Index
This.Controls[ This.Index ].Hwnd := hwnd
return hwnd
}
DrawTriggers( color := "0xFFFF0000" , AutoUpdate := 0 ){
local brush , cc
Brush := Gdip_BrushCreateSolid( color )
Gdip_SetSmoothingMode( This.G , 3 )
loop, % This.Controls.Length() {
cc := This.Controls[ A_Index ]
Gdip_FillRectangle( This.G , Brush , cc.x , cc.y , cc.w , cc.h )
}
Gdip_DeleteBrush( Brush )
Gdip_SetSmoothingMode( This.G , This.Smoothing )
if( AutoUpdate )
This.UpdateWindow()
}
UpdateSettings( obj := "" , UpdateGraphics := 0 ){
local k , v
if( IsObject( obj ) )
for k, v in obj
This[ k ] := obj[ k ]
( This.X = "Center" ) ? ( This.X := ( A_ScreenWidth - This.W ) / 2 )
( This.Y = "Center" ) ? ( This.Y := ( A_ScreenHeight - This.H ) / 2 )
if( UpdateGraphics ){
This._DestroyWindowsGraphics()
This._CreateWindowGraphics()
}
}
_CreateWindow(){
local hwnd
Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.Options
PopUpWindow.Index++
This.Index := PopUpWindow.Index
PopUpWindow.Windows[ PopUpWindow.Index ] := This
This.Hwnd := hwnd
PopUpWindow.Handles[ hwnd ] := PopUpWindow.Index
if( This.GdipStartUp && !PopUpWindow.pToken )
PopUpWindow.pToken := GDIP_STARTUP()
}
_DestroyWindowsGraphics(){
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
}
_CreateWindowGraphics(){
This.hbm := CreateDIBSection( This.W , This.H )
This.hdc := CreateCompatibleDC()
This.obm := SelectObject( This.hdc , This.hbm )
This.G := Gdip_GraphicsFromHDC( This.hdc )
Gdip_SetSmoothingMode( This.G , This.Smoothing )
}
ShowWindow( Title := "" ){
Gui , % This.Hwnd ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
}
HideWindow(){
Gui , % This.Hwnd ":Hide",
}
UpdateWindow(){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
}
ClearWindow( AutoUpdate := 0 ){
Gdip_GraphicsClear( This.G )
if( Autoupdate )
This.UpdateWindow()
}
DrawBitmap( pBitmap , obj , dispose := 1 , AutoUpdate := 0 ){
Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
if( dispose )
Gdip_DisposeImage( pBitmap )
if( Autoupdate )
This.UpdateWindow()
}
PaintBackground( color := "0xFF000000" , AutoUpdate := 0 ){
if( isObject( color ) ){
Brush := Gdip_BrushCreateSolid( ( color.HasKey( "Color" ) ) ? ( color.Color ) : ( "0xFF000000" ) )
if( color.Haskey( "Round" ) )
Gdip_FillRoundedRectangle( This.G , Brush , color.X , color.Y , color.W , color.H , color.Round )
else
Gdip_FillRectangle( This.G , Brush , color.X , color.Y , color.W , color.H )
}else{
Brush := Gdip_BrushCreateSolid( color )
Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 )
}
Gdip_DeleteBrush( Brush )
if( AutoUpdate )
This.UpdateWindow()
}
DeleteWindow( GDIPShutdown := 0 ){
Gui, % This.Hwnd ":Destroy"
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
Gdip_DeleteGraphics( This.G )
hwnd := This.Hwnd
for k, v in PopUpWindow.Windows[ Hwnd ]
This[k] := ""
PopUpWindow.Windows[ Hwnd ] := ""
if( GDIPShutdown ){
Gdip_Shutdown( PopUpWindow.pToken )
PopUpWindow.pToken := ""
}
}
_OnClose( wParam ){
if( wParam = 0xF060 ){ ;SC_CLOSE ;[ clicking on the gui close button ]
Try{
Gui, % PopUpWindow.HelperHwnd ":Destroy"
SoundBeep, 555
}
}
}
CreateCachedBitmap( pBitmap , Dispose := 0 ){
local pCachedBitmap
if( This.CachedBitmap )
This.DisposeCachedbitmap()
DllCall( "gdiplus\GdipCreateCachedBitmap" , "Ptr" , pBitmap , "Ptr" , this.G , "PtrP" , pCachedBitmap )
This.CachedBitmap := pCachedBitmap
if( Dispose )
Gdip_DisposeImage( pBitmap )
}
DrawCachedBitmap( AutoUpdate := 0 ){
DllCall( "gdiplus\GdipDrawCachedBitmap" , "Ptr" , this.G , "Ptr" , This.CachedBitmap , "Int" , 0 , "Int" , 0 )
if( AutoUpdate )
This.UpdateWindow()
}
DisposeCachedbitmap(){
DllCall( "gdiplus\GdipDeleteCachedBitmap" , "Ptr" , This.CachedBitmap )
}
Helper(){
local hwnd , MethodList := ["__New","UpdateSettings","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow" , "AddTrigger" , "DrawTriggers", "CreateCachedBitmap" , "DrawCachedBitmap" , "DisposeCachedbitmap" ]
Gui, New, +AlwaysOnTop +ToolWindow +HwndHwnd
PopUpWindow.HelperHwnd := hwnd
Gui, Add, Edit, xm ym w250 r1 Center hwndhwnd, Gui1
PopUpWindow.EditHwnd := hwnd
loop, % MethodList.Length()
Gui, Add, Button, xm y+1 w250 r1 gPopUpWindow._HelperClip, % MethodList[ A_Index ]
Gui, Show,,
OnMessage( 0x112 , This._OnClose.Bind( hwnd ) )
}
_HelperClip(){
local ClipList
GuiControlGet, out, % PopUpWindow.HelperHwnd ":", % PopUpWindow.EditHwnd
ClipList := { __New: " := New PopUpWindow( { X: 0 , Y: 0 , W: A_ScreenWidth , H: A_ScreenHeight , Options: "" -DPIScale +AlwaysOnTop "" } )"
, UpdateSettings: ".UpdateSettings( { X: """" , Y: """" , W: """" , H: """" } , UpdateGraphics := 0 )"
, ShowWindow: ".ShowWindow( Title := """" )"
, HideWindow: ".HideWindow()"
, UpdateWindow: ".UpdateWindow()"
, ClearWindow: ".ClearWindow( AutoUpdate := 0 )"
, DrawBitmap: ".DrawBitmap( pBitmap := """" , { X: 0 , Y: 0 , W: " Out ".W , H: " Out ".H } , dispose := 1 )"
, PaintBackground: ".PaintBackground( color := ""0xFF000000"" ) " ";{ Color: ""0xFF000000"" , X: 2 , Y: 2 , W: " Out ".W - 4 , H: " Out ".H - 4 , Round: 10 }"
, DeleteWindow: ".DeleteWindow( GDIPShutdown := 0 )"
, AddTrigger: ".AddTrigger( { X: """" , Y: """" , W: """" , H: """" , Value: """" , Label: """" , BoundClass: """" , BoundMethod: """" } )"
, DrawTriggers: ".DrawTriggers( color := ""0xFFFF0000"" , AutoUpdate := 0 )"
, CreateCachedBitmap: ".CreateCachedBitmap( pBitmap , Dispose := 0 )"
, DrawCachedBitmap: ".DrawCachedBitmap( AutoUpdate := 0 )"
, DisposeCachedbitmap: ".DisposeCachedbitmap()" }
clipboard := Out ClipList[ A_GuiControl ]
}
}
This is the window template class. As I said before, it is missing the part that adds and controls the inner window. See the sample code for an example of it.
Window Template Class (aka #Include <Dark Layered Window Class>)
Code: Select all
;**************************************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************************************
class DarkWindow1 {
;Written By: Hellbent
;Date: June 10th, 2021
static Index := 0 , Handles := [] , Windows := [] , pToken , FT , Methods := ["_CreateGUI","_AddControls","_RepositionControls","_CreateBitmap","_DrawGraphics","_UpdateWindow","ShowWindow"]
__New( obj := "" ){
if( !DarkWindow1.pToken )
DarkWindow1.pToken := GDIP_StartUp()
DarkWindow1.Index++
This._SetDefaults()
This.UpdateDefaults( obj )
Loop, % DarkWindow1.Methods.Length()
This[ DarkWindow1.Methods[ A_Index ] ]()
This._MoveWindow()
DarkWindow1.Handles[ This.Hwnd ] := DarkWindow1.Index
DarkWindow1.Windows[ DarkWindow1.Index ] := This
}
_SetDefaults(){
This.X := "Center"
This.Y := "Center"
This.W := 185
This.H := 192
This.MinWidth := 185
This.MinHeight := 192
This.WindowOptions := " +AlwaysOnTop -DPIScale "
This.MainColor := ""
This.TitleBarColor := ""
This.TextColor :=
This.Text := "Window"
This.Handles := []
This.Controls := []
This.Controls[1] := { Name: "CloseButton" , X: 11 , Y: 10 , W: 15 , H: 15 , Hwnd: "" , Method: "_CloseWindow" }
This.Controls[2] := { Name: "TitleBar" , X: 26 , Y: 0 , W: This.W - 36 , H: 27 , Hwnd: "" , Method: "_MoveWindow" }
This.Controls[3] := { Name: "ReSize" , X: This.W - 24 , Y: This.H - 24 , W: 15 , H: 15 , Hwnd: "" , Method: "_ResizeWindow" }
This.Hwnd := ""
This.hbm := ""
This.hdc := ""
This.obm := ""
This.G := ""
This.WindowSmoothing := 2
}
UpdateDefaults( obj := "" ){
for k, v in obj
This[ k ] := v
( This.X = "Center" ) ? ( This.X := ( A_ScreenWidth - This.W ) / 2 )
( This.Y = "Center" ) ? ( This.Y := ( A_ScreenHeight - This.H ) / 2 )
if( !DarkWindow1.FT && DarkWindow1.FT := 1 )
return
This._DeleteBitmap()
This._CreateBitmap()
}
_DeleteBitmap(){
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
}
_CreateBitmap(){
This.hbm := CreateDIBSection( This.W , This.H )
This.hdc := CreateCompatibleDC()
This.obm := SelectObject( This.hdc , This.hbm )
This.G := Gdip_GraphicsFromHDC( This.hdc )
Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )
}
_AddControls(){
local hwnd , bd
Loop, % This.Controls.Length() {
Gui, % This.Hwnd ":Add" , Text, % "x" This.Controls[ A_Index ].X " y" This.Controls[ A_Index ].Y " w" This.Controls[ A_Index ].W " h" This.Controls[ A_Index ].H " hwndhwnd"
This.Handles[ hwnd ] := A_Index
This.Controls[ A_Index ].Hwnd := hwnd
bd := This[ This.Controls[ A_Index ].Method ].Bind( This )
GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
}
}
_CreateGUI(){
local hwnd
Gui, New, % " +E0x80000 hwndhwnd -Caption " This.WindowOptions
This.Hwnd := hwnd
}
_CloseWindow(){
This.DeleteWindow()
}
_MoveWindow(){
PostMessage, 0xA1, 2
While(GetKeyState("LButton"))
sleep, 30
WinGetPos, x, y,,, % "ahk_id " This.Hwnd
This.UpdateDefaults( { X: x , Y: y } )
;~ if(y < 1){
;~ ToolTip, here
;~ This.UpdateDefaults( { X: -12 , Y: -12 ,W: A_ScreenWidth + 24 , H: A_ScreenHeight - 70 } )
;~ This.ClearWindow()
;~ This._DrawGraphics()
;~ This._UpdateWindow()
;~ This._RepositionControls()
;~ }
}
_ResizeWindow(){
static lx
local x , y
CoordMode, Mouse, Screen
While(GetKeyState( "LButton" ) ){
MouseGetPos, x , y
if( lx != x ){
lx := x
This._GCycle( x , y )
gosub, ResizeIt
}
sleep, 30
}
This._RepositionControls()
gosub, ResizeIt
}
_RepositionControls(){
GuiControl, % This.Hwnd ":Move" , % This.Controls[ 2 ].Hwnd , % "w" This.W - 26 - 10
GuiControl, % This.Hwnd ":Move" , % This.Controls[ 3 ].Hwnd , % "x" This.W - 24 " y" This.H - 24
}
_GCycle( x , y ){
This.W := x - This.X + 5
This.H := y - This.Y + 5
if( This.W < This.MinWidth )
This.W := This.MinWidth
if( This.H < This.MinHeight )
This.H := This.MinHeight
This.UpdateDefaults()
This.ClearWindow()
This._DrawGraphics()
This._UpdateWindow()
}
ClearWindow(){
Gdip_GraphicsClear( This.G )
}
ShowWindow(){
Gui, % This.Hwnd ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H
}
_UpdateWindow(){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
}
_DrawGraphics(){
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , This.W , This.H , "0x01000000" , "0x66000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , 13 , 1 , This.W - 15 , This.H - 4 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 6 , 6 , This.W - 12 , This.H - 12 , "0xff808080" , "0xFF474747" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , 6 , 6 , This.W - 12 , This.H - 12 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 6 , 6 , This.W - 12 , This.H - 12 , "0xFF171717" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , 6 , 6 , This.W - 12 , This.H - 12 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xff252525" ) , Gdip_FillRoundedRectangle( This.G , Brush , 8 , 8 , This.W - 16 , This.H - 16 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xff2E2E2E" ) , Gdip_FillRoundedRectangle( This.G , Brush , 8 , 28 , This.W - 16 , This.H - 36 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF2E2E2E" ) , Gdip_FillRectangle( This.G , Brush , 8 , 28 , This.W - 16 , This.H - 142 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF383838" , 1 ) , Gdip_DrawLine( This.G , Pen , 9 , 28 , This.W - 9 , 28 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 5 , 10 , This.W - 12 , This.H - 22 , "0x66171717" , "0x66000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , 8 , 8 , This.W - 16 , This.H - 16 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFFB6B6B6" ) , Gdip_FillEllipse( This.G , Brush , 11 , 10 , 15 , 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF323232" ) , Gdip_TextToGraphics( This.G , "r" , "s11 Center vCenter Bold c" Brush " x11 y12" , "Webdings" , 15 , 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFB3B3B3" ) , Gdip_TextToGraphics( This.G , This.Text , "s12 Center vCenter Bold c" Brush " x0 y8" , "Verdana" , This.W , 25 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFacacac" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawLine( This.G , Pen , This.W - 24 , This.H - 12 , This.W - 12 , This.H - 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFFacacac" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawLine( This.G , Pen , This.W - 20 , This.H - 12 , This.W - 12 , This.H - 20 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFFacacac" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawLine( This.G , Pen , This.W - 16 , This.H - 12 , This.W - 12 , This.H - 16 ) , Gdip_DeletePen( Pen )
}
DeleteWindow(){
Gui, % This.Hwnd ":Destroy"
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
Gdip_DeleteGraphics( This.G )
;~ GDIP_ShutDown( DarkWindow1.pToken )
hwnd := This.Hwnd
for k, v in DarkWindow1.Windows[ Hwnd ]
This[k] := ""
DarkWindow1.Windows[ Hwnd ] := ""
}
}
And here is a little demo. (most of the code is for a simple graphics example inside the window [ HB_BITMAP_MAKER() ] ).
Demo
Code: Select all
;***************************************************************************************************
#Include <My Altered Gdip Lib> ;Replace with your path to the Gdip.ahk lib
#Include <PopUpWindow_V2>
#Include <Dark Layered Window Class>
;***************************************************************************************************
#SingleInstance force
SetBatchLines, -1
Gui1 := New DarkWindow1( { X: 800 , Y: 100 , W: 300 , H: 300 , Text: "Demo Window 1" , MinWidth: 250 , MinHeight: 50 } )
Gui2 := New PopUpWindow( { X: 20 , Y: 30 , W: Gui1.W - 40 , H: Gui1.H - 50 , Options: " -DPIScale +AlwaysOnTop +Parent" Gui1.Hwnd } )
Gui2.ShowWindow()
Gui2.PaintBackground( color := "0xFF00ff00" , 1 )
Gui3 := New PopUpWindow( { X: 0 , Y: 0 , W: 700 , H: 400 , Options: " -DPIScale +AlwaysOnTop +Parent" Gui2.Hwnd } )
Gui3.ShowWindow()
Gui3.PaintBackground( { Color: "0xFF22262a" , X: 2 , Y: 2 , W: Gui3.W - 4 , H: Gui3.H - 4 , Round: 10 } , 1 ) ;{ Color: "0xFF000000" , X: 2 , Y: 2 , W: Gui3.W - 4 , H: Gui3.H - 4 , Round: 10 }
Gui3.DrawBitmap( HB_BITMAP_MAKER() , { X: 100 , Y: 100 , W: 300 , H: 220 } , 1 , 1 )
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
Numpad3::PopUpWindow.Helper()
Numpad1::New DarkWindow1( { X: 800 , Y: 100 , W: 500 , H: h := 360 , Text: "Put The Windows Title Here" , MinWidth: 280 , MinHeight: 50 } )
ResizeIt:
Gui2.UpdateSettings( { W: Gui1.W - 40 , H: Gui1.H - 50 } , UpdateGraphics := 0 )
Gui2.ShowWindow()
return
HB_BITMAP_MAKER(){
;Bitmap Created Using: HB Bitmap Maker
pBitmap := Gdip_CreateBitmap( 300 , 220 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF1D1D1D" ) , Gdip_FillRectangle( G , Brush , -1 , -1 , 302 , 222 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 10 , 15 , 280 , 198 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF1D1D1D" ) , Gdip_FillRectangle( G , Brush , 15 , 5 , 138 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 15 , 8 , 96 , 17 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Button Colors" , "s12 Bold c" Brush " x42 y8" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 15 , 5 , 138 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF006666" ) , Gdip_TextToGraphics( G , "Outer Border:" , "s12 c" Brush " x16 y38" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 102 , 35 , 30 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 102 , 35 , 30 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 142 , 35 , 90 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 142 , 35 , 90 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 236 , 34 , 49 , 24 , "0xFF2d2d2d" , "0xFF0d0d0d" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 237 , 34 , 48 , 24 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 236 , 35 , 51 , 49 , "0xFF006666" , "0xFF121212" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 237 , 34 , 48 , 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 15 , 8 , 96 , 17 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Get" , "s12 Bold c" Brush " x249 y38" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF006666" ) , Gdip_TextToGraphics( G , "Center Border:" , "s12 c" Brush " x16 y68" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 102 , 65 , 30 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 102 , 65 , 30 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 142 , 65 , 90 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 142 , 65 , 90 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 238 , 63 , 47 , 25 , "0xFF2d2d2d" , "0xFF0d0d0d" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 237 , 64 , 48 , 24 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 236 , 61 , 51 , 49 , "0xFF006666" , "0xFF121212" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 237 , 64 , 48 , 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 237 , 66 , 49 , 20 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Get" , "s12 Bold c" Brush " x249 y68" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF006666" ) , Gdip_TextToGraphics( G , "Inner Border 1:" , "s12 c" Brush " x16 y98" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 102 , 95 , 30 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 102 , 95 , 30 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 142 , 95 , 90 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 142 , 95 , 90 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 237 , 94 , 47 , 24 , "0xFF2d2d2d" , "0xFF0d0d0d" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 237 , 94 , 48 , 24 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 236 , 94 , 50 , 40 , "0xFF006666" , "0xFF121212" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 237 , 94 , 48 , 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 238 , 94 , 47 , 24 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Get" , "s12 Bold c" Brush " x249 y98" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF006666" ) , Gdip_TextToGraphics( G , "Inner Border 2:" , "s12 c" Brush " x16 y128" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 102 , 125 , 30 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 102 , 125 , 30 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 142 , 125 , 90 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 142 , 125 , 90 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 238 , 124 , 47 , 23 , "0xFF2d2d2d" , "0xFF0d0d0d" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 237 , 124 , 48 , 24 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 238 , 124 , 47 , 43 , "0xFF006666" , "0xFF121212" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 237 , 124 , 48 , 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 238 , 128 , 48 , 21 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Get" , "s12 Bold c" Brush " x249 y128" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF006666" ) , Gdip_TextToGraphics( G , "Main 1:" , "s12 c" Brush " x16 y158" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 102 , 155 , 30 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 102 , 155 , 30 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 142 , 155 , 90 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 142 , 155 , 90 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 236 , 154 , 50 , 21 , "0xFF2d2d2d" , "0xFF0d0d0d" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 237 , 154 , 48 , 24 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 236 , 153 , 52 , 42 , "0xFF006666" , "0xFF121212" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 237 , 154 , 48 , 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 237 , 154 , 48 , 23 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Get" , "s12 Bold c" Brush " x249 y158" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF006666" ) , Gdip_TextToGraphics( G , "Main 2:" , "s12 c" Brush " x16 y188" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 102 , 185 , 30 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 102 , 185 , 30 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF121212" ) , Gdip_FillRectangle( G , Brush , 142 , 185 , 90 , 22 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0xFF004444" , 1 ) , Gdip_DrawRectangle( G , Pen , 142 , 185 , 90 , 22 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 237 , 184 , 48 , 24 , "0xFF2d2d2d" , "0xFF0d0d0d" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 237 , 184 , 48 , 24 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 236 , 182 , 51 , 51 , "0xFF006666" , "0xFF121212" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 237 , 184 , 48 , 24 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 237 , 154 , 48 , 23 , "0xFF00aaaa" , "0xFF006666" , 1 , 1 ) , Gdip_TextToGraphics( G , "Get" , "s12 Bold c" Brush " x249 y188" , "Segoe ui" , 122 , 22 ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
return pBitmap
}
Let me know if you have questions.