WinAPI help

Miscellaneous Forums/Win32 Discussion/WinAPI help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi Dave

This works here

decls
.lib "user32.dll"
api_SetWindowLong%(hwnd%,nIndex%,dwNewLong%):"SetWindowLongA" 
api_SetLayeredWindowAttributes%(hwnd%,crKey%,bAlpha%,dwFlags%):"SetLayeredWindowAttributes" 
api_InvalidateRect%(hwnd%,lpRect%,bErase%):"InvalidateRect"


and the example
win = CreateWindow("Test",0,0,600,400,Desktop(),0);
canvas = CreateCanvas(200,200,32,32,win); SMALL CANVAS 32x32
SetGadgetLayout canvas,1,1,1,1
SetBuffer CanvasBuffer(canvas)

skin_window(win,"test.bmp",canvas, $FFFFFF,100,3);
;^^^^^THIS CALLS THE RELEVANT FUNCTION^^^^^^

timer = CreateTimer (60)
Global timerframes
winsym = LoadImage("winsym.bmp") ; 24x24 bmp top-left pixel black

Repeat
  Select WaitEvent()
  Case $101
    Select EventData()
    
	Case 1
    	End
    End Select    
	
	Case $4001;   THIS SECTION JUST TO MAKE WIN DRAGABLE
    If MouseDown(1) Then	
     If gedrueckt = 0 Then		
       maus_X = MouseX()
       maus_Y = MouseY()
       fenster_X = GadgetX(win) 
       fenster_Y = GadgetY(win)
       gedrueckt = 1
     Else 
       neues_maus_X = MouseX()
       neues_maus_Y = MouseY()
       differenz_X = maus_X - neues_maus_X
       differenz_Y = maus_Y - neues_maus_Y
       fenster_X = fenster_X - differenz_X
       fenster_Y = fenster_Y - differenz_Y
       maus_X = neues_maus_X
       maus_Y = neues_maus_Y	
       SetGadgetShape (win, fenster_X, fenster_Y, 600,400)
     End If
    Else 
	    gedrueckt = 0
	  End If
	 End Select
	
	Select EventID()
    Case $803 ; Window Close
        End
	Case $4001 ; Timer tick
		Cls
		If JoyDown(1) Then
			DrawImage(winsym,0,0); x,y
		EndIf
		FlipCanvas(canvas)
	End Select; ends EventID() select	
Forever

Function skin_window(window_handle, image_path$,panel,colorkey,alpha,colororalpha)
;^^^HipTeen CALLED THAT ARG PANEL BUT IN MY CASE IT'S
;ACTUALLY A CANVAS... HERE IS HIS COMMENTS:
; colorkey is transparency color in hexadecimal form, black ist for example $FFFFFF
; alpha describes the opacity of the window, 0 for full translucent and 255 for non translucent
; use coloralpha to choose the mode you want to use
; 1 to set one color fully lucent
; 2 to set the level of the transperence of the whole window
; 3 to do both
; I think the rest ist self-explanatory
   
	;If Not panel Then
   ;  panel = CreatePanel (0,0,GadgetWidth (window_handle), GadgetHeight (window_handle), window_handle)
	;End If
   ;SetPanelImage canvas, image_path$ ; panel,

   hwnd = QueryObject (window_handle, 1); these 3 lines needed for transparency effect
   api_SetWindowLong(hwnd, -20,  $80000) ; -20 GWL(getwindowLong)_EXSTYLE
   api_SetLayeredWindowAttributes(hwnd, colorkey, alpha, colororalpha)
   ;api_InvalidateRect(api_GetDesktopWindow(), Null, True) ;(GetDesktopWindow(), Null, True)
;api_RedrawWindow(api_GetDesktopWindow(),Null,hwnd,RDW_ERASE)
;api_SendMessage(api_GetDesktopWindow(), WM_PAINT, 0,0)
End Function


the window moves clean and the desktop does not curupt, you could try api_InvalidateRect(QueryObject(Desktop(),1), 0, True)

kev