Welcome to Foxite.COM Community Weblog Sign in | Join | Help

Providing pre-selection help from a messagebox

Since VFP3 I've wanted to be able to present end users - under specific circumstances - with a messagebox with a Help button. The user views the associated help file, and then makes their choice of the messagebox options. It hasn't been possible (using standard Windows Messagebox functions) until VFP9: VFP ignored the WM_HELP message that the API function MessageBox passed to it: binding to Windows Messages makes it possible, though.
#define WM_HELP 	0x0053
#define MB_HELP 		0x00004000
#define MB_OKCANCEL 0x00000001

* Bind Windows help message
oCatcher = createobject("helpcatcher")
=bindevent(_vfp.hwnd, WM_HELP, oCatcher, "CallHelp")

*#beautify keyword_nochange
* see http://support.microsoft.com/kb/894818/

declare integer MessageBox in user32 as Win32_MessageBox;
	integer hwnd,;
	string  lpText,;
	string  lpCaption,;
	integer wType
*#beautify

nChoice = Win32_MessageBox(_vfp.hwnd, ;
	"Users can make their choice after viewing the help file.", ;
	_vfp.caption, MB_HELP + MB_OKCANCEL)

* Unbind the message binding (it would be released 
* when the object goes out of scope anyway)
unbindevents(_vfp.hwnd , WM_HELP)

define class helpcatcher as relation

	procedure CallHelp(nHWND as number, nMessage as number, ;
			nParameters1 as number, nParameters2 as number) as integer
		* Start VFP help
		help
	endproc

enddefine

Published Thursday, May 05, 2005 8:48 AM by stuartd

Comments

Anonymous comments are disabled