Sign in to follow this  
Followers 0
nf67

WS_POPUP style - How to move the window?

9 posts in this topic

Hello there,

I've created a very simple script that works like a live subtitle bar when I record my desktop.

So I just record and type my comment on what I'm doing in the bar ( which is basically a strechted inputbox ).

Because I only record 660x440 pixels I'd rather not waste any space, so I used the WS_POPUP style to remove the window-borders....

but now I can't seem to move the window..? What can I do?

My script

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$commentpile = GUICreate("commentpile", 650, 22, 193, 125, $WS_POPUP)
$zooi = GUICtrlCreateInput("zooi", 0, 0, 649, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

Thank you,

Chris

Share this post


Link to post
Share on other sites



Hi, try this:

#include <GuiConstants.au3>

Global Const $WM_LBUTTONDOWN = 0x0201

$HWnd = GUICreate("DRAG GUI", 240, 180, -1, -1, $WS_POPUP+$WS_BORDER)
GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
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

but now I can't seem to move the window..? What can I do?

Well, you can not move the window only draging the input :) - you will need some kind of static control to move the parent...

#include <GuiConstants.au3>

#Region ### START Koda GUI section ### Form=
$commentpile = GUICreate("commentpile", 650, 32, 193, 125, $WS_POPUP+$WS_BORDER)

GUICtrlCreateLabel("Custom Title", 0, 0, 650, -1, $ES_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 7)

$zooi = GUICtrlCreateInput("zooi", 0, 10, 649, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

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

Love it! Just what I was looking for :) Thanks a lot

Share this post


Link to post
Share on other sites

Love it! Just what I was looking for :) Thanks a lot

@MsCreator

Thanks for the solution, this is what I'm looking for...;)


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

More examples:

#include <GuiConstants.au3>

;Global Const $HTCLIENT = 0x1
;Global Const $HTCAPTION = 0x2

$hGui = GUICreate("Test", 300, 200, -1, -1, $WS_POPUP + $WS_BORDER)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    Local $iProc
    
    $iProc = DllCall("user32.dll", "int", "DefWindowProc", "hwnd", $hWnd, "int", $Msg, "wparam", $wParam, "lparam", $lParam)
    $iProc = $iProc[0]
    
    If $iProc = $HTCLIENT Then Return $HTCAPTION
    
    Return $GUI_RUNDEFMSG
EndFunc
:) Edited by rasim

Share this post


Link to post
Share on other sites

Another one:

#include <GuiConstants.au3>

Opt("GUICloseOnESC",1)
Opt("GUIOnEventMode",1)

$hGui = GUICreate("Test", 300, 200, -1, -1, $WS_POPUP + $WS_BORDER)
GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" )
GUISetState()

While 1
      Sleep(10)
WEnd

Func Drag()
      dllcall("user32.dll","int","SendMessage","hWnd", $hGui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

this thread is timely, so this is as good a place as any.

I noticed several days ago that the WM_NCHITTEST method of moving a Gui by it's form

no longer works in beta v3.2.11.1 and 3.2.11.2

use the WM_NCLBUTTONDOWN method

was working up to v3.2.10.0 (tested on 3.2.8.1 and 3.2.10.0)

tested on 2 machines running XP SP2 EN X86

AutoIt: beta v3.2.11.1 and v3.2.11.2

SciTE4AutoIt3: 8-3-2008

Edit: typos

test in beta

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
$hGui = GUICreate("Test", 300, 200, -1, -1)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()

Do
    $msg = GUIGetMsg()
Until  $msg = -3

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    Local $iProc
    $iProc = DllCall("user32.dll", "int", "DefWindowProc", _
    "hwnd", $hWnd, "int", $Msg, "int", $wParam, "int", $lParam)
    If @error Then SetError(@error, 0, 0)
    $iProc = $iProc[0]
    If $iProc = $HTCLIENT Then Return $HTCAPTION
    Return $GUI_RUNDEFMSG
EndFunc
Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

this thread is timely, so this is as good a place as any.

I noticed several days ago that the WM_NCHITTEST method of moving a Gui by it's form

no longer works in beta v3.2.11.1 and 3.2.11.2

use the WM_NCLBUTTONDOWN method

was working up to v3.2.10.0 (tested on 3.2.8.1 and 3.2.10.0)

tested on 2 machines running XP SP2 EN X86

AutoIt: beta v3.2.11.1 and v3.2.11.2

SciTE4AutoIt3: 8-3-2008

Edit: typos

test in beta

Verified also with beta 3.2.11.3, XP PRO SP2 EN x86

Time for a bug report?

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