Sign in to follow this  
Followers 0
martin

Resize a Popup window without borders.

6 posts in this topic

#1 ·  Posted (edited)

I thought the messages were interesting, but it might not be so useful.

#include <GuiConstants.au3>
 #include <windowsconstants.au3>

 ;Global Const $WM_LBUTTONDOWN = 0x0201
 Global Const $margin = 12; distance from edge of window where dragging is possible
 $Gui = GUICreate("Drag sides to resize", 420, 200, -1, -1, $WS_POPUP)
 GUISetBkColor(0xf1f100)

 $chk1 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40)
 GUICtrlSetResizing(-1,$GUI_DOCKWIDTH)
 $Button = GUICtrlCreateButton("Exit", 140, 90, 150, 30)

 GUISetState(@SW_SHOW, $Gui)

 GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
 GUIRegisterMsg($WM_MOUSEMOVE, "SetCursor")

 While 1
 $msg = GUIGetMsg()
 Select
    Case $msg = $Button
    Exit
 EndSelect

 WEnd

;GetMousePosType returns a code depending on the border the mouse cursor is near
 Func GetMousePosType()
 Local $cp = GUIGetCursorInfo()
 Local $wp = WinGetPos($Gui)
 Local $side = 0
 Local $TopBot = 0
 Local $curs
 If $cp[0] < $margin Then $side = 1
 If $cp[0] > $wp[2] - $margin Then $side = 2
 If $cp[1] < $margin Then $TopBot = 3
 If $cp[1] > $wp[3] - $margin Then $TopBot = 6

 Return $side + $TopBot

 EndFunc;==>GetMousePosType

 Func SetCursor()
 Local $curs
 If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return
 Switch GetMousePosType()
    Case 0
    $curs = 2
    Case 1, 2
    $curs = 13
    Case 3, 6
    $curs = 11
    Case 5, 7
    $curs = 10
    Case 4, 8
    $curs = 12
 EndSwitch

 GUISetCursor($curs, 1)

 EndFunc;==>SetCursor


 Func WM_LBUTTONDOWN($hWnd, $iMsg, $StartWIndowPosaram, $lParam)

 If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG
 Local $drag = GetMousePosType()
 If $drag > 0 Then
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0)
 Else
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", $WM_SYSCOMMAND, "int", 0xF012, "int", 0)
 EndIf

;F001 = LHS, F002 = RHS, F003 = top, F004 = TopLeft, F005 = TopRight, F006 = Bottom, F007 = BL, F008 = BR
;F009 = move gui, same as F011 F012 to F01F
;F010, moves cursor to centre top of gui - no idea what that is useful for.
;F020 minimizes
;F030 maximizes

 EndFunc;==>WM_LBUTTONDOWN

Edit: Corrected code F012 from F12

EDIT 2: Commented out definition of $WM_LBUTTONDOWN which is no longer longer needed. Added dragging.

mgrefdragmessages

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Cool stuff Martin, I'm sure I'll find a use for it sometime.

Share this post


Link to post
Share on other sites

Cool stuff Martin, I'm sure I'll find a use for it sometime.

Thanks, but lets be honest, with yours the only reply in 7 months it can't be very cool ^_^

But I'm glad you did post a reply because I had forgotten this and I can use it for something I'm doing now.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

It's nice.

Today I will use it. :mellow:

But you have to delete:

Global Const $WM_LBUTTONDOWN = 0x0201

Else you get an error: :(

ERROR: $WM_LBUTTONDOWN previously declared as a 'Const'

Global Const $WM_LBUTTONDOWN = 0x0201

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's nice.

Today I will use it. :mellow:

But you have to delete:

Global Const $WM_LBUTTONDOWN = 0x0201

Else you get an error: :(

ERROR: $WM_LBUTTONDOWN previously declared as a 'Const'

Global Const $WM_LBUTTONDOWN = 0x0201

Ok, I'll change it, AutoIt has moved on a bit since I wrote that.

I added dragging while I was at it.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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