source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/HandlerCreate.java @ 922

Last change on this file since 922 was 922, checked in by sherbold, 12 years ago
  • renaming of packages from de.ugoe.cs.quest to de.ugoe.cs.autoquest
File size: 3.0 KB
Line 
1package de.ugoe.cs.autoquest.plugin.mfc;
2
3import de.ugoe.cs.autoquest.plugin.mfc.guimodel.WindowTree;
4
5/**
6 * <p>
7 * Message handler for {@code WM_CREATE} messages. The handler maintains the {@link WindowTree}.
8 * </p>
9 *
10 * @author Steffen Herbold
11 * @version 1.0
12 */
13public class HandlerCreate extends MessageHandler {
14
15    /**
16     * <p>
17     * Constructor. Creates a new HandlerCreate.
18     * </p>
19     *
20     * @param windowTree the tree of GUI element specifications to be created and adapted during
21     *                   parsing
22     */
23    public HandlerCreate(WindowTree windowTree) {
24        super(windowTree);
25    }
26
27    /**
28     * <p>
29     * Name of the created window.
30     * </p>
31     */
32    private String windowName;
33
34    /**
35     * <p>
36     * HWND of the created window.
37     * </p>
38     */
39    private long hwnd;
40
41    /**
42     * <p>
43     * HWND of the created window's parent.
44     * </p>
45     */
46    private long parentHwnd;
47
48    /**
49     * <p>
50     * Resource Id of the created window.
51     * </p>
52     */
53    private int resourceId;
54
55    /**
56     * <p>
57     * Window class of the created window.
58     * </p>
59     */
60    private String className;
61
62    /**
63     * <p>
64     * Modality of the created window.
65     * </p>
66     */
67    private boolean isModal;
68
69    /*
70     * (non-Javadoc)
71     *
72     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onEndElement()
73     */
74    @Override
75    public void onEndElement() {
76        if (hwnd != 0) {
77            super.getWindowTree().add(parentHwnd, hwnd, windowName, resourceId, className, isModal);
78        }
79    }
80
81    /*
82     * (non-Javadoc)
83     *
84     * @see de.ugoe.cs.autoquest.plugin.mfc.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 = Long.parseLong(value);
91        }
92        else if (name.equals("window.name")) {
93            windowName = value;
94        }
95        else if (name.equals("window.parent.hwnd")) {
96            parentHwnd = Long.parseLong(value);
97        }
98        else if (name.equals("window.resourceId")) {
99            resourceId = Integer.parseInt(value);
100        }
101        else if (name.equals("window.class")) {
102            if (value.startsWith("Afx:")) {
103                className = "Afx:";
104            }
105            else {
106                className = value;
107            }
108        }
109        else if (name.equals("window.ismodal")) {
110            if (value.equals("true") || value.equals("1")) {
111                isModal = true;
112            }
113        }
114    }
115
116    /*
117     * (non-Javadoc)
118     *
119     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onStartElement()
120     */
121    @Override
122    public void onStartElement() {
123        windowName = "";
124        hwnd = 0;
125        parentHwnd = 0;
126        resourceId = 0;
127        className = "";
128        isModal = false;
129    }
130
131}
Note: See TracBrowser for help on using the repository browser.