Programming Windows D Examples are now Online!
Sean Cavanaugh
WorksOnMyMachine at gmail.com
Sat Jul 9 15:36:28 PDT 2011
On 6/21/2011 1:08 AM, Brad Anderson wrote:
> On Mon, Jun 20, 2011 at 10:14 PM, Andrej Mitrovic
> <andrej.mitrovich at gmail.com <mailto:andrej.mitrovich at gmail.com>> wrote:
>
> This is a translation project of Charles Petzold's Programming Windows
> (5th edition) book code samples.
>
> Currently over 120 code samples have been translated into D, with only
> a few modules remaining.
>
> Everything else you need to know is in the Readme file:
> https://github.com/AndrejMitrovic/DWindowsProgramming
>
> The examples were tested on fresh installs of XP and Win7 with the
> only dependency being DMD v2.053 and an NT operating system. I hope
> everyone will be able to build these examples without too much
> trouble. *crosses fingers*
>
>
>
> Awesome. If only I hadn't sold my copy a month ago :(. It's great that
> Petzold was OK with you doing this. He's a great author. Code is
> probably the most interesting technical book I've ever read (sorry, Andrei).
I had ported a subset of the WTL functionality over to D for a personal
project. This primarily consists of a D version of port of atlcrack.h
for creating a message map for an HWND wrapped class, and some template
mixins to hook up the message map to a class.
The WTL uses the curiously recurring template design, and D can do the
same thing, but is also able to use mixins which makes things a lot more
flexible.
The message handlers and bindings a bulk of the annoying work, so while
my 'DWindow' class was only filled in just enough to function for my
app, filling out Win32 API calls as needed is pretty trivial, compared
to making all the message handlers typesafe and extract their arguments
properly.
I am not working on this at the moment but it would be a good starting
point especially if you are working with GDI directly. I am also still
quite new to D so style or alternative techniques available in the
language might have been overlooked.
Message cracking and handler binding helpers (dwindowmessages.d):
http://codepad.org/0ApNSvas
Simple 'DWindow' and MSG class and aliases (dwindow.d)
http://codepad.org/Q4Flyanw
A 'GameWindow' class with a bunch of message handlers hooked up
correctly, and the message pump.
http://codepad.org/JJpfqE7a
win32fix.d, stuff that should be in the win32 bindings on the bindings
web site but isn't (I was using rawinput for the mouse which is rather
esoteric to most programmers). They are also missing from the Microsoft
C/C++ headers, they are that obscure :)
http://codepad.org/xA18pGEX
More information about the Digitalmars-d-announce
mailing list