ScummVM API documentation
global_functions.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BAGEL_MFC_GLOBAL_FUNCTIONS_H
23 #define BAGEL_MFC_GLOBAL_FUNCTIONS_H
24 
25 #include "common/stream.h"
26 #include "bagel/mfc/afxstr.h"
27 #include "bagel/mfc/minwindef.h"
28 #include "bagel/mfc/winnt.h"
29 
30 namespace Bagel {
31 namespace MFC {
32 
33 class CWinApp;
34 class CWnd;
35 
36 /* Global Memory Flags */
37 #define GMEM_FIXED 0x0000
38 #define GMEM_MOVEABLE 0x0002
39 #define GMEM_NOCOMPACT 0x0010
40 #define GMEM_NODISCARD 0x0020
41 #define GMEM_ZEROINIT 0x0040
42 #define GMEM_MODIFY 0x0080
43 #define GMEM_DISCARDABLE 0x0100
44 #define GMEM_NOT_BANKED 0x1000
45 #define GMEM_SHARE 0x2000
46 #define GMEM_DDESHARE 0x2000
47 #define GMEM_NOTIFY 0x4000
48 #define GMEM_LOWER GMEM_NOT_BANKED
49 #define GMEM_VALID_FLAGS 0x7F72
50 #define GMEM_INVALID_HANDLE 0x8000
51 
52 #define GHND (GMEM_MOVEABLE | GMEM_ZEROINIT)
53 #define GPTR (GMEM_FIXED | GMEM_ZEROINIT)
54 
55 #define MB_ICONHAND 0x00000010L
56 #define MB_ICONQUESTION 0x00000020L
57 #define MB_ICONEXCLAMATION 0x00000030L
58 #define MB_ICONASTERISK 0x00000040L
59 #define MB_ICONINFORMATION MB_ICONASTERISK
60 #define MB_ICONSTOP MB_ICONHAND
61 
62 extern CWinApp *AfxGetApp();
63 extern CWnd *AfxGetMainWnd();
64 extern HINSTANCE AfxGetInstanceHandle();
65 extern int LoadString(HINSTANCE hInstance,
66  unsigned int uID, char *lpBuffer, int cchBufferMax);
67 extern HMODULE LoadLibrary(const char *lpLibFileName);
68 extern void FreeLibrary(HMODULE hModule);
69 extern FARPROC GetProcAddress(HMODULE hModule,
70  const char * lpProcName);
71 extern HMODULE GetModuleHandle(const char *lpModuleName);
72 
73 extern const char *AFXAPI AfxRegisterWndClass(unsigned int nClassStyle,
74  HCURSOR hCursor = 0, HBRUSH hbrBackground = 0, HICON hIcon = 0);
75 extern bool GetClassInfo(HINSTANCE hInstance,
76  const char *lpClassName, LPWNDCLASS lpWndClass);
77 extern int GetSystemMetrics(int nIndex);
78 
79 extern HGLOBAL GlobalAlloc(unsigned int uFlags, size_t dwBytes);
80 extern void *GlobalLock(HGLOBAL hMem);
81 extern bool GlobalUnlock(HGLOBAL hMem);
82 extern HGLOBAL GlobalFree(HGLOBAL hMem);
83 extern size_t GlobalSize(HGLOBAL hMem);
84 extern size_t GlobalCompact(uint32 dwMinFree);
85 #define LocalAlloc GlobalAlloc
86 #define LocalLock GlobalLock
87 #define LocalUnlock GlobalUnlock
88 #define LocalFree GlobalFree
89 #define LocalCompact GlobalCompact
90 #define GetFreeSpace(w) (0x100000L)
91 
92 extern int MessageBox(HWND hWnd, const char *lpText,
93  const char *lpCaption, unsigned int uType);
94 extern int MessageBox(const char *lpText, const char *lpCaption, unsigned int uType = 0);
95 extern int MessageBox(const char *lpText);
96 extern unsigned int GetPrivateProfileInt(const char *lpAppName,
97  const char *lpKeyName, int nDefault, const char *lpFileName);
98 extern uint32 GetPrivateProfileString(const char *lpAppName,
99  const char *lpKeyName, const char *lpDefault, char * lpReturnedString,
100  uint32 nSize, const char *lpFileName);
101 
102 extern bool WritePrivateProfileString(
103  const char *lpAppName, const char *lpKeyName,
104  const char *lpString, const char *lpFileName);
105 
106 extern HTASK GetCurrentTask();
107 extern FARPROC MakeProcInstance(FARPROC lpProc, HINSTANCE hInstance);
108 extern void FreeProcInstance(FARPROC lpProc);
109 extern HHOOK SetWindowsHookEx(int idHook,
110  HOOKPROC lpfn, HINSTANCE hmod, HTASK dwThreadId);
111 extern bool UnhookWindowsHookEx(HHOOK hhk);
112 extern LRESULT CallNextHookEx(HHOOK hhk, int nCode,
113  WPARAM wParam, LPARAM lParam);
114 extern uintptr SetTimer(HWND hWnd, uintptr nIDEvent, unsigned int nElapse,
115  void (CALLBACK *lpfnTimer)(HWND, unsigned int, uintptr, uint32) = nullptr);
116 extern bool KillTimer(HWND hWnd, uintptr nIDEvent);
117 extern void Sleep(unsigned int milli);
118 extern uint32 GetTickCount();
119 
120 extern Common::SeekableReadStream *OpenFile(const char *filename);
121 extern bool FileExists(const char *filename);
122 extern long FileLength(const char *filename);
123 
124 extern bool PeekMessage(LPMSG lpMsg, HWND hWnd,
125  unsigned int wMsgFilterMin, unsigned int wMsgFilterMax,
126  unsigned int wRemoveMsg);
127 extern void TranslateMessage(LPMSG lpMsg);
128 extern void DispatchMessage(LPMSG lpMsg);
129 extern bool PostMessage(HWND hWnd, unsigned int Msg,
130  WPARAM wParam, LPARAM lParam);
131 extern LRESULT SendMessage(HWND hWnd, unsigned int Msg,
132  WPARAM wParam, LPARAM lParam);
133 
134 extern HINSTANCE AfxGetResourceHandle();
135 extern HINSTANCE AfxFindResourceHandle(const char *lpszName, const char *lpszType);
136 extern HRSRC FindResource(HMODULE hModule,
137  const char *lpName, const char *lpType);
138 extern size_t SizeofResource(HMODULE hModule, HRSRC hResInfo);
139 extern HGLOBAL LoadResource(HMODULE hModule, HRSRC hResInfo);
140 extern void *LockResource(HGLOBAL hResData);
141 extern void UnlockResource(HGLOBAL hResData);
142 extern bool FreeResource(HGLOBAL hResData);
143 extern HFONT CreateFontIndirect(const LOGFONT *lf);
144 
145 extern bool AfxExtractSubString(CString &rString, const char *lpszFullString,
146  int iSubString, char chSep = '\n');
147 
148 inline char *strUpper(char *s) {
149  for (char *curr = s; *curr; ++curr)
150  *curr = toupper(*curr);
151  return s;
152 }
153 
154 inline char *strLower(char *s) {
155  for (char *curr = s; *curr; ++curr)
156  *curr = tolower(*curr);
157  return s;
158 }
159 
160 } // namespace MFC
161 } // namespace Bagel
162 
163 #endif
Definition: stream.h:745
Definition: afxwin.h:27