1
2
3
4 package org.sirius.server.win32.classes;
5
6 import javax.jws.WebService;
7
8 import org.sirius.server.win32.constants.IMenuFlag;
9 import org.sirius.server.win32.constants.IWMConsts;
10 import org.sirius.server.win32.core.types.WinDefExt.MENUINFO;
11 import org.sirius.server.win32.core.types.WinDefExt.MENUITEMINFO;
12
13 import com.sun.jna.Pointer;
14 import com.sun.jna.platform.win32.WinDef;
15
16
17
18
19
20 @WebService
21 public class Menu extends Common implements IMenuFlag, IWMConsts, WinDef {
22
23
24
25
26 public Menu() {
27
28 }
29
30
31
32
33
34
35
36
37 public final int getMenuDefaultItem(final long hMenu, final int fByPos,
38 final int gmdiFlags) {
39 HMENU handle = longToHmenu(hMenu);
40 return getUser32().GetMenuDefaultItem(handle, fByPos, gmdiFlags);
41 }
42
43
44
45
46
47
48
49 public final boolean getMenuInfo(final long hmenu, final MENUINFO lpcmi) {
50 HMENU handle = longToHmenu(hmenu);
51 return getUser32().GetMenuInfo(handle, lpcmi);
52 }
53
54
55
56
57
58
59 public final int getMenuItemCount(final long hMenu) {
60 HMENU handle = longToHmenu(hMenu);
61 return getUser32().GetMenuItemCount(handle);
62 }
63
64
65
66
67
68
69
70 public final int getMenuItemID(final long hMenu, final int nPos) {
71 HMENU handle = longToHmenu(hMenu);
72 return getUser32().GetMenuItemID(handle, nPos);
73 }
74
75
76
77
78
79
80
81
82
83 public final boolean getMenuItemInfo(final long hMenu, final int uItem,
84 final boolean fByPosition, final MENUITEMINFO lpmii) {
85 HMENU handle = longToHmenu(hMenu);
86 return getUser32().GetMenuItemInfo(handle, uItem, fByPosition, lpmii);
87 }
88
89
90
91
92
93
94
95
96
97 public final boolean getMenuItemRect(final long hWnd, final long hMenu,
98 final int uItem, final RECT rect) {
99 HWND handle = longToHwnd(hWnd);
100 HMENU menuHandle = longToHmenu(hMenu);
101 return getUser32().GetMenuItemRect(handle, menuHandle, uItem, rect);
102 }
103
104
105
106
107
108
109
110
111 public final int getMenuState(
112 final long hMenu,
113 final int uId,
114 final int uFlags) {
115 HMENU handle = longToHmenu(hMenu);
116 return getUser32().GetMenuState(handle, uId, uFlags);
117 }
118
119
120
121
122
123
124
125
126
127
128 public final int getMenuString(
129 final long hMenu,
130 final int uIDItem,
131 final char[] lpString,
132 final int nMaxCount,
133 final int uFlag) {
134 HMENU handle = longToHmenu(hMenu);
135 return getUser32()
136 .GetMenuString(handle, uIDItem, lpString, nMaxCount, uFlag);
137 }
138
139
140
141
142
143
144
145 public final long getSubMenu(final long hMenu, final int nPos) {
146 HMENU handle = longToHmenu(hMenu);
147 return Pointer
148 .nativeValue(getUser32().GetSubMenu(handle, nPos).getPointer());
149 }
150
151
152
153
154
155
156 public final boolean isMenu(final long hMenu) {
157 HMENU handle = longToHmenu(hMenu);
158 return getUser32().IsMenu(handle);
159 }
160
161
162
163
164
165
166
167
168 public final boolean pickItem(
169 final long hwnd,
170 final long hMenu,
171 final int iPos) {
172 int count = getMenuItemCount(hMenu);
173 if (count < iPos) {
174 return false;
175 }
176
177 HWND handle = longToHwnd(hwnd);
178
179 WPARAM wParam = new WPARAM();
180 LPARAM lParam = new LPARAM();
181 int id = getMenuItemID(hMenu, iPos);
182
183 wParam.setValue(id);
184 lParam.setValue(0);
185
186 getUser32().PostMessage(handle, WM_COMMAND, wParam, lParam);
187
188 return true;
189 }
190 }