It is currently Thu Jul 02, 2020 6:45 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: How to call a win32.chm file via F1 in the IDE?
PostPosted: Fri Apr 19, 2019 2:13 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
Hello everybody,
I have a question regarding the PureBasics F1 help function.

As described in the PureBasic help, one can include the old Microsoft Win32.hlp help file into PureBasics help functionality.
https://www.purebasic.com/documentation ... _help.html

The WIn32.hlp is automatically called with the correct context when the caret is on a Win API command in the IDE and the user presses F1. For Example if the user press F1 and the caret is placed on 'CreateWindowEx_('

The *.hlp help file format is very old and you will find here http://laurencejackson.com/win32/ the same Win32 help but in chm format, which is a modern help format and offers a table of contence and a better search.

Image

Is it somehow possible to call this WIn32.CHM file via F1 instead of the old WIn32.hlp file?

Greetings, Kurzer

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Fri Apr 19, 2019 2:54 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1112
Location: Gernsbach (Germany)
win32.chm is very outdated. Many functions are not documented in the help file. E.g. GetLastInputInfo_(), ProcessIdToSessionId_(), GetProductInfo_(), InternetGetConnectedStateEx_(), CreateHardLink_(), ...
If you want to read information from a function that is not documented in win32.chm, you must always use Google.
I recommend Google. E.g. GetLastInputInfo msdn
Or you can create a PB tool to access the MSDN page.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Fri Apr 19, 2019 3:12 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3869
Location: Berlin, Germany
RSBasic wrote:
Or you can create a PB tool to access the MSDN page.

See this code by ts-soft on the German forum. :-)

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Fri Apr 19, 2019 5:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
Thank you for your contributions and hints. Image

It don't mind if I can't call the chm directly. It would have been just a "nice to have".

For me the online msdn page is a bit confusing, but I'm not a hardcore winapi user either. I mainly look into this Win32 help out of curiosity. For the F1 help I leave the old Win32.hlp file in the help folder and call the chm file manually or via the help menu of the IDE.

Out of curiosity I changed the hard coded call of the "Win32.hlp" file in the PureBasic editor with a hex editor to "Win32.chm". This works, but obviously the transfer of the topic (the winapi command under the caret) has to be done differently than with a ".hlp" file. So it didn't worked for me, except that the chm file can be called with F1 and then shows me "The topic doesn't exist". :lol:

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Fri Apr 19, 2019 5:56 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1112
Location: Gernsbach (Germany)
kurzer wrote:
Out of curiosity I changed the hard coded call of the "Win32.hlp" file in the PureBasic editor with a hex editor to "Win32.chm".

Good idea :)

kurzer wrote:
kurzer wrote:
Out of curiosity I changed the hard coded call of the "Win32.hlp" file in the PureBasic editor with a hex editor to "Win32.chm".

You may be able to develop an application called "Win32.exe" and change it to this application in the hex editor. Your Win32.exe application only needs to forward the parameter to Win32.chm (hh.exe).

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Fri Apr 19, 2019 7:15 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
RSBasic wrote:
You may be able to develop an application called "Win32.exe" and change it to this application in the hex editor. Your Win32.exe application only needs to forward the parameter to Win32.chm (hh.exe).

Hehe, yes good idea, RSBasic. :D I had this idea too, but unfortunately I don't know the convention for parameters for a CHM file call.

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sat Apr 20, 2019 3:49 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 737
Location: Linz, Austria
If you don't mind using a different key than F1, you could use your own shortcut (e.g. Alt-F1) with this little IDE Tool (needs no arguments).
Code:
EnableExplicit

