it seems to be very difficult to draw controls on layered windows after you used the UpdateLayeredWindow() with per-pixel alpha. I suppose it happens because the controls are drawn with GDI functions and the alpha byte of the colors is set to zero (transparent). So this is the best I've got:
Code: Select all
#NoEnv
#SingleInstance, Force
SetWinDelay, -1
SetBatchLines, -1
#include <gdip>
Global HMain, XMain, YMain, HChild, XChild, YChild
sFile := "bg.png"
; ----------------------------------------------------------------------------------------------------------------------
; Main GUI
Gui, Main: New, -Caption +AlwaysOnTop +LastFound +HwndHMain +E0x80000 +LabelGui
pToken := Gdip_Startup()
pBitmap:=Gdip_CreateBitmapFromFile(sFile)
Gdip_GetDimensions(pBitmap, w, h)
hbm := CreateDIBSection(w,h)
hdc := GetDC(HMain)
mdc := CreateCompatibleDC(hdc)
obm := SelectObject(mdc, hbm)
pGraphics := Gdip_GraphicsFromHDC(mdc)
Gdip_DrawImage(pGraphics, pBitmap,0,0,w,h)
UpdateLayeredWindow(HMain, mdc, (A_ScreenWidth-w)//2, (A_ScreenHeight-h)//2, w,h)
DeleteObject(hbm)
DeleteDC(mdc)
ReleaseDC(hdc, HMain)
Gdip_DeleteGraphics(pGraphics)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
; ----------------------------------------------------------------------------------------------------------------------
; Child GUI
Gui, Child: New, -Caption +LastFound +HwndHChild +OwnerMain
Gui, Margin, 0, 0
Gui, Color, 123456
Gui, Add, ListView, x0 y0 w200 h200, Colum1|Colum2 ; <----- This control can't be seen
Loop, 10
LV_Add("", "Col1 " . A_Index, "Col2 " . A_Index)
Gui, Add, Edit, x+10 yp w50, Edit
Gui, Add, Button, xp y+10 wp gClicked, Button
WinSet, TransColor, 123456
; ----------------------------------------------------------------------------------------------------------------------
Gui, Main: Show, w%w% h%h%
WinGetPos, XMain, YMain, W, H, ahk_id %HMain%
XChild := XMain + 33, YChild := YMain + 90
Gui, Child: Show, x%XChild% y%YChild%
OnMessage(0x0201, "WM_LBUTTONDOWN")
OnMessage(0x0216, "WM_MOVING")
OnMessage(0x0232, "WM_EXITSIZEMOVE")
Return
Clicked:
Gui, +OwnDialogs
MsgBox, Bingo!
Return
GuiEscape:
ExitApp
WM_LBUTTONDOWN() {
If (A_Gui = "Main")
PostMessage, 0xA1, 2, 0, , ahk_id %HMain%
}
WM_EXITSIZEMOVE() {
If (A_Gui = "Main")
WinActivate, ahk_id %HChild%
}
WM_MOVING(W, L) {
If (A_Gui = "Main") {
DX := NumGet(L + 0, 0, "Int") - XMain, DY := NumGet(L + 0, 4, "Int") - YMain
WinMove, ahk_id %HChild%, , % (XChild += DX), % (YChild += DY)
XMain += DX, YMain += DY
}
}
BTW: The GDIP.ahk included in your ZIP doesn't work properly in an x64 environment.