Modify

Opened 12 years ago

Closed 12 years ago

#227 closed Bug (Rejected)

_GDIPlus_GraphicsFillRect and transperent windows

Reported by: Lakes Owned by:
Milestone: Component: AutoIt
Version: 3.2.10.0 Severity: None
Keywords: Cc:

Description

In the example below _GDIPlus_GraphicsFillEllipse works as it should (draggable), but _GDIPlus_GraphicsFillRect is not draggable and the fill is corrupted if the mouse is clicked in the fill area.

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <misc.au3>

Global Const $iOpacity = 220
Global Const $ULW_ALPHA = 2
Global $hGui, $hGraphic, $hBrush, $hPen, $hBrush
Global $dll = DllOpen("user32.dll")
Global $GuiSize = @DesktopWidth / 4  ; 200 ;
Global Const $WM_LBUTTONDOWN = 0x0201  ; Drag Window 1 of 3 addin

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)

Rectangles()

Func Rectangles()
    Local $hWnd, $hDC, $hBitmap, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend,$hPen
    
    $hGui = GUICreate("GDI Rectangles", 100, 200, -1, -1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
    GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove")    ; Drag Window 2 of 3 addin
    ;GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
    GUISetState()
    _GDIPlus_Startup ()
    $hWnd = _WinAPI_GetDC (0)
    $hDC = _WinAPI_CreateCompatibleDC ($hWnd)
    $hBitmap = _WinAPI_CreateCompatibleBitmap ($hWnd, $GuiSize, $GuiSize)
    _WinAPI_SelectObject ($hDC, $hBitmap)
    $hGraphic = _GDIPlus_GraphicsCreateFromHDC ($hDC)
    $hBrush = _GDIPlus_BrushCreateSolid (Random(0xff000000, 0xffffff00, 1)) 
   
     _GDIPlus_GraphicsFillRect ($hGraphic, 0, 0,150, 200, $hBrush)  ;this not moveable
    
      $hPen = _GDIPlus_PenCreate(0xFF000000, 5)
     _GDIPlus_GraphicsDrawRect ($hGraphic, 0, 0,150, 200,$hPen) ; Border is moveable

    _GDIPlus_GraphicsFillEllipse ($hGraphic, 0, 0, 10, 10, $hBrush)  ;this  is moveable
   
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $GuiSize)
    DllStructSetData($tSize, "Y", $GuiSize)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow ($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_BrushDispose ($hBrush)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_ReleaseDC (0, $hWnd)
    _WinAPI_DeleteObject ($hBitmap)
    _WinAPI_DeleteDC ($hDC)
   
    Do
        Sleep(20)
    Until _IsPressed("1B")  ; ESC key
    DllClose($dll)
    _GDIPlus_Shutdown ()
EndFunc   ;==>Rectangles

#cs
    ; ============================================================================
    ; Handle the WM_NCHITTEST message so our window can be dragged
    ; ============================================================================
    Func WM_NCHITTEST($HWnd, $iMsg, $iwParam, $ilParam)
    if $HWnd = $hGui then Return $HTCAPTION
    EndFunc
#ce

; =================================================================
; Drag Window 3 of 3 addin
; =================================================================
Func _WinMove($hWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG
    ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $hWnd, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
EndFunc   ;==>_WinMove

Attachments (0)

Change History (1)

comment:1 Changed 12 years ago by Gary

  • Resolution set to Rejected
  • Status changed from new to closed

Nothing wrong with the UDF function, it works. Layered you can't see the fill but it works.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.