efarayenkay Posted February 17, 2016 Share Posted February 17, 2016 Hi all I'm creating an offline dashboard for my company to bring in information from our process management system and I'd like to have the last column be a sort of progress bar showing how much of the job is complete. I've created 100 images for each percentage point of completion, now I just need to figure out how to put that image into the column I've tried searching but the only things I can find are how to give a column value an icon. Is what I want to do possible or am I simply chasing my tail? Thanks! Link to comment Share on other sites More sharing options...
InunoTaishou Posted February 17, 2016 Share Posted February 17, 2016 Something like this? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $hGUI = GUICreate("ListView example", 300, 250) Global $progress_width = 100 Global $progress_height = 20 Global $bitmap_path = @ScriptDir & "\Progress\" CreateGdipProgress() Global $hListView = _GUICtrlListView_Create($hGUI, "Progress|Task", 10, 10, 280, 230, $LVS_REPORT, $WS_EX_CLIENTEDGE) Global $ilImageList = _GUIImageList_Create($progress_width, $progress_height, 5, 3) Global $tps_reports[4] = ["TPS Reports", "TPS Reports Started", "TPS Reports Halfway!", "TPS Reports Almost!!!"] _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP)) _GUICtrlListView_SetColumnOrder($hListView, "1|0") _GUICtrlListView_SetColumn($hListView, 0, "Progress", 120) _GUICtrlListView_SetColumn($hListView, 1, "Task", 120) For $i = 0 to 100 _GUIImageList_AddBitmap($ilImageList, $bitmap_path & $i & ".bmp") Next _GUICtrlListView_SetImageList($hListView, $ilImageList, 1) _GUICtrlListView_AddItem($hListView, "", Random(0, 1, 1)) _GUICtrlListView_AddSubItem($hListView, 0, "TPS Reports", 1) _GUICtrlListView_AddItem($hListView, "", Random(0, 100, 1)) _GUICtrlListView_AddSubItem($hListView, 1, "Cat Photos", 1) _GUICtrlListView_AddItem($hListView, "", Random(0, 100, 1)) _GUICtrlListView_AddSubItem($hListView, 2, "Code", 1) GUISetState(@SW_SHOW, $hGUI) For $i = 1 to 3 Sleep(1200) _GUICtrlListView_SetItem($hListView, "", 0, 0, 25 * $i) _GUICtrlListView_SetItem($hListView, $tps_reports[$i], 0, 1) Next Sleep(1000) _GUICtrlListView_SetItem($hListView, "", 0, 0, 0) _GUICtrlListView_SetItem($hListView, "TPS Reports JK :)", 0, 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func CreateGdipProgress() _GDIplus_Startup() Local $hWnd_graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hWnd_bitmap = _GDIPlus_BitmapCreateFromGraphics($progress_width, $progress_height, $hWnd_graphic) Local $hWnd_gdi_buffer = _GDIPlus_ImageGetGraphicsContext($hWnd_bitmap) Local $hWnd_progress_brush = _GDIPlus_BrushCreateSolid(0xFFCACACA) Local $hWnd_font_family = _GDIPlus_FontFamilyCreate("Segoe UI") Local $hWnd_font = _GDIPlus_FontCreate($hWnd_font_family, 10) Local $hWnd_rect = _GDIPlus_RectFCreate(0, 0, $progress_width, $progress_height) Local $hWnd_string_format = _GDIPlus_StringFormatCreate() Local $hWnd_string_brush = _GDIPlus_BrushCreateSolid(0xFF000000) If (Not FileExists($bitmap_path)) Then DirCreate($bitmap_path) _GDIPlus_StringFormatSetAlign($hWnd_string_format, 1) _GDIPlus_StringFormatSetLineAlign($hWnd_string_format, 1) _GDIPlus_GraphicsSetSmoothingMode($hWnd_bitmap, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($hWnd_graphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) For $i = 0 to 100 If (FileExists($bitmap_path & $i & ".bmp")) Then ContinueLoop _GDIPlus_GraphicsClear($hWnd_gdi_buffer, 0xFFF0F0F0) _GDIPlus_GraphicsFillRect($hWnd_gdi_buffer, 1, 0, ($i / 100) * 98, $progress_height, $hWnd_progress_brush) _GDIPlus_GraphicsDrawRect($hWnd_gdi_buffer, 0, 0, $progress_width - 1, $progress_height - 1) _GDIplus_GraphicsDrawStringEx($hWnd_gdi_buffer, $i & "%", $hWnd_font, $hWnd_rect, $hWnd_string_format, $hWnd_string_brush) _GDIPlus_ImageSaveToFile($hWnd_bitmap, $bitmap_path & $i & ".bmp") Next _GDIPlus_GraphicsDispose($hWnd_graphic) _GDIPlus_BitmapDispose($hWnd_bitmap) _GDIPlus_BrushDispose($hWnd_progress_brush) _GDIPlus_FontFamilyDispose($hWnd_font_family) _GDIPlus_FontDispose($hWnd_Font) _GDIPlus_StringFormatDispose($hWnd_string_format) _GDIPlus_BrushDispose($hWnd_string_brush) _GDIPlus_Shutdown() EndFunc I used GDI+ to create some progress bars since we don't have your images. You could use what is created by the script using GDI+ or have your own images instead (just make sure they're .bmp files). Someone said that you can only have an image in the first column of a listview but _GUICtrlListView_SetColumnOrder will change the order. Technically the images are still in the first column (_GUICtrlListView_SetColumn($hListView, 0, "Progress", 120) changes column 0, but what's displayed in column 0 is the task) but it's just displayed opposite. efarayenkay and DinFuv 2 Link to comment Share on other sites More sharing options...
efarayenkay Posted February 17, 2016 Author Share Posted February 17, 2016 Exactly what I was looking for. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now