Jump to content

Popup window with Title like in Tooltip


AcidUser
 Share

Recommended Posts

Hello all!

I'm trying to imitate "Tooltip" window using GuiCreate function.

"Tooltip" has an option for title, but if I use "WS_CAPTION" for GuiCreate it automatically draws border around window. I want to make visible only title without any border.

Is there any way to implement title for GuiCreate to look like a Tooltip title ? Thank you in advance!

Here is the code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>
$WINDOW_TITLE = "Adobe Reader 10.1.1 installation:"
$Form1 = GUICreate($WINDOW_TITLE, @DesktopWidth/5, @DesktopHeight/8, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$size = WinGetClientSize($Form1)
;$Button1 = GUICtrlCreateButton("Cancel", ($size[0]/4), $size[1]-($size[1]/4), $size[0]/2, $size[1]/8,BitOR($BS_CENTER,$BS_FLAT))
$Button1 = GUICtrlCreateButton("Cancel", ($size[0]/4), $size[1]-($size[1]/4), $size[0]/2, -1,BitOR($BS_CENTER,$BS_FLAT))
GUICtrlSetState(-1,$GUI_NOFOCUS)
GUICtrlSetResizing($Button1,$GUI_DOCKALL)
$Button2 = GUICtrlCreateButton("1", 1, 1, 1, 1,BitOR($BS_CENTER,$BS_FLAT))
GUICtrlSetState($Button2,@SW_HIDE)
GUICtrlSetState($Button2,$GUI_FOCUS)
GUICtrlSetBkColor($Button1,0xFFEC8B)
GUICtrlSetStyle($Form1,$WS_EX_CLIENTEDGE)
GUISetBkColor(0xFFEC8B)
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   Exit
EndSwitch
WEnd
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

  • Moderators

AcidUser,

If you look at my Toast UDF (link in my sig) you will see that I create a label to act as the title bar within the Toast GUI which has the $WS_POPUPWINDOW and $WS_EX_TOOLWINDOW styles to get rid of the border. :D

Not quite what you wanted to know, but shows you are not alone in having problems in finding out how do it! :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi Melba! Thank you for the tip!

I added the following code snippet to my project:

$iTitle_Height = 20
Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
Global $iToast_Header_BkCol  = $aRet[0]
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
Global $iToast_Header_Col    = $aRet[0]

GUICtrlCreateLabel("blablabla", 20, 0, @DesktopWidth/5, $iTitle_Height, 0x0200) ; $SS_CENTERIMAGE
GUICtrlSetBkColor(-1,$iToast_Header_BkCol)
GUICtrlSetColor(-1, $iToast_Header_Col)

but the Title-bar is coloured black. I expected it will take default Title-bar setting (like default blue)

Am I doing something wrong?

Link to comment
Share on other sites

  • Moderators

AcidUser,

Those DLLCalls get the default colours for the text and background of a standard window. On my system that usually means 0x000000 (black) for the text and 0xFEFEFE (nearly white) for the background. I reversed these colours for the default "title" label to make it stand out, but there is no reason not to use other colours - as you can in the UDF bu using the _ExtMsgBoxSet function.

Just assign the colours you want to the $iToast_Header_BkCol and $iToast_Header_BkCol variables - then your "title" label will be in the colours you wish. :oops:

All clear? :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I wanted not to set colours that I like, but rather take default system colour for window's title.

I don't understand why these DLL calls return Black for Windows title and White for text:

Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", $COLOR_WINDOWTEXT) ; $COLOR_WINDOWTEXT = 8
Global $iToast_Header_BkCol  = $aRet[0]
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", $COLOR_WINDOW) ; $COLOR_WINDOW = 5
Global $iToast_Header_Col    = $aRet[0]

as I run on Windows 7 and Windows XP and on both machines the default colour is be "blue".

Would not it suppose to take a default colour?

... wait, I found that changing "$COLOR_WINDOWTEXT" to "$COLOR_ACTIVECAPTION" is almost what I wanted

Took from here: http://code.google.com/p/autoit-cn/source/browse/trunk/Include/WindowsConstants.au3?r=669

The problem is that it sets incorrect colour, instead of blue it sets dark red.

Maybe it's required to mess with colour schemes or something like this?

Link to comment
Share on other sites

  • Moderators

AcidUser,

The system colour constants are also found in the Help file for _WinAPI_GetSysColor. :oops:

Maybe it's required to mess with colour schemes or something like this?

No idea - you should get what the user has selected in the Windows appearance dialog. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You could run this script and you'll see that It does show incorrect colour, even that I specified "$COLOR_ACTIVECAPTION"

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>
#include <date.au3>

Opt("GUIOnEventMode", 1)$WINDOW_TITLE = "Adobe Reader 10.1.1 installation:"
Global $afksleep, $lasth, $lastm, $lasts
Global $begin = 1000 * 60 * 60 * 2 ; 2 Hours
$afksleep = $begin
Global $start = TimerInit()
$Form1 = GUICreate("", @DesktopWidth/5, @DesktopHeight/8, -1, -1, $WS_POPUP) ;, $WS_EX_CLIENTEDGE
$size = WinGetClientSize($Form1)$iTitle_Height = 20
Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", $COLOR_ACTIVECAPTION) ; $COLOR_WINDOWTEXT = 8
Global $iToast_Header_BkCol  = $aRet[0]
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", $COLOR_WINDOW) ; $COLOR_WINDOW = 5
Global $iToast_Header_Col   = $aRet[0]GUICtrlCreateLabel($WINDOW_TITLE, 0, 0, @DesktopWidth/5, $iTitle_Height, 0x0200) ; $SS_CENTERIMAGE
GUICtrlSetBkColor(-1,$iToast_Header_BkCol)
GUICtrlSetColor(-1, $iToast_Header_Col)

Global $CD_TIMER_LABLE = GUICtrlCreateLabel("", 0, 20, $size[0], -1, 0x0200) ; $SS_CENTERIMAGE
;GUICtrlSetBkColor($CD_TIMER_LABLE,0xCD3700)
$Button1 = GUICtrlCreateButton("Cancel", ($size[0]/4), $size[1]-($size[1]/4), $size[0]/2, -1,BitOR($BS_CENTER,$BS_FLAT,$GUI_ONTOP))
$Button2 = GUICtrlCreateButton("", 1, 1,1, 1,BitOR($BS_FLAT,$GUI_FOCUS))
GUICtrlSetState($Button1,$GUI_NOFOCUS)
GUICtrlSetState($Button2,$GUI_FOCUS)
GUICtrlSetState($Button2,@SW_HIDE)
GUICtrlSetBkColor($Button1,0xFFEC8B)
GUISetBkColor(0xFFEC8B)
GUICtrlSetResizing($Button1,$GUI_DOCKALL)
GUICtrlSetResizing($Button2,$GUI_DOCKALL)
GUICtrlSetResizing($CD_TIMER_LABLE,$GUI_DOCKALL)
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent($Button1, "F_Button1")

While ($afksleep > 0)
   $afksleep = $begin - TimerDiff($start)
   GoToBathroom()
   Sleep(1000)
  
WEnd;If Not (ProcessExists("iexplore.exe") OR ProcessExists("Firefox.exe")) Then
; Exit(0)
;Else
; Exit(1)
;EndIf
Func F_Button1()
Exit
EndFunc
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False Return $GUI_RUNDEFMSG
EndFunc
Func GoToBathroom()
    Local $iHours, $iMins, $iSecs, $CD_TIMER
    _TicksToTime($afksleep, $iHours, $iMins, $iSecs)
    If $lasth <> $iHours Or $lastm <> $iMins Or $lasts <> $iSecs Then

  $CD_TIMER = "Estimated wait time: " & $iHours & ":" & StringFormat("%02d",$iMins) & ":" & StringFormat("%02d",$iSecs)

  GUICtrlSetData($CD_TIMER_LABLE,$CD_TIMER)
        ;ToolTip("Please close all open Internet Browsers (IE, FireFox) and Adobe Reader" & @CR & "Estimated wait time: " & $iHours & ":" & StringFormat("%02d",$iMins) & ":" & StringFormat("%02d",$iSecs), @DesktopWidth/2, @DesktopHeight/2, "Adobe Reader X Installation:", 2, 6)

  $lasth = $iHours
        $lastm = $iMins
        $lasts = $iSecs
    EndIfEndFunc  ;==>GoToBathroom

Any ideas, why this might happen? :D

Edited by AcidUser
Link to comment
Share on other sites

  • Moderators

AcidUser,

Any ideas, why this might happen?

Yes. The DllCall returns the BGR value of the colour - we need to convert it to RGB like this:

Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", $COLOR_HIGHLIGHT)
$iColor = Hex($aRet[0], 6)
Global $iToast_Header_BkCol = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2)

And something similar for the other call. Now you will get the proper colour. :oops:

Thanks for pointing it out - I may have to amend the UDF now! :rip:

M23

Edit: The plot thickens - it seems the DLLCall should return the RGB colour. I will explore further tomorrow. :D

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...