1. Dan Cooperstock
  2. PowerBuilder
  3. Monday, 24 July 2017

I'm using Roland Smith's wonderful free GetFileName tool (http://www.topwizprogramming.com/freecode_getfilename.html) to get a more modern version of GetFileOpenName and GetFileSaveName, including allowing those dialogs to have a Help button which goes to a topic in my program's Help file. (That last part is actually an improvement I drafted and worked on with him.)

You get that Help button by setting a flag in the OPENFILENAME structure used by the relevant Windows API function, and you have to catch clicks on that Help button by using RegisterWindowMessage("commdlg_help"), which returns a message number, and we then catch calls to that message in the calling window's Other event, and open the desired Help topic from there.

But I really don't like using the Other event, because it is triggered by so many Windows events. Obviously the code checks that it's the right message number, so it's not that it's causing bugs, but when I'm using the debugger in PB windows with code for this event, I often get caught in a loop of calls to that event, and if I do tracing (e.g. with /PBDEBUG) I get pages and pages of calls to it, that significantly inflate the size of the trace file.

Can anyone think of any other way to catch such messages without using the Other event? I've read all the Help I can find on declaring events and can't see any obvious other way to do this, but maybe someone else knows more about it.

Matthew Balent Accepted Answer Pending Moderation

I had a similar need to have code in the other event and this is what I came up with.

I created a new ancestor window and changed the inheritance for those windows I wanted the desired code.  It's not a perfect solution but it allowed for the new functionality to exist on a smaller set of windows without making the majority subject to the debugging hell you describe.

Thanks, Matt, but I never put that into an ancestor window at all, only the ones that specifically needed it. Of course your idea would be good for centralizing code, but it wouldn't cut down my current number of windows with Other events. I guess I wish there was a way to define an event, and then in code at runtime tell it which Windows message number it was to respond to.

  1. Dan Cooperstock
  2. Monday, 24 July 2017
There are no comments made yet.
  1. Monday, 24 July 2017
  2. PowerBuilder
  3. # 1
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.