Jump to content

Window dock


janci
 Share

Recommended Posts

No, it isnĀ“t that what I whant ... :-(

Janci, yeah I know it's not exactly what you wanted. It's still freakin' amazing (well I at least got a lot out of it and think it is). I'll see if I can help you develop a UDF. Smoke_N, do you know if there is a "Win API" or dll for doing what Google Desktop does and dragged folders to the side do (ie. they mvoe the desktop icons over and windows are "aware" of the docked win? Thank again Smoke_N for directing me toward that though!

Edit:

Janci

Yeah, I understand what you're wanting to do. I'm really thinking it has to be done with some sort of API or dll or something.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Janci

"Of course, there is no built-in feature of the Win API that allows windows to snap to the screen edge - we will have to deal with Windows messages."

- http://delphi.about.com/od/formsdialogs/l/aa070301a.htm

But this doesn't seem to be the case with Google's Desktop or with the folders dragged to the sides.

A decision is a powerful thing
Link to comment
Share on other sites

Heureca...

We have to use DllCall on user32.dll with SPI_SETWORKAREA, 0, rect, 0

rect=pointer to rect structure

TIGHT!! Way to go Janci!! Where in the world did you find that? Crud I am really not good with Dll structures are you?

Indeed you did find :)

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

You're probably MUCH farther than I am with this, but http://forums.microsoft.com/MSDN/ShowPost....66&SiteID=1

Something like this is what you might need, but if it works it might will mess up your desktop so don't blame me.

Const $SPI_SETWORKAREA = 47
Const $SPIF_SENDCHANGE = 11


$newWid = @DesktopWidth - 300;reduce the desktop working width by some amount
$newHt = @DesktopHeight;keep this the same

$DtopRect = DllStructCreate("int[4]")
DllStructSetData($DtopRect,1,0,1);top
DllStructSetData($DtopRect,1,0,2);left
DllStructSetData($DtopRect,1,$newWid,3);bottom
DllStructSetData($DtopRect,1,$newHt,4);right
$PRect = DllStructGetPtr($DtopRect);pointer to rect structure

$res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_SETWORKAREA,"int",0,"ptr",$PRect,"int",$SPIF_SENDCHANGE)

MsgBox(0,"somthing might have changed on your desktop","better have a look")

DllStructSetData($DtopRect,1,$newWid+500,3);we'll put the working area back to how it was

$res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_SETWORKAREA,"int",0,"ptr",$PRect,"int",$SPIF_SENDCHANGE)
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.
Link to comment
Share on other sites

Thanks Martin..

I did it earlier than you have posted it... but thanks

my script:

#include <GUIConstants.au3>
$Gui = GUICreate("pokus", 100)
GUISetState()
DockIt($Gui, "right")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
UnDockIt($Gui)
Func UnDockIt($gui)
        $SPI_SETWORKAREA = 47
    $SPI_GETWORKAREA = 48
$DINewRect = DllStructCreate("long;long;long;long")
        DllStructSetData($DINewRect, 1,0)
        DllStructSetData($DINewRect, 2,0)
        DllStructSetData($DINewRect, 3,1024)
        DllStructSetData($DINewRect, 4,730)
    DllCall("user32.dll", "uint", "SystemParametersInfoA", "uint", $SPI_SETWORKAREA, "uint", 0, "ptr", DllStructGetPtr($DINewRect), "uint", 0)
$var = WinList()
    For $i = 1 To $var[0][0]
        If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2 + 32 + 8) Then
            WinMove($var[$i][1], "", DllStructGetData($DINewRect, 1), DllStructGetData($DINewRect, 2), DllStructGetData($DINewRect, 3), DllStructGetData($DINewRect, 4))
        EndIf
    Next
    
