Jump to content

Adding Information, Warning, and Error icons in text box


 Share

Recommended Posts

I'd like to emulate the log shown here in AutoIt:

Untitled.png

The Information, Warning, and Error icons are used in AutoIt, but I don't see anyway to create, say, and edit box and insert them next to the text output.

Gerard J. Pinzonegpinzone AT yahoo.com
Link to comment
Share on other sites

Thanks. I'm trying to get the column to autofit. (I'd also like it to autofit when the windows is resized.)

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI

    $hLog = GUICreate("Log", 800, 200, 200, 420, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
    $idListview = GUICtrlCreateListView("", 2, 2, 800, 200, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOCOLUMNHEADER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_SUBITEMIMAGES,$LVS_EX_FULLROWSELECT))

    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1")
    _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 ", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Gerard J. Pinzonegpinzone AT yahoo.com
Link to comment
Share on other sites

Autofit what when the window is resized?

; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1")

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 Row 3: Col 1 ", 2)
    _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

This will autosize the column width to the width of the data in the column, you had it autosizing before you put anything in it.

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

Link to comment
Share on other sites

I need help with one more thing. I found the way to add an icon instead of an image:

_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)

Where do I find the error, warning, and information icons? I think the warning one is in shell32. What about the rest?

EDIT: Also, how do I make the background transparent for the icons? They're showing up with a black background.

EDIT 2: Found the solution to the transparency issue: _GUIImageList_Create(16, 16, 5, 3)

EDIT 3: I discovered that setting the style to $LVS_LIST avoids all the resizing and autosizing issues since I don't really want or need columns.

EDIT 4: Scratch #3. $LVS_LIST is NOT what I need. Back to the default with hiding the column header and doing an autoresize after every entry added.

In case anyone else is interested, here's what I came up with:
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()

    Local $hImage, $idListview

    ; Create GUI.
    Local $hLog = GUICreate("Log", 800, 200, 200, 420, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
    Local $idListview = GUICtrlCreateListView("", 0, 0, 800, 180, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER))
    Local $hFile = GUICtrlCreateMenu("File")
    Local $hSaveAs = GUICtrlCreateMenuItem("Save As...", $hFile)

    ; Load images.
    Local $hImage = _GUIImageList_Create(16, 16, 5, 3)
    ; Error icon.
    _GUIImageList_AddIcon($hImage, @SystemDir & "\imageres.dll", 93)
    ; Warning icon.
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 77)
    ; Information icon.
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 277)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add column.
    _GUICtrlListView_InsertColumn($idListview, 0, "Log Output")

    GUISetState(@SW_SHOW)

    ; Add items.
    For $i = 0 To 20
        LogAddRow($idListview, "Row " & $i & ": Col 1", Mod($i, 3))
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

EndFunc   ;==>Example

Func LogAddRow($idListview, $sText, $nImage)

    _GUICtrlListView_AddItem($idListview, $sText, $nImage)
    _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE)
    _GUICtrlListView_Scroll($idListview, 0, (_GUICtrlListView_GetItemCount($idListview)))

EndFunc   ;==>LogAddRow

I found the error icon in imageres.dll. Hopefully that's the proper one to use.

Edited by GPinzone
Gerard J. Pinzonegpinzone AT yahoo.com
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...