Hi all,

Two things first:
1) I am quite new to D and have been using Java at school and a bit of C++ at home so some things confuse me. Please bear with me. 2) Apologies about the ambiguity of the title, I have no idea how to ask this in just one line so I'll elaborate here:

What I want to do is create a static library to create a small wrapper/ to the Win API GUI functions for some basic GUI components for some projects instead of using some of the already made and slightly bulky GUI libraries around for D. This is what gives me a problem explained below.

I need the WinMain(...) entry point to be run so that I can get my window handle for many of the windows GUI functions so using main() is out, and I want WinMain to be in the library, so the entry point of the program is in the library not the importing file, so if I have my (simplified) files:

--------------
File: MyLib.d:
--------------

module MyLib;

import core.runtime;
import core.sys.windows.windows;
//import std.string;

extern(windows) {
    int WinMain(...) {
        int success;
        //Init code
        success = myWin(...);
        return success;
    }
}

int myWin(...) {
    progMain();
}

//Other code...

--------------
File: test.d (i.e. importing file):
--------------

import MyLib;

pragma(lib, "MyLib.lib");

void progMain() {
    //User TODO code...
}

So if I want to make any file (in this case "test.d", which can just import MyLib after I have -lib'd it and use the custom "entry point" -> "progMain" after "MyLib" has gotten everything it needs from the WinMain entry point, so that the programmer (me) can now just import MyLib and start typing their code in progMain instead of the usual main() without having to alter the source of MyLib. Basically I want MyLib to be able to call test's "progMain()", as when I try I get some error along the lines of progMain() not existing. I hope someone understands me, if you do and have an answer could you give me a step by step way of doing this?

Thanks

-Rowan

Reply via email to