Mercurial > vba-linux
comparison src/win32/WinResUtil.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 #include "stdafx.h" | |
2 #include "WinResUtil.h" | |
3 | |
4 static HINSTANCE winResGetInstance(LPCTSTR resType, LPCTSTR resName) | |
5 { | |
6 // TODO: make language DLL first | |
7 return AfxFindResourceHandle(resName, resType); | |
8 } | |
9 | |
10 UCHAR *winResGetResource(LPCTSTR resType, LPCTSTR resName) | |
11 { | |
12 HINSTANCE winResInstance = winResGetInstance(resType, resName); | |
13 | |
14 HRSRC hRsrc = FindResourceEx(winResInstance, resType, resName, 0); | |
15 | |
16 if (hRsrc != NULL) | |
17 { | |
18 HGLOBAL hGlobal = LoadResource(winResInstance, hRsrc); | |
19 | |
20 if (hGlobal != NULL) | |
21 { | |
22 UCHAR *b = (UCHAR *)LockResource(hGlobal); | |
23 | |
24 return b; | |
25 } | |
26 } | |
27 return NULL; | |
28 } | |
29 | |
30 HMENU winResLoadMenu(LPCTSTR menuName) | |
31 { | |
32 UCHAR *b = winResGetResource(RT_MENU, menuName); | |
33 | |
34 if (b != NULL) | |
35 { | |
36 HMENU menu = LoadMenuIndirect((CONST MENUTEMPLATE *)b); | |
37 | |
38 if (menu != NULL) | |
39 return menu; | |
40 } | |
41 | |
42 return LoadMenu(NULL, menuName); | |
43 } | |
44 | |
45 int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc, LPARAM lParam) | |
46 { | |
47 /* | |
48 UCHAR * b = winResGetResource(RT_DIALOG, boxName); | |
49 | |
50 if(b != NULL) { | |
51 | |
52 return DialogBoxIndirectParam(hInstance, | |
53 (LPCDLGTEMPLATE)b, | |
54 parent, | |
55 dlgProc, | |
56 lParam); | |
57 } | |
58 | |
59 return DialogBoxParam(hInstance, | |
60 boxName, | |
61 parent, | |
62 dlgProc, | |
63 lParam); | |
64 */ | |
65 return 0; | |
66 } | |
67 | |
68 int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc) | |
69 { | |
70 return winResDialogBox(boxName, | |
71 parent, | |
72 dlgProc, | |
73 0); | |
74 } | |
75 | |
76 CString winResLoadString(UINT id) | |
77 { | |
78 int stId = id / 16 + 1; | |
79 HINSTANCE inst = winResGetInstance(RT_STRING, MAKEINTRESOURCE(stId)); | |
80 | |
81 CString res; | |
82 if (!res.LoadString(id)) | |
83 { | |
84 // TODO: handle case where string is only in the default English | |
85 res = ""; | |
86 } | |
87 | |
88 res.Replace('_', '|'); | |
89 | |
90 return res; | |
91 } | |
92 | |
93 CString winResLoadFilter(UINT id) | |
94 { | |
95 CString res = winResLoadString(id); | |
96 res.Replace('_', '|'); | |
97 | |
98 return res; | |
99 } |