#1 2013-06-13 15:12:29

uligerhardt
Member
Registered: 2011-03-08
Posts: 52

SynTaskDialog - The problem with resourcestring and packages

Hello again!

Some time ago the problem occurred that array of resourcestrings can't be used in units inside packages. You solved that by using arrays of strings instead, e.g.

const
  TD_BTNS: array[TCommonButton] of string = (
    SMsgDlgOK, SMsgDlgYes, SMsgDlgNo, SMsgDlgCancel, SMsgDlgRetry,
    SCloseButton);

instead of

const
  TD_BTNS: array[TCommonButton] of pointer = (
    @SMsgDlgOK, @SMsgDlgYes, @SMsgDlgNo, @SMsgDlgCancel, @SMsgDlgRetry,
    @SCloseButton);

Unfortunately we have to assign the resourcestrings at runtime (with HookResourceString or similar), so this doesn't work. An alternative solution considered back then was using functions like

function TD_BTNS(cb: TCommonButton): Pointer;
begin
  case cb of
    cbOK: Result := @SMsgDlgOK;
    cbYes: Result := @SMsgDlgYes;
    cbNo: Result := @SMsgDlgNo;
    cbCancel: Result := @SMsgDlgCancel;
    cbRetry: Result := @SMsgDlgRetry;
    cbClose: Result := @SCloseButton;
    else Result := nil;
  end;
end;

which seem to work under these circumstances. What do you think about changing this?

Cheers,
Uli

Offline

#2 2013-06-14 08:20:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: SynTaskDialog - The problem with resourcestring and packages

Nice.

It allows indeed on-the fly translation of resource strings for SynTaskDialog.
See http://synopse.info/fossil/info/a021423994

Thanks for the proposal!
smile

Offline

#3 2013-06-14 11:04:11

uligerhardt
Member
Registered: 2011-03-08
Posts: 52

Re: SynTaskDialog - The problem with resourcestring and packages

Cool. I'm gonna make use of that as soon as time permits. :-)

Offline

Board footer

Powered by FluxBB