Jump to content

Transparent button


liten
 Share

Recommended Posts

i need help creating a transparent button, that is theier but "Not their" (because you cant see it, so if you click in the AEREA where the button is ETc, Basicly how would i make a Transparent button, i tried winsetrans, then i reliezed, it said win...........ETC, i need help any one with knowledege on this (not english spelling bad)

My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u]

Link to comment
Share on other sites

You can use _WinAPI_PtInRect() function to determine if mouse click coordinates are within a rectangular area like:

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

If Not IsDeclared('WM_LBUTTONDOWN') Then Global Const $WM_LBUTTONDOWN = 0x0201

Global $hGUI = GUICreate('Click in the middle', 100, 100)
Global $tRect
Global $fPress = False

$tRect = DllStructCreate($tagRECT)

DllStructSetData($tRect, 'Left', 15)
DllStructSetData($tRect, 'Top', 40)
DllStructSetData($tRect, 'Right', 80)
DllStructSetData($tRect, 'Bottom', 63)

GUISetState()
GUIRegisterMsg($WM_LBUTTONUP, 'WM_LBUTTONUP')
GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN')

Do
Until GUIGetMsg() = -3

GUIDelete()
Exit

Func WM_LBUTTONUP($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tPoint
    
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, 'X', BitAND($ilParam, 0xFFFF))
    DllStructSetData($tPoint, 'Y', Int(BitAND($ilParam, 0xFFFF0000)/65536))
    
    If _WinAPI_PtInRect($tRect, $tPoint) And $fPress Then
        MsgBox(0, 'Title', 'Text')
    EndIf
    
    $fPress = False
    Return 'GUI_RUNDEFMSG'
EndFunc

Func WM_LBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tPoint
    
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, 'X', BitAND($ilParam, 0xFFFF))
    DllStructSetData($tPoint, 'Y', Int(BitAND($ilParam, 0xFFFF0000)/65536))
    
    If _WinAPI_PtInRect($tRect, $tPoint) Then $fPress = True
    
    Return 'GUI_RUNDEFMSG'
EndFunc
Link to comment
Share on other sites

You can use _WinAPI_PtInRect() function to determine if mouse click coordinates are within a rectangular area like:

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

If Not IsDeclared('WM_LBUTTONDOWN') Then Global Const $WM_LBUTTONDOWN = 0x0201

Global $hGUI = GUICreate('Click in the middle', 100, 100)
Global $tRect
Global $fPress = False

$tRect = DllStructCreate($tagRECT)

DllStructSetData($tRect, 'Left', 15)
DllStructSetData($tRect, 'Top', 40)
DllStructSetData($tRect, 'Right', 80)
DllStructSetData($tRect, 'Bottom', 63)

GUISetState()
GUIRegisterMsg($WM_LBUTTONUP, 'WM_LBUTTONUP')
GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN')

Do
Until GUIGetMsg() = -3

GUIDelete()
Exit

Func WM_LBUTTONUP($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tPoint
    
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, 'X', BitAND($ilParam, 0xFFFF))
    DllStructSetData($tPoint, 'Y', Int(BitAND($ilParam, 0xFFFF0000)/65536))
    
    If _WinAPI_PtInRect($tRect, $tPoint) And $fPress Then
        MsgBox(0, 'Title', 'Text')
    EndIf
    
    $fPress = False
    Return 'GUI_RUNDEFMSG'
EndFunc

Func WM_LBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tPoint
    
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, 'X', BitAND($ilParam, 0xFFFF))
    DllStructSetData($tPoint, 'Y', Int(BitAND($ilParam, 0xFFFF0000)/65536))
    
    If _WinAPI_PtInRect($tRect, $tPoint) Then $fPress = True
    
    Return 'GUI_RUNDEFMSG'
EndFunc

ok i have been messign with this and i STILL cant find out how to adjust the corrds of the click range

DllStructSetData($tRect, 'Left', 15)

DllStructSetData($tRect, 'Top', 40)

DllStructSetData($tRect, 'Right', 80)

DllStructSetData($tRect, 'Bottom', 63)

tried messing with that

EDIT:i want it to make if ANYWHERE on the gui is clicked...

Edited by liten

My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u]

Link to comment
Share on other sites

Try thinking of it like a button that is as followed but it definitely not one:

$Btn = GUICtrlCreateButton('Button', 15, 40, 70, 23)

So if you read the function description of GUICtrlCreateButton() you'll have a clue but the rect works a little different in that it represents coordinates rather than x, y, width, height. So x+width will get you the right and the same goes to the y+height.

Edit: So you don't need it anyway:

#include <GUIConstantsEx.au3>

Global $hGUI = GUICreate('Test', 200, 200)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_PRIMARYUP
            MsgBox(0, 'Title', 'Text')
            
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by Authenticity
Link to comment
Share on other sites

i tried

While 1

$nMsg = GUIGetMsg($Gui)

Select

Case $nMsg = $GUI_EVENT_CLOSE

Exit

Case $nMsg = $GUI_EVENT_PRIMARYUP

MsgBox(0, 'Title', 'Text')

EndSelect

WEnd

and a variety of other wyas By messing with GUiGermeaasae, SO that it only get the message for one form (GUI) instead of both

No luck, any advice?

My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u]

Link to comment
Share on other sites

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

Global $hGUI1, $hGUI2

$hGUI1 = GUICreate('Test', 200, 200)
GUISetState()
$hGUI2 = GUICreate('', 100, 100, 50, 50, $WS_CHILD, 0, $hGUI1)
GUISetState()

While 1
    Local $aMsg = GUIGetMsg(1)
    Switch $aMsg[0]
        Case $GUI_EVENT_PRIMARYUP
            If $aMsg[1] = $hGUI1 Then
                MsgBox(0, '', 'GUI1')
            Else
                MsgBox(0, '', 'GUI2')
            EndIf
            
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Next time read the function and parameters description carefully.

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...