Jump to content
Sign in to follow this  
incepator

Problem with - png image in ListViewItem

Recommended Posts

incepator

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

Global $Bin = InetRead ("http://www.find-ip-address.org/ip-location-lookup-module.php")
Global $Page = BinaryToString ($Bin)

$YourIP = Grep($Page, "Your IP Number")
$YourCountry = Grep($Page, "Your Country Name")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 334, 153, 431, 304)
$ListView1 = GUICtrlCreateListView("my ip|my contry|flag state", 0, 0, 330, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
$ListView1_0 = GUICtrlCreateListViewItem($YourIP&"|"&$YourCountry&"|"&"-", $ListView1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Func Grep($sString, $sSearch)
Local $aGrep = StringRegExp($Page, "(?i)(?U)" & $sSearch & ": <b>(.*)</b>", 3)
If @error Then Return SetError(@error, 0, 0)
Return $aGrep[0]
EndFunc

hello!

can someone help me with this ...

I made this script, but the problem is that they fail in any way to set a small size picture inside the list.

Thank you!

post-75717-0-29548800-1364457212_thumb.p

post-75717-0-59500100-1364457269_thumb.p

Edited by incepator

Share this post


Link to post
Share on other sites
careca

I've been playing around with that, (i mean it has been playing around with me)

and couldn't find a way to do it, in here, no image appears anywhere in the listview.

I managed to place a colored image in some places of the listview, but no external png or other,

just plain image with a color code in hex defined by me.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
water

Please have a look at the GUIListView UDF (comes with AutoIt). Check function _GUICtrlListView_AddItem and the example script in the help file.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
UEZ

Try this:

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

_GDIPlus_Startup()
Global $Bin = InetRead("http://www.find-ip-address.org/ip-location-lookup-module.php")
Global $Page = BinaryToString($Bin)

$YourIP = Grep($Page, "Your IP Number")
$YourCountry = Grep($Page, "Your Country Name")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 334, 153, 431, 304)
$ListView1 = GUICtrlCreateListView("my ip|my contry|flag state", 0, 0, 330, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))
$hListView = GUICtrlGetHandle($ListView1)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
;~ $ListView1_0 = GUICtrlCreateListViewItem($YourIP&"|"&$YourCountry&"|", $ListView1)
$hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Flag_ROM.png")
$hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
$hFlags = _GUIImageList_Create(16, 16, 5, 0)
_GUIImageList_Add($hFlags, $hHBitmap)
_GUICtrlListView_SetImageList($hListView, $hFlags, 1)
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject($hHBitmap)
_GUICtrlListView_AddItem($hListView, $YourIP, 1000)
_GUICtrlListView_AddSubItem($hListView, 0, $YourCountry, 1, 1000)
_GUICtrlListView_AddSubItem($hListView, 0, "", 2, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func Grep($sString, $sSearch)
    Local $aGrep = StringRegExp($Page, "(?i)(?U)" & $sSearch & ": <b>(.*)</b>", 3)
    If @error Then Return SetError(@error, 0, 0)
    Return $aGrep[0]
EndFunc   ;==>Grep

Br,

UEZ

Edited by 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
water

@UEZ,

brilliant!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Clark

Very cool UEZ,

I am not understanding why the number 1000 in the following line though:

_GUICtrlListView_AddSubItem($hListView, 0, $YourCountry, 1, 1000)

Can you enlighten me please?

Share this post


Link to post
Share on other sites
UEZ

Very cool UEZ,

I am not understanding why the number 1000 in the following line though:

_GUICtrlListView_AddSubItem($hListView, 0, $YourCountry, 1, 1000)

Can you enlighten me please?

This selects the 1001st icon to display it, a dummy one.

E.g. if you use these lines

_GUICtrlListView_AddItem($hListView, $YourIP, 0)
_GUICtrlListView_AddSubItem($hListView, 0, $YourCountry, 1, 0)

you will see that the 1st and 2nd colums have the 1st icon, too. 1000 means simply select the 1001st icon (zero based) and display it. If there is no icon on that index display nothing.

I hope it's clear now.

Br,

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
Clark

Yes, I understand now. I knew it was the reference to the icon but I couldn't figure out why the number 10,000

One further question about your script. I noticed that if I put some error checking around this line:

_GUICtrlListView_SetImageList($hListView, $hFlags, 1)

...it is returning a zero, which according to the help file indicates a failure. Is this important? (I guess not seeing as your programme works, but if it returning an error does the line of code need to be there at all?) [edit: Well, removing the line means the icon doesn't get displayed, so not sure what the return value of zero is all about.]

Now, I know this is asking a lot, but if I wanted to be able to click on the displayed icon, and change it to another icon, is that possible do you think? (This is a real world application I am writing, not an intellectual exercise.)

I am already using the udf that allows listboxview items to be editable and sortable, if that helps.

(I feel that it could and should be possible, as the second image can be the next image in the list, and the listviewitem is editable, but not sure how to go about making the program realise the user has clicked on the icon and then display the second icon.)

Edited by Clark

Share this post


Link to post
Share on other sites
Clark

Further to this, there is some funny stuff going on with listviewboxes. :)

For example, using your program above, if I add the following line:

_GUICtrlListView_SetExtendedListViewStyle($ListView1, $LVS_EX_FULLROWSELECT)

...the icon will not display.

However, if I include $LVS_EX_FULLROWSELECT as part of the initial creation of the listboxview, the icon will display. i.e.

$ListView1 = GUICtrlCreateListView("my ip|my contry|flag state", 0, 0, 330, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES,$LVS_EX_FULLROWSELECT))

Very strange...

Share this post


Link to post
Share on other sites
UEZ

Further to this, there is some funny stuff going on with listviewboxes. :)

For example, using your program above, if I add the following line:

_GUICtrlListView_SetExtendedListViewStyle($ListView1, $LVS_EX_FULLROWSELECT)

...the icon will not display.

However, if I include $LVS_EX_FULLROWSELECT as part of the initial creation of the listboxview, the icon will display. i.e.

$ListView1 = GUICtrlCreateListView("my ip|my contry|flag state", 0, 0, 330, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES,$LVS_EX_FULLROWSELECT))

Very strange...

With _GUICtrlListView_SetExtendedListViewStyle() you are overwritting the ext. styles. You have to use this instead:

_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES, $LVS_EX_FULLROWSELECT))

Regarding the return value of _GUICtrlListView_SetImageList(). The reason for being 0 is that there is no previous image list. The error code is also 0 which means no error has occured.

To change the icon when clicking on it you have to extend the image list at least by one image. Afterwards you have to use notify windows message to check which column / row was clicked to change the icon.

Br,

UEZ

Edited by 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
Clark

Got it!

Thanks for the explanations UEZ :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.