Thread overview
Re: Programming Windows D Examples are now Online!
Jun 21, 2011
Brad Anderson
Jun 21, 2011
Walter Bright
Jul 09, 2011
Sean Cavanaugh
Jun 21, 2011
zhang
Jun 21, 2011
Nick Sabalausky
Jun 21, 2011
Andrej Mitrovic
Jun 21, 2011
Andrej Mitrovic
Jun 21, 2011
Andrej Mitrovic
Dec 16, 2011
Andrej Mitrovic
June 21, 2011
On Mon, Jun 20, 2011 at 10:14 PM, Andrej Mitrovic < andrej.mitrovich@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).


June 21, 2011
On 6/21/11 1:08 AM, Brad Anderson wrote:
> On Mon, Jun 20, 2011 at 10:14 PM, Andrej Mitrovic
> <andrej.mitrovich@gmail.com <mailto:andrej.mitrovich@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).

There are comparisons I love to lose.

Andrei
June 21, 2011
That's great!
I'm porting the Scintilla which is an editor library. I think I can get benefit from your works greatly.
----------
Zhang <bitworld@qq.com>


June 21, 2011
I completey forgot about single-project compilation yesterday.

I've pushed a new changeset which allows you to build each project alone by CD-ing to the directory and building, e.g.:

$ cd "C:\Documents and Settings\Andrej\Desktop\WinAPI\Samples\Chap01\HelloMsg" $ rdmd ..\..\..\build.d "%cd%"

The quotes are important for CD in order for paths with spaces to work. The build script will warn you if you passed an incorrect path though. :)
June 21, 2011
On 6/21/11, zhang <bitworld@qq.com> wrote:
> That's great!
> I'm porting the Scintilla which is an editor library. I think I can get
> benefit from your works greatly.
> ----------
> Zhang <bitworld@qq.com>
>
>
>

Nice! Btw, I have DSciteWin in my projects too:
https://github.com/AndrejMitrovic/dscitewin
But that simply uses the DLL via D.
June 21, 2011
On 6/21/11, zhang <bitworld@qq.com> wrote:
> That's great!
> I'm porting the Scintilla which is an editor library. I think I can get
> benefit from your works greatly.
> ----------
> Zhang <bitworld@qq.com>
>

Btw, I'd like to know more about this. Is it an open-source project? Will it be hosted somewhere? And what additions/changes are you planning to make in the D version?

I'm sure there's at least a couple of people interested in this, including me, and probably Nick too (I've seen him mention he wanted to do this if he had the time).
June 21, 2011
On 6/21/2011 7:06 AM, Andrei Alexandrescu wrote:
>> He's a great author. Code is
>> probably the most interesting technical book I've ever read (sorry, Andrei).
>
> There are comparisons I love to lose.

It's true. There's no shame in losing to Petzold!
June 21, 2011
"zhang" <bitworld@qq.com> wrote in message news:mailman.1072.1308669972.14074.digitalmars-d-announce@puremagic.com...
> That's great!
> I'm porting the Scintilla which is an editor library. I think I can get
> benefit from your works greatly.

That sounds great, I'd love to see the result when you're done. I've wanted to make some modifications to Scintilla, but I didn't really feel like dealing with C/C++.


July 09, 2011
On 6/21/2011 1:08 AM, Brad Anderson wrote:
> On Mon, Jun 20, 2011 at 10:14 PM, Andrej Mitrovic
> <andrej.mitrovich@gmail.com <mailto:andrej.mitrovich@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


December 16, 2011
On 6/21/11, Andrej Mitrovic <andrej.mitrovich@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/DWinProgramming
>
> 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*
>

Update: The cool news is that most samples now build via GDC, you will
need to download the latest GDC (there's a new one from a few hours
ago), from:
https://bitbucket.org/goshawk/gdc/downloads
(tested with https://bitbucket.org/goshawk/gdc/downloads/gcc-4.6.1-tdm-1-gdc-7e22befef29c-20111215.7z).
You will also need to install Perl (GDMD is still a perl script) and
copy the gdmd.bat batch file to GDC's bin dir.

There's also a couple of new samples unrelated to the book.