-
Notifications
You must be signed in to change notification settings - Fork 9
/
examples.txt
261 lines (228 loc) · 14.8 KB
/
examples.txt
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
== List of Examples and their Description ==
Note: These samples are described alphabetically, but they might appear in a different order
in the book.
Chap01:
HelloMsg - Creates a simple Dialog Box without a window.
Chap02:
ScrnSize - Shows the screen dimensions in a dialog box.
Chap03:
HelloWin - Create a window class, spawn the window, display text on the screen
and load and play a wave file.
Chap04:
SysMets1 - Display various system metrics: screen dimensions, icon/cursor dimensions,
window sizes, etc.
SysMets2 - Same as above, but adds a scrollbar to view text that doesn't fit in the
window.
SysMets3 - Same as above, but makes the scrollbar smarter by making its size relative
to the contents of a text buffer.
Chap05:
AltWind - Draws points, lines, and rectangles on the screen. Also shows various fill modes.
Bezier - Draws bezier curves which can be dynamically changed with the left or right
mouse buttons.
Clover - Draws a complex Clover shape by using regions and combinations.
DevCaps1 - Displays capabilities of the drawing device (the display screen).
LineDemo - Draws lines, rectangles and ellipses layered on top of each other.
RandRect - Draws random rectangles (time pauses were added to avoid flicker).
SineWave - Draws a full phase of a sine wave.
WhatSize - Displays the size of the window, dynamically reflecting any changes.
Chap06:
KeyView1 - Dynamically displays pressed and released keys over time.
KeyView2 - Same as above, but selects the current system-default font when displaying.
StokFont - Displays an ASCII table in various default fonts. Use the scrollbars to cycle
drawing with different fonts.
SysMets4 - Same as SysMets3, but also enables scrolling via the up/down, pageup/pagedown
keys on the keyboard.
Typer - A simplistic text drawing program which displays text as it's inputted by the
user, and also responds to the delete, backspace, and tab keys.
Chap07:
BlokOut1 - Draws a filled rectangle in an area dynamically selected by the mouse.
BlokOut2 - Same as above, but also enables drawing even if the mouse is outside the
window area.
Checker1 - Draws rectangles and demonstrates a hitbox tracking method, where the
rectangle hit is drawn over with two diagonal lines.
Checker2 - Same as above, but also enables keyboard control which moves the mouse
cursor to the center of a rectangle.
Checker3 - Same as Checker1, but uses windows for each rectangle and makes a single
window class that handles the hitbox tracking logic.
Checker4 - Same as above, but enables keyboard control and draws a dotted rectangle
which marks the currently selected window by the keyboard.
Connect - Tracks mouse movement when the left button is pressed, stores the coordinates
and then draws lines connecting all the coordinates when the button is released.
SysMets - Same as SysMets4, but also enables scrolling with the mouse wheel.
Chap08:
Beeper1 - Uses a timer to flip between drawing the screen in red and blue colors.
Beeper2 - Same as above, but uses its own custom timer function.
Clock - Draws an analog-style clock which follows the system time.
DigClock - Draws a digital-style clock which follows the system time.
WhatClr - Displays the current color pointed to by the mouse cursor in hexadecimal.
Chap09:
BtnLook - Draws various types of buttons and receiving notification when
the buttons are pressed or when their states are cycled through.
Colors1 - Draws a rectangle filled with a color dynamically set by three scrollbars
which control the Red, Green and Blue values.
Environ - Lists all the Environment Variables in a list box. When a variable is selected,
its contents are also displayed.
head - A custom DOS-style file system browser controled by either the keyboard or the
mouse. Also displays the contents of each file when double-clicked or entered.
OwnDraw - Draws two custom buttons which, when clicked, change the size of the window.
PopPad1 - Instantiates the standard Windows Edit control.
Chap10:
IconDemo - Draws an icon resource which was compiled into the application.
MenuDemo - Instantiates a window with a menu defined from a resource file. Uses menu actions
to change the background color of the window.
NoPopups - Uses a menu which expands its options inline.
PoePoem - Loads and displays a text resource compiled into the application.
PoorMenu - Adds options in the system menu (accessible by clicking the icon in the top-left
corner of the application).
PopMenu - Displays popup submenus.
PopPad2 - Same as PopPad1 but also loads a menu with cut/copy/paste actions.
Chap11:
About1 - Displays a simple about dialog box.
About2 - Displays a dialog box which adds controls to change the background shape and color.
About3 - Displays custom shapes in a dialog box.
Colors2 - Same as Colors1, but places the scrollbars inside their own dialog box.
Colors3 - Instantiates a standard Windows color selection dialog box.
HexCalc - A hex calculator with buttons used for calculations. Can also control it with the
keyboard.
PopPad3 - An enhanced version of the PopPad2 editor, adding searching, file handling and
copy/paste functionality, as well as font selection.
Chap12:
ClipText - A simple clipboard viewer.
ClipView - A dynamic version of the above which automatically displays new clipboard contents.
Chap13 (Note: You can use a virtual printer driver such as CutePDF to print documents to a PDF file)
DevCaps2 - Uses menus to select between displaying various draw/print capable devices,
and their various functions and capabilities.
FormFeed - Feeds a form to a printer device.
PopPad - Same as PopPad3, but also adds printing functionality.
Print1 - Prints a customly drawn shape.
Print2 - Same as above, but adds option to abort printing.
Print3 - Same as Print1, but pops up a dialog box that shows the printing state (Note: this
dialog box closes pretty fast if you're using a virtual printer driver)
Chap14:
BitBlt - Bit-blits an icon loaded from a resource to the screen.
BitMask - Uses a mask to limit drawing an image to an eliptic area.
Blowup - Draws contents from the clipboard and resizes the image to the size of the window.
Bounce - Animates a ball that bounces to the corners of the window.
Bricks1 - Draws a small resource-loaded icon tiled seamlessly on the screen.
Bricks2 - Same as above, but this time draws the icon programmaticaly and then tiles it on the
screen.
Bricks3 - Creates a pattern brush out of a resource-loaded image. This has the added advantage
of avoiding flicker when resizing the window.
GrafMenu - Uses a graphical menu and also demonstrates custom item-selection drawing.
HelloBit - Draws text to a bitmap, and based on a menu item selection either stretches it
or draws it in a pattern and bit-blits it to the screen.
Scramble - Creates a snapshot of the entire screen, and then draws scrambled rectangle sections
for a few seconds.
Sketch - Draws black and white pixels on the screen based on the state of the left and right
mouse buttons.
Stretch - Uses the location of the system menu icon as the source to a bit-blit operation.
It stretches the icon of the system menu to the size of the window.
Chap15:
Apollo11 - Loads bitmap images from the disk and displays them in a window.
DibConv - Converts a Device Independent Bitmap (DIB) to a Device Dependent Bitmap (DDB)
and displays it on the screen.
DibHeads - Displays the header information of a bitmap file.
DibSect - Displays a bitmap in a window.
SeqDisp - Displays a bitmap sequentially, in a row-by-row fashion.
ShowDib1 - Loads and saves a bitmap.
ShowDib2 - Same as above, but adds menu options that can display the image in actual size,
centered, stretched to window, and stretched to window isotropically. Also adds
cut/copy/paste functionality.
Chap16:
The examples from this chapter have not been translated as they cover 8-bit displays,
which no-longer exist.
Chap17:
ChosFont - Displays Unicode text and a list of the currently selected font's properties.
EndJoin - Draws ends and joins of a path.
EZTest - Draws text in increasing sizes and shows its dimensions.
FontClip - Draws paths clipped to some text.
FontFill - Fills the inside of each character drawn.
FontOut1 - Draws an outline of a font's text.
FontOut2 - Same as above, but uses dotted lines instead.
FontRot - Draws text in several degrees rotated on an axis.
Justify1 - Draws left-aligned text with word wrapping functionality.
Justify2 - Draws text which, based on a menu option, can be aligned left, right, centered,
or stretched. The font can be selected.
PickFont - Shows numerous font options which can be used to manipulate how the font is drawn.
UniChars - Similar to Chap06/StokFont, but this time draws characters in a Unicode table.
Chap18:
Emf1 - Creates and displays an enhanced metafile (EMF).
Emf2 - Creates an enhanced metafile, saves it to disk, and then displays it.
Emf3 - Creates non-default pens and brushes and stores it to an EMF.
Emf4 - Draws a bitmap in a metafile device context.
Emf5 - Enumerates individual records of a metafile.
Emf6 - Copies and modifies metafile records before rendering them.
Emf7 - Embeds images into a metafile.
Emf8 - Accurately display a metafile with a proper aspect ratio by using
the sizing information in the header of the metafile.
Emf9 - Uses sizing information from a metafile header to both display the metafile
accurately on the screen, and correctly print it out.
Emf10 - Demonstrates scaling and aspect ratio handling of a metafile.
Emf11 - Uses mapping modes with metafiles.
Emf12 - Shows more usage of mapping modes.
Emf13 - Loads an existing metafile, and uses a mapping mode to calculate
the destionation rectangle.
EmfView - Saves and loads metafiles, and transfers them from and to the clipboard.
Metafile - Creates and shows an old-format metafile.
Chap19:
MDIDemo - Instantiates multiple windows within the main window, and adds options to
align the windows by side, cascade, or maximize. Can instantiate any number
of windows.
Chap20:
Note: C and D multithreaded programming differ in significant ways. These are not
typical examples of programming multithreaded D code, they use globally shared
variables to simulate the C examples.
Techniques such as message passing and thread pools should be used instead of
Windows multithreading API primitives.
Please take a look at the documentation of std.concurrency and std.parallelism for
a better demonstration of multithreaded programming in D.
BigJob1 - Spawns a work thread which does some processing. The foreground thread (which
spawned the work thread) can signal the work thread to stop processing by
changing the state of a global variable. The work load was increased by an
order of magnitude compared to the C example.
BigJob2 - Uses the Windows function WaitForSingleObject to wait for an object to be
signalled.
Multi1 - Creates 4 windows that each have separate window classes. This is a very
minimal form of multithreading, as Windows will attempt to automatically
load-balance the window classes on a multi-core system.
Multi2 - Similar to above, but this time each window class spawns its own work thread.
Based on your system this could significantly improve performance.
RndRctMT - A multithreaded version of Chap05\RandRect, which draws random rectangles
on the screen.
Chap21:
At the time of writing there are various bugs with using D DLLs.
Some of these examples use workarounds to make them compilable.
EdrTest - Implicitly loads a DLL, calls its custom drawing function which draws some
text on the screen.
ShowBit - Explicitly loads a DLL and draws image resources from the DLL.
StrProg - Implicitly loads a DLL which internally stores a list of strings (implemented
as a hash of strings), and which provides functions to add or remove strings.
The application provides menus that allow the user to add or remove strings.
Chap22:
AddSynth - Generates various sound forms, stores them to a file, loads them back and
adds an interface so the user can play them back.
BachTocc - Plays a programmatically generated MIDI sequence.
Drum - A sequencer which has a table interface where the user can activate notes,
change the tempo and volume, and save and load patterns in RIFF format.
KBMidi - Converts PC keyboard key presses into MIDI notes, and plays them back
via the sound card (Make sure to select Status\Open first).
SineWave - Plays back a sinewave at a specific frequency. The frequency can be manipulated
with a horizontal scrollbar.
TestMci - Sends and recieves Media Control Interface (MCI) commands. (Try typing in
"open cdaudio" without the quotes and press enter. Some other commands are:
play cdaudio, pause cdaudio, stop cdaudio, status cdaudio position,
status cdaudio time format).
WakeUp - Generates a pulsating waveform which is used as the sound of an alarm clock.
The alarm clock can be set and the user can wait for the alarm to be set off.
Chap23:
NetTime - Retrieves timing information from various selectable timing servers.
@BUG@: Currently this example doesn't seem to succesfully retrieve any
timing info. The C example doesn't work either.
Extra:
These examples are not part of the book, but custom-made examples to demonstrate some
other parts of the API or some aspect of GDI not covered in the book.
BackBuffer - Uses a simple back-buffer double-buffering mechanism to draw on the screen
without flicker.
Cartesian - Demonstrates how to use a custom coordinate system via GDI. By flipping
the Y axis we get the standard cartesian coordinate system.
More info found here: http://www.functionx.com/visualc/gdi/gdicoord.htm