Jump to content
Sign in to follow this  
Zuma

How i can make moveable Gui?

Recommended Posts

Zuma

Hello

I want to make movable Gui window without XP style (border) i used this:

GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))

but its not movable the question is how i can make it movable?

when i click by left mouse button!!

Example in delphi7:

procedure TForm1.I1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  ReleaseCapture;
  SendMessage(Form1.Handle, WM_SYSCOMMAND, $F012, 0);
end;

Thanks

Share this post


Link to post
Share on other sites
ProgAndy

This way muttley

#include <WinAPI.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

#region - GUI Create
$GUI = GUICreate('dd',-1,-1,-1,-1,BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))
GUICtrlCreateLabel("Label",10,10,100,200)
GUICtrlSetBkColor(-1,0x999999)
GUICtrlCreateButton("Btn",10,220,50,25)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Prim")
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            _SendMessage($GUI,$WM_SYSCOMMAND,0xF012,0)
    EndSelect
WEnd
#endregion

*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

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

comment this line: ;~ GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Prim")

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Zedna

Const $HTCAPTION = 2
Const $WM_NCLBUTTONDOWN = 0xA1

dllcall("user32.dll","int","ReleaseCapture")
dllcall("user32.dll","int","SendMessage","hWnd", $gui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)

Edited by Zedna

Share this post


Link to post
Share on other sites
Malkey

I've been experimenting with all the scriptables on this thread.

I could not get the "ReleaseCapture" to work in this situation. But I did get a toggle button to enable / disable the dragging of the GUI.

This GUI dragging method is going to replace my current method. Something better has come along.

#include <SendMessage.au3> ; or #include <WinAPI.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

local $CapFlag = True

#region - GUI Create
$GUI = GUICreate('dd',-1,-1,-1,-1,BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))
GUICtrlCreateLabel("Label",10,10,100,200)
GUICtrlSetBkColor(-1,0x999999)
$ButCap = GUICtrlCreateButton("Toggle Drag GUI On/Off",10,220,150,25)
$ButExit = GUICtrlCreateButton("Exit",10,250,50,25)
;GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Prim")
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $ButExit or $msg = -3  ; $GUI_EVENT_CLOSE from GUIConstants.au3
            Exit
        Case  $msg = -7 ;$GUI_EVENT_PRIMARYDOWN from GUIConstants.au3   
            ;if $CapFlag then dllcall("user32.dll","int","SendMessage","hWnd", $gui,"int",0xA1,"int", 2,"int", 0)
            ;if $CapFlag then dllcall("user32.dll","int","SendMessage","hWnd", $gui, _
            ;                       "int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
           if $CapFlag then _SendMessage($GUI,$WM_SYSCOMMAND,0xF012,0)
           
        Case  $msg = $ButCap 
            $CapFlag = Not $CapFlag  
        ;   $CapFlag = BitXOR($CapFlag, 1)  ; Toggles $CapFlag True/False
            ;dllcall("user32.dll","int","ReleaseCapture")
            
    EndSelect
WEnd
#endregion

Edit 2008-7-23: Replaced $CapFlag = BitXOR($CapFlag, 1) with $CapFlag = Not $CapFlag. I prefer the simplicity of the "Not".

Edited by Malkey

Share this post


Link to post
Share on other sites
MrCreatoR

Another method:

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

Global $GUI = GUICreate("Drag using any place on GUI - Demo", -1, -1, -1, -1, $WS_OVERLAPPEDWINDOW)
GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))

$Menu = GUICtrlCreateMenu("Test Menu")
GUICtrlCreateMenuItem("Exit Item", $Menu)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Menu+1
            Exit
    EndSwitch
WEnd

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If $hWnd <> $GUI Or $iMsg <> $WM_NCHITTEST Then Return $GUI_RUNDEFMSG
    
    Local $iRet = _WinAPI_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam)
    If $iRet = 1 Then Return 2
    
    Return $iRet
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.