problem with #gwl_exstyle gadgets wont show up!!

Just starting out? Need help? Post your questions and find answers here.
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

problem with #gwl_exstyle gadgets wont show up!!

Post by doodlemunch »

hi SetWindowLong_(WindowID(#Win),#GWL_EXSTYLE,GetWindowLong_(WindowID(#Win),#GWL_EXSTYLE)|$00080000)

i have to set my window like that so i can use gdi plus and draw some stuff on it

but when i want to place a gadget on the window i can not see it
why?!! how to fix it??

thx!
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

Post by doodlemunch »

any winapi gurus ???
i can not solve this i do not know why it is not drawin my gadget!
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

I'm in a bit of hurry, can you make a simple example where you add gadgets to the window?

I am not an api guru, but I am very experienced dealing with api.
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

Post by doodlemunch »

i just have no error on creatin the gadget that is ok it only does not work when i do this

SetWindowLong_(WindowID(#Win),#GWL_EXSTYLE,GetWindowLong_(WindowID(#Win),#GWL_EXSTYLE)|$00080000)

and then i call this after some other code

UpdateLayeredWindow_()

it displais my png with shadow correctely but my gadgets are long gone will never apear

how can i make a window with no bakground so i can place it over this one at least?
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Without seeing some code, it's difficult to debug. ;)

What is the result returned by UpdateLayeredWindow_(), zero or nonzero :?:

What is the result returned by GetLastError_() :?:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

Post by doodlemunch »

UpdateLayeredWindow_()
gives 1


after callin that if i call GetLastError_() i get 8
?

but my png is displayed niceley i just can not see my gadgets!
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Need to see your code.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

Post by doodlemunch »

hi it is not my code but i do not know who made it
i just wantet to addd gadgets

u will need a png file to test this

Code: Select all

Procedure Error(message.s, fatal.b)
  ErrorBuffer$ = Space(256)
  FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, ErrorBuffer$, Len(ErrorBuffer$), 0)
  MessageRequester("Error", message+Chr(10)+Chr(10)+ErrorBuffer$, 0)
  If fatal
    End
  EndIf
EndProcedure

Global MDIFrame, MDIClient, hChild, hStatus, hToolBar, hMainMenu, hChildMenu, ActiveMDIChild
Global xPos, yPos, WindowWidth, WindowHeight, ChildNumber, ExtraWidth, ExtraHeight
Global hInstance
Global wc.WNDCLASSEX
Global ClassName$


Structure GdiplusStartupInput
  GdiplusVersion.l
  DebugEventCallback.l
  SuppressBackgroundThread.l
  SuppressExternalCodecs.l
EndStructure

Structure CLSID
  Data1.l
  Data2.w
  Data3.w
  Data4.b 
EndStructure

Structure bsize
  Width.l
  Height.l
EndStructure

Structure bpoint
  x.l
  y.l
EndStructure

Structure ARGB
  blue.b
  green.b
  red.b
  alpha.b
EndStructure

Structure blendfunction
  blendop.b
  blendflags.b
  sourceconstant.b
  alphaformat.b
EndStructure

;Structure GUID
;  Data1.l
;  Data2.w
;  Data3.w
;  Data4.b 
;EndStructure

Structure ImageItemInfo
  Clsid.CLSID         ; Codec identifier. 
  FormatID.GUID       ; File format identifier. GUIDs that identify various file formats (ImageFormatBMP, ImageFormatEMF, And the like) are defined in Gdiplusimaging.h. 
  CodecName.s         ; WCHAR * Pointer To a null-terminated string that contains the codec name. 
  DllName.s           ; WCHAR * Pointer To a null-terminated string that contains the path name of the DLL in which the codec resides. If the codec is not in a DLL, this pointer is NULL. 
  FormatDescription.s ; WCHAR * Pointer To a null-terminated string that contains the name of the file format used by the codec. 
  FilenameExtension.s ; WCHAR * Pointer To a null-terminated string that contains all file-name extensions associated with the codec. The extensions are separated by semicolons. 
  MimeType.s          ; WCHAR * Pointer To a null-terminated string that contains the mime type of the codec. 
  flags.l             ; DWORD  Combination of flags from the ImageCodecFlags enumeration. 
  Version.l           ; DWORD  Integer that indicates the version of the codec. 
  SigCount.l          ; DWORD  Integer that indicates the number of signatures used by the file format associated with the codec. 
  SigSize.l           ; DWORD  Integer that indicates the number of bytes in each signature. 
  SigPattern.l        ; BYTE * Pointer To an array of bytes that contains the pattern For each signature. 
  SigMask.l           ; BYTE * Pointer To an array of bytes that contains the mask For each signature. 
EndStructure

Global Gdiplus, gdiplusToken, Bitmap, hbmReturn, encoderClsid
Global *GdiplusStartup, *GdipCreateBitmapFromFile, *GdipCreateHBITMAPFromBitmap, *GdipGetImageHeight, *GdipGetImageWidth, *GdiplusShutdown, *GdipSaveImageToFile, *GdipGetImageEncodersSize, *GdipGetImageEncoders, *GdipCreateBitmapFromHBITMAP




Procedure OpenImageFile(File$)
  result = 0
  If Gdiplus
    FileWSize = (Len(File$)*2)+2
    *FileW = CoTaskMemAlloc_(FileWSize)
    
    If *FileW
      If MultiByteToWideChar_(#CP_ACP, 0, File$, -1, *FileW, FileWSize)
        Bitmap.l = 0
        CallFunctionFast(*GdipCreateBitmapFromFile, *FileW, @Bitmap)
        
        If Bitmap
          hbmReturn.l = 0
          ;Dim argbtest.argb(0)
           ; argbtest(0)\blue=0
           ;;argbtest(0)\green=0
           ; argbtest(0)\red=0
           ; argbtest(0)\alpha=0
            
          CallFunctionFast(*GdipCreateHBITMAPFromBitmap, Bitmap, @hbmReturn, 0)
          ;CallDebugger
          ;Error("hbitmap.", 0)
          If hbmReturn
            ;hChild = CreateWindowEx_(#WS_EX_MDICHILD, ClassName$, "", #WS_CHILDWINDOW|#WS_TILEDWINDOW|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#WS_VISIBLE|$0000C000|#MDIS_ALLCHILDSTYLES, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, MDIClient, #NULL, hInstance, #NULL)
            ;If hChild
            ;  SetWindowText_(hChild, File$)
             ; ShowWindow_(hChild, #SW_SHOW)
            ;  ChildNumber+1
             ; result = 1
            ;EndIf
          EndIf
        Else
          Error("GdipCreateBitmapFromFile() failed."+Chr(10)+File$+" is not a valid image file.", 0)
        EndIf
      EndIf
    Else
      SetLastError_(#ERROR_NOT_ENOUGH_MEMORY)
    EndIf
    CoTaskMemFree_(*FileW)
  EndIf
  ProcedureReturn hbmReturn
EndProcedure 

CoInitialize_(#Null)
        Gdiplus = OpenLibrary(0, "GDIPLUS.DLL")
        If Gdiplus
          *GdiplusStartup = IsFunction(0, "GdiplusStartup")
          If *GdiplusStartup
            gdpsi.GdiplusStartupInput
            gdpsi\GdiplusVersion = 1
            gdpsi\DebugEventCallback = 0
            gdpsi\SuppressBackgroundThread = 0
            gdpsi\SuppressExternalCodecs = 0
            CallFunctionFast(*GdiplusStartup, @gdiplusToken, gdpsi, #Null)
            If gdiplusToken
              *GdipCreateBitmapFromFile = IsFunction(0, "GdipCreateBitmapFromFile")
              *GdipCreateHBITMAPFromBitmap = IsFunction(0, "GdipCreateHBITMAPFromBitmap")
              *GdipGetImageWidth = IsFunction(0, "GdipGetImageWidth")
              *GdipGetImageHeight = IsFunction(0, "GdipGetImageHeight")
              *GdipGetImageEncodersSize = IsFunction(0, "GdipGetImageEncodersSize")
              *GdipGetImageEncoders = IsFunction(0, "GdipGetImageEncoders")
              *GdipCreateBitmapFromHBITMAP = IsFunction(0, "GdipCreateBitmapFromHBITMAP")
              *GdipSaveImageToFile = IsFunction(0, "GdipSaveImageToFile")
              *GdiplusShutdown = IsFunction(0, "GdiplusShutdown")
            Else
              Gdiplus = 0
            EndIf
          Else
            Gdiplus = 0
          EndIf
        Else
          Gdiplus = 0
        EndIf
    

hwnd=OpenWindow(0,400,400,400,400,#PB_Window_BorderLess,"alpha") 
SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|$00080000) 
;Error("Set Window Long.", 0)


;File$ = OpenFileRequester("Open image file:", "", "BMP image (*.bmp)|*.bmp|JPEG image (*.jpg)|*.jpg|PNG image (*.png)|*.png|TIFF image (*.tif)|*.tif|GIF image (*.gif)|*.gif|All files (*.*)|*.*", #PB_Requester_MultiSelection)


bitmap1=OpenImageFile("test.png")
;File$ = NextSelectedFileName()
;Error("Open Image.", 0)
width1.l=0
;CallFunctionFast(*GdipGetImageWidth, bitmap1, @width1)

screenDc=GetDC_(#Null)
;Error("GetDc.", 0)

memDc=CreateCompatibleDC_(screenDc)
;Error("Create Compat.", 0)
oldbitmap=SelectObject_(memDc, bitmap1)
;Error("SelectObj.", 0)
;Code now gets BMP SIze dynamically thanks to PolyVector!
GetObject_(bitmap1,SizeOf(BITMAP),bmInfo.BITMAP)
bitmapsize.bsize
bitmapsize\Width=bmInfo\bmWidth
bitmapsize\Height=bmInfo\bmHeight 

;Old code for hardcoded size
;bitmapsize.bsize
;bitmapsize\width=450
;bitmapsize\height=175

pointsource.bpoint
pointsource\x=0
pointsource\y=0

topPos.bpoint
topPos\x=0
topPos\y=0

BlendFunc.blendfunction
BlendFunc\blendop=0
BlendFunc\blendflags=0
BlendFunc\sourceconstant=255;
BlendFunc\alphaformat=1

UpdateLayeredWindow_(WindowID(0), screenDc, topPos, bitmapsize, memDc, pointsource, 0, BlendFunc, 2);
;Error("Update Layered failed.", 0)
;

CreateGadgetList(WindowID(0))
ButtonGadget(1,10,10,100,20,"HELLO WORLD")

;

;hbitmap=gethbitmap_(0)

ReleaseDC_(#Null,screenDc)
SelectObject_(memDc,oldbitmap)
DeleteObject_(hbitmap)
DeleteDC_(memDc)

Repeat 
ev=WaitWindowEvent() 
  
  If ev=#WM_LBUTTONDOWN 
    ReleaseCapture_() 
    SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0) 
  EndIf 
  
Until ev=#WM_RBUTTONDOWN
End


;Error("Release DC.", 0)
; IDE Options = PureBasic v3.94 (Windows - x86)
; CursorPosition = 180
; FirstLine = 149
; Folding = -

if u do not use the calls UpdateLayeredWindow_() and the first SetWindowLong_() then the button appears valid and looks as it should

with the calls i can not see my button why? is the image being over it?
i want the image as background :(
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

This works, but the colors are messed up and you won't get the utton's events:

Code: Select all

Procedure Error(message.s, fatal.b)
  ErrorBuffer$ = Space(256)
  FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, ErrorBuffer$, Len(ErrorBuffer$), 0)
  MessageRequester("Error", message+Chr(10)+Chr(10)+ErrorBuffer$, 0)
  If fatal
    End
  EndIf
EndProcedure

Global MDIFrame, MDIClient, hChild, hStatus, hToolBar, hMainMenu, hChildMenu, ActiveMDIChild
Global xPos, yPos, WindowWidth, WindowHeight, ChildNumber, ExtraWidth, ExtraHeight
Global hInstance
Global wc.WNDCLASSEX
Global ClassName$


Structure GdiplusStartupInput
  GdiplusVersion.l
  DebugEventCallback.l
  SuppressBackgroundThread.l
  SuppressExternalCodecs.l
EndStructure

; Structure CLSID
;   Data1.l
;   Data2.w
;   Data3.w
;   Data4.b
; EndStructure

Structure bsize
  Width.l
  Height.l
EndStructure

Structure bpoint
  x.l
  y.l
EndStructure

Structure ARGB
  blue.b
  green.b
  red.b
  alpha.b
EndStructure

Structure blendfunction
  blendop.b
  blendflags.b
  sourceconstant.b
  alphaformat.b
EndStructure

;Structure GUID
;  Data1.l
;  Data2.w
;  Data3.w
;  Data4.b
;EndStructure

Structure ImageItemInfo
  Clsid.CLSID         ; Codec identifier.
  FormatID.GUID       ; File format identifier. GUIDs that identify various file formats (ImageFormatBMP, ImageFormatEMF, And the like) are defined in Gdiplusimaging.h.
  CodecName.s         ; WCHAR * Pointer To a null-terminated string that contains the codec name.
  DllName.s           ; WCHAR * Pointer To a null-terminated string that contains the path name of the DLL in which the codec resides. If the codec is not in a DLL, this pointer is NULL.
  FormatDescription.s ; WCHAR * Pointer To a null-terminated string that contains the name of the file format used by the codec.
  FilenameExtension.s ; WCHAR * Pointer To a null-terminated string that contains all file-name extensions associated with the codec. The extensions are separated by semicolons.
  MimeType.s          ; WCHAR * Pointer To a null-terminated string that contains the mime type of the codec.
  flags.l             ; DWORD  Combination of flags from the ImageCodecFlags enumeration.
  Version.l           ; DWORD  Integer that indicates the version of the codec.
  SigCount.l          ; DWORD  Integer that indicates the number of signatures used by the file format associated with the codec.
  SigSize.l           ; DWORD  Integer that indicates the number of bytes in each signature.
  SigPattern.l        ; BYTE * Pointer To an array of bytes that contains the pattern For each signature.
  SigMask.l           ; BYTE * Pointer To an array of bytes that contains the mask For each signature.
EndStructure

Global Gdiplus, gdiplusToken, Bitmap, hbmReturn, encoderClsid
Global *GdiplusStartup, *GdipCreateBitmapFromFile, *GdipCreateHBITMAPFromBitmap, *GdipGetImageHeight, *GdipGetImageWidth, *GdiplusShutdown, *GdipSaveImageToFile, *GdipGetImageEncodersSize, *GdipGetImageEncoders, *GdipCreateBitmapFromHBITMAP




Procedure OpenImageFile(File$)
  result = 0
  If Gdiplus
    FileWSize = (Len(File$)*2)+2
    *FileW = CoTaskMemAlloc_(FileWSize)
   
    If *FileW
      If MultiByteToWideChar_(#CP_ACP, 0, File$, -1, *FileW, FileWSize)
        Bitmap.l = 0
        CallFunctionFast(*GdipCreateBitmapFromFile, *FileW, @Bitmap)
       
        If Bitmap
          hbmReturn.l = 0
          ;Dim argbtest.argb(0)
           ; argbtest(0)\blue=0
           ;;argbtest(0)\green=0
           ; argbtest(0)\red=0
           ; argbtest(0)\alpha=0
           
          CallFunctionFast(*GdipCreateHBITMAPFromBitmap, Bitmap, @hbmReturn, 0)
          ;CallDebugger
          ;Error("hbitmap.", 0)
          If hbmReturn
            ;hChild = CreateWindowEx_(#WS_EX_MDICHILD, ClassName$, "", #WS_CHILDWINDOW|#WS_TILEDWINDOW|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#WS_VISIBLE|$0000C000|#MDIS_ALLCHILDSTYLES, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, MDIClient, #NULL, hInstance, #NULL)
            ;If hChild
            ;  SetWindowText_(hChild, File$)
             ; ShowWindow_(hChild, #SW_SHOW)
            ;  ChildNumber+1
             ; result = 1
            ;EndIf
          EndIf
        Else
          Error("GdipCreateBitmapFromFile() failed."+Chr(10)+File$+" is not a valid image file.", 0)
        EndIf
      EndIf
    Else
      SetLastError_(#ERROR_NOT_ENOUGH_MEMORY)
    EndIf
    CoTaskMemFree_(*FileW)
  EndIf
  ProcedureReturn hbmReturn
EndProcedure

CoInitialize_(#Null)
        Gdiplus = OpenLibrary(0, "GDIPLUS.DLL")
        If Gdiplus
          *GdiplusStartup = GetFunction(0, "GdiplusStartup")
          If *GdiplusStartup
            gdpsi.GdiplusStartupInput
            gdpsi\GdiplusVersion = 1
            gdpsi\DebugEventCallback = 0
            gdpsi\SuppressBackgroundThread = 0
            gdpsi\SuppressExternalCodecs = 0
            CallFunctionFast(*GdiplusStartup, @gdiplusToken, gdpsi, #Null)
            If gdiplusToken
              *GdipCreateBitmapFromFile = GetFunction(0, "GdipCreateBitmapFromFile")
              *GdipCreateHBITMAPFromBitmap = GetFunction(0, "GdipCreateHBITMAPFromBitmap")
              *GdipGetImageWidth = GetFunction(0, "GdipGetImageWidth")
              *GdipGetImageHeight = GetFunction(0, "GdipGetImageHeight")
              *GdipGetImageEncodersSize = GetFunction(0, "GdipGetImageEncodersSize")
              *GdipGetImageEncoders = GetFunction(0, "GdipGetImageEncoders")
              *GdipCreateBitmapFromHBITMAP = GetFunction(0, "GdipCreateBitmapFromHBITMAP")
              *GdipSaveImageToFile = GetFunction(0, "GdipSaveImageToFile")
              *GdiplusShutdown = GetFunction(0, "GdiplusShutdown")
            Else
              Gdiplus = 0
            EndIf
          Else
            Gdiplus = 0
          EndIf
        Else
          Gdiplus = 0
        EndIf
   

hwnd=OpenWindow(0,400,400,400,400,#PB_Window_BorderLess,"alpha")
;Error("Set Window Long.", 0)


;File$ = OpenFileRequester("Open image file:", "", "BMP image (*.bmp)|*.bmp|JPEG image (*.jpg)|*.jpg|PNG image (*.png)|*.png|TIFF image (*.tif)|*.tif|GIF image (*.gif)|*.gif|All files (*.*)|*.*", #PB_Requester_MultiSelection)

CreateGadgetList(WindowID(0))
ButtonGadget(1,10,10,100,20,"HELLO WORLD")

showwindow_(WindowID(0), #SW_SHOW)
updatewindow_(WindowID(0))

hdc = getdc_(WindowID(0))

mdc = createcompatibledc_(hdc)
hbm = createcompatiblebitmap_(hdc, GadgetWidth(1), GadgetHeight(1))
oldb = Selectobject_(mdc, hbm)
bitblt_(mdc, 0, 0, GadgetWidth(1), GadgetHeight(1), hdc, GadgetX(1), GadgetY(1), #SRCCOPY)
releasedc_(WindowID(0), hdc)

SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|$00080000)

bitmap1=OpenImageFile("test.png")
;File$ = NextSelectedFileName()
;Error("Open Image.", 0)
width1.l=0
;CallFunctionFast(*GdipGetImageWidth, bitmap1, @width1)

screenDc=GetDC_(WindowID(0))
;Error("GetDc.", 0)

memDc=CreateCompatibleDC_(screenDc)
;Error("Create Compat.", 0)
oldbitmap=SelectObject_(memDc, bitmap1)

bitblt_(memDc, GadgetX(1), GadgetY(1), GadgetWidth(1), GadgetHeight(1), mdc, 0, 0, #SRCCOPY)

Selectobject_(mdc, oldb)
deleteobject_(hbm)
deleteobject_(mdc)


;Error("SelectObj.", 0)
;Code now gets BMP SIze dynamically thanks to PolyVector!
GetObject_(bitmap1,SizeOf(BITMAP),bmInfo.BITMAP)
bitmapsize.bsize
bitmapsize\Width=bmInfo\bmWidth
bitmapsize\Height=bmInfo\bmHeight

;Old code for hardcoded size
;bitmapsize.bsize
;bitmapsize\width=450
;bitmapsize\height=175

pointsource.bpoint
pointsource\x=0
pointsource\y=0

topPos.bpoint
topPos\x=400
topPos\y=400

BlendFunc.blendfunction
BlendFunc\blendop=0
BlendFunc\blendflags=0
BlendFunc\sourceconstant=255;
BlendFunc\alphaformat=1

UpdateLayeredWindow_(WindowID(0), screenDc, #Null, bitmapsize, memDc, pointsource, 0, BlendFunc, 2);
;Error("Update Layered failed.", 0)
;


;

;hbitmap=gethbitmap_(0)

ReleaseDC_(#Null,screenDc)
SelectObject_(memDc,oldbitmap)
DeleteObject_(hbitmap)
DeleteDC_(memDc)

Repeat
ev=WaitWindowEvent()

  If ev=#WM_LBUTTONDOWN
    ReleaseCapture_()
    SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
  EndIf
 
Until ev=#WM_RBUTTONDOWN
End

Layered windows are not meant to be used with controls. You would have to handle all mouse stuff yourself.
El_Choni
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

Post by doodlemunch »

i just see a white rectangel with transparent "hello world" text hmm
i only want to display text over this window how could i do it? i can not save a temp image first cos pb wont load and save my alpha data! (sucks)
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Why are you using a layered window in the first place :?: Why not just use the image for the window background and eliminate the GDI+ and layered window?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

!!

Post by doodlemunch »

because it has an alpha channel!
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Ok, now I see what you're trying to do. 8)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Does this work for you. :?: It uses a png (with alpha channel) for the window background. Just make sure to change the image path and the RGB() color for the #LWA_COLORKEY in the SetLayeredWindowAttributes_() function.

Code: Select all

UsePNGImageDecoder() 
#LWA_ALPHA = 2
#LWA_COLORKEY = 1
#WS_EX_LAYERED = $80000
imageBG$ = ("PATH_TO_PNG_IMAGE") 
myImage = LoadImage(0, imageBG$) 
containerBrush = CreatePatternBrush_(UseImage(0)) 

If OpenWindow(0, 0, 0, ImageWidth(), ImageHeight(), #PB_Window_BorderLess, "Test") And CreateGadgetList(WindowID(0)) 
  SetClassLong_(WindowID(0), #GCL_HBRBACKGROUND, containerBrush) 
  SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED) 
  SetLayeredWindowAttributes_(WindowID(0), RGB(255, 0, 255), 255, #LWA_COLORKEY)
  ButtonGadget(1, 10, 10, 100, 20, "HELLO WORLD") 
  Repeat 
    event = WaitWindowEvent() 
    If event=#WM_LBUTTONDOWN 
      ReleaseCapture_() 
      SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0) 
    EndIf 
  Until event = #WM_RBUTTONDOWN
  DeleteObject_(containerBrush) 
EndIf 
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

Post by doodlemunch »

that is alpha key color no? well im using an alph chanel for a shadow how am i suposed to use this metod with that? it wont show up the alpha
:( but thanks
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
Post Reply