Restore function added, enhanced drag&drop added (works with ctrl pressed down), a little bit more pixels removed at the top of the table with just borders. Rate it's work please so that i could upload this version to Overcards.
Code:
; #### NoTitlebar ####
; AHK version: 1.0.48.05
; date: 4:05 PM Wednesday, December 16, 2009
; version: 1.05
; author: Roland (roland@overcards.com)
#NoEnv
#NoTrayIcon
#SingleInstance force
#Include %a_scriptDir%
#Include Functions.ahk
#Include *i casinos.ahk
#Include dfc.ahk
SetWorkingDir %a_scriptDir%
If 1 != -i
Menu, Tray, Icon
OnMessage(0x5555, "ExitMsg")
ini = NoTitlebar.ini
IniRead, includeLobby, % ini, Prefs, includeLobby, 0
IniRead, dragNdrop, % ini, Prefs, dragNdrop, 1
IniRead, noBorder, % ini, Prefs, noBorder, 0
IniRead, restore, % ini, Prefs, restore, 0
IniRead, version, % ini, Prefs, version
Loop, Casinos\*.ahk
casinos:=addToList(casinos, StrRep(a_loopFileName, ".ahk"))
Menu, Tray, NoStandard
Menu, Tray, Add, &Help, Help
Menu, Tray, Default, &Help
Menu, Tray, Add
Menu, Tray, Add, &About, About
Menu, Tray, Add
Menu, Tray, Add, &Preferences, Prefs
Menu, Tray, Add
Menu, Tray, Add, Plug-&In..., PlugIn
Menu, Tray, Add
Menu, Tray, Add, E&xit, Exit
Menu, Tray, Tip, NoTitlebar v%version%
If ( dragNdrop )
Hotkey, ~LButton, DragNDrop
SetTimer, timer, 300
return
; ## end of auto-execute section ##
; ## timer ##
Timer:
tables := tables()
Loop, Parse, tables, `,
{ If ( a_loopfield="" )
continue
WinGetPos,,, w,, ahk_id%a_loopfield%
If ( w!=wPrev%a_loopfield% ) {
WinWaitStatic(a_loopfield, 200)
Cut(a_loopfield)
}
wPrev%a_loopfield% := w
}
return
; ## cut ##
Cut(win) {
global caption,noBorder,restore
WinGetPos,x,y, w, h, ahk_id%win%
WinGet, style, style, ahk_id%win%
code:=( style & 0x40000 ) ? 32 : 7
SysGet, border, % code
SysGet, caption, 4
b:=( noBorder ? border : 0 )
c:=dfc(caption . casino(win))
c:=caption!="" ? c : caption
c:=( noBorder ? caption+border : caption )
if A_OSVersion = WIN_VISTA
if !restore
;This sets the DWMWA_NCRENDERING_POLICY attribute to DWMNCRP_DISABLED. To reset it (i.e. from +#Esc), set it back to DWMNCRP_USEWINDOWSTYLE:
DllCall("dwmapi\DwmSetWindowAttribute","uint",win,"uint",2,"int*",1,"uint",4)
if restore
{
if A_OSVersion = WIN_VISTA
DllCall("dwmapi\DwmSetWindowAttribute","uint",win,"uint",2,"int*",0,"uint",4)
b:=0
c:=0
}
xx:=w-b, yy:=h-b
if !noborder
if !restore
c:=border+c
WinSet, Region
, %b%-%c% %xx%-%c% %xx%-%yy% %b%-%yy% %b%-%c%
, ahk_id%win%
}
; ## tables ##
tables() {
global casinos, includeLobby
Loop, Parse, casinos, `,
{ lobby := dfc("lobby" . a_loopfield)
If ! lobby
continue
theseTables:=dfc("tables" . a_loopfield, lobby)
If ( theseTables="" )
continue
tables := addToList(tables, theseTables)
If ( includeLobby )
tables := addToList(tables, lobby)
} return tables
}
; ## casino ##
casino(id) {
global casinos
Loop, Parse, casinos, `,
{ lobby := dfc("lobby" . a_loopfield)
If ! lobby
continue
If IsIn(id, dfc("tables" . a_loopfield, lobby))
return a_loopfield
}
}
; ## drag&drop ##
DragNDrop:
win := MouseGetWin()
tables := tables()
If ! IsIn(win, tables)
return
MouseGetPos,, y
If ( y > 60 )
return
WinExist("a")
PostMessage, 0xA1, 2
return
; ## Prefs ##
Prefs:
Gui, +toolwindow
Gui, Margin, 5, 5
Gui, Font,, Comic Sans MS
Gui, Add, Checkbox, vincludeLobby checked%includeLobby%, &Include Lobby
Gui, Add, Checkbox, vdragNdrop checked%dragNdrop%, &Enable drag&&drop
Gui, Add, Checkbox, vnoBorder checked%noBorder%, &Strip border completely
Gui, Add, Checkbox, vrestore checked%restore%, &restore borders and caption
Gui, Add, Button, default section h20, Submit
Gui, Add, Button, ys h20, &Cancel
Gui, Show,, Preferences
return
ButtonSubmit:
Gui, Submit
IniWrite, % includeLobby, % ini, Prefs, includeLobby
IniWrite, % dragNdrop, % ini, Prefs, dragNdrop
IniWrite, % noBorder, % ini, Prefs, noBorder
IniWrite, % restore, % ini, Prefs, restore
Reload
return
GuiClose:
GuiEscape:
ButtonCancel:
Gui destroy
return
; ## tray menu ##
Help:
Run http://www.overcards.com/wiki/moin.cgi/NoTitlebar
return
About:
TrayTip
, NoTitlebarStars v%version%, Author: Roland`nE-mail: roland@overcards.com
,, 1
return
PlugIn:
RunWait PlugIn.ahk
Run Start.ahk
Exit:
exitApp
CTRL & LButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return
EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWD_WatchMouse, off
return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled.
{
SetTimer, EWD_WatchMouse, off
WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
Return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
EWD_DeltaX = %EWD_MouseX%
EWD_DeltaX -= %EWD_MouseStartX%
EWD_DeltaY = %EWD_MouseY%
EWD_DeltaY -= %EWD_MouseStartY%
EWD_MouseStartX = %EWD_MouseX% ; Update for the next timer call to this subroutine.
EWD_MouseStartY = %EWD_MouseY%
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
EWD_WinX += %EWD_DeltaX%
EWD_WinY += %EWD_DeltaY%
SetWinDelay, -1 ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, %EWD_WinX%, %EWD_WinY%
return