Board index » cppbuilder » Display a special Help file when F1 is pressed

Display a special Help file when F1 is pressed


2005-05-01 10:45:46 PM
cppbuilder6
Hi,
I need to display a special help file (Help.mht) when the user
presses on the F1 button.
I tried the following using KeyPress, FormHelp, etc. events without success
what am I missing?
thanks
Rob
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
if(Key ==VK_F1)
{
ShellExecute(NULL, "open", "Help.mht", 0, 0, SW_SHOWNORMAL);
}
}
 
 

Re:Display a special Help file when F1 is pressed

Quote
I tried the following using KeyPress, FormHelp, etc.
events without success. What am I missing?
1) Make sure that you have set Form1::KeyPreview property
to true.
2) Make a full path of your file to show:
AnsiString Help = ExtractFilePath( ParamStr(0) ) + "\\" + "Help.mht";
and then:
ShellExecute( Application->Handle, "open", Help.c_str(), 0, 0,
SW_SHOWNORMAL );
Note that I have used: Application->Handle instead of NULL.
3) firther, you can check the return result:
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
if ( Key == VK_F1 )
{
AnsiString Help = ExtractFilePath( ParamStr(0) ) + "\\" + "Help.mht";
int rc = (int) ShellExecute( Application->Handle, "open",
Help.c_str(), NULL, NULL, SW_SHOWDEFAULT ) ;
if ( rc <= 32 )
{
if ( rc == SE_ERR_NOASSOC )
{
// Program not associated to the file type?
}
else
{
// File missing?
}
}
}
}
--
Best regards,
Vladimir Stefanovic
"rob kemp" < XXXX@XXXXX.COM >wrote in message
Quote

Hi,

I need to display a special help file (Help.mht) when the user
presses on the F1 button.

I tried the following using KeyPress, FormHelp, etc. events without
success

what am I missing?

thanks
Rob

void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{

if(Key ==VK_F1)
{
ShellExecute(NULL, "open", "Help.mht", 0, 0, SW_SHOWNORMAL);
}

}