- Olan Knight
- PowerBuilder
- Friday, 4 June 2021 02:33 PM UTC
Update: The issue was that the window title was too long AND had spaces in it.
Once I replaced the title with a simple, short string using no spaces it worked.
I replaced my search code with the more complete version presented by Chris!
--------------------------------------------------------------
PBv12.1, b7055
Q: What am I doing wrong?
App A renames its FRAME window to be unique; appending the session ID.
App A uses the RUN command to start app B.
App B uses FindWindowW() to get a handle to app A, but always fails.
App A Window title:
50001 - InterconnecT CABS - (026D - CSGI NTtest (026D-CO)) (Database: DEV12C) 21156
App B knows the title:
Here's the declaration:
// Returns a handle to the named application if it exists/is active
FUNCTION ulong FindWindowW (long classname, string windowname) LIBRARY "user32.dll"
// This is the messageBox shown above:
Messagebox ("W_Invoicing", "Open event - called from ~r~n~t " + gs_cabs_window_name)
Here's the code to find app A:
// Get a pointer to the calling application
ll_seconds = 0
DO
iui_cabs = FindWindowW (0, gs_cabs_window_name)
ll_seconds = ll_seconds + 1
Sleep (0.5)
LOOP UNTIL(iui_cabs > 0) OR (ABS (ll_seconds) > 10)
Messagebox ("W_Invoicing", "Open event - found the calling window: " + string (iui_cabs))
The value returned is always zero:
I've also tried using this:
FUNCTION ulong FindWindowW (ref string classname, string windowname) LIBRARY "user32.dll"
and
iui_cabs = FindWindowW ("w_cabs_frame", gs_cabs_window_name)
Thank You!
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.