ich hatte meine DXE_Toolbar ja schon vor einige Zeit veröffentlicht und auch eingesetzt.
nun kam letztens eine Anfrage wegen Tooltip und ich dachte mir das kann ja kein "grosses" Problem sein.
es gab einige Konstanten die man setzten musste und damit funktionierte es auch ... wenn man sich an "einen" Weg hält.
Code: Alles auswählen
a.) oToobar:AddItem(cCaption, xImage, xDisabledImage, xHotImage, cDLL, nStyle, cKey ... )
Code: Alles auswählen
b.) oButton := oToobar:AddItem()
oButton:Caption := cCaption
oButton:Image := xImage
Code: Alles auswählen
INLINE ASSIGN METHOD _Caption(xValue) VAR Caption
INLINE ASSIGN METHOD _image(xValue) VAR image
INLINE ASSIGN METHOD _key(xValue) VAR key
INLINE ASSIGN METHOD _tooltipText(xValue) VAR tooltipText
ich habe dabei die "simple" Lösung gewählt
und das daraus gemachtThe only way that the automatic tooltip is going to be shown is if the button's text doesn't fit.
Sending the TB_SETMAXTEXTROWS message ensures that the text will never fit by setting the maximum number of rows available for text to 0.
Code: Alles auswählen
SendMessage(hWndToolbar, TB_SETMAXTEXTROWS, 0, 0)
... aber leider bekomme ich keinen Tooltip wenn ich nachträglich, nach Version b.), die Caption setzte und der Button die Caption haben "müsste" ...
ich musste immer tiefer im Source graben bis ich auf ein ursprüngliches Workaround gestossen bin was die ganz Zeit funktionierte. es ging um den iString in der Structure TTButton
den ich nicht kannte und durch DYNSZ cString ersetzt hatte.https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
iString
Type: INT_PTR
Zero-based index of the button string, or a pointer to a string buffer that contains text for the button.
Code: Alles auswählen
* Toolbar Button Structure
*
* here iString DYNSZ is different
* vs.
* ot4xb winapi_CommonStructures.cpp
*
BEGIN STRUCTURE TBBUTTON
MEMBER int iBitmap
MEMBER int idCommand
MEMBER BYTE fsState
MEMBER BYTE fsStyle
MEMBER BINSTR bReserved SIZE 2
MEMBER POINTER32 dwData
MEMBER LPSTR iString DYNSZ cString // als "normalen" String
END STRUCTURE
Code: Alles auswählen
oTbButton:cString := oButton:Caption
@user32:SendMessageA(::hToolbar, TB_BUTTONSTRUCTSIZE, oTbButton:_sizeof_() , 0)
@user32:SendMessageA(::hToolbar, TB_ADDBUTTONS, 1, oTbButton )
Code: Alles auswählen
oTbButton := TBBUTTON():New()
pBuffer := _xgrab( oTbButton:_sizeof_() )
oTbButton:_link_( pBuffer , .F. ) // link to the first item
FOR i := 1 TO iMax
IF oTbButton:idCommand = xValue
oTbButton:cString := NewText
EXIT
ENDIF
GwstArrayNext(oTbButton) // go to the next item
NEXT
oTbButton:_unlink_()
_xfree( pBuffer)
oTbButton := NIL
beim google entdeckte ich dann diesen C# Code
Code: Alles auswählen
//Button Strings
LPSTR toolStrings[ ] = {
"New", "Open", "Save","", "Refresh", "", "Cut", "Copy", "Paste","Undo","","Find","","Calculator",
};
// Associate strings with buttons
for (index = 0;index < 14;index++) {
if (*toolStrings[index] != *"")
tbb[index].iString = SendMessage(hwndTB, TB_ADDSTRING, 0, (LPARAM) (LPSTR) toolStrings[index]);
else tbb[index].iString = 0;
}
nun gibt TB_ADDSTRING den Index, also numerisch zurück
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
also habe ich meinen Code umgestellt auf
Code: Alles auswählen
oTbButton:iString := @user32:SendMessageA(::hToolbar,TB_ADDSTRING,0,::aItems[nNo][_cCaption])
allerdings war es bis zur Lösung nur noch ein kurzer Schritt
Code: Alles auswählen
@user32:SendMessageA(::hToolbar,TB_DELETEBUTTON,nNo-1,0) // zero-based Index