delphi - Detect help button click in MessageBox? -


in delphi xe7, need use button in messagebox. msdn states:

mb_help 0x00004000l adds button message box. when user clicks button or presses f1, system sends wm_help message owner.

however, when click button in messagebox, no wm_help message seems sent application:

procedure tform1.applicationevents1message(var msg: tagmsg; var handled: boolean); begin   if msg.message = wm_help     codesite.send('applicationevents1message wm_help'); end;  procedure tform1.btnshowmessageboxclick(sender: tobject); begin   messagebox(self.handle, 'let''s test button.', 'test', mb_iconinformation or mb_ok or mb_help); end; 

so how can messagebox button click , how can detect messagebox did come from?

the documentation says, emphasis:

the system sends wm_help message owner.

that msdn code fact message delivered synchronously directly window procedure. in other words, has been sent using sendmessage, or equivalent api.

you've attempted handle in tapplicationevents.onmessage used intercept asynchronous messages. messages placed on message queue. these messages (typically) placed on queue postmessage.

so reason never seeing message in tapplicationevents.onmessage message never placed in queue. instead need handle message in owner window's window procedure. in delphi simplest way follows:

type   tform1 = class(tform)   ....   protected     procedure wmhelp(var message: twmhelp); message wm_help;   end; .... procedure tform1.wmhelp(var message: twmhelp); begin   // code goes here end; 

as how detect message box responsible message being sent, there's no simple way when using messagebox. perhaps best switch messageboxindirect. allows specify id in dwcontexthelpid field of msgboxparams. id passed recipient of wm_help message, described in documentation.

if going display topic file, in response user pressing button, might consider vcl function messagedlg. allows pass context id, , framework show application file, passing on context id.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -