Jump to content

_WinAPI_DrawText Problem : Text can be clicked through it


komalo
 Share

Recommended Posts

i am having a problem with _WinAPI_DrawText when using it

with the DC of a Layered Window _WinAPI_UpdateLayeredWindow

with it can be clicked through it even if i changed the Text Color with

_WinAPI_SetTextColor

here's an example ( this is not my code it just shows my probelm )

#NoTrayIcon
#include <GDIPlus.au3>
#include <TransWinAPI.au3>
#include <SendMessage.au3>
#include <FontConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Global Const $DT_END_ELLIPSIS = 32768
$hWnd = GUICreate("",-1,-1,-1,-1,-1,$WS_EX_LAYERED)
_WinAPI_SetLayeredWindowAttributes($hWnd, 0)
GUISetState()
$hDC = _WinAPI_GetDC($hWnd)
$tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, 1, 43)
DllStructSetData($tRect, 2, 20)
DllStructSetData($tRect, 3, 125)
DllStructSetData($tRect, 4, 100)
_WinAPI_DrawText($hDC,"aaaa", $tRect, $DT_END_ELLIPSIS) ;try to move the window
Do
Until GUIGetMsg() = -3
Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

i am having a problem with _WinAPI_DrawText when using it

with the DC of a Layered Window _WinAPI_UpdateLayeredWindow

with it can be clicked through it even if i changed the Text Color with

_WinAPI_SetTextColor

here's an example ( this is not my code it just shows my probelm )

#NoTrayIcon
#include <GDIPlus.au3>
#include <TransWinAPI.au3>
#include <SendMessage.au3>
#include <FontConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Global Const $DT_END_ELLIPSIS = 32768
$hWnd = GUICreate("",-1,-1,-1,-1,-1,$WS_EX_LAYERED)
_WinAPI_SetLayeredWindowAttributes($hWnd, 0)
GUISetState()
$hDC = _WinAPI_GetDC($hWnd)
$tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, 1, 43)
DllStructSetData($tRect, 2, 20)
DllStructSetData($tRect, 3, 125)
DllStructSetData($tRect, 4, 100)
_WinAPI_DrawText($hDC,"aaaa", $tRect, $DT_END_ELLIPSIS) ;try to move the window
Do
Until GUIGetMsg() = -3
If you set the text colour to be the transparent colour then you will be able to see the window behind your window and if you click on a transparent area you will be clicking on the window behind. If you don't want that to happen you would need to have some way to make the text not completely transparent. What i sthe effect you want to achieve?
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

i am not trying to achieve any effect , it just

happened while using it with a Layered Gui

all i want that make the text solid not transperent

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

Why do you use a layered GUI, when you don't need it? To have solid black text, set the transparent color for the layered window to another color than black.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

i am using a layered GUI to be able to use _WinAPI_UpdateLayeredWindow

so i can't use _WinAPI_SetLayeredWindowAttributes to set the transperent

color to another color than black , i tried to set the text color to another color

but it just stays transparent .

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

Does it work, if you use WinSetTrans instead of _WinAPI_SetLayeredWindowAttributes

or using

_WinAPI_SetLayeredWindowAttributes($hWnd,0,255,0x2)?

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 3 years later...

Why do you use a layered GUI, when you don't need it? To have solid black text, set the transparent color for the layered window to another color than black.

Hi. Anyone can tell me how could i move the drawed text with _WinApi_DrawText like WinMove? sorry for my bad english
Link to comment
Share on other sites

Here is an example showing solid coloured text, and moving the text with the arrow keys.

#include <WinAPI.au3>
#include <Misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Local $sText = " ABC123 " & @LF & " DEF123 " & @LF & " GHI12A "

Local $hWnd = GUICreate("Use Up, Down, Left, Right Arrows", 400, 400, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
;GUISetBkColor("0x" & Hex(-1, 6)) ; All color channels full = (Hex -1) = 0xFFFFFF=White.
_WinAPI_SetLayeredWindowAttributes($hWnd, 0xFFFFFF) ; 0xFFFFFF=White

; or

;Local $hWnd = GUICreate("Use Up, Down, Left, Right Arrows", 400,400, -1, -1) ;

GUISetState()
$hDC = _WinAPI_GetDC($hWnd)
$tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, 1, 43)
DllStructSetData($tRect, 2, 20)
DllStructSetData($tRect, 3, 125)
DllStructSetData($tRect, 4, 63) ; 68) ;
_WinAPI_SetTextColor($hDC, 0x0000FF) ; 0x0000FF=Red (Color format is hex 0xBBGGRR - 3 color channels Blue, Green, and Red); No colors, 0, or 0x000000=Black

_WinAPI_DrawText($hDC, $sText, $tRect, BitOR($DT_CENTER, $DT_END_ELLIPSIS))

Do
    Select
        Case _IsPressed("28") ;Down
            If DllStructGetData($tRect, 4) < 400 Then
                _WinAPI_RedrawWindow($hWnd, $tRect, "", $RDW_INVALIDATE)
                DllStructSetData($tRect, 2, DllStructGetData($tRect, 2) + 1)
                DllStructSetData($tRect, 4, DllStructGetData($tRect, 4) + 1)
                _WinAPI_DrawText($hDC, $sText, $tRect, BitOR($DT_CENTER, $DT_END_ELLIPSIS)) ;
            EndIf
        Case _IsPressed("26") ; Up
            If DllStructGetData($tRect, 2) > 0 Then
                _WinAPI_RedrawWindow($hWnd, $tRect, "", $RDW_INVALIDATE)
                DllStructSetData($tRect, 2, DllStructGetData($tRect, 2) - 1)
                DllStructSetData($tRect, 4, DllStructGetData($tRect, 4) - 1)
                _WinAPI_DrawText($hDC, $sText, $tRect, BitOR($DT_CENTER, $DT_END_ELLIPSIS))
            EndIf
        Case _IsPressed("27") ; To right
            If DllStructGetData($tRect, 3) < 400 + 15 Then
                _WinAPI_RedrawWindow($hWnd, $tRect, "", $RDW_INVALIDATE)
                DllStructSetData($tRect, 1, DllStructGetData($tRect, 1) + 1)
                DllStructSetData($tRect, 3, DllStructGetData($tRect, 3) + 1)
                _WinAPI_DrawText($hDC, $sText, $tRect, BitOR($DT_CENTER, $DT_END_ELLIPSIS))
            EndIf
        Case _IsPressed("25") ; To left
            If DllStructGetData($tRect, 1) > -15 Then
                _WinAPI_RedrawWindow($hWnd, $tRect, "", $RDW_INVALIDATE)
                DllStructSetData($tRect, 1, DllStructGetData($tRect, 1) - 1)
                DllStructSetData($tRect, 3, DllStructGetData($tRect, 3) - 1)
                _WinAPI_DrawText($hDC, $sText, $tRect, BitOR($DT_CENTER, $DT_END_ELLIPSIS))
            EndIf
    EndSelect
Until GUIGetMsg() = -3
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...