Jump to content

Recommended Posts

Posted (edited)

Hello everyone!!!

I'll tell you right away - most likely my task is impossible to solve. However, perhaps I will be lucky.

Is there any way to move or change the position of an already created region?

is this impossible or maybe I don't know something?

I mean changing the location of a region (new x y) that has already been created. It seems unrealistic. But it would be cool!!

 

#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>

$hGUI = GUICreate('Move region - is it possible.. ?', 600, 600)
GUISetBkColor($COLOR_RED, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80
$hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)
Global $x = 120, $y = 120, $iWidth = 80, $iHeight = 80
$hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)

$hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1)
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3)

;help me
;how to move region?
;ex. _WinAPI_MoveRgn ... (set new iX iY)
;ex. _WinAPI_RgnSetPos ... (set new iX iY)
;any ideas?

_WinAPI_SetWindowRgn($hGUI, $hCombinedRgn)
_WinAPI_DeleteObject($hRgn1)
_WinAPI_DeleteObject($hCombinedRgn)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

Sorry for my English!

Edited by SEKOMD
Posted (edited)
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>

Global $hGUI = GUICreate('Move region - is it possible.. ?', 600, 600)
GUISetBkColor($COLOR_RED, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80
Global $hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)
$x = 120
$y = 120
Global $hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)
Global $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1)
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3)
_WinAPI_SetWindowRgn($hGUI, $hCombinedRgn)

Sleep(3000)

; Move the first region to (50, 50)
$x = 50 ; New X position
$y = 50 ; New Y position
$hRgn1 = MoveRegion($hRgn1, $x, $y)

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

; Clean up
_WinAPI_DeleteObject($hRgn1)
_WinAPI_DeleteObject($hRgn2)
GUIDelete($hGUI)

;---------------------------------------------------------------------------------------
Func MoveRegion($hRegion, $newX, $newY)
    Local $hNewRgn = _WinAPI_CreateRectRgn($newX, $newY, $newX + $iWidth, $newY + $iHeight)
    Local $hNewCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])

    _WinAPI_CombineRgn($hNewCombinedRgn, $hNewCombinedRgn, $hNewRgn, 1)
    _WinAPI_CombineRgn($hNewCombinedRgn, $hNewCombinedRgn, $hRgn2, 3) ; Keep the second region

    _WinAPI_SetWindowRgn($hGUI, $hNewCombinedRgn)

    _WinAPI_DeleteObject($hRegion)
    _WinAPI_DeleteObject($hNewCombinedRgn)

    Return $hNewRgn
EndFunc
;---------------------------------------------------------------------------------------

 

Edited by ioa747
corrections

I know that I know nothing

Posted
6 minutes ago, ioa747 said:
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>

$hGUI = GUICreate('Move region - is it possible.. ?', 600, 600)
GUISetBkColor($COLOR_RED, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80
$hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)
Global $x = 120, $y = 120, $iWidth = 80, $iHeight = 80
$hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)

Global $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1)
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3)
_WinAPI_SetWindowRgn($hGUI, $hCombinedRgn)

Sleep(3000)

; Move the first region to (50, 50)
$x1 = 50 ; New X position
$y1 = 50 ; New Y position
$hRgn1 = MoveRegion($hRgn1, $x1, $y1)

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

; Clean up
_WinAPI_DeleteObject($hRgn1)
_WinAPI_DeleteObject($hRgn2)
GUIDelete($hGUI)

;---------------------------------------------------------------------------------------
Func MoveRegion($hRegion, $newX, $newY)
    Local $hNewRgn = _WinAPI_CreateRectRgn($newX, $newY, $newX + $iWidth, $newY + $iHeight)
    Local $hNewCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])

    _WinAPI_CombineRgn($hNewCombinedRgn, $hNewCombinedRgn, $hNewRgn, 1)
    _WinAPI_CombineRgn($hNewCombinedRgn, $hNewCombinedRgn, $hRgn2, 3) ; Keep the second region

    _WinAPI_SetWindowRgn($hGUI, $hNewCombinedRgn)

    _WinAPI_DeleteObject($hRegion)
    _WinAPI_DeleteObject($hNewCombinedRgn)

    Return $hNewRgn
EndFunc
;---------------------------------------------------------------------------------------

 

yes, I can do that too, thank you for the useful example. But what I mean is to transfer the already created region..

