summaryrefslogtreecommitdiff
path: root/src/msvc6/testrunner/DynamicWindow/doc/cdxCDynamicWnd-DOC.html
blob: 6b5798ff72a2b28a83b525b861f123848a184cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title></title>

<style type="text/css">
body,td /* p,h1,h2,h3,h4,ul,ol,li,div,td,th,address,a,blockquote,nobr,b,i,em */
{
   font-size:13px;
   font-family:sans-serif,arial,Verdana;
}

small  { font-size=11px; }
.small { font-size=11px; }

h1 { font-size:16px; }
h2 { font-size:16px;color:#FF0000; }
h3 { font-size:15px; }
h4 { font-size:15px;color:#FF0000; }
h5 { font-size:14px;font-weight:bold; }
h6 { font-size:14px;color:#FF0000;font-weight:bold; }

a:link    { color:#800000;text-decoration:none; }
a:visited { color:#BF0000;text-decoration:none; }
a:active  { color:#0000C0;text-decoration:none; }
a:hover   { color:#0000C0;text-decoration:underline; }

</style>

</head>

<body bgcolor="#FFFFFF">

<h2 align="center"><a name="top"></a></h2>

<h2 align="center"><font color="#00000A">cdxCDynamicWnd and
derived classes<br>
</font><font color="#00000A" size="2">by Hans Bühler : codex
design</font></h2>

<h2 align="center"><font color="#00000A">documentation</font></h2>
<!-- Author and contact details -->
<p align="center"><small>[ <a href="#p1">preface</a> | <a href="#p2">about</a> | <a href="#p3">techniques</a>
| <a href="#p4">a <i>dynamic</i>&nbsp;dialog</a> | <a href="#p5">finally</a></small><small>
]</small></p>

<h3><a name="p1">1 | Preface, Definition</a></h3>

<blockquote>
    <p><u>Definiton:</u><br>
    A <em>dynamic</em> window is a window that automatically
    repositions its child controls when its size changes.<br>
    The opposite behaviour is called <em>static.</em></p>
    <p>The classes described here will help you implementing <em>dynamic</em>&nbsp;dialogs,
    formviews, property sheets and control bars.</p>
    <p>It replaces my former class tree &quot;cdxCSizingDialog, ...&quot;.</p>
</blockquote>

<h3><a name="p2">2 | About this document</a></h3>

<blockquote>
    <p>Since I found out that not many of you seem to like
    reading documentation, I shortened this documentation.<br>
    If you have any suggestions, problems or questions that are
    not covered by this text, feel free to write an <a
    href="mailto:Hans%20Buehler%20%3chans.buehler@topmail.de%3e">email
    to me</a>.</p>
    <p>As a result, I won't discuss all my member functions but
    will give you a quick introduction in making windows dynamic.<br>
    The basic example will be a dialog.<br>
    The technique is nearly the same for property sheets,
    formviews and control bars.</p>
    <p>Here it is:</p>
    <blockquote>
        <p><img src="cdxCDynamicWnd-DOC-small.gif" width="188"
        height="192" alt="small window"><br>
        (picture#1)</p>
    </blockquote>
</blockquote>

<blockquote>
    <p>We want to make it <em>dynamic</em>&nbsp;i.e. it should
    look like this if you change its size:</p>
    <blockquote>
        <p><img src="cdxCDynamicWnd-DOC-big.gif" width="320"
        height="229" alt="big window"><br>
        (picture #2)</p>
    </blockquote>
</blockquote>

<h3><a name="p3">3 | Techniques</a></h3>

<blockquote>
  <p>The cdxCDynamicWnd class is a base class of all the ready-to-use classes as
  cdxCDynamicDialog.<br>
  To implement the resizing code, you need to tell the cdxCDynamicWnd object,
  which of your child controls should react on a resizing of your windows and
  how.</p>

  <p>To do so, there are now two techniques:</p>

  <ul>
    <li><u>Using AddSzControl():<br>
      </u>As you may know from my former cdxCSizing... classes, you use one of
      the AddSzControl() overloads to make the dynamic window known to a child
      window of it.<br>
      In the upper example window, you would add the following lines to your
      OnInitDialog() code:</li>
  </ul>
  <blockquote>
    <blockquote>
      <blockquote>
        <p><code><font color="#008000">AddSzControl(IDC_BOX_1,mdResize,mdResize);<br>
        AddSzControl(IDC_LIST,mdResize,mdResize);<br>
        AddSzControl(IDC_EDIT,mdResize,mdRepos);<br>
        AddSzControl(IDC_NEW,mdRepos,mdRepos);<br>
        AddSzControl(IDOK,mdRelative,mdRepos);<br>
        AddSzControl(IDCANCEL,mdRelative,mdRepos);</font></code></p>
      </blockquote>
    </blockquote>
    <ul>
      <li>The first argument is the ID of the child control to make known to the
        dynamic window (note that we do not assign IDC_CHECKBOX since this
        control does not need to react on changes to the window's size).</li>
      </ul><ul>      <li>The second argument defines how the control should be treated if the
        window's width changes,<br>
        The third defines how to deal with height-changes:<br>
        You can choose among the following constants:<br>
        - mdNone (do nothing)<br>
        - mdRepos (move to left)<br>
        - mdResize (resize)<br>
        - mdRelative (keep relative position; e.g. keep centered if control was
        centered before)</li>
    </ul>
    <p>Among others, the following overloads of AddSzControl() are defined (the <i>wnd</i>
    parameter might be either an ID or a HWND object while a CWnd casts properly
    to a HWND):</p>
    <blockquote>
      <blockquote>
        <p><code><font color="#008000">AddSzControl(wnd, Mode mdX, Mode mdY);<br>
        AddSzXControl(wnd, Mode md);<br>
        AddSzYControl(hwnd, Mode md);</font></code></p>
      </blockquote>
    </blockquote>
    <p>If you are not satisfied with my predefined modes, you can make your own:<br>
    The following overload takes two bytes for each direction: They defined how
    much percent of the change in width should be added to the left side of the
    the child control (<i>x1</i>) and to the right side (<i>x2</i>) (equally for
    height changes):</p>
    <blockquote>
      <blockquote>
        <p><font color="#008000"><code>AddSzControl(wnd, SBYTE x1, SBYTE y1, SBYTE x2, SBYTE y2);</code><br>
        <code>AddSzXControl(wnd, SBYTE x1, SBYTE x2);<br>
        AddSzYControl(wnd, SBYTE y1, SBYTE y2);
        </code></font></p>
        <p>My predefined modes have the following values:<br>
        - mdNone is (<i>x1=</i>0,<i>x2=</i>0)<br>
        - mdRepos is (100,100)<br>
        - mdResize is (0,100)<br>
        - mdRelative is (50,50)</p>
      </blockquote>
    </blockquote>
    <p>Depending on the base class you use the following functions are suitable
    places to call AddSzControl():</p>
    <ul>
      <li>Dialog: OnInitDialog()</li>
      <li>FormView: OnInitialUpdate()</li>
      <li>PropPage: OnInitDialog()</li>
    </ul>
  </blockquote>
  <ul>
    <li><u>Using my new <i>dynamic maps</i>:<br>
      </u>Some people noted that it is annoying to use the AddSzControl() method
      since they don't need OnInitDialog() for example - only for the
      AddSzControl() code.<br>
      Therefore I added the <i>dynamic maps</i>&nbsp;feature.<br>
      To use it, add the line DECLARE_DYNAMIC_MAP() to your class definition,
      and add something like:</li>
  </ul>
  <blockquote>
    <blockquote>
      <p><code><font color="#008000">BEGIN_DYNAMIC_MAP(CTestDlg,cdxCDynamicDialog)<br>
      &nbsp;&nbsp;&nbsp; DYNAMIC_MAP_ENTRY(IDC_BOX_1, mdResize, mdResize)<br>
      &nbsp;&nbsp;&nbsp; DYNAMIC_MAP_ENTRY(IDC_LIST1, mdResize, mdResize)<br>
      &nbsp;&nbsp;&nbsp; DYNAMIC_MAP_ENTRY(IDC_EDIT, mdResize, mdRepos)<br>
      &nbsp;&nbsp;&nbsp; DYNAMIC_MAP_ENTRY(IDC_NEW, mdRepos, mdRepos)<br>
      &nbsp;&nbsp;&nbsp; DYNAMIC_MAP_ENTRY(IDOK, mdRelative, mdRepos)<br>
      &nbsp;&nbsp;&nbsp; DYNAMIC_MAP_ENTRY(IDCANCEL, mdRelative, mdRepos)<br>
      END_DYNAMIC_MAP()</font></code></p>
    </blockquote>
    <p>If you compare these lines to the above AddSzControl() statements, you'll
    note that they act similarily.<br>
    The following macros are defined:</p>
    <blockquote>
      <p><code><font color="#008000">DYNAMIC_MAP_ENTRY(ID,MODEX,MODEY)<br>
      DYNAMIC_MAP_XENTRY(ID,MODEX)<br>
      DYNAMIC_MAP_YENTRY(ID,MODEY)</font></code></p>
      <p><code><font color="#008000">DYNAMIC_MAP_ENTRY_EX(ID,X1,Y1,X2,Y2)<br>
	DYNAMIC_MAP_XENTRY_EX(ID,X1,X2)<br>
      DYNAMIC_MAP_YENTRY_EX(ID,Y1,Y2)</font></code></p>
    </blockquote>
  </blockquote>
</blockquote>

<h3><a name="p4">4 | Example: How to create a <em>dynamic</em> dialog</a></h3>

<blockquote>
    <ol>
        <li><u>A dialog:</u><br>
            I suggest that you used your dialog resource editor
            to design a dialog as shown in picture #1.<br>
            The names of the controls should indicate their
            control IDs.<br>
          <i><u>Important note #1:</u>
            Every control that should dynamically move need a
            unique ID (=&gt; it is not possible to move static
            texts with IDC_STATIC).</i><strong>
            <br>
            </strong>Moreoever, I assume that you have created a
            dialog class called &quot;CTestDlg&quot; for this
            dialog.<br>
          <br>
            </li>
        <li><u>Resizable border and WS_CLIPCHILDREN for your dialog:<br>
            </u>Please open your dialog's properties (in the
            resource editor), go to the tab &quot;Styles&quot;
            and change the &quot;Border&quot; into &quot;resizing&quot;
            (otherwise use won't be able to resize your dialog
            although it might be dynamic by code).<br>
          Then, switch to the first tab and activate &quot;clip children&quot;.<br>
          <br>
          <b>NOTE</b>: If &quot;clip children&quot; is on and you use <u>group
          boxes</u>, these boxes need the WS_EX_TRANSPARENT style (can be found
          at the &quot;extended styles&quot; tab of the group box).<br>
          This is not a problem with these classes but with the MFC at all !<br>
          <br>
            </li>
        <li><u>Changing the base-class of your dialog:</u><br>
            Open your dialog classes header file, add an<br>
            #include &quot;cdxCDynamicDialog.h&quot;<br>
            to its head and replace <i> all</i> &quot;CDialog&quot; by
            &quot;cdxCDynamicDialog&quot; in both your header and
            implementation file.<br>
          <br>
            </li>
        <li><u>Define how childs should be moved:<br>
            </u>Since this release, you can choose among the two techniques
          described above to implement this behaviour (they can
            be mixed if you need that).<br>
          <br>
          See <a href="#p3">above</a> to learn how to do so.<br>
          <br>
        </li>
        <li><u>Compile and run.<br>
          <br>
          </u>
        </li>
        <li>Open your constructor and try to add&nbsp;<code>
          <font color="#008000">
          ModifyFlags(flSWPCopyBits,0)</font>&nbsp;</code> to your code.<br>
          This is an anti-flickering option which does not work with all
          childconstrols, unfortunately - thus you may need to disable it one
          time.<br>
        </li>
    </ol>
    <p>Once your code runs, you can modify the behaviour of your class in many
    ways.</p>
    <p>The options you may want to make use of are:</p>
    <ul>
      <li>Disabling the size icon.</li>
      <li>Setting a window's minimum and maximum size.</li>
      <li>Advanced anti-flickering.</li>
      <li>Advanced AddSzControl() code.</li>
      <li>Virtual functions that you may like to overload for a more
        sofisticated <i>dynamic</i> reaction.</li>
      <li>Default resizing values and many more...</li>
    </ul>
    <p>
    Check the flags, available to you, check functions and if you don't make it
    work, <a href="mailto:hans.buehler@topmail.de">drop a note to me</a>.</p>
</blockquote>

<h3><a name="p5">5 | </a><a name="p2">Finally</a></h3>
<blockquote>
  <p>The classes described in this document have been written by</p>
  <blockquote>
    <p>Hans Bühler, codex design (w)1997 - 2000<br>
    <a href="mailto:hans.buehler@topmail.de">hans.buehler@topmail.de</a></p>
  </blockquote>
  <p>You are free to use and modify the code and the classes but I would like
  you to note the author (that's me :) in your product's documentation at any
  place, if possible.<br>
  You use this code at your own risk.<br>
  Any damange caused by the use or misuse of this code is the sole
  responsibility of the user.</p>
  <p align="center"><small>[ back to <a href="#top">top</a>  of this document ]</small></p>
</blockquote>

</body>
</html>