Jump to content

$WS_EX_LAYERED Clipping


Recommended Posts

Hey Everyone ;)

I have ran in to a problem and am not exactly sure what I can do about it.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$GUI_Width = 800
$GUI_Height = 800

$Path = @ScriptDir & "\"

$Main_GUI = GUICreate("", $GUI_Width, $GUI_Height , Default , Default , $WS_POPUP , $WS_EX_LAYERED)
GUICtrlCreatePic($Path & "Vis.Gif" , 0 , 0 , $GUI_Width , $GUI_Height)
GUICtrlCreatePic($Path & "Frame.gif", 0, 0, 415, 338)
GUICtrlCreatePic($Path & "Ext_Frame.gif", 257, 257, 315, 257)
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Example: This is how it should look and the other picture is how it does look.

Note: 0xFF00FF is used as the transparent color

Images are included so you can play around with it yourself.

Please Help Me :evil:

Posted Image

Posted Image

Link to comment
Share on other sites

Hi, i tried your code.. I found 2 solution.. :evil:

First example,

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$GUI_Width = 800
$GUI_Height = 800

$Path = @ScriptDir & "\"

$Main_GUI = GUICreate("", $GUI_Width, $GUI_Height , Default , Default , $WS_POPUP , $WS_EX_LAYERED)
GUICtrlCreatePic($Path & "Vis.Gif" , 0 , 0 , $GUI_Width , $GUI_Height)
GUICtrlCreatePic($Path & "Frame.gif", 0, 0, 415, 338)
GUICtrlCreatePic($Path & "Ext_Frame.gif", 270, 270, 315, 257) ;change the x and y position
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Second example, used gdi+ (png format).. This works perfect but the picture is small! ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>;used gdi+

$GUI_Width = 800
$GUI_Height = 800

$Path = @ScriptDir & "\"

$Main_GUI = GUICreate("", $GUI_Width, $GUI_Height , Default , Default , $WS_POPUP , $WS_EX_LAYERED)
_GDIPlus_StartUp()
$hImage   = _GDIPlus_ImageLoadFromFile("D:\Frame.png")
$hImage2   = _GDIPlus_ImageLoadFromFile("D:\Ext_Frame.png")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Main_GUI)
GUICtrlCreatePic($Path & "Vis.Gif" , 0 , 0 , $GUI_Width , $GUI_Height)
;~ GUICtrlCreatePic($Path & "Frame.gif", 0, 0, 415, 338)
;~ GUICtrlCreatePic($Path & "Ext_Frame.gif", 257, 257, 315, 257)
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState(@SW_SHOW)


While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()

Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($Main_GUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, 150, 110)
    _WinAPI_RedrawWindow($Main_GUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc

[size="2"][font="Lucida Sans Unicode"][b][/b][/font][/size]

Link to comment
Share on other sites

One way is to have 2 windows. Then you have to have some way of keeping the positions correct if one window is moved, so you could register $WM_MOVE.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$GUI_Width = 800
$GUI_Height = 800

Global Const $WM_ENTERSIZEMOVE = 0x231, $WM_EXITSIZEMOVE = 0x232

$Path = @ScriptDir & "\"

$Main_GUI = GUICreate("", $GUI_Width, $GUI_Height , default, default, $WS_POPUP , $WS_EX_LAYERED)
GUISetBkColor(0xFF00FF)
;GUICtrlCreatePic($Path & "Vis.Gif" , 0 , 0 , $GUI_Width , $GUI_Height)
GUICtrlCreatePic($Path & "Frame.gif", 0, 0, 415, 338,-1, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
$gp = wingetpos($Main_GUI)
$SEc_GUI = GUICreate("", $GUI_Width, $GUI_Height , default, default, $WS_POPUP ,$WS_EX_LAYERED)
GUISetBkColor(0xFF00FF)
GUICtrlCreatePic($Path & "Ext_Frame.gif", 257, 257, 315, 257);,-1, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
Global $RelPos[2]
GUIRegisterMsg($WM_ENTERSIZEMOVE, "setrelpos")
GUIRegisterMsg($WM_MOVE, "followme")
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
WEnd


Func followme($hW, $iM, $wp, $lp)

    If $hW <> $Main_GUI Then Return
    Local $xpos = BitAND($lp, 0xffff)
    Local $ypos = BitShift($lp, 16)
    Local $xypos = WinGetPos($Main_GUI)
    WinMove($SEc_GUI, "", $xypos[0] - $RelPos[0], $xypos[1] - $RelPos[1])

EndFunc ;==>followme

Func SetRelPos($hW, $iM, $wp, $lp)

    If $hW <> $Main_GUI Then Return

    Local $gpp = WinGetPos($Main_GUI)
    Local $gsp = WinGetPos($Main_GUI)

    $RelPos[0] = $gpp[0] - $gsp[0]
    $RelPos[1] = $gpp[1] - $gsp[1]


EndFunc ;==>SetRelPos
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Another way (easiest).

#Include <GUIConstantsEx.au3>
#Include <Icons.au3>
#Include <WindowsConstants.au3>

$GUI_Width = 800
$GUI_Height = 800

$Path = @ScriptDir & "\"

$Main_GUI = GUICreate("", $GUI_Width, $GUI_Height, Default, Default, $WS_POPUP, $WS_EX_LAYERED)
GUICtrlCreatePic('', 0, 0, $GUI_Width, $GUI_Height)
_SetImage(-1, $Path & "Vis.png")
GUICtrlCreatePic('', 0, 0, 415, 338)
_SetImage(-1, $Path & "Frame.png")
GUICtrlCreatePic('', 257, 257, 315, 257)
_SetImage(-1, $Path & "Ext_Frame.png")
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Icons.au3, Images.zip

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...