IBM Support

FindWindow API function does not work if only the class name is passed as a parameter

Troubleshooting


Problem

This technote states the FindWindow API function in IBM® Rational® Robot does not work if only the class name is passed as a parameter.

Symptom

If you try to use the FindWindow API function, passing only the class name and an empty string for the caption, Robot is unable to detect the window. This can be reproduced by opening Notepad and trying to execute the line:


    ret = FindWindow("Notepad", "")

Cause

The problem is that SQABasic does not have an equivalent to VBNullString

Resolving The Problem

The workaround is to change the data type for the second parameter in the declaration of the FindWindow function from 'String' to 'Any', and then pass 0& as the second parameter when calling the function.

For example, the following code will return the handle of the first window found with the class name "Notepad":


Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Any) As Long

Sub Main
Dim ret As Long
ret = FindWindow("Notepad",0&)
MsgBox Str(ret)
End Sub


[{"Product":{"code":"SSSHDX","label":"Rational Robot"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Scripting","Platform":[{"code":"PF033","label":"Windows"}],"Version":"2003.06.00;2003.06.10;2003.06.12;2003.06.13;2003.06.14;2003.06.15;2003.06.16;7.0;7.0.0.1;7.0.0.2;7.0.0.3;7.0.1;7.0.1.1;7.0.1.2;7.0.0.4;7.0.1.3;7.0.2","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

8782

Document Information

More support for:
Rational Robot

Software version:
2003.06.00, 2003.06.10, 2003.06.12, 2003.06.13, 2003.06.14, 2003.06.15, 2003.06.16, 7.0, 7.0.0.1, 7.0.0.2, 7.0.0.3, 7.0.1, 7.0.1.1, 7.0.1.2, 7.0.0.4, 7.0.1.3, 7.0.2

Operating system(s):
Windows

Document number:
334189

Modified date:
16 June 2018

UID

swg21151084