Expand Autocomplete/Quickhelp (Windows only)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Expand Autocomplete/Quickhelp (Windows only)

Post by Josh »

PB supports API's which are not shown with autocomplete and supports much more API's without quickhelp. With this little program, you can easily add API's for autocomplete and additional parameters for the quickhelp. If you have some further information, feel so free to post here and I will add it in the ApiListingExpand.txt

At the moment autocomplete/quickhelp for the following API's is included:
  • Window Properties
  • Visual Styles
  • Window Procedure Functions (added 2013.08.04 07:25)
  • Font and Text Functions (added 2013.08.04 07:25)

ApiListingExpand.pb

Code: Select all

 ;*****************************************************************************
 ;*
 ;* ApiListingExpand.pb
 ;* Created by Josh
 ;* 
 ;* Created     : 03.08.2013
 ;* Last update : 03.08.2013
 ;*
 ;* http://www.purebasic.fr/english/viewtopic.php?f=27&t=55771
 ;*
 ;*
 ;* PB supports API's which are not shown with autocomplete and supports much more
 ;* API's where the parameters are not displayed in the helpline.
 ;*
 ;* This program adds missing information to the file APIFunctionListing.txt. Save
 ;* this file to any directory and copy the file ApiListingExpand.txt to the same
 ;* directory. After running this program, the items in ApiListingExpand.txt are 
 ;* added to APIFunctionListing.txt. You will see the changes after PB is restartet.
 ;*
 ;* Items in ApiListingExpand.txt can be marked with [checked]. In this case always
 ;* this item is used, although the original PB file has other params.
 ;*
 ;* A backup file is made from APIFunctionListing.txt. The new file has to write in
 ;* the PB programdirectory, so you need to run this program in administrator mode.
 ;*
 ;*****************************************************************************

  EnableExplicit

  Structure APIS
    ApiName   .s
    TextOri   .s
    TextExt   .s
    ParamsOri .s
    ParamsExt .s
    ParamsNew .s
    CheckedExt.i
  EndStructure

  Structure APIS_LIST
    TextSort .s
    TextNew  .s
  EndStructure

  NewMap  Apis       .APIS()
  NewList ApisList   .APIS_LIST()

  Define FileNameOri.s
  Define FileNameBak.s
  Define FileNameUsr.s
  Define TextOri    .s
  Define TextExt    .s
  Define ApiName    .s
  Define ParamsOri  .s
  Define ParamsExt  .s
  Define msg        .s
  Define CheckedExt .i

 ;Check OS
  If #PB_Compiler_OS <> #PB_OS_Windows
    msg = "This program supports only Windows API's"
    MessageRequester ("ApiListingExpand", msg, #MB_ICONERROR)
    End
  EndIf

 ;Check admin status
  If OSVersion () >= #PB_OS_Windows_Vista
    If IsUserAnAdmin_() = #False
      msg = "You have to start the program with admin rights."
      MessageRequester ("ExpandApiListing", msg, #MB_ICONERROR)
      End
    EndIf
  EndIf

 ;Define filenames
  FileNameOri = #PB_Compiler_Home     + "Compilers\APIFunctionListing.txt"
  FileNameBak = #PB_Compiler_Home     + "Compilers\APIFunctionListing.bak"
  FileNameUsr = #PB_Compiler_FilePath + "ApiListingExpand.txt"

 ;If BAK file doesn't exist, rename the original file
  If FileSize (FileNameBak) = -1
    If RenameFile (FileNameOri, FileNameBak) = 0
      msg = "The following file couldn't be renamed" + #CRLF$ + FileNameOri
      MessageRequester ("ApiListingExpand", msg, #MB_ICONERROR)
      End
    EndIf
  EndIf

 ;__________________
 ;Read original file
 ;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 ;Open the original file and read the first line
  If ReadFile (0, FileNameBak) = 0
    msg = "Can't open the following file" + #CRLF$ + FileNameBak
    MessageRequester ("ApiListingExpand", msg, #MB_ICONERROR)
    End
  EndIf
  ReadString (0)

 ;Read the original file into the map
  While Eof (0) = 0
    TextOri   = ReadString (0)
    TextOri   = Trim (TextOri)
    If TextOri = ""  : Continue : EndIf
    ApiName   = StringField (TextOri, 1, "")
    ApiName   = StringField (ApiName, 1, "(")
    ApiName   = Trim (ApiName)
    ParamsOri = RemoveString (TextOri, ApiName)
    ParamsOri = Trim (ParamsOri)
    Apis(ApiName)\TextOri   = TextOri
    Apis(ApiName)\ApiName   = ApiName
    Apis(ApiName)\ParamsOri = ParamsOri
  Wend

 ;Close the original file
  CloseFile (0)

 ;________________
 ;Read expand file
 ;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 ;Open the expand file
  If ReadFile (0, FileNameUsr) = 0
    msg = "The following file couldn't be opened," + #CRLF$
    msg + FileNameUsr + #CRLF$ + #CRLF$
    msg + "The original file will be restored."
    MessageRequester ("ApiListingExpand", msg, #MB_ICONINFORMATION)
    CopyFile (FileNameBak, FileNameOri)
    End
  EndIf

 ;Read the expand file into the map
  While Eof (0) = 0
    TextExt = ReadString (0)
    TextExt = Trim (TextExt)
    If Left (TextExt, 1) = ";" : Continue : EndIf
    If TextExt           = ""  : Continue : EndIf
    If FindString (TextExt, "[checked]", 1, #PB_String_NoCase)
      TextExt = RemoveString (TextExt, "[checked]", #PB_String_NoCase)
      CheckedExt = #True
    Else
      CheckedExt = #False
    EndIf
    ApiName   = StringField (TextExt, 1, "")
    ApiName   = StringField (ApiName, 1, "(")
    ApiName   = Trim (ApiName)
    ParamsExt = RemoveString (TextExt, ApiName)
    ParamsExt = Trim (ParamsExt)
    Apis(ApiName)\TextExt    = TextExt
    Apis(ApiName)\ApiName    = ApiName
    Apis(ApiName)\ParamsExt  = ParamsExt
    Apis(ApiName)\CheckedExt = CheckedExt
  Wend

 ;Close the expand file
  CloseFile (0)

 ;_________________
 ;Create new params
 ;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

  ForEach Apis()

    If Apis()\CheckedExt = #True
      Apis()\ParamsNew = Apis()\ParamsExt
      Continue
    EndIf

    If Apis()\ParamsOri And Apis()\ParamsExt = ""
      Apis()\ParamsNew = Apis()\ParamsOri
      Continue
    EndIf

    If Apis()\ParamsOri = "" And Apis()\ParamsExt
      Apis()\ParamsNew = Apis()\ParamsExt
      Continue
    EndIf

    If Apis()\ParamsOri And Apis()\ParamsExt And Apis()\ParamsOri <> Apis()\ParamsExt And UCase (Apis()\ParamsOri) = UCase (Apis()\ParamsExt)
      Apis()\ParamsNew = Apis()\ParamsExt
      Continue
    EndIf

    If Apis()\ParamsOri And Apis()\ParamsExt And Apis()\ParamsOri <> Apis()\ParamsExt
      Apis()\ParamsNew = Apis()\ParamsOri + " ;***** differences in ApiListingExpand.txt"
      Continue
    EndIf

    If Apis()\ParamsOri And Apis()\ParamsExt And Apis()\ParamsOri = Apis()\ParamsExt
      Apis()\ParamsNew = Apis()\ParamsOri + " ;***** please remove in ApiListingExpand.txt"
      Continue
    EndIf

  Next

 ;_______________________________________
 ;Write in list, sort and create textfile
 ;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 ;Create list
  ForEach Apis()
    AddElement (ApisList())
    ApisList()\TextSort = UCase (Apis()\ApiName)
    ApisList()\TextNew  = Apis()\ApiName + " " + Apis()\ParamsNew
  Next

 ;Sort List (underscores at the end)
  SortStructuredList (ApisList(), #PB_Sort_Ascending, OffsetOf (APIS_LIST\TextSort), #PB_String)

 ;Write in textfile
  CreateFile  (0, FileNameOri)
  WriteString (0, Str (ListSize (ApisList())+1) + #CRLF$)
  ForEach ApisList()
    WriteString (0, ApisList()\TextNew + #CRLF$)
  Next
  CloseFile (0)

ApiListingExpand.txt

Code: Select all

;>>>>>>>>>> Added 03.08.2013 <<<<<<<<<<

;_________________________
;Window Property Functions
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
EnumProps (hWnd, lpEnumFunc)
EnumPropsEx (hWnd, lpEnumFunc, lParam)
GetProp (hWnd, lpString)
RemoveProp (hWnd, lpString)
SetProp (hWnd, lpString, hData)

;______________________
;Visual Style Functions
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
CloseThemeData (hTheme)
DrawThemeBackground (hTheme, hDc, iPartId, iStateId, *pRect, *pClipRect)
DrawThemeBackgroundEx (hTheme, hDc, iPartId, iStateId, *pRect, *pOptions)
DrawThemeEdge (hTheme, hDc, iPartId, iStateId, pDestRect, uEdge, uFlags, pContentRect)
DrawThemeIcon (hTheme, hDc, iPartId, iStateId, pRect, himl, iImageIndex)
DrawThemeParentBackground (hWnd, hDc, *prc)
DrawThemeText (hTheme, hDc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, dwTextFlags2, pRect)
EnableThemeDialogTexture (hWnd, dwFlags)
EnableTheming (fEnable)
GetCurrentThemeName (pszThemeFileName, dwMaxNameChars, pszColorBuff, cchMaxColorChars, pszSizeBuff, cchMaxSizeChars)
GetThemeAppProperties ()
GetThemeBackgroundContentRect (hTheme, hDc, iPartId, iStateId, pBoundingRect, pContentRect)
GetThemeBackgroundExtent (hTheme, hDc, iPartId, iStateId, pContentRect, pExtentRect)
GetThemeBackgroundRegion (hTheme, hDc, iPartId, iStateId, pRect, *pRegion)
GetThemeBool (hTheme, iPartId, iStateId, iPropId, *pfVal)
GetThemeColor (hTheme, iPartId, iStateId, iPropId, *pColor)
GetThemeDocumentationProperty (pszThemeName, pszPropertyName, pszValueBuff, cchMaxValChars)
GetThemeEnumValue (hTheme, iPartId, iStateId, iPropId, *piVal)
GetThemeFilename (hTheme, iPartId, iStateId, iPropId, pszThemeFilename, cchMaxBuffChars)
GetThemeFont (hTheme, hDc, iPartId, iStateId, iPropId, *pFont)
GetThemeInt (hTheme, iPartId, iStateId, iPropId, *piVal)
GetThemeIntList (hTheme, iPartId, iStateId, iPropId, *pIntList)
GetThemeMargins (hTheme, hDc, iPartId, iStateId, iPropId, prc, *pMargins)
GetThemeMetric (hTheme, hDc, iPartId, iStateId, iPropId, *piVal)
GetThemePartSize (hTheme, hDc, iPartId, iStateId, prc, eSize, *psz)
GetThemePosition (hTheme, iPartId, iStateId, iPropId, *pPoint)
GetThemePropertyOrigin (hTheme, iPartId, iStateId, iPropId, *pOrigin)
GetThemeRect (hTheme, iPartId, iStateId, iPropId, pRect)
GetThemeString (hTheme, iPartId, iStateId, iPropId, pszBuff, cchMaxBuffChars)
GetThemeSysBool (hTheme, iBoolID)
GetThemeSysColor (hTheme, iColorID)
GetThemeSysColorBrush (hTheme, iColorID)
GetThemeSysFont (hTheme, iFontID, *plf)
GetThemeSysInt (hTheme, iIntID, *piValue)
GetThemeSysSize (hTheme, iSizeID)
GetThemeSysString (hTheme, iStringID, pszStringBuff, cchMaxStringChars)
GetThemeTextExtent (hTheme, hDc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, pBoundingRect, pExtentRect)
GetThemeTextMetrics (hTheme, hDc, iPartId, iStateId, *ptm)
GetWindowTheme (hWnd)
IsAppThemed ()
IsThemeActive ()
IsThemeBackgroundPartiallyTransparent (hTheme, iPartId, iStateId)
IsThemeDialogTextureEnabled (hWnd)
IsThemePartDefined (hTheme, iPartId, iStateId)
OpenThemeData (hWnd, pszClassList)
SetThemeAppProperties (dwFlags)
SetWindowTheme (hWnd, pszSubAppName, pszSubIdList)

;>>>>>>>>>> Added 04.08.2013 <<<<<<<<<<

;__________________________
;Window Procedure Functions
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
CallWindowProc (lpPrevWndFunc, hWnd, uMsg, wParam, lParam)
DefWindowProc (hWnd, uMsg, wParam, lParam)

;_______________________
;Font and Text Functions
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
AddFontMemResourceEx (pbFont, cbFont, pdv, *pcFonts)
AddFontResource (lpszFilename)
CreateScalableFontResource (fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath)
DrawText (hDc, lpchText, nCount, lpRect, uFormat)
DrawTextEx (hDc, lpchText, cchText, lprc, dwDTFormat, lpDTParams)
EnumFontFamilies (hDc, lpszFamily, lpEnumFontFamProc, lParam)
EnumFontFamiliesEx (hDc, lpLogfont, lpEnumFontFamExProc, lParam, dwFlags)
EnumFonts (hDc, lpFaceName, lpFontFunc, lParam)
GetAspectRatioFilterEx (hDc, lpAspectRatio) [checked]
GetCharABCWidths (hDc, UuFirstChar, UuLastChar, lpabc)
GetCharABCWidthsFloat (hDc, UiFirstChar, UiLastChar, lpABCF)
GetCharacterPlacement (hDc, lpString, nCount, nMaxExtent, lpResults, dwFlags)
GetCharWidth (hDc, UiFirstChar, UiLastChar, lpBuffer)
GetCharWidth32 (hDc, UiFirstChar, UiLastChar, lpBuffer)
GetCharWidthFloat (hDc, UiFirstChar, UiLastChar, pxBuffer)
GetFontData (hDc, dwTable, dwOffset, lpvBuffer, cbData) [checked]
GetFontLanguageInfo (hDc)
GetGlyphOutline (hDc, UuChar, UuFormat, lpgm, cbBuffer, lpvBuffer, *lpmat2)
GetKerningPairs (hDc, nNumPairs, lpkrnpair)
GetRasterizerCaps (lprs, Ucb) [checked]
GetTabbedTextExtent (hDc, lpString, nCount, nTabPositions, lpnTabStopPositions)
GetTextCharacterExtra (hDc)
GetTextColor (hDc)
GetTextExtentExPoint (hDc, lpszStr, cchString, nMaxExtent, lpnFit, alpDx, lpSize)
GetTextExtentPoint (hDc, lpString, cbString, lpSize)
GetTextExtentPoint32 (hDc, lpString, c, lpSize)
GetTextFace (hDc, nCount, lpFaceName)
GetTextMetrics (hDc, lptm)
PolyTextOut (hDc, *pptxt, cStrings)
RemoveFontMemResourceEx (fh)
RemoveFontResource (lpFileName)
SetMapperFlags (hDc, dwFlag) [checked]
SetTextCharacterExtra (hDc, nCharExtra) [checked]
SetTextColor (hDc, crColor) [checked]
SetTextJustification (hDc, nBreakExtra, nBreakCount) [checked]
TabbedTextOut (hDc, X, Y, lpString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin)
TextOut (hDc, nXStart, nYStart, lpString, cchString)
Last edited by Josh on Sun Aug 04, 2013 6:33 am, edited 3 times in total.
sorry for my bad english
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: Expand Autocomplete/Quickhelp (Windows only)

Post by Zebuddi123 »

Thanks Josh That`s great, really usefull :D

I`ve had a play about with it and set my "ApiListingExpand.txt" to AppData\Roaming\PureBasic and adapted your code to update x86 and x64 at the same time.

Also using Procmon and filtering purebasic for ApiFunctionListing.txt, the file is not re-read on "restart compiler" so PBIDE needs to be closed and re-opened after the ApiFunctionListing.txt is updated.

TIP: make sure the file format is (Encoding "Plain code:" ) and (newline windows "CRLF") encoded

Big Thanks 8) :idea:

Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Expand Autocomplete/Quickhelp (Windows only)

Post by Josh »

Hi Zebuddi,

thanks for your response and I hope my little app will help you.
Zebuddi123 wrote:I`ve had a play about with it and set my "ApiListingExpand.txt" to AppData\Roaming\PureBasic and adapted your code to update x86 and x64 at the same time.

If you make changes, make sure that ApiListingExpand.txt is only once renamed to ApiListingExpand.bak at your first program start for each compiler (x86 + x64). I made changes in the program code yesterday evening. If there is no item CheckedExt.i in the structure APIS, you have a old code. The new one will be needed for further code extensions. Please check.
Zebuddi123 wrote:TIP: make sure the file format is (Encoding "Plain code:" ) and (newline windows "CRLF") encoded
I think you are speaking from the file format in Menu > File format. I tested all possible justifications, but couldn't create any problems :?


WTF, Sunday 07:14. Some years ago, I went to bed at this time :lol:
sorry for my bad english
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Expand Autocomplete/Quickhelp (Windows only)

Post by Josh »

Added 2 further areas for autocomplete/quickhelp in my first posting:
  • Window Procedure Functions
  • Font and Text Functions
sorry for my bad english
Post Reply