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