Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Highlighted
Absent Member.. vzamoraz Absent Member..
Absent Member..
130 views

QTP/UFT support tip: How to use windows messaging system to get the state of a winlistview item

There are syslistview32 controls that show checkboxes on each item. One easy sample to found is in the system configuration application.

       1.Click on "Start>Run"

       2.Type: msconfig

       3.Click Ok

       4.Select services tab   

       

 

    1. Declare the constants

    Const LVM_GETITEMSTATE = &H102C
    Const LVIS_STATEIMAGEMASK = &HF000

    This are constants used as parameters for the sendmessage function. For more information visit this site:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ff485961(v=vs.85).aspx

    2. Then declare the library which has the sendmessage function.

    Extern.Declare micLResult, "SendMessage", "User32.dll","SendMessage", micHwnd, micLong, micUInteger, micString

    Additional information can be found in this article: Document ID KM177243 - How to run a function from a DLL (QTP)

    3. Get the index of the item you want to check (in this sample using an input box).

    lvIndex = clng(inputbox("Index?", , 5))

    4. Obtain the handle of the SysListView32 control

    hwnd = clng(Dialog("System Configuration").WinListView("SysListView32").GetROProperty("hwnd"))

    5. Activate the main parent control of the application to ensure it will be on top and focused (in this sample the main parent is the Dialog control)

    Dialog("System Configuration").Activate

    6. Use the windows SendMessage command

    res = Extern.SendMessage(hwnd, LVM_GETITEMSTATE, lvIndex, LVIS_STATEIMAGEMASK)

    The parameters will return the item state, 8192 for checked or 4096 for uncheked
    For additional information visit this site: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx

     

    7. Validate the response and display the response

     

    If res = 4096 Then
    print "Row Is Unchecked"
    ElseIf res = 8192 Then
    print "Row Is Checked"
    End If

     

    Note: Remember that this is a sample for troublesooting purpose in order to check if the control respond, you need to type right handle the control and index of the item.

     

    The Opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.

Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.