Reputation: 23640
I try to do some gui programming in D using the WinAPI. My problem is that buttons look ugly as in the question another user asked. In order to solve that I want to embed a manifest into my D application. As soon as I can include resources into my executable, I should also be able to add a manifest by hand according to this Microsoft documentation.
So my question is: How can I include a resource into my D application on Visual Studio? Is it even possible to do that? If not, are there any other ways to make buttons look nice?
Upvotes: 3
Views: 353
Reputation: 10299
Looking at old project which used dsss:
$cat dsss.conf
[*]
buildflags+=-Jresources
version(Windows) {
version(gui) {
buildflags+= -L/SUBSYSTEM:windows:5
} else {
buildflags+= -L/SUBSYSTEM:console:5
}
buildflags+= -L/rc:.\resources\dwt
...
}
...
This should translate to something like:
dmd -JRES_PATH -L/rc:.\RES_PATH\MANIFEST_WHITHOUT_RES_EXT ...
Upvotes: 0
Reputation: 78635
If you don't care about it actually being a "resources" but just need a data blob from a file embedded into the binary; take a look at "import expressions"
Upvotes: 1
Reputation: 3342
Check the 'VisualStyles' examples here: https://github.com/AndrejMitrovic/DWinProgramming/tree/master/Samples/Extra
Also the 'ThemedSimpleWakeUp' sample uses a resource file whereas 'ThemedWakeUp' dynamically enables visual styles.
Upvotes: 0
Reputation: 613282
I'm not familiar with the integration of dmd into Visual Studio, but one way to achieve what you need is to add the compiled .res file to the list of files passed to dmd.exe. For example:
dmd.exe main.d manifest.res
I'd expect there be some way in your VS integration for you to add files to the dmd command that the IDE uses to compile your code.
Upvotes: 1
Reputation: 210643
A little ugly, but it gets the job done, no manifests:
auto enableVisualStyles()
{
TCHAR dir[MAX_PATH];
dir[GetSystemDirectory(dir.ptr, dir.length)] = '\0';
auto actCtx = ACTCTX(
ACTCTX.sizeof, 0x0C, "shell32.dll", PROCESSOR_ARCHITECTURE_INTEL,
0, dir.ptr, MAKEINTRESOURCE(124), null, HMODULE.init);
ULONG_PTR ulpActivationCookie;
return ActivateActCtx(CreateActCtx(actCtx), ulpActivationCookie);
}
Just make sure to call it once when your program starts.
Upvotes: 2