Hello,
Trying to get a "?" question mark to appear in a form's caption bar. Checked the option in ExStyles but I may have the wrong type of dialog frame selected as no "?" appears.
Also, the "?" will be used for context sensitive help in (the form of) a .chm file but I'm struggling with the API that (I think) is what I need to get the chm file open. (In VB I used App.HelpFile = App.Path & "\myhelpfile.chm"...)
Any help/ideas would be appreciated.
Thanks
Clive
https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx
The title bar of the window includes a question mark. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.
WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.
Context sensitive help... here is what I use for WinFBE:
at start of program, load the library
' Global handle to hhctrl.ocx for context sensitive help
Dim Shared As Any Ptr gpHelpLib
' Load the HTML help library for displaying FreeBASIC help *.chm file
gpHelpLib = DyLibLoad( "hhctrl.ocx" )
' Before program ends, unload the library
' Free the HTML help library
Dylibfree(gpHelpLib)
' WinFBE - Programmer's Code Editor for the FreeBASIC Compiler
' Copyright (C) 2016 Paul Squires, PlanetSquires Software
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT any WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
' Size = 32 bytes
TYPE HH_AKLINK
cbStruct AS LONG ' int cbStruct; // sizeof this structure
fReserved AS BOOLEAN ' BOOL fReserved; // must be FALSE (really!)
pszKeywords AS WSTRING PTR ' LPCTSTR pszKeywords; // semi-colon separated keywords
pszUrl AS WSTRING PTR ' LPCTSTR pszUrl; // URL to jump to if no keywords found (may be NULL)
pszMsgText AS WSTRING PTR ' LPCTSTR pszMsgText; // Message text to display in MessageBox if pszUrl is NULL and no keyword match
pszMsgTitle AS WSTRING PTR ' LPCTSTR pszMsgTitle; // Message text to display in MessageBox if pszUrl is NULL and no keyword match
pszWindow AS WSTRING PTR ' LPCTSTR pszWindow; // Window to display URL in
fIndexOnFail AS BOOLEAN ' BOOL fIndexOnFail; // Displays index if keyword lookup fails.
END TYPE
#Define HH_DISPLAY_TOPIC 0000
#Define HH_DISPLAY_TOC 0001
#Define HH_KEYWORD_LOOKUP 0013
#Define HH_HELP_CONTEXT 0015
' ========================================================================================
' Show context help or general contents if word does not exist
' ========================================================================================
Function ShowContextHelp() As Long
Dim HtmlHelpW As Function ( BYVAL hwndCaller AS HWnd, _
BYVAL pswzFile AS WSTRING Ptr, _
BYVAL uCommand AS UNIT, _
BYVAL dwData AS DWORD_PTR _
) AS HWND
' Ensure that the CurDrive parameter is converted if applicable
gConfig.CompilerHelpFile = ProcessFromCurdrive( gConfig.CompilerHelpFile )
If AfxFileExists(gConfig.CompilerHelpFile) = 0 Then
MessageBoxW( HWND_FRMMAIN, L(244,"FreeBASIC Help file not found."), L(201,"Error"), _
MB_OK Or MB_ICONWARNING Or MB_DEFBUTTON1 Or MB_APPLMODAL )
Exit Function
End If
HtmlHelpW = DyLibSymbol( gpHelpLib, "HtmlHelpW" )
If (gpHelpLib = 0) OrElse (HtmlHelpW = 0) Then
MessageBoxW( HWND_FRMMAIN, L(243,"Error loading HtmlHelp."), L(201,"Error"), _
MB_OK Or MB_ICONWARNING Or MB_DEFBUTTON1 Or MB_APPLMODAL )
Exit Function
End If
' If we are currently in an active document then attempt to lookup the
' word immediately under the caret.
Dim pDoc as clsDocument Ptr = gTTabCtl.GetActiveDocumentPtr()
If pDoc = 0 Then
HtmlHelpW( 0, gConfig.CompilerHelpFile, HH_DISPLAY_TOC, NULL )
Exit Function
ENd If
Dim wszKeyword as WString * MAX_PATH
wszKeyword = WStr( pDoc->GetWord )
Dim li As HH_AKLINK
With li
.cbStruct = SizeOf(HH_AKLINK)
.fReserved = FALSE
.pszKeywords = @wszKeyword
.pszUrl = Null
.pszMsgText = Null
.pszMsgTitle = Null
.pszWindow = Null
.fIndexOnFail = FALSE
End With
' Open the help and show the topic
HtmlHelpW( 0, gConfig.CompilerHelpFile, HH_DISPLAY_TOC, Null ) '<-- needed?
If HtmlHelpW( 0, gConfig.CompilerHelpFile, HH_KEYWORD_LOOKUP, Cast(DWORD_PTR, @li) ) = 0 Then
' Normal case search failed, try a ucase search
wszKeyword = UCase(wszKeyword)
li.pszKeywords = @wszKeyword
HtmlHelpW( 0, gConfig.CompilerHelpFile, HH_KEYWORD_LOOKUP, Cast(DWORD_PTR, @li) )
End If
Function = 0
End Function
Thanks, Paul! I had WS_MINIMIZEBOX set.