Giter Site home page Giter Site logo

dwinprogramming's Introduction

DWinProgramming - D WinAPI programming

This is a collection of samples from Charles Petzold's Programming Windows book, translated into the D programming language. It also contains a small collection of other Windows API samples.

See examples.txt for a description of the samples.

This project has been created by Andrej Mitrovic. Project Homepage: https://github.com/AndrejMitrovic/DWinProgramming

Building Requirements

  • Windows XP or newer.
  • Compiler: DMD v2.065 or GDC 2.065.

Building

Compile the build script:

$ make_build.bat

And then to build all samples via DMD call:

$ build.exe

Alternatively to build all the samples via GDC call:

$ build.exe GDC

Note: Building all samples is quite slow with GDC at the moment.

To build only a single example, CD to its directory and run:

$ ..\..\..\build.exe filename.d (filename being the main file)

Other options are: clean, debug.

Useful Scripts

  • Use dbg.bat to quickly invoke the ddbg debugger on an executable. ('dbg main.exe')
  • Use gdmd.bat to invoke the GDMD perl script. ('gdmd main.d -ofmain.exe')
  • Use where.bat to find out the location of an exe/batch file. ('where dmd')

Optional Tools

  • HTOD: http://www.digitalmars.com/d/2.0/htod.html HTOD needs to be in your PATH. It's probably best to put it in the \DMD2\Windows\Bin directory.

  • Microsoft RC compiler and header files. Without these the build script will use precompiled .res files.

    Note: This is a big download, depending on what you select in the setup. Note: DigitalMars has a resource compiler, but it still requires header files. See the "Using Resources in D" Tutorial in the Links section.

    • Create the RCINCLUDES environment variable and add paths to the header files needed by the RC resource compiler. On an XP system these paths could be: C:\Program Files\Microsoft SDKs\Windows\v7.1\Include C:\Program Files\Microsoft Visual Studio 10.0\VC\include C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include

      Typically the include paths for resource header files are different on each system, so you will have to adjust these.

    Note: The build script will attempt to find these default paths if you don't have RCINCLUDES already set up. Note: Setting up an environment variable might require you to log off and log on again before the build script can pick up the new changes.

  • The uncrustify executable bundled with UniversalIndentGUI could be outdated compared to the latest Uncrustify version. Please see the Uncrustify homepage in the Links section in this Readme to get the latest binary or to compile from source.

Contact

Please do not e-mail Charles Petzold about bugs in these examples, any bugs in these samples are entirely my fault. File bugs here: https://github.com/AndrejMitrovic/DWinProgramming/issues

Acknowledgments

Thanks to the authors of the WindowsAPI translation project: http://dsource.org/projects/bindings/wiki/WindowsApi

Big Thanks to Charles Petzold for writing a great Windows API programming book and for allowing me to host these code samples online.

Contributors

Simen Endsjø tested the project on an x64 Win7 system and found several issues. Leonardo Maffi created a Python script that got rid of stray parens.

Thanks goes out to all contributors.

Licensing

All code examples copyright belongs to Charles Petzold. Also see the answer to the 3rd question here: http://www.charlespetzold.com/faq.html

Links

D2 Programming Language Homepage: http://d-programming-language.org/

Code samples of using Win32 API and Cairo: https://github.com/AndrejMitrovic/cairoDSamples

How to make extensionless files open in your editor in WinXP: http://perishablepress.com/press/2006/08/08/associate-extensionless-files-with-notepad/ Note: Also, make sure you hit the 'Open with' button and select your editor.

How to make extensionless files open in your editor in Windows 7 and Windows 8 (and probably XP): Run this in the command prompt: assoc .="No Extension" ftype "No Extension"="C:\path\to\your editor.exe" "%1" Also see http://superuser.com/a/13947/47065

Programming Windows Homepage: http://www.charlespetzold.com/pw5/

Programming Windows C Code Samples: http://www.charlespetzold.com/books.html (search for ProgWin5.zip)

Charles Petzold FAQ: http://www.charlespetzold.com/faq.html

Programming Windows Errata #1: http://www.computersciencelab.com/PetzoldErrata.htm

Programming Windows Errata #2: http://www.jasondoucette.com/books/pw5/pw5errata.html

MSDN GDI page: http://msdn.microsoft.com/en-us/library/dd145203%28v=vs.85%29.aspx

MSDN list of Windows APIs: http://msdn.microsoft.com/en-us/library/ff818516.aspx

Windows API bindings: http://dsource.org/projects/bindings/wiki/WindowsApi

RDMD: http://www.digitalmars.com/d/2.0/rdmd.html

RDMD@github: https://github.com/D-Programming-Language/tools

HTOD: http://www.digitalmars.com/d/2.0/htod.html

DDBG D Debugger: http://ddbg.mainia.de/doc.html

Uncrustify - Code Beautifier: http://sourceforge.net/projects/uncrustify/develop

UniversalIndentGUI - GUI Frontend for Code Beautifiers:

http://universalindent.sourceforge.net/

Using Resources in D Tutorial: http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/WindowsResources

Unicode Character Viewer: http://rishida.net/scripts/uniview/

Environment Variables: http://www.computerhope.com/issues/ch000549.htm

Environment Editor: http://www.rapidee.com/

dwinprogramming's People

Contributors

andrejmitrovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dwinprogramming's Issues

Please post a simple messagbox example

Hi,
I tried a lot to display a messagebox in D.

module main;

import std.stdio;
import core.sys.windows.windows;
import core.runtime ;
import std.utf ;
//import win32.windef ;

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
    string amsg = "Hi, I am a message" ;
    string att = "MsgBox D" ;
    MessageBox(null, amsg.toUTF16z , att.toUTF16z, null) ; //
    return 0;
}

Bu this is not working. Please all your messagebox examples are in try catch block and the message is the exception message. But i just want to see how to declare a string and use it in win api functions.

Cleanup and fixes

Hi @WebFreak001, @AndrejMitrovic,

This project is mentioned by https://wiki.dlang.org/D_for_Win32 but doesn't build for me. I would like to do some changes to the build setup (i.e: use dub instead of a custom build script) and also some cleanup/update of the implementation and file structure, but I'm not sure what's the license situation and if that's better to do in my own repository or in this one.

I don't know exactly what changes I would like to do as I'm using this as a way to learn D build system and have some fun with Win32 API, but in any case it would stay a translation of Charles Petzold's code to D (and I really don't expect that much change regarding the actual logic and structure).

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.