Acce Posted October 3, 2020 Posted October 3, 2020 Hi guys I have been working with a sliding menu that slides in from left to right and back again to the left. Have almost made it but have gotten some issues I hope to get help with. Here is the code I have made expandcollapse popupFunc Sliding_Menu() ;Menu GUI $mGUI = GUICreate("",800, 590,100,120, $WS_POPUP, $WS_EX_LAYERED+$WS_EX_TOOLWINDOW,$hGUI) GUISetBkColor(0xabcdef) _WinAPI_SetLayeredWindowAttributes($mGUI,0xabcdef) GUISetState(@SW_SHOW) ;Menu GUI <===== ;Menu GDI ;Load Image $hImage_1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\assets\HUD\" & "Menu_slider.png") $hImage_resized = _GDIPlus_ImageResize($hImage_1, 650, 500) ;create buffered graphics frame set for smoother gfx object movements $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($mGUI) ;create a graphics object from a window handle $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 590, $g_hGfx) ;create a Bitmap object based on a graphics object $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;get the graphics context of the image / bitmap to draw on image / bitmap _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) ;capture screen $mGUI_Pos = WinGetPos($mGUI) $x = $mGUI_Pos[0] $y = $mGUI_Pos[1] $hHBitmap = _ScreenCapture_Capture("",$x,$y,$x + 800, $y + 700) $hImageBg = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) For $i = -400 to -20 step 10 _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $hImageBg, 0, 0) ; Draw to buffer (bg) _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $hImage_resized, $i, 0) ; Draw to buffer (Hud) _GDIPlus_GraphicsDrawImage($g_hGfx, $g_hBitmap, 0, 0) ; draw to GUI Next sleep(1000) slideout() EndFunc Func slideout() ;Load Image $hImage_1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\assets\HUD\" & "Menu_slider.png") $hImage_resized = _GDIPlus_ImageResize($hImage_1, 650, 500) ;create buffered graphics frame set for smoother gfx object movements $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($mGUI) ;create a graphics object from a window handle $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 590, $g_hGfx) ;create a Bitmap object based on a graphics object $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;get the graphics context of the image / bitmap to draw on image / bitmap _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) _GDIPlus_GraphicsClear($g_hGfxCtxt) For $i = -20 to -500 step -10 _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $hImageBg, 0, 0) ; Draw to buffer (background global va) _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $hImage_resized, $i, 0) ; Draw to buffer _GDIPlus_GraphicsDrawImage($g_hGfx, $g_hBitmap, 0, 0) ; draw to GUI Next ;slowdown For $i = -500 to -580 step -1 _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $hImageBg, 0, 0) ; Draw to buffer _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $hImage_resized, $i, 0) ; Draw to buffer _GDIPlus_GraphicsDrawImage($g_hGfx, $g_hBitmap, 0, 0) ; draw to GUI Next GUIDelete($mGUI) $mGUI = GUICreate("",800, 590,100,120, $WS_POPUP, $WS_EX_LAYERED+$WS_EX_TOOLWINDOW,$hGUI) GUISetBkColor(0xabcdef) _WinAPI_SetLayeredWindowAttributes($mGUI,0xabcdef) GUISetState(@SW_SHOW) $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($mGUI) ;create a graphics object from a window handle $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 590, $g_hGfx) ;create a Bitmap object based on a graphics object $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;get the graphics context of the image / bitmap to draw on image / bitmap _GDIPlus_GraphicsSetSmoothingMode($hImage_resized, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) _GDIPlus_GraphicsClear($g_hGfxCtxt) _GDIPlus_GraphicsDrawImage($g_hGfx, $hImage_resized, -580, 0) ; draw to GUI EndFunc It works like this , A gui loads on top of my main gui window and I use screen capture to get background when lopading sliding menu. However My main gui is movable and resize-able , and I would like to clear the 2nd gui from the screen capture image and only showing the sliding icon , This is my best attempt but for some reason the image icon gets a blue border in the end ? Have also tried to clear graphic content but this gives me a completely black image as background , How can I get this GUI show only the menu icon at the end with no (transparent ) background ? Hope to get some help ?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now