2
votes

When i add this:

GUI, Add, Text,, this is my Control in Window

to any line (after new gui) of these:

#Include %A_ScriptDir%\Gdip.ahk

Gui popmain:New
Gui, +lastfound -resize +AlwaysOnTop -Border +E0x80000 -Caption +ToolWindow
Gui, Color, ffffff

    sFile = %A_ScriptDir%\bg.png
    mDC_Scr := Gdi_CreateCompatibleDC(0)
    pToken  := Gdip_Startup()
    pBitmap := Gdip_CreateBitmapFromFile(sFile)
    nWidth  := Gdip_GetImageWidth(pBitmap)
    nHeight := Gdip_GetImageHeight(pBitmap)
    hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
    oBitmap := Gdi_SelectObject(mDC_Scr, hBitmap)

Gui, popmain:show, x0 y0 W%nWidth% H%nHeight% ;hide
Gui, popmain: +LastFound

    DllCall("UpdateLayeredWindow", "Uint", WinExist(), "Uint", 0, "Uint", 0, "int64P", nWidth|nHeight<<32, "Uint", mDC_Scr, "int64P", 0, "Uint", 0, "UintP", 255<<16|1<<24, "Uint", 2)

    Gdip_DisposeImage(pBitmap)
    Gdip_Shutdown(pToken)
    Gdi_SelectObject(mDC_Scr, oBitmap)
    Gdi_DeleteObject(hBitmap)
    Gdi_DeleteDC(mDC_Scr)

return

my text control and any gui control not visible on window. (placed on window but not visible)

how to show gui controls?

thanks

Included Gdip.ahk:

Gdi_CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
    NumPut(VarSetCapacity(bi, 40, 0), bi)
    NumPut(nW, bi, 4)
    NumPut(nH, bi, 8)
    NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")

    Return  DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}

Gdi_CreateCompatibleDC(hDC = 0)
{
   Return   DllCall("gdi32\CreateCompatibleDC", "Uint", hDC)
}

Gdi_SelectObject(hDC, hGdiObj)
{
   Return   DllCall("gdi32\SelectObject", "Uint", hDC, "Uint", hGdiObj)
}

Gdi_DeleteObject(hGdiObj)
{
   Return   DllCall("gdi32\DeleteObject", "Uint", hGdiObj)
}

Gdi_DeleteDC(hDC)
{
   Return   DllCall("gdi32\DeleteDC", "Uint", hDC)
}

Gdip_CreateBitmapFromFile(sFile)
{
   VarSetCapacity(wFile, 1023)
   DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sFile, "int", -1, "Uint", &wFile, "int", 512)
   DllCall("gdiplus\GdipCreateBitmapFromFile", "Uint", &wFile, "UintP", pBitmap)
   Return   pBitmap
}

Gdip_CreateBitmapFromHICON(hIcon)
{
   DllCall("gdiplus\GdipCreateBitmapFromHICON", "Uint", hIcon, "UintP", pBitmap)
   Return   pBitmap
}

Gdip_CreateHBITMAPFromBitmap(pBitmap, ARGB = 0)
{
   DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pBitmap, "UintP", hBitmap, "Uint", ARGB)
   Return   hBitmap
}

Gdip_DisposeImage(pImage)
{
   Return   DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
}

Gdip_GetImageWidth(pImage)
{
   DllCall("gdiplus\GdipGetImageWidth", "Uint", pImage, "UintP", nW)
   Return   nW
}

Gdip_GetImageHeight(pImage)
{
   DllCall("gdiplus\GdipGetImageHeight", "Uint", pImage, "UintP", nH)
   Return   nH
}

Gdip_Startup()
{
   If Not   DllCall("GetModuleHandle", "str", "gdiplus")
   DllCall("LoadLibrary"    , "str", "gdiplus")
   VarSetCapacity(si, 16, 0), si := Chr(1)
   DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)
   Return   pToken
}

Gdip_Shutdown(pToken)
{
   DllCall("gdiplus\GdiplusShutdown", "Uint", pToken)
   If   hModule :=   DllCall("GetModuleHandle", "str", "gdiplus")
         DllCall("FreeLibrary"    , "Uint", hModule)
   Return   0
}

it was included as above code

1
What version of Autohotkey and what gdi library are you using?Joe DF
Autohotkey_L v1.1.14.03 from ahkscript.org and with included gdip.ahk (DllCall gdiplus, gdi32).hahamed
my windows 7 is 32 bithahamed
What is the Errorlevel and return value of the DllCall?Joe DF
no error. the above code is completed and show my gui window in best status (with transparented png background). Seemingly layered gui not allow to add gui control.hahamed

1 Answers

1
votes

You cannot show controls that are added after the "Gui, Show"

Here is my approach, after showing the GUI, you could destroy it then create a new gui adding the new controls you have dynamically added. Remember if you don't want to destroy the previous Gui, you can give the new Gui a random name then show it while destroying the previous one.

I hope that makes sense.