If CreateMutex_(0, 1, "Win32.chm") = 0 Or GetLastError_() <> 0
  PostMessage_(FindWindow_(0,"Win32 Programmer's Reference"), #WM_CLOSE, 0, 0)
EndIf

Prototype HtmlHelp(a, b.s, c, d)

#HH_DISPLAY_TOPIC  = 0
#HH_DISPLAY_TOC    = 1
#HH_KEYWORD_LOOKUP = $D

Structure tAKLIN
  cbStruct.l
  fReserved.l
  pszKeywords.s
  pszUrl.s
  pszMsgText.s
  pszMsgTitle.s
  pszWindow.s
  fIndexOnFail.l
EndStructure

Procedure HtmlHelp(HelpFile.s, Keyword.s) ;by ts-soft (https://www.purebasic.fr/english/viewtopic.php?p=355981#p355981)
  Protected AKLIN.tAKLIN
  Protected HtmlHelp_.HtmlHelp
  Protected hWnd
  Protected DLL = OpenLibrary(#PB_Any, "HHCtrl.ocx")
  If DLL
    CompilerIf #PB_Compiler_Unicode
      HtmlHelp_ = GetFunction(DLL, "HtmlHelpW")
    CompilerElse
      HtmlHelp_ = GetFunction(DLL, "HtmlHelpA")
    CompilerEndIf
    With AKLIN
      \cbStruct = SizeOf(tAKLIN)
      \fReserved = 0
      \pszKeywords = Keyword
      \fIndexOnFail = #True
    EndWith
    hWnd = HtmlHelp_(0, HelpFile, #HH_KEYWORD_LOOKUP, AKLIN)
    HtmlHelp_(0, HelpFile, #HH_DISPLAY_TOC, 0)
    CloseLibrary(DLL)
    ProcedureReturn hWnd
  EndIf
EndProcedure

Define chm$ = "D:\Program Files\PureBasicTools\Win32.chm"
Define word$ = RTrim(GetEnvironmentVariable("PB_TOOL_Word"), "_")
Define hWnd_chm = HtmlHelp(chm$, word$)

If hWnd_chm
  While IsWindow_(hWnd_chm)
    Delay(1000)
  Wend
EndIf
Edit: fixed mix-up with constants (#HH_DISPLAY_TOPIC = 0, #HH_DISPLAY_TOC = 1), changed the order of execution (#HH_KEYWORD_LOOKUP before #HH_DISPLAY_TOC) to provide a better experience ;)

_________________
Et cetera is my worst enemy


Last edited by chi on Mon Apr 22, 2019 6:38 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sat Apr 20, 2019 5:11 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
Chi and ts-soft,

thank you both. What a great solution.
This works like a charm. Jippie Image

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sun Apr 21, 2019 9:57 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
chi wrote:
HtmlHelp_(0, HelpFile, #HH_DISPLAY_TOPIC, 0)
hWnd = HtmlHelp_(0, HelpFile, #HH_KEYWORD_LOOKUP, AKLIN)

@ts-soft: Thank you for creating the original snipplet, I try to understand all of it, but I did not understand exactly this part. Can you explain why you are calling HtmlHelp_() twice? The first call would display the topic content (if it were the only call), but the second call immediately commands the help to display the keyword.

@chi: You've implemented the ingenious mutex() check to see if the help has already been called from the PB IDE.
Will a WInAPI created mutex be automatically released when PB exits the program? To be on the safe side I added the following to the program, because I wasn't sure.

Code:
Define iMutex.i = CreateMutex_(0, 1, "Win32.chm")
If iMutex = 0 Or GetLastError_() <> 0
   PostMessage_(FindWindow_(0,"Win32 Programmer's Reference"), #WM_CLOSE, 0, 0)
EndIf
; ... calling the Help and wait for user quits the help window ...
If iMutex <> 0
   ReleaseMutex_(iMutex)
EndIf
End

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sun Apr 21, 2019 11:19 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 877
kurzer wrote:
Will a WInAPI created mutex be automatically released when PB exits the program?

Yes. From MSDN for CreateMutex: "The system closes the handle automatically when the process terminates."


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sun Apr 21, 2019 7:05 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 737
Location: Linz, Austria
kurzer wrote:
Can you explain why you are calling HtmlHelp_() twice? The first call would display the topic content (if it were the only call), but the second call immediately commands the help to display the keyword.
HH_KEYWORD_LOOKUP command
Quote:
You must first call the HH_DISPLAY_TOPIC command before calling this command to ensure that the help window is created.

_________________
Et cetera is my worst enemy


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sun Apr 21, 2019 7:55 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
Thank you very much for the explanation, Chi.

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Sun Apr 21, 2019 11:32 pm 
Offline
Always Here
Always Here
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 5755
Location: Berlin - Germany
double holds better :mrgreen:

_________________
PureBasic 5.71 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 19.3 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Mon Apr 22, 2019 6:40 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 737
Location: Linz, Austria
made small changes... previous code updated

_________________
Et cetera is my worst enemy


Top
 Profile  
Reply with quote  
 Post subject: Re: How to call a win32.chm file via F1 in the IDE?
PostPosted: Mon Apr 22, 2019 2:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 558
Location: Near Hamburg
Thank you, I've updated my own code. Image

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye