Jump to content

GUICtrlCreateListViewItem......stopped working......


hogfan
 Share

Recommended Posts

Well sort of. :)  I hoping there is an easy fix on this one.  I have been using the following line of code in my application for over a year without issue.  Recently my company upgraded user workstations from Windows XP to Windows 7, and a strange issue started happening in  my application.

$callEntry = GUICtrlCreateListViewItem($myCallerName & "|" & $myCallerTN & "|" & $myCBRTN & "|" & $myCallType , $lstvwLOGGEDCALLS)

 

As you can see I am loading several variables to a Listview control named $lstvwLOGGEDCALLS.  

This has worked fine in the application on Windows XP, but now in Windows 7, it is creating the listviewitem entry and populating every item except the first one.

the variable in $myCallerName is not added to the first column of the listview, but all other variables are.  I am hoping there is just something wrong with my syntax.  

I have no idea why this would work fine on Windows XP and not Windows 7.  It's very strange.  Any input appreciated.

-hogfan

Link to comment
Share on other sites

Does $myCallerName hold any value prior to you trying to use it? If the column is empty, but the rest of the subitems are in the correct columns, then it would point to that.

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

  • Moderators

This is working for me on WIN7, but as BrewManNH is trying to point out, it is just a bit difficult to help you troubleshoot when you provide only one line of code.

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


Local $msg, $myCallerName = "Mine", $myCallerTN = "2", $myCBRTN = "CBRTN", $myCallType = "Incident"

GUICreate("Test", 300, 300)
$lstvwLOGGEDCALLS = GUICtrlCreateListView("col1|col2|col3|col4", 10, 10, 280, 100)
$callEntry = GUICtrlCreateListViewItem($myCallerName & "|" & $myCallerTN & "|" & $myCBRTN & "|" & $myCallType, $lstvwLOGGEDCALLS)

GUISetState(@SW_SHOW)


    While 1
        $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
            EndSelect
    WEnd

GUIDelete()
Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

When the Log function I have created is executed, the first thing I do is read the contents of the inputboxes on my form to these variables.  Here is a basic version of what my function is doing.

Func _LogCall()
 
;Read the Callers name, TN, & CBR from the input boxes
$myCallerName = GUICtrlRead($inptDSLCALLER)
$myCallerTN = GUICtrlRead($inptTSDSLTN)
$myCBRTN = GUICtrlRead($inptCALLBACKTN)
 
;add info the listview
$callEntry = GUICtrlCreateListViewItem($myCallerName & "|" & $myCallerTN & "|" & $myCBRTN & "|" & $myCallType , $lstvwLOGGEDCALLS)
 
EndFunc
Link to comment
Share on other sites

Doesn't really answer the question. Did you try checking the contents of the variable $myCallerName prior to using it in the LVItem creation? A simple consolewrite will tell you if there's 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

Are those inputs added by a user, or populated programatically (specifically $inptDSLCALLER).  Maybe you want to do a check that they are populated prior to creating the item?

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I am unable to test on Windows 7  as my machine has not been upgraded yet.  However, the user enters data into those inputboxes and then clicks a Log Call button which calls that function.  I guess my question would be:

Why would the $myCallerName variable possibly be empty before being used to add to the listview on Windows 7, but not on XP?   

I can verify that the variable is not empty though because I am also using the variables to write to .log file, and the variable contents of $myCallerName is logged there.

So the issue appears to be specific to the GUICtrlCreateListViewItem function.  

-hogfan

Link to comment
Share on other sites

That variable is being used in a function, is $myCallerName a global variable or a local in what ever is calling that function?

VERY hard to troubleshoot a problem when all we get is a peek through the keyhole.

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

sample of data checking...or you can create a lable with red text (more a system standard)...I'd have to assume there is no data in the input, given the info provided...

Func _LogCall()
 
    ;Read the Callers name, TN, & CBR from the input boxes
    $myCallerName = GUICtrlRead($inptDSLCALLER)
    $myCallerTN = GUICtrlRead($inptTSDSLTN)
    $myCBRTN = GUICtrlRead($inptCALLBACKTN)

    If StringLen($myCallerName) = 0 Then
        MsgBox(1,1,"Required data not present for $inptDSLCALLER")
        Return False
    EndIf

    ;add info the listview
    $callEntry = GUICtrlCreateListViewItem($myCallerName & "|" & $myCallerTN & "|" & $myCBRTN & "|" & $myCallType , $lstvwLOGGEDCALLS)

EndFunc
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

 $myCallerName  is a Global variable.  

@jdelaney

I will add in a messagebox to display the the contents of the variable before it is used in GUICtrlCreateListViewItem function and compile the application and have a user that has been upgraded to Windows 7 test it.  It will probably first thing in the AM before I will have those results.  I will post back to this thread with my findings.  Thanks.

-hogfan

Link to comment
Share on other sites

  • 3 months later...

Well, it's been a good while since I've been able to look at this issue, but I decided to revisit it today.  I compiled the app with a messagebox just before the GUICtrlCreateListViewItem  function to display the contents of the $myCallerName variable.   Then I had a user on Windows 7 test it.  On the Windows 7 machine, the users input was successfully displayed in the messagebox, so that confirms that the $myCallerName variable is getting populated.  However, it does not show up in the listview still when it is added via the GUICtrlCreateListViewItem  function.

In additon, my application is compiled for 32-bit.  The only other variable is that the Windows 7 machines are running a 64-bit version of Windows 7.  

