I have written a function to display an information box.
Although I have specified +Alwaysontop, it always appears behind my main window!!
It is to do with the fact that I am using transparency, because when I comment out the transparency lines, it works fine.
However I would like to keep the transparency feature. HAve I programmed something wrong, or is it a limitation?
Here is the code:
Code:
infobox1(movebox =1,boxtext ="",pic ="",pich ="",boxnumber =10,interval =5,awayinterval =5,infocolor ="e72e49"
,infosound ="",infofont ="",infofontsize =14)
{
detecthiddenwindows,on
;ControlGetPos ,flarex,flarey,,,Button23,Worms Automator
title:=title="" ? "...Information..." : title
topmargin:=10
pictextgap:=10
coordmode,mouse,screen ;set coords to be relative to screen - not active window
mouseGetPos ,flarex,flarey
;msgbox %flarex%,%flarey%
flarex20:=flarex+20
SysGet, maxpix, Monitor
;msgbox gui.%boxnumber%:color.%infosound%
gui, %boxnumber%:+alwaysontop +owner1 +noactivate ;-sysmenu
gui, %boxnumber%:color,%infocolor%
gui, %boxnumber%:font,s%infofontsize%,%infofont%
gui, %boxnumber%:add, text, x10 y10 center hwndinfobox1id,%boxtext%
ystart:=movebox=1 ? maxpixbottom : flarey
gui, %boxnumber%:show,hide x%flarex20% y%ystart%,%title%
if (pic<>"")
{
pichandle:=addlogo(boxnumber,pic,topmargin,pich,title)
if (pich="")
controlgetpos,,,,pich,,ahk_id%pichandle% ;get height of pic if not specified
}
controlmove,,,topmargin+pich+pictextgap+20,,,ahk_id%infobox1id%
winset,transparent,0,%title%
gui, %boxnumber%:show,autosize
playit(infosound)
trans:=0
count:=maxpixbottom
;msgbox,%moveto%
loop
{
if (count<=flarey)
break
trans+=(250/((maxpixbottom-flarey)//interval))
winset,transparent,%trans%,%title%
winset,alwaysontop,on,%title%
if movebox
{
winmove,%title%,,flarex20,%count%
}
count-=interval
sleep 50
}
sleep 2000
count:=flarey
trans:=250
loop
{
if (count>=maxpixbottom)
break
trans-=(250/((maxpixbottom-flarey)//awayinterval))
winset,transparent,%trans%,%title%
winset,alwaysontop,on,%title%
if movebox
winmove,%title%,,flarex20,%count%
sleep 50
count+=awayinterval
}
gui, %boxnumber%:destroy
detecthiddenwindows,off
return
}
addlogo(winnumber,pic="",ypos =10,pich="",wintitle="") ;centres a pic in a window horizontally
{ ;no matter what size window
;msgbox %wintitle%
if (wintitle <>"")
{
wingetpos,,,winwidth,,%wintitle%
}
else
wingetpos,,,winwidth
gui, %winnumber%:add,picture,hwndpichandle y%ypos% h%pich% w-1,%pic%
controlgetpos,,,picwidth,picheight,, ahk_id%pichandle%
xco:=(winwidth/2)-(picwidth/2)
;msgbox %winwidth%.%xco%.%picwidth%.%picheight%.%pichandle%.%wintitle%
controlmove,,xco,,,,ahk_id%pichandle%
return pichandle
}