Sign in to follow this  
Followers 0
Enforcer

Need help to MOVE a window :D

3 posts in this topic

Hi All. I made window like this one:

$shirina = 520

$visota = 387

$FORM1= GUICreate("Form1", $shirina, $visota, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS),2)

And right now i need to move it... By a mouse like other normal windows, i made a simple

script but its still works bad and not correct, maybe someone know hot to fix this or other method to move this kind of window ?...

FULL SCRIPT:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <ImageListConstants.au3>
#include <Misc.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>



#Region ### START Koda GUI section ### Form=Form1.kxf
$shirina = 520
$visota = 387


$FORM1= GUICreate("Form1", $shirina, $visota, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS),2)
$SKIN = GUICtrlCreatePic("win.bmp", 0, 0, 520, 387)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


$dll = DllOpen("user32.dll")
Local $coords[4]

While 1
    

;ПОЛУЧАЕМ КООРДИНАТЫ ОКНА и КУРСОРА
$pos = MouseGetPos()
$winpos = WinGetPos($form1)

;ЕСЛИ НЕ НАЖАТА КЛАВИША И МЫ В ОКНЕ ТО ПОЛУЧАЕМ КООРДИНАТЫ НАШЕЙ МЫШКИ
if  not _IsPressed("01", $dll) and $pos[0] > $winpos[0] and $pos[0] < $winpos[0] + $shirina And $pos[1] > $winpos[1] and $pos[1] < $winpos[1] + $visota then
    $xz=$pos[0]-$winpos[0]
    $yz=$pos[1]-$winpos[1]
    ;_MouseTrap()
endif

;ЕСЛИ МЫШКА НАЖАТА И ОКНО АКТИВНО И МЫ В ОКНЕ ТО РАЗРЕШИТЬ ДВИГАТЬ
if _IsPressed("01", $dll) and WinActive($FORM1) and  $pos[0] > $winpos[0] and $pos[0] < $winpos[0] + $shirina   And $pos[1] > $winpos[1] and $pos[1] < $winpos[1] + $visota Then 
;   _MouseTrap($winpos[0], $winpos[1], $winpos[0] + $winpos[2], $winpos[1] + $winpos[3])
    WinMove($form1, "", $pos[0]-$xz, $pos[1]-$yz)
    
    
endif

;БАГ ЕСЛИ МЫ ДВИГАЕМ БЫСТРО МЫШКОЙ То ОНА ПОЛЮБОМУ ВЫСКАКИВАЕТ ЗА ОКНО,
;ДЛЯ ЭТОГО НАДО ПРОВЕРИТЬ В МОМЕНТ НАЖАТИЯ ГДЕ МЫ А ПОТОМ РАЗРЕШИТЬ ВСЁ ДЕЛАТЬ...


; KNOWN BUGS: IF WE TRYING TO MOVE WINDOW VERRY FAST SOMETIMES ITS JUST STOP MOVING...
;MAYBE SOMEONE KNOW'S BETTER WAYS TO MOVE THAT KIND OF WINDOWS CORRECT... !?


$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            

EndSwitch
WEnd

DllClose($dll)

win.rar


[RU] Zone

Share this post


Link to post
Share on other sites



Enforcer,

Here you go:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <ImageListConstants.au3>
#include <Misc.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

#Region ### START Koda GUI section ### Form=Form1.kxf
$shirina = 520
$visota = 387

$FORM1= GUICreate("Form1", $shirina, $visota, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS),2)
$SKIN = GUICtrlCreatePic("win.bmp", 0, 0, 520, 387)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;$dll = DllOpen("user32.dll")
;Local $coords[4]

While 1

$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN  ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Added
            _SendMessage($FORM1, $WM_SYSCOMMAND, 0xF012, 0)  ; <<< Added
EndSwitch
WEnd

;DllClose($dll)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thx for reply, but I already solved this broblem, I'l post my working script later, BUT BiG THX Eny way =)


[RU] Zone

Share this post


Link to post
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
Sign in to follow this  
Followers 0