I think you've hit on a problem that a lot of people run into, which runs right through a loophole in PB that lets you start editing a DataWindow without warning you to check it out. Unfortunately, to the best of my knowledge there is no way to hook into the context menu.
However, you can hook into toolbar items. If that was the way I wanted to go, and I had plenty of time to spare, I'd write an app that I would launch from the toolbar, and here's what it would do:
- Find the PowerBuilder window with APIs
- Find the current sheet in PB
- Get the object name out of the title
- Get the current application (registry or PB.INI, depending on the version of PB, and may involve getting the workspace first, then the current target)
- Get the library list (PB.INI or target file)
- Do a LibraryExport() on the object that's open
- Find all DataWindow controls (this may involve looking at ancestors to determine control types)
- Identify dataobjects for these controls (again, you may need to look at ancestors)
- Use LibraryDirectory() to get a list of all objects in all PBLs
- Find the dataobjects' PBLs
- Throw up a window listing the dataobjects and their PBLs
OTOH, if I had PBL Peeper (and, yes, this is biased advice), I'd
- Launch the "PBL Peeper (Browse current application)" icon on my desktop (OK, that's a lie; I'd already have PBL Peeper open and would just switch to the Browse page)
- Ctrl-Q (for QuickFind) and start typing the name of the object (if you pause, it will find a partial match on what you've typed)
- Hit [Enter] once to accept QuickFind's selection
- Hit [Enter] again to expand the object
- Find the DataWindow control in question and RMB on it
- Select "Go to Default DataWindow"
- If it doesn't show the library and name in the microhelp (it's been a long time since I've released a version, and I can't keep track of what's in the released version), find the Up toolbar item to go up to the PBL
I know this doesn't achieve a checkout, but it does "avoid having to hunt for the datawindow in several PBLs". And, you can probably achieve this faster than my first suggestion.
Good luck,
Terry