Jump to content

[SOLVED] Toolbar icon quesion.


fett8802
 Share

Recommended Posts

Hello,

I'm creating a GUI interface to significantly ease the coding burden as an internal project for the company I work for. The program is fully functional as is, but the interface is rather bulky and ugly. Currently, I have buttons representing the normal word processor tasks, Bold, Italics, etc. I am able to create a toolbar and use the typical buttons (save, copy, etc). I have looked all over this forum and google to find the location of the extended toolbar icons in MS Word or a pack online I could use; I even tried using my own custom buttons (that looked terrible). So, I'm finally breaking down and asking:

Does anyone know the location of those icons in word? And if so, how to correctly load it into the toolbar image list? I tried loading the Shell32.dll in as a test, but could never get it to work. Thanks a lot!

-Kris

Edited by fett8802
[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]
Link to comment
Share on other sites

Hello there,

Here's a little snippet to show out Shell32.dll icons

;test icons
#include "winapi.au3"
Local $fIcons = "shell32.dll"

Local $hGui = GUICreate("",100,100,100,100)
GUISetState()
For $x = 1 To _WinAPI_ExtractIconEx($fIcons, -1, 0, 0, 0)
    GUICtrlCreateIcon($fIcons, $x,10,10)
    WinSetTitle($hGui, "", $x)
    Sleep(500)
Next

By the way, without the intention to hijack this thread but as a complimentary information, I'm curious to know if it's possible to extract and use BITMAP resources of a DLL or EXE on a gui button image.

Without extracting it with Resource Hacker ...

Well, hope this help !

hench

Link to comment
Share on other sites

Ok, I ended up going with some custom icons. The script I'm going to present is just the basic toolbar creation that I'll add into my main GUI later. The problem that I'm having is that one icon won't show up at all, and one shows up as a square. I'll include the script and a zip of the icon files. (25 files. 23x23 size) Give it a test and let me know if it happens to you:

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <ToolbarConstants.au3>

Global $Custom[26]
Global $Bitmap[26]

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 732, 447, 215, 129)
$MenuItem3 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenu("Options")
$MenuItem1 = GUICtrlCreateMenu("Help")
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$ToolBar1 = _GUICtrlToolbar_Create($Form1)

For $i = 1 to 25
    $Custom[$i] = @ScriptDir & "\Icons\" & $i & ".bmp"
    $Bitmap[$i] = _GUICtrlToolbar_LoadBitmap($Toolbar1, $Custom[$i])
    If $i = 5 or $i = 9 or $i = 15 or $i = 19 or $i = 21 Then
        _GUICtrlToolbar_AddButtonSep($Toolbar1)
    EndIf
    If $i = 10 Then
        _GUICtrlToolbar_AddButton($ToolBar1, 0, $Bitmap[$i], 99, "", $TBSTATE_WRAP)
    Else
        _GUICtrlToolbar_AddButton($ToolBar1, 0, $Bitmap[$i], 99)
    EndIf
Next

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Form1Close()
    Exit
EndFunc

Edit: I figured out why one icon wasn't showing up. I had saved it as a 256 color bitmap instead of a 24 bit bitmap. Not sure why that mattered, but apparently it did. So, the Undo button is good now. The Redo button still shows up as a square.

Icons.zip

Edited by fett8802
[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]
Link to comment
Share on other sites

Ok, I ended up going with some custom icons. The script I'm going to present is just the basic toolbar creation that I'll add into my main GUI later. The problem that I'm having is that one icon won't show up at all, and one shows up as a square. I'll include the script and a zip of the icon files. (25 files. 23x23 size) Give it a test and let me know if it happens to you:

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <ToolbarConstants.au3>

Global $Custom[26]
Global $Bitmap[26]

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 732, 447, 215, 129)
$MenuItem3 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenu("Options")
$MenuItem1 = GUICtrlCreateMenu("Help")
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$ToolBar1 = _GUICtrlToolbar_Create($Form1)

For $i = 1 to 25
    $Custom[$i] = @ScriptDir & "\Icons\" & $i & ".bmp"
    $Bitmap[$i] = _GUICtrlToolbar_LoadBitmap($Toolbar1, $Custom[$i])
    If $i = 5 or $i = 9 or $i = 15 or $i = 19 or $i = 21 Then
        _GUICtrlToolbar_AddButtonSep($Toolbar1)
    EndIf
    If $i = 10 Then
        _GUICtrlToolbar_AddButton($ToolBar1, 0, $Bitmap[$i], 99, "", $TBSTATE_WRAP)
    Else
        _GUICtrlToolbar_AddButton($ToolBar1, 0, $Bitmap[$i], 99)
    EndIf
Next

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Form1Close()
    Exit
EndFunc

Hi, good day!

-File 9.bmp seem broken

-And It looks like there's trouble using the $TBSTATE_WRAP, 10.bmp will show up just fine if added as a normal button. Maybe you'll want to add a "dummy" empty bmp before sending a line break with $TBSTATE_WRAP.

Good luck

hench

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