summaryrefslogtreecommitdiff
path: root/rtl/inc/resh.inc
blob: f40690d0851f52667db7fbb3c9f95df4eafbd74a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  
type
  //Obsolete types, kept for backwards compatibility
  TResourceHandle = PtrUint;
  HMODULE = PtrUint;
  HGLOBAL = PtrUint;
  //New types
  TFPResourceHandle = PtrUInt;
  TFPResourceHMODULE = PtrUInt;
  TFPResourceHGLOBAL = PtrUInt;
{$ifdef FPC_OS_UNICODE}
  {roozbeh : maybe it shoud be moved after ifndef mswindows,as there is one declared in wince,base.inc}
  MAKEINTRESOURCE = pwidechar;
{$else}
  MAKEINTRESOURCE = pchar;
{$endif}  
  
{$ifndef MSWINDOWS }
{ windows has this in the windows unit. It probably would better
  fit into the classes/sysutils unit but because it is resource
  related, I put it here (FK)
}
const
  RT_CURSOR = MAKEINTRESOURCE(1);
  RT_BITMAP = MAKEINTRESOURCE(2);
  RT_ICON = MAKEINTRESOURCE(3);
  RT_MENU = MAKEINTRESOURCE(4);
  RT_DIALOG = MAKEINTRESOURCE(5);
  RT_STRING = MAKEINTRESOURCE(6);
  RT_FONTDIR = MAKEINTRESOURCE(7);
  RT_FONT = MAKEINTRESOURCE(8);
  RT_ACCELERATOR = MAKEINTRESOURCE(9);
  RT_RCDATA = MAKEINTRESOURCE(10);
  RT_MESSAGETABLE = MAKEINTRESOURCE(11);
  RT_GROUP_CURSOR = MAKEINTRESOURCE(12);
  RT_GROUP_ICON = MAKEINTRESOURCE(14);
  RT_VERSION = MAKEINTRESOURCE(16);
  RT_ANICURSOR = MAKEINTRESOURCE(21);
  RT_ANIICON = MAKEINTRESOURCE(22);
  RT_HTML = MAKEINTRESOURCE(23);
  RT_MANIFEST = MAKEINTRESOURCE(24);

{$endif MSWINDOWS }

// Win32 API compatible Resource callbacks
type
  EnumResTypeProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; lParam : PtrInt) : LongBool; stdcall;
  EnumResNameProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; lParam : PtrInt) : LongBool; stdcall;
  EnumResLangProc = function(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; IDLanguage : word; lParam : PtrInt) : LongBool; stdcall;

// Useful functions (macros in win32 headers)
function Is_IntResource(aStr : pchar) : boolean; {$ifdef SYSTEMINLINE}inline;{$endif}
function MakeLangID(primary,sub : word) : word; {$ifdef SYSTEMINLINE}inline;{$endif}

// Win32 API compatible Resource functions
Function HINSTANCE : TFPResourceHMODULE;
Function EnumResourceTypes(ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
Function EnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
Function EnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar): TFPResourceHandle;
Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PChar; Language : word): TFPResourceHandle;
Function LoadResource(ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): TFPResourceHGLOBAL;
Function SizeofResource(ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): LongWord;
Function LockResource(ResData: TFPResourceHGLOBAL): Pointer;
Function UnlockResource(ResData: TFPResourceHGLOBAL): LongBool;
Function FreeResource(ResData: TFPResourceHGLOBAL): LongBool;
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
Function FindResource(ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: AnsiString): TFPResourceHandle;
Function FindResourceEx(ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: AnsiString; Language : word): TFPResourceHandle;
{$endif}

type
  TResourceManager = record
    HINSTANCEFunc : function : TFPResourceHMODULE;
    EnumResourceTypesFunc : function (ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
    EnumResourceNamesFunc : function (ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
    EnumResourceLanguagesFunc : function (ModuleHandle : TFPResourceHMODULE; ResourceType,ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;
    FindResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResourceName, ResourceType: PChar): TFPResourceHandle;
    FindResourceExFunc : function (ModuleHandle: TFPResourceHMODULE; ResourceType, ResourceName: PChar; Language : word): TFPResourceHandle;
    LoadResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): TFPResourceHGLOBAL;
    SizeofResourceFunc : function (ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): LongWord;
    LockResourceFunc : function (ResData: TFPResourceHGLOBAL): Pointer;
    UnlockResourceFunc : function (ResData: TFPResourceHGLOBAL): LongBool;
    FreeResourceFunc : function (ResData: TFPResourceHGLOBAL): LongBool;
  end;

procedure GetResourceManager (var Manager : TResourceManager);
procedure SetResourceManager (const New : TResourceManager);