EndFunc   ;==>UnDockIt
Func DockIt($DIguiHwnd, $DIpos)
    $SPI_SETWORKAREA = 47
    $SPI_GETWORKAREA = 48
    $DIOrigRect = DllStructCreate("long left;long right;long top;long bottom")
    DllCall("user32.dll", "uint", "SystemParametersInfoA", "uint", $SPI_GETWORKAREA, "uint", 0, "ptr", DllStructGetPtr($DIOrigRect), "uint", 0)
    If $DIpos = "right" Then
        $DIGuiPos = WinGetPos($DIguiHwnd)
        $DINewRect = DllStructCreate("long;long;long;long")
        DllStructSetData($DINewRect, 1, DllStructGetData($DIOrigRect, 1))
        DllStructSetData($DINewRect, 2, DllStructGetData($DIOrigRect, 2))
        DllStructSetData($DINewRect, 3, DllStructGetData($DIOrigRect, 3) - $DIGuiPos[2])
        DllStructSetData($DINewRect, 4, DllStructGetData($DIOrigRect, 4))
    ElseIf $DIpos = "left" Then
        $DIGuiPos = WinGetPos($DIguiHwnd)
        $DINewRect = DllStructCreate("long;long;long;long")
        DllStructSetData($DINewRect, 1, DllStructGetData($DIOrigRect, 1) - $DIGuiPos[2])
        DllStructSetData($DINewRect, 2, DllStructGetData($DIOrigRect, 2))
        DllStructSetData($DINewRect, 3, DllStructGetData($DIOrigRect, 3))
        DllStructSetData($DINewRect, 4, DllStructGetData($DIOrigRect, 4))
    Else
        Return False
    EndIf
    DllCall("user32.dll", "uint", "SystemParametersInfoA", "uint", $SPI_SETWORKAREA, "uint", 0, "ptr", DllStructGetPtr($DINewRect), "uint", 0)
    $var = WinList()
    For $i = 1 To $var[0][0]
        If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2 + 32 + 8) Then
            WinMove($var[$i][1], "", DllStructGetData($DIOrigRect, 1), DllStructGetData($DIOrigRect, 2), DllStructGetData($DIOrigRect, 3), DllStructGetData($DIOrigRect, 4))
        EndIf
    Next
    If $DIpos = "right" Then
        WinMove($DIGuiPos, "", DllStructGetData($DINewRect, 3), DllStructGetData($DINewRect, 2), $DIGuiPos[2], DllStructGetData($DIOrigRect, 4) - DllStructGetData($DIOrigRect, 2))
    ElseIf $DIpos = "left" Then
        WinMove($DIGuiPos, "", DllStructGetData($DINewRect, 3) - $DIGuiPos[2], DllStructGetData($DINewRect, 2), $DIGuiPos[2], DllStructGetData($DIOrigRect, 4) - DllStructGetData($DIOrigRect, 2))
    EndIf
EndFunc   ;==>DockIt

Thanks Everybody

Link to comment
Share on other sites

Where in the world did you find that?

I have clicked your link(about delphi programming) and I have found, that they use SPI_GETWORKAREA to find the edge of the screen..

so I googled for SPI_SETWORKAREA and I have found that the function SystemParametersInfoA (in uder32.dll)can set that...

after it was EASY :)

and...... thakns for help

Link to comment
Share on other sites

coool!! Janci (and Martin) cool!!

Janci way to go on the success with that! We should develop a UDF for it. I can do it if you want and post and then people can tare it apart :)

Congrats!

Martin and Smoke_N thanks for your help ;) ;)

Janci a strong second welcome to the forums

Edits:

Glad my senseless ramblings ;) helped a bit.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Janci, one thing we need to do for sure is retrieve and store the original Workarea. Haha, because when you close the app it doesn't go back to what you had before the app. Instead, it retains that workarea and then your workarea is just all goofed-up.
A decision is a powerful thing
Link to comment
Share on other sites

:) Looks like it does ;)

TzarAlkex, thanks for posting that. ;)

EDIT:

Looks like there are a few updates still to be made for it. One would be returning the workarea to the original workarea.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

I wrote this a while ago, simple little script to dock a window to any side of the screen when it is placed past the edge of that side, just seemed to be on topic so I decided I'd add it as a suggestion for an easy way to add it to your script.

#include <GUIConstants.au3>

$parent = GUICreate("test",195,175,-1,-1,-1,-1)

GUISetState()
Do
$msg = GUIGetMsg()

_DockToScreenSide($parent)


Until $msg = $GUI_EVENT_CLOSE
GUIDelete()

Func _DockToScreenSide($hWindow)
    $hPos = WinGetPos($hWindow,"")
        if $hPos[0] + $hPos[2] > @DesktopWidth then
            WinMove($hWindow,"",@DesktopWidth - $hPos[2],$hPos[1])
        endif
        if $hPos[1] + $hPos[3] > @DesktopHeight then
            WinMove($hWindow,"",$hPos[0],@DesktopHeight - $hPos[3])
        endif
        if $hPos[0] < 1 then
            WinMove($hWindow,"",1,$hPos[1])
        endif
        if $hPos[1] < 1 then
            WinMove($hWindow,"",$hPos[0],1)
        endif
EndFunc
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

  • 2 years later...

Thanks Martin..

