Jump to content
Sign in to follow this  
ngskicker

Better way to create GUI with close button only AND without taskbar entry and without Icon in title bar

Recommended Posts

ngskicker

Just wondering, this is always in my mind, how to create a gui that has only close button and does not have taskbar entry, I now i can make one with:

GUICreate("Form1", 373, 263, 192, 124, Default, $WS_EX_TOOLWINDOW)

that reproduce something like this:

oz84.png

I'ts perfect except the close button is shrinking, I took the screenshoot above on Windows 8, as I recall in previous windows version (maybe XP) close button is smaller than that, one work around I found is create GUI using:

GUICreate("Form2", 367, 510, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))

and then add this code (found in help) to delete taskbar entry:

; Declare the CLSID, IID and interface description for ITaskbarList.
Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"

; Create the object.
Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)

; Initialize the iTaskbarList object.
$oTaskbarList.HrInit()

; Delete window entry from the Taskbar.
$oTaskbarList.DeleteTab($Form2)

GUISetState(@SW_SHOW)

this one produce nicer close button,

ZXnbTKf.png

No taskbar entry, but the icon still there, after doing forum search i found >this code by rover and modified by guiness to remove the icon, but, is there a better way to do this without so much code

Share this post


Link to post
Share on other sites
BrewManNH

Use the search, it's been discussed about half a dozen times with solutions posted.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
ngskicker

Use the search, it's been discussed about half a dozen times with solutions posted.

 

Can you find one for me sir, I was so stupid, I can not find it.

Share this post


Link to post
Share on other sites
Valuater

Here is a possibility...

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
$Dummy = GUICreate("")
GUISetState(@SW_HIDE, $Dummy)
$GUI = GUICreate("Form2", 367, 510, -1, -1, BitXOR($WS_CAPTION,
$WS_POPUP), -1,  $Dummy)
$Btn = GUICtrlCreateButton("X",344,-1,25,25)
;GUICtrlSetFont($Btn, 10, 400)
GUICtrlSetColor($Btn, 0xffffff)
GUICtrlSetBkColor($Btn, 0xdd0000)
GUISetState()
while 1
 if GUIGetMsg() = $Btn then Exit
WEnd

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
ngskicker

Thanks, but that's create a weird GUI not the one that I want

7oxIDlS.png

Share this post


Link to post
Share on other sites
TheSaint

Can't you just create a popup window with no buttons or caption bar, then add your own button and maybe a label for title.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
UEZ

What about this here?

AutoIt version 3.3.9.x is needed:

#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

#NoTrayIcon

$hGUI = GUICreate("Form 1", 300, 200, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_DLGMODALFRAME)
$hIcon = _WinAPI_GetClassLongEx($hGUI, $GCL_HICON)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_SetClassLongEx($hGUI, $GCL_HICON, 0)
_WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, 0)

GUISetState()


Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Br,

UEZ

Edited by UEZ
  • Like 1

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Mat

Here's a little trick to remove the entry from the taskbar without getting it to flash.

#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

#NoTrayIcon

$hGUI = GUICreate("Form 1", 300, 200, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_DLGMODALFRAME, WinGetHandle(AutoItWinGetTitle()))
$hIcon = _WinAPI_GetClassLongEx($hGUI, $GCL_HICON)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_SetClassLongEx($hGUI, $GCL_HICON, 0)
_WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, 0)


GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites
UEZ

Indeed, I forgot to hide the taskbar :whistle: . Can also be done with $WS_EX_TOOLWINDOW style.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Wombat

You could always draw you're own exit button and title by hand (manually) with labels, or use GUICtrlCreatePic to import custom graphics and set the window to either borderless or just a small frame.

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Share this post


Link to post
Share on other sites
Valuater

I was trying to do something like this a while back and ended up designing this

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
ngskicker

Everyone thanks, too bad we have to wait for the beta in order to do this, one question that may not be related, whether autoit beta has been running well?

Share this post


Link to post
Share on other sites
FireFox

The beta is needed for the _WinAPI functions and/or the constants.

Nothing related to the internal stuff.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
PhoenixXL

To expand upon what Wombat and TheSaint said

Example

#include-once
#include <WinAPI.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#NoTrayIcon

Local $hGUI = GUICreate("", -1, -1, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW)
Local $iClose = CreateNCRegion($hGUI, "M y  W i n d o w")

GUISetState()

Local $nMsg
Do
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $iClose
            Exit
    EndSwitch

Until $nMsg = $GUI_EVENT_CLOSE











Func CreateNCRegion($hWnd, $s_Title)

    Local Const $aPos = WinGetPos($hWnd)
    Local Const $iHeight = _WinAPI_GetSystemMetrics($SM_CYSIZE)
    Local Const $iWidth = _WinAPI_GetSystemMetrics($SM_CXFRAME)
    Local Const $iHeight_H = _WinAPI_GetSystemMetrics($SM_CYFRAME)

    ;the title
    GUICtrlCreateLabel($s_Title, 0, 0, $aPos[2], $iHeight, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetBkColor(-1, 0x63B4FB)
    GUICtrlSetFont(-1, 10, 550, 0, "Tahoma")
    _GuiHole(GUICtrlGetHandle(-1),  $aPos[2] - $iWidth - 15, 2, 15, $iHeight - 4, $aPos[2], $aPos[3])

    ;left/right frame
    GUICtrlCreateLabel("", 0, $iHeight, $iWidth, $aPos[3] - $iHeight)
    GUICtrlSetBkColor(-1, 0x63B4FB)
    GUICtrlCreateLabel("", $aPos[2] - $iWidth, $iHeight, $iWidth, $aPos[3] - $iHeight)
    GUICtrlSetBkColor(-1, 0x63B4FB)
    GUICtrlCreateLabel("", $iWidth, $aPos[3] - $iHeight_H, $aPos[2] - $iHeight_H - $iHeight_H, $iHeight_H)
    GUICtrlSetBkColor(-1, 0x63B4FB)

    ;Close button
    Local Const $iCloseBtn = GUICtrlCreateLabel("X", $aPos[2] - $iWidth - 15, 2, 15, $iHeight - 4, $SS_CENTER)
;~  GUICtrlSetState(-1, $GUI_ONTOP)  <<<<< Don't know why this doesn't work.. therefore I had to add _GuiHole
    GUICtrlSetBkColor(-1, 0xC75050)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 10, 550, 0, "Tahoma")

    Return $iCloseBtn
EndFunc   ;==>CreateNCRegion

; make inner transparent area
Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh, $width, $height)
    Local $outer_rgn, $inner_rgn, $combined_rgn

    $outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height)
    $inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh)
    $combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    _WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($outer_rgn)
    _WinAPI_DeleteObject($inner_rgn)
    _WinAPI_SetWindowRgn($h_win, $combined_rgn)
EndFunc   ;==>_GuiHole 

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
kylomas

 how to create a gui that has only close button and does not have taskbar entry

 

Could be this simple...

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

local $button_size = 30
local $offset = 5

local $gui010   =   guicreate('',-1,-1,-1,-1,$ws_popup)
local $aSize    =   wingetclientsize($gui010)
local $button   =   guictrlcreatebutton('X',$aSize[0]-$button_size-$offset,$offset,$button_size,$button_size)
                    guictrlsetfont(-1,$button_size*.6,800)
                    guisetstate()

while 1
    switch guigetmsg()
        Case $gui_event_close
            Exit
    EndSwitch
wend

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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  

×