Ich möchte ein transparenes Bild per "Childwindow" anzeigen und der User soll es per ok-Button schliessen können.
Das Programm zeigt zwar das transparente PNG-Bild sehr schön an, aber den OK-Button nicht. Wer kann mir meinen Denkfehler erklären und hat eine Lösung dafür parat?
Code: Alles auswählen
UsePNGImageDecoder()
Enumeration
#ParentWin
#fontnum
#imagenum
EndEnumeration
#about = 1
Procedure WindowBackground(Window.i, Image.i)
Protected WindowID.i = WindowID(Window)
Protected ImageID.i = ImageID(Image)
Protected HDC.i = CreateCompatibleDC_(#Null)
Protected Object.i = SelectObject_(HDC, ImageID)
Protected Size.Size
Size\cx = ImageWidth(Image)
Size\cy = ImageHeight(Image)
Protected Point.Point
Protected Blend.BLENDFUNCTION
Blend\SourceConstantAlpha = 255
Blend\AlphaFormat = 1
SetWindowLong_(WindowID, #GWL_EXSTYLE, GetWindowLong_(WindowID, #GWL_EXSTYLE) | #WS_EX_LAYERED)
UpdateLayeredWindow_(WindowID, 0, 0, @Size, HDC, @Point, 0, @Blend, 2)
SelectObject_(HDC, Object)
DeleteDC_(HDC)
EndProcedure
Procedure TranspChildWin()
pmainwindow = GetActiveWindow()
DisableWindow(pmainwindow, #True)
CatchImage(#imagenum, ?Logo)
bx = ImageWidth(#imagenum)
by = ImageHeight(#imagenum)
xx = GetSystemMetrics_(#SM_CXSCREEN) : yy = GetSystemMetrics_(#SM_CYSCREEN)
cw = OpenWindow(#PB_Any, (xx-bx)/2,(yy-by)/2, bx, by, "", #PB_Window_BorderLess, WindowID(pmainwindow))
ok = ButtonGadget(#PB_Any,bx-30, by-30, 25,25,"ok")
WindowBackground(cw, #imagenum)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case ok
Break
EndSelect
EndSelect
ForEver
CloseWindow(cw)
DisableWindow(pmainwindow, #False)
EndProcedure
;- openwindow
hWnd = OpenWindow(#ParentWin,0,0,333,333,"",#PB_Window_SystemMenu)
hSysMenu = GetSystemMenu_(hWnd, #False)
AppendMenu_(hSysMenu, #MF_STRING, #about, "Info zum Programm")
If LoadFont(#fontnum, "Arial", 11) : SetGadgetFont(#PB_Default, FontID(#fontnum)) : EndIf
Repeat
event = WaitWindowEvent()
If event = #WM_SYSCOMMAND
Select EventwParam()
Case #about
TranspChildWin()
EndSelect
EndIf
If event = #PB_Event_CloseWindow
End
EndIf
ForEver
End
DataSection
Logo:
IncludeBinary "C:\Users\zuhause\Documents\PureBasic\Projekt\about.png"
EndDataSection