Board index » delphi » Adding String to Toolbar failes (TB_ADDSTRING) ExchExt

Adding String to Toolbar failes (TB_ADDSTRING) ExchExt

Hello all,
Iv been tring to add a caption to this button iv add in my ExchExt but when
i call the method SendMessage with TB_ADDSTRING i get -1 back, i saw in the
delhi source code that im doing exactly the same thing as they do, is there
a difference with ol toolbars and regular toolbars?
the button is shown in the toobar with the bitmap.
heres the code

function TTeleMessageExchExt.InstallCommands(lpeecb: IExchExtCallback;
  hwnd: HWND; hmenu: HMENU; var lpcmdidBase: UINT;
  lptbeArray: LPTBENTRY_Array; ctbe: UINT; ulFlags: ULONG): HRESULT;
const
    METHOD_NAME = 'TTeleMessageExchExt.InstallCommands: ';
var
    Captions: array [0..100]of char;
    Text: PChar;
    i: Integer;
    TBA:TTBADDBITMAP;
    Str: String
begin
    Result := S_FALSE;
    try
        if (EECONTEXT_VIEWER = FContext) then
        begin

{OleCheck(lpeecb.GetMenuPos(EECMDID_ToolsCustomizeToolbar,HMenuTools, width,
hight, 0));
            AppendMenu(hmenu,MF_SEPARATOR,0,nil);
            AppendMenu(hmenu,MF_BYCOMMAND or
MF_STRING,lpcmdidBase,'TeleMessage');}
            FCommandId := lpcmdidBase;
            Inc(lpcmdidBase);
            for i := ctbe - 1 downto 0 do
            begin
                if (EETBID_STANDARD = lptbeArray[i].tbid) then
                begin
                    hToolbar := lptbeArray[i].hwnd;
                    FButtonId := lptbeArray[i].itbbBase;
                    inc(lptbeArray[i].itbbBase);
                    break;
                end;
            end;
            if HToolBar <> 0 then
            begin
                Str := 'YADAYADA';
                StrPCopy(Captions,Str);
                Captions[Length(Str)+ 1] := #0;
                TBA.hInst := HInstance;
                TBA.nID := 102;
                FPicID := -1;
                //THIS WORKS, MY BUTTON IS SHOWN WITH THE BITMAP
                FPicID := SendMessage(hToolbar, TB_ADDBITMAP, 1,
LPARAM(@TBA));
                ShowMessage('Pic ID = ' + IntToStr(FPicID));
                FStrID := -1;
                //THIS FAILES
               FStrId :=
SendMessage(HToolBar,TB_ADDSTRING,0,LongInt(@Captions));
                ShowMessage('Str ID = ' + IntToStr(FStrID));
            end;
        end;
    except
        on E: Exception do
            Log(LOG_ERROR,METHOD_NAME,E.Message);
    end
end;

 

Re:Adding String to Toolbar failes (TB_ADDSTRING) ExchExt


this brings back some painful memories...

As I remember, you can't have a button with Text AND a bitmap on an exchange
extension generated toolbar button.  I spent a couple of days trying this
myself and never got it to work.  Basically, you have to choose one or the
other. (or is it just the bitmap only).

I think that the reason that this occurs because you aren't really working
with a REAL toolbar, rather a proxy toolbar that Outlook snoops under the
covers to grab the buttons from when it wants to put buttons on its toolbar.
Probably because you can have multiple outlook windows open (or something
like that)

Paul

Quote
"Daniel Shrem" <shr...@zahav.net.il> wrote in message

news:3cf63d35$1_1@dnews...
Quote
> Hello all,
> Iv been tring to add a caption to this button iv add in my ExchExt but
when
> i call the method SendMessage with TB_ADDSTRING i get -1 back, i saw in
the
> delhi source code that im doing exactly the same thing as they do, is
there
> a difference with ol toolbars and regular toolbars?
> the button is shown in the toobar with the bitmap.
> heres the code

snip

Other Threads