Adjustable Hole.......
Posted: Thu Feb 23, 2012 5:26 am
I have slapped together a simple Window that contains a transparent region. The region size is adjustable. The code works as required, the width of the transparent region is adjusted by dragging the Window width and the height of the region is adjusted via two splitter gadgets. However, it would be nice to be able to move the transparent region within the Window, and to have the currently opaque border semi-transparent. That I think would require a completely different approach (= better!) to what I have now:
Anyone have the know-how?
Note, the above code requires Gnozal's PureRESIZE lib. http://gnozal.ucoz.com/
Code: Select all
ExamineDesktops()
Enumeration
#WIN
#Image1
#Image2
#BorderTop
#TranspCv1
#TranspCv2
#BorderBtm
#BorderLh
#BorderRh
#SplitterTop
#SplitterBtm
EndEnumeration
Procedure ShowWin()
;-------------------
If OpenWindow(#WIN, 0, 0, 400, 200, "Adjustable Hole",#PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_Invisible | #PB_Window_ScreenCentered)
SetWindowColor(#WIN,RGB(0,0,255))
SetWindowLongPtr_(WindowID(#WIN),#GWL_EXSTYLE,#WS_EX_LAYERED | #WS_EX_TOPMOST)
SetWindowPos_(WindowID(#WIN),#HWND_TOPMOST,0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE)
SetLayeredWindowAttributes_(WindowID(#WIN),RGB(0,0,255),0,#LWA_COLORKEY)
CanvasGadget(#BorderTop, 0, 0, 0, 0)
CanvasGadget(#TranspCv1, 0, 0, 0, 0)
CanvasGadget(#TranspCv2, 0, 0, 0, 0)
CanvasGadget(#BorderBtm, 0, 0, 0, 0)
CanvasGadget(#BorderLh, 0, 0, 10, 200)
CanvasGadget(#BorderRh, 390, 0, 10, 200)
SplitterGadget(#SplitterTop, 10, 0, 380, 98, #BorderTop,#TranspCv1)
SplitterGadget(#SplitterBtm, 10, 104, 380, 98, #TranspCv2,#BorderBtm)
PureRESIZE_SetGadgetResize(#BorderLh, 1, 1, 0, 1)
PureRESIZE_SetGadgetResize(#BorderRh, 0, 1, 1, 1)
PureRESIZE_SetGadgetResize(#SplitterTop, 1, 1, 1, 1)
PureRESIZE_SetGadgetResize(#SplitterBtm, 1, 1, 1, 1)
WindowBounds(#WIN, 30, 200, #PB_Ignore, 200)
HideWindow(#WIN,#False)
EndIf
EndProcedure
Procedure WaitForUser()
;----------------------
Repeat
iEvent = WaitWindowEvent(1)
StartDrawing(CanvasOutput(#TranspCv1))
DrawingMode(#PB_2DDrawing_Default)
FillArea(10,10,1,RGB(0,0,255))
StopDrawing()
StartDrawing(CanvasOutput(#TranspCv2))
FillArea(10,10,1,RGB(0,0,255))
StopDrawing()
StartDrawing(CanvasOutput(#BorderTop))
FillArea(10,10,1,RGB(185,185,185))
StopDrawing()
StartDrawing(CanvasOutput(#BorderBtm))
FillArea(10,10,1,RGB(185,185,185))
StopDrawing()
StartDrawing(CanvasOutput(#BorderLh))
FillArea(1,1,1,RGB(185,185,185))
StopDrawing()
StartDrawing(CanvasOutput(#BorderRh))
FillArea(1,1,1,RGB(185,185,185))
StopDrawing()
Until iEvent = #PB_Event_CloseWindow
EndProcedure
ShowWin()
WaitForUser()
EndNote, the above code requires Gnozal's PureRESIZE lib. http://gnozal.ucoz.com/