I did it earlier than you have posted it... but thanks

my script:

#include <GUIConstants.au3>
$Gui = GUICreate("pokus", 100)
GUISetState()
DockIt($Gui, "right")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
UnDockIt($Gui)
Func UnDockIt($gui)
        $SPI_SETWORKAREA = 47
    $SPI_GETWORKAREA = 48
$DINewRect = DllStructCreate("long;long;long;long")
        DllStructSetData($DINewRect, 1,0)
        DllStructSetData($DINewRect, 2,0)
        DllStructSetData($DINewRect, 3,1024)
        DllStructSetData($DINewRect, 4,730)
    DllCall("user32.dll", "uint", "SystemParametersInfoA", "uint", $SPI_SETWORKAREA, "uint", 0, "ptr", DllStructGetPtr($DINewRect), "uint", 0)
$var = WinList()
    For $i = 1 To $var[0][0]
        If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2 + 32 + 8) Then
            WinMove($var[$i][1], "", DllStructGetData($DINewRect, 1), DllStructGetData($DINewRect, 2), DllStructGetData($DINewRect, 3), DllStructGetData($DINewRect, 4))
        EndIf
    Next
    
EndFunc   ;==>UnDockIt
Func DockIt($DIguiHwnd, $DIpos)
    $SPI_SETWORKAREA = 47
    $SPI_GETWORKAREA = 48
    $DIOrigRect = DllStructCreate("long left;long right;long top;long bottom")
    DllCall("user32.dll", "uint", "SystemParametersInfoA", "uint", $SPI_GETWORKAREA, "uint", 0, "ptr", DllStructGetPtr($DIOrigRect), "uint", 0)
    If $DIpos = "right" Then
        $DIGuiPos = WinGetPos($DIguiHwnd)
        $DINewRect = DllStructCreate("long;long;long;long")
        DllStructSetData($DINewRect, 1, DllStructGetData($DIOrigRect, 1))
        DllStructSetData($DINewRect, 2, DllStructGetData($DIOrigRect, 2))
        DllStructSetData($DINewRect, 3, DllStructGetData($DIOrigRect, 3) - $DIGuiPos[2])
        DllStructSetData($DINewRect, 4, DllStructGetData($DIOrigRect, 4))
    ElseIf $DIpos = "left" Then
        $DIGuiPos = WinGetPos($DIguiHwnd)
        $DINewRect = DllStructCreate("long;long;long;long")
        DllStructSetData($DINewRect, 1, DllStructGetData($DIOrigRect, 1) - $DIGuiPos[2])
        DllStructSetData($DINewRect, 2, DllStructGetData($DIOrigRect, 2))
        DllStructSetData($DINewRect, 3, DllStructGetData($DIOrigRect, 3))
        DllStructSetData($DINewRect, 4, DllStructGetData($DIOrigRect, 4))
    Else
        Return False
    EndIf
    DllCall("user32.dll", "uint", "SystemParametersInfoA", "uint", $SPI_SETWORKAREA, "uint", 0, "ptr", DllStructGetPtr($DINewRect), "uint", 0)
    $var = WinList()
    For $i = 1 To $var[0][0]
        If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2 + 32 + 8) Then
            WinMove($var[$i][1], "", DllStructGetData($DIOrigRect, 1), DllStructGetData($DIOrigRect, 2), DllStructGetData($DIOrigRect, 3), DllStructGetData($DIOrigRect, 4))
        EndIf
    Next
    If $DIpos = "right" Then
        WinMove($DIGuiPos, "", DllStructGetData($DINewRect, 3), DllStructGetData($DINewRect, 2), $DIGuiPos[2], DllStructGetData($DIOrigRect, 4) - DllStructGetData($DIOrigRect, 2))
    ElseIf $DIpos = "left" Then
        WinMove($DIGuiPos, "", DllStructGetData($DINewRect, 3) - $DIGuiPos[2], DllStructGetData($DINewRect, 2), $DIGuiPos[2], DllStructGetData($DIOrigRect, 4) - DllStructGetData($DIOrigRect, 2))
    EndIf
EndFunc   ;==>DockIt

Thanks Everybody

replace:

DllStructSetData($DINewRect, 3,1024)
DllStructSetData($DINewRect, 4,730)

with:

DllStructSetData($DINewRect, 3,@DesktopWidth)
DllStructSetData($DINewRect, 4,@DesktopHeight)

it will work much better xD

Edited by sam2332
Link to comment
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
 Share

  • Recently Browsing   0 members

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