• Welcome to Theos PowerBasic Museum 2017.

Windows API Headers III v.1.05

Started by José Roca, October 18, 2013, 12:01:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J.G. Huang


Paul Squires

Hi José,

The help file ("WinApiHeaders.chm") for ListBox_ReplaceString is missing the second parameter "index".

Thanks - Paul
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Paul Squires

Hi José,

I am currently converting FireFly Visual Designer to become fully unicode enabled. As such, I am leveraging the use of your functions in your various Include files. You have certainly saved me an enormous amount of work when dealing with functions in both unicode and non-unicode versions.

I do have a question regarding your AfxSetWindowText function.

' ========================================================================================
' Changes the text of a window.
' Note: SetWindowText cannot change the text of a control in another application.
' ========================================================================================
FUNCTION AfxSetWindowText (BYVAL hwnd AS DWORD, BYVAL bstrText AS WSTRING) AS LONG
   FUNCTION = SendMessage(hwnd, %WM_SETTEXT, 0, STRPTR(bstrText))
END FUNCTION
' ========================================================================================


I believe that it only works when Unicode is enabled. It accepts a WSTRING for the text but uses SENDMESSAGE. If Unicode is not defined then SENDMESSAGE will be SENDMESSAGEA which causes the WSTRING text to be truncated at the second position (the nul in the two byte unicode character). I assume that I am correct in saying that (in the absence of separate unicode/nonunicode versions) that you should using SENDMESSAGEW in the function.


' ========================================================================================
' Changes the text of a window.
' Note: SetWindowText cannot change the text of a control in another application.
' ========================================================================================
FUNCTION AfxSetWindowText (BYVAL hwnd AS DWORD, BYVAL bstrText AS WSTRING) AS LONG
   FUNCTION = SendMessageW(hwnd, %WM_SETTEXT, 0, STRPTR(bstrText))
END FUNCTION
' ========================================================================================



Hope I am clear in my explanation  :)

Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

José Roca

Must have missed it because there are not separate WM_SETTEXTA and WM_SETTEXTW messages, but only WM_SETTEXT.

I have modified the function in AfxWin.inc as follows:


' ========================================================================================
' Changes the text of a window.
' Note: SetWindowText cannot change the text of a control in another application.
' ========================================================================================
FUNCTION AfxSetWindowTextA (BYVAL hwnd AS DWORD, BYVAL strText AS STRING) AS LONG
   FUNCTION = SendMessageA(hwnd, %WM_SETTEXT, 0, STRPTR(strText))
END FUNCTION
' ========================================================================================
FUNCTION AfxSetWindowTextW (BYVAL hwnd AS DWORD, BYVAL bstrText AS WSTRING) AS LONG
   FUNCTION = SendMessageW(hwnd, %WM_SETTEXT, 0, STRPTR(bstrText))
END FUNCTION
' ========================================================================================

#IF %DEF(%UNICODE)
   MACRO AfxSetWindowText = AfxSetWindowTextW
#ELSE
   MACRO AfxSetWindowText = AfxSetWindowTextA
#ENDIF



Holger Taschenberger

typo in Shlwapi.inc:

DECLARE FUNCTION UrlEscapeW IMPORT "SHLWAPI.DLL" ALIAS "UrlescapeW" ( _
   ...
) AS LONG

should be:

DECLARE FUNCTION UrlEscapeW IMPORT "SHLWAPI.DLL" ALIAS "UrlEscapeW" ( _
   ...
) AS LONG

José Roca


Scott Slater

Two thumbs up (as always)!  Thank you.

Norbert Doerre

Jose, astonishing - your work
Alle the best,
Norbert in his CAD submarine
Ing.-Buero Doerre (IBD)
Dipl-Ing. TH Norbert Doerre
Elpenbachstr. 63 - 65
46119 Oberhausen,  Germany
Technical Hard- and Software
Computer Forensic