Jump to content

Recommended Posts

Posted

Is it possible to embed a graphic control in a status bar? The help document says we can embed ANY control in status bar,so what about graphic control?

#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>

Local $hGUI, $hStatus, $Graphic, $hGraphic
Local $aParts[4] = [80, 160, 300, -1]

$hGUI = GUICreate("StatusBar Embed Control", 400, 300)
$hStatus = _GUICtrlStatusBar_Create ($hGUI)
_GUICtrlStatusBar_SetMinHeight ($hStatus, 20)
;~ $Graphic = GUICtrlCreateGraphic(300, 270, 100, 20, -1)     ; I can't cover the StatusBar Control
;~ GUICtrlSetBkColor(-1, 0xa0ffa0)
;~ GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
;~ For $i = 0 To 4
;~  GUICtrlSetGraphic(-1, $GUI_GR_RECT, 10+$i*20, 5, 10, 10)
;~ Next
GUISetState()
_GUICtrlStatusBar_SetParts ($hStatus, $aParts)
_GUICtrlStatusBar_SetText ($hStatus, "Part 1")
_GUICtrlStatusBar_SetText ($hStatus, "Part 2", 1)

$Graphic = GUICtrlCreateGraphic(0, 0, -1, -1, -1)            ; Embed Graphic??
GUICtrlSetBkColor(-1, 0xa0ffa0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
For $i = 0 To 4
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 10+$i*20, 5, 10, 10)
Next
$hGraphic = GUICtrlGetHandle($Graphic)
_GUICtrlStatusBar_EmbedControl ($hStatus, 3, $hGraphic, 3)
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
Posted

A graphic control is associated with a window, and it is not a separate component like a button is for example. So if you want the graphic control in the status bar you have to first associate it with another window and then insert that window in the status bar. Since you don't want all the non-client bits of the window you need to make a window with the style WS_POPUP.

#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <winapi.au3>
#include <windowsconstants.au3>

Local $hGUI, $hStatus, $Graphic, $hGraphic
Local $aParts[4] = [80, 160, 300, -1]

$hGUI = GUICreate("StatusBar Embed Control", 400, 300)
$hStatus = _GUICtrlStatusBar_Create($hGUI)
_GUICtrlStatusBar_SetMinHeight($hStatus, 20)

GUISetState()

_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "Part 1")
_GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

;create a new window
$hg = GUICreate("Graphic holder", 90, 20, 0, 0, $WS_POPUP)
$Graphic = GUICtrlCreateGraphic(0, 0, -1, -1, -1) ; Embed Graphic
GUICtrlSetBkColor(-1, 0xa0ffa0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
For $i = 0 To 4
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 10 + $i * 20, 5, 10, 10)
Next
GUISetState()

;add the graphic holder window to the status bar
_GUICtrlStatusBar_EmbedControl($hStatus, 3, $hg, 3)

GUISwitch($hGUI)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
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.
Posted (edited)

A graphic control is associated with a window, and it is not a separate component like a button is for example. So if you want the graphic control in the status bar you have to first associate it with another window and then insert that window in the status bar. Since you don't want all the non-client bits of the window you need to make a window with the style WS_POPUP.

#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <winapi.au3>
#include <windowsconstants.au3>

Local $hGUI, $hStatus, $Graphic, $hGraphic
Local $aParts[4] = [80, 160, 300, -1]


$hGUI = GUICreate("StatusBar Embed Control", 400, 300)
$hStatus = _GUICtrlStatusBar_Create($hGUI)
_GUICtrlStatusBar_SetMinHeight($hStatus, 20)

GUISetState()

_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "Part 1")
_GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

;create a new window
$hg = GUICreate("Graphic holder", 90, 20, 0, 0, $WS_POPUP)
$Graphic = GUICtrlCreateGraphic(0, 0, -1, -1, -1) ; Embed Graphic
GUICtrlSetBkColor(-1, 0xa0ffa0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
For $i = 0 To 4
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 10 + $i * 20, 5, 10, 10)
Next
GUISetState()

;add the graphic holder window to the status bar
_GUICtrlStatusBar_EmbedControl($hStatus, 3, $hg, 3)

GUISwitch($hGUI)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

THANK YOU! martin. I have figured out the 'EMBED' is though '_WinAPI_MoveWindow' Function. And the graphic control can't be moved. THANKS again. Edited by flashlab

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
  • Recently Browsing   0 members

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