Kylix
Tips

NEW TIPS
Database (91)
Files (138)
Forms (112)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (133)
IntraWeb (0)
Math (77)
Misc (128)
Multimedia (46)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (246)

Search Tip
Top15
Add new Tip

Forum

...change resource strings at run-time?
Author: P. Below
Homepage: http://www.teamb.com
[ Print tip ]    

Tip Rating (12):  
     





uses
  
Consts;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
InputBox('Test', 'Enter something', 'Test');
end;

procedure HookResourceString(rs: PResStringRec; newStr: PChar);
var
  
oldprotect: DWORD;
begin
  
VirtualProtect(rs, SizeOf(rs^), PAGE_EXECUTE_READWRITE, @oldProtect);
  rs^.Identifier := Integer(newStr);
  VirtualProtect(rs, SizeOf(rs^), oldProtect, @oldProtect);
end;

const
  
NewOK: PChar = 'New Ok';
  NewCancel: PChar = 'New Cancel';

initialization
  
HookResourceString(@SMsgDlgOK, NewOK);
  HookResourceString(@SMsgDlgCancel, NewCancel);
end.

Rate this tip:

poor
very good


Copyright  Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright 1996-2001