So to recap:

Same 32-bit compiled .exe

When it's run on Windows XP x86, it works as expected, $myCallerName variable is populated and the entry shows up in the listview control.

When it's run on Windows 7 x64 , the $myCallerName variable is populated, but the listview item does not show up in the listview control.  However, all subitems are populated for the listview item.

 

I also tried compiling my application as x64 and had a Windows 7 x64 user test this build.  However, the x64 build of my application behaves the same as the 32-bit version on Windows 7 x64.

This issue has me totally baffled.  I believe at this point I have narrowed the issue down to the way the GUICtrlCreateListViewItem () function is behaving on Windows 7 x64 vs Windows XP x86, since I have been able to confirm that the $myCallerName variable is successfully populated on both OS version prior to the GUICtrlCreateListViewItem () function getting executed.

Any other thoughts are suggestions are appreciated.

-hogfan

Link to comment
Share on other sites

Post your script, or at least a runnable one that demonstrates your problem. Without knowing what you're doing we can't troubleshoot it for you. We asked you this before, and you're still not giving enough information.

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

  • Moderators

@OP it has now been 4 months of people asking you the same thing - post your script. How can you expect any help if you're going to keep up guessing at what you're trying to do?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Ok, I can't post my entire script here as it interfacing with some of my companies internal systems, etc.   This issue is just a small piece of the application.  I guess I will have to rebuild this portion of the application as separate script so I can post it to prove my findings.

FWIW, I did test this at home last night as well on a Windows 7 32-bit installation, and the behavior is  exactly the same as it is on Win 7 x64.  So the issue appears to be specific to Windows 7, regardless of architecture.  

-hogfan

Link to comment
Share on other sites

  • Moderators

If you cannot post the whole script, you need to at least create a small reproducer. Otherwise, you're asking us to first guess at what you're trying to accomplish, and then troubleshoot it for you ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Example is attached, but this example apparently DOES work on Windows 7.  So now I have no idea how to troubleshoot this.  In my main script,  I've done this same troubleshooting process as in this example with the messagebox to prove the $myCallerName variable is populated before this function is called:

;Create the Listview item entry
$callEntry = GUICtrlCreateListViewItem($myCallerName & "|" & $myCallerTN & "|" & $myCBRTN & "|" & $myCallType , $lstvwLOGGEDCALLS)

The only other difference I found was in the Includes section.  The new example I just built with Koda and attached has 

#include <ListViewConstants.au3>

My main script didn't.

I added that to the includes, re-compiled and had a Win 7 user test again.  Same issue, Listview item is still not populating.

Edit. and why does using

 

 tags manually always delete half of my post?

And I'm not seeing my attachment here, so apparently this site doesn't like Chrome Browser........here is the full example code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 2)



;####################################################################################

; KODA GUI
#Region ### START Koda GUI section ### Form=C:\TAC Magic\frmCallLogger.kxf
$frmCallLogger = GUICreate("Call Logger", 655, 385, 192, 114)
$inptDSLCaller = GUICtrlCreateInput("Bob", 16, 50, 113, 21)
$inptDSLTN = GUICtrlCreateInput("3235552369", 144, 50, 121, 21)
$inptCALLBACKTN = GUICtrlCreateInput("3236595869", 283, 50, 105, 21)
$inptCallType = GUICtrlCreateInput("New", 407, 50, 121, 21)
$cmdLogCall = GUICtrlCreateButton("LOG CALL", 16, 96, 145, 33)
GUICtrlSetBkColor(-1, 0x7DBA00)
$lstvwLOGGEDCALLS = GUICtrlCreateListView("Callers Name|Telephone #|Callback #|Call Type", 16, 152, 625, 217, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOSORTHEADER,$WS_VSCROLL), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150)
$Label1 = GUICtrlCreateLabel("Callers Name:", 16, 24, 115, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Telephone #:", 147, 21, 108, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Callback #:", 285, 22, 92, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Type:", 409, 22, 47, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


;Make Window X button call the Exit Function
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")


;set event action for the Log Call button
GUICtrlSetOnEvent($cmdLogCall, "_LogCall")


; show the form
GUISetState()


While 1
    Sleep(100)
WEnd


;declare the global variables
Global $myCallerName, $myCallerTN, $myCBRTN, $myCallType

;####################################################################################

;Functions


;Function for logging a call entry to the listview
Func _LogCall()

    ;Read the Callers name, TN, & CBR, & Call Type from the input boxes
    $myCallerName = GUICtrlRead($inptDSLCALLER)
    $myCallerTN = GUICtrlRead($inptDSLTN)
    $myCBRTN = GUICtrlRead($inptCALLBACKTN)
    $myCallType = GUICtrlRead($inptCALLType)

    ;check to make sure the user filled out the minimum required fields
    If $myCallerName = "" Or $myCallerTN = "" Then
        MsgBox(16, "No Values Entered!", "You must specify a minimum of the caller's name and the TN they are working on!")

    Else

        ;Display the $myCallerName variable in a messagebox to prove the variable is populated successfully
        MsgBox(32, "Contents of $myCallerName Variable:", $myCallerName)

        ;Create the Listview item entry
        $callEntry = GUICtrlCreateListViewItem($myCallerName & "|" & $myCallerTN & "|" & $myCBRTN & "|" & $myCallType , $lstvwLOGGEDCALLS)

    EndIf
EndFunc

Func _Quit ()
    Exit
EndFunc
Edited by hogfan
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...