1 | package de.ugoe.cs.eventbench.windows;
|
---|
2 |
|
---|
3 | import de.ugoe.cs.eventbench.windows.data.WindowTree;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * <p>
|
---|
7 | * Message handler for {@code WM_CREATE} messages. The handler maintains the
|
---|
8 | * {@link WindowTree}.
|
---|
9 | * </p>
|
---|
10 | *
|
---|
11 | * @author Steffen Herbold
|
---|
12 | * @version 1.0
|
---|
13 | */
|
---|
14 | public class HandlerCreate extends MessageHandler {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * <p>
|
---|
18 | * Constructor. Creates a new HandlerCreate.
|
---|
19 | * </p>
|
---|
20 | */
|
---|
21 | public HandlerCreate() {
|
---|
22 | super();
|
---|
23 | }
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * <p>
|
---|
27 | * Name of the created window.
|
---|
28 | * </p>
|
---|
29 | */
|
---|
30 | private String windowName;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * <p>
|
---|
34 | * HWND of the created window.
|
---|
35 | * </p>
|
---|
36 | */
|
---|
37 | private int hwnd;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * <p>
|
---|
41 | * HWND of the created window's parent.
|
---|
42 | * </p>
|
---|
43 | */
|
---|
44 | private int parentHwnd;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * <p>
|
---|
48 | * Resource Id of the created window.
|
---|
49 | * </p>
|
---|
50 | */
|
---|
51 | private int resourceId;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * <p>
|
---|
55 | * Window class of the created window.
|
---|
56 | * </p>
|
---|
57 | */
|
---|
58 | private String className;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * <p>
|
---|
62 | * Modality of the created window.
|
---|
63 | * </p>
|
---|
64 | */
|
---|
65 | private boolean isModal;
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * (non-Javadoc)
|
---|
69 | *
|
---|
70 | * @see de.ugoe.cs.eventbench.windows.MessageHandler#onEndElement()
|
---|
71 | */
|
---|
72 | @Override
|
---|
73 | public void onEndElement() {
|
---|
74 | if (hwnd != 0) {
|
---|
75 | WindowTree.getInstance().add(parentHwnd, hwnd, windowName,
|
---|
76 | resourceId, className, isModal);
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * (non-Javadoc)
|
---|
82 | *
|
---|
83 | * @see
|
---|
84 | * de.ugoe.cs.eventbench.windows.MessageHandler#onParameter(java.lang.String
|
---|
85 | * , java.lang.String)
|
---|
86 | */
|
---|
87 | @Override
|
---|
88 | public void onParameter(String name, String value) {
|
---|
89 | if (name.equals("window.hwnd")) {
|
---|
90 | hwnd = Integer.parseInt(value);
|
---|
91 | } else if (name.equals("window.name")) {
|
---|
92 | windowName = value;
|
---|
93 | } else if (name.equals("window.parent.hwnd")) {
|
---|
94 | parentHwnd = Integer.parseInt(value);
|
---|
95 | } else if (name.equals("window.resourceId")) {
|
---|
96 | resourceId = Integer.parseInt(value);
|
---|
97 | } else if (name.equals("window.class")) {
|
---|
98 | if (value.startsWith("Afx:")) {
|
---|
99 | className = "Afx:";
|
---|
100 | } else {
|
---|
101 | className = value;
|
---|
102 | }
|
---|
103 | } else if (name.equals("window.ismodal")) {
|
---|
104 | if (value.equals("true") || value.equals("1")) {
|
---|
105 | isModal = true;
|
---|
106 | }
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * (non-Javadoc)
|
---|
112 | *
|
---|
113 | * @see de.ugoe.cs.eventbench.windows.MessageHandler#onStartElement()
|
---|
114 | */
|
---|
115 | @Override
|
---|
116 | public void onStartElement() {
|
---|
117 | windowName = "";
|
---|
118 | hwnd = 0;
|
---|
119 | parentHwnd = 0;
|
---|
120 | resourceId = 0;
|
---|
121 | className = "";
|
---|
122 | isModal = false;
|
---|
123 | }
|
---|
124 |
|
---|
125 | }
|
---|