I just don't think it is possible. But maybe I'm wrong?

Posted
2 minutes ago, ioa747 said:

I know so far. Wait for someone more advanced. :)

the thing is that this is not just moving a region, it is... moving a part of the window interface, which is a single whole..

Posted

Maybe this ?

#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <ColorConstants.au3>

$hGUI = GUICreate('Move region - is it possible.. ?', 600, 600)
GUISetBkColor($COLOR_RED, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

Global $x = 30, $y = 30, $iWidth = 80, $iHeight = 80
$hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)
Global $x = 120, $y = 120, $iWidth = 80, $iHeight = 80
$hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)

$hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1)
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3)

_WinAPI_OffsetRgn($hCombinedRgn, +200, +200)
_WinAPI_SetWindowRgn($hGUI, $hCombinedRgn)

_WinAPI_DeleteObject($hRgn1)
_WinAPI_DeleteObject($hCombinedRgn)

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

 

Posted
9 minutes ago, Nine said:
_WinAPI_OffsetRgn($hCombinedRgn, +200, +200)

But the contents also change. But to move it along with a part of the window...

Do you need to somehow "cut off" a part of the window?

Posted
12 minutes ago, junkew said:

Maybe invalidating the region? Win32 api example

in theory it is possible, but it is not exactly what is needed

I just wanted to move part of the interface.. which will continue to work, react to clicks..

Posted

Something like that?

#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>

$hGUI = GUICreate('Move region - is it possible.. ?', 600, 600)
GUISetBkColor($COLOR_RED, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80
$hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)
Global $x = 120, $y = 120, $iWidth = 80, $iHeight = 80
$hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight)

$hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])

_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1)
_WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3)
_WinAPI_SetWindowRgn($hGUI, $hCombinedRgn)

;help me
;how to move region?
;ex. _WinAPI_MoveRgn ... (set new iX iY)
;ex. _WinAPI_RgnSetPos ... (set new iX iY)
;any ideas?

Global $i, $tPAINTSTRUCT

_Timer_SetTimer($hGUI, 10, "UpdateRegion")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _Timer_KillAllTimers($hGUI)
            _WinAPI_DeleteObject($hRgn1)
            _WinAPI_DeleteObject($hRgn2)
            _WinAPI_DeleteObject($hCombinedRgn)
            ExitLoop
    EndSwitch
WEnd

Func UpdateRegion($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _WinAPI_OffsetRgn($hRgn2, Sin($i) * 10, Cos($i) * 10)
    $i += 0.1
    $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3])
    _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1)
    _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3)
    _WinAPI_SetWindowRgn($hGUI, $hCombinedRgn)
    _WinAPI_DeleteObject($hCombinedRgn)
EndFunc

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
40 minutes ago, UEZ said:

Something like that?

excuse me please, I'm probably explaining something incorrectly

the point is to move the region together with the content (without changing it), and to grab it together.. and for this content to be active (in terms of the interface). For now it seems impossible to me.

sorry my English..

Posted

Alright one last attempt :

#include <GUIConstants.au3>
#include <WinAPIGdi.au3>
#include <ColorConstants.au3>

Example()

Func Example()

  Local $hGUI1 = GUICreate('Move region 1', 300, 300, 300, 200, -1, $WS_EX_CONTROLPARENT)
  GUISetBkColor($COLOR_RED)
  GUISetState()

  Local $hRgn1 = _WinAPI_CreateRectRgn(0, 0, 80, 80)
  _WinAPI_SetWindowRgn($hGUI1, $hRgn1)

  Local $hGUI2 = GUICreate('Move region 2', 300, 300, 420, 320, -1, $WS_EX_CONTROLPARENT)
  GUISetBkColor($COLOR_RED, $hGUI2)
  GUISetState(@SW_SHOW, $hGUI2)

  $hRgn2 = _WinAPI_CreateRectRgn(30, 30, 110, 110)

  _WinAPI_SetWindowRgn($hGUI2, $hRgn2)

  Sleep(2000)

  WinMove($hGUI1, "", 500, 500)

  _WinAPI_DeleteObject($hRgn1)
  _WinAPI_DeleteObject($hRgn2)

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

EndFunc   ;==>Example

You can also drag each square (button ?) independently...

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
  • Recently Browsing   0 members

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