Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 18, 2017 Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Hello! I have a question about creating native GUI applications for Windows 7 or/and Windows 10. I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK. And what about D? What should I do? Make some kind of wrapper above C WinApi? I also know that on GitHub exists such wrapper (https://github.com/AndrejMitrovic/DWinProgramming) but it is old - last commit was 4 years ago. Could you help me? |
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote: > Hello! > I have a question about creating native GUI applications for Windows 7 or/and Windows 10. > I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK. > And what about D? What should I do? Make some kind of wrapper above C WinApi? > I also know that on GitHub exists such wrapper (https://github.com/AndrejMitrovic/DWinProgramming) but it is old - last commit was 4 years ago. > > Could you help me? You can use libuid which can be found here https://code.dlang.org/packages/libuid. It wrapped the native os gui for d, and it's cross-platform. |
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote: > Hello! > I have a question about creating native GUI applications for Windows 7 or/and Windows 10. > I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK. > And what about D? What should I do? Make some kind of wrapper above C WinApi? You can use the C Windows API out of the box: import core.sys.windows.windows; // And away you go > I also know that on GitHub exists such wrapper (https://github.com/AndrejMitrovic/DWinProgramming) but it is old - last commit was 4 years ago. > The purpose of that repository was to port Petzold's examples to D. The Win32 API bindings (it's not a wrapper) were included to make building easier. I'm pretty sure somebody else set up a github mirror of the original DSource.org repository and Andrej simply copied it into his directory tree under the WindowsAPI directory. Meaning, I don't think the purpose of DWinProgramming was ever to actually host Windows bindings. Regardless, third-party bindings are no longer necessary. All the examples in that repository should work (perhaps with minor changes) if you replace the win32.* imports with core.sys.windows. For example, the HelloMsg sample in the Chapter 01 folder could use a couple f changes. toUTF16z is now part of std.utf, so no need for a custom implementation. And the versions of Runtime.initialize/terminate that take a delegate are deprecated. So this is what it should look like now: module HelloMsg; import core.runtime; import std.utf; import core.sys.windows.windows; extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { int result; try { Runtime.initialize(); result = myWinMain(hInstance, hPrevInstance, lpCmdLine, iCmdShow); Runtime.terminate(); } catch (Throwable o) { MessageBox(null, o.toString().toUTF16z, "Error", MB_OK | MB_ICONEXCLAMATION); result = 0; } return result; } int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { MessageBox(NULL, "Hello, Windows!", "Your Application", 0); return 0; } On the other hand, you can dispense with the WinMain nonsense just do this: import core.runtime; import std.utf; import core.sys.windows.windows; void main() { MessageBox(null, "Hello, Windows!", "Your Application", 0); } Then compile with this to the same behavior as WinMain (i.e. no console window attached to the program): dmd -L/SUBSYSTEM:windows HelloMsg.d Or, when using the MS linker: dmd -L/SUBSYSTEM:windows -L/ENTRY:mainCRTStartup -m64 HelloMsg.d user32.lib Replace -m64 with -m32mscoff for 32-bit COFF output. Also note that when using the MS linker, you have to explicitly link with user32.lib. The same is true for the original WinMain version. |
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Binghoo Dang | On Monday, 18 December 2017 at 08:49:51 UTC, Binghoo Dang wrote:
> You can use libuid which can be found here https://code.dlang.org/packages/libuid.
>
> It wrapped the native os gui for d, and it's cross-platform.
Nice...
But I want to use WinApi. Is it possible? Or what one should do first to make it possible?
|
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Monday, 18 December 2017 at 09:45:38 UTC, Mike Parker wrote:
> You can use the C Windows API out of the box:
Aaa, excelent! I always thought that first one should port winapi to D and then use it...
Is core.sys.windows.windows equals fully to C WinApi, do you know?
|
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | On Monday, 18 December 2017 at 10:08:13 UTC, Andrey wrote:
> Is core.sys.windows.windows equals fully to C WinApi, do you know?
Should be enough for most things.
|
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | On 2017-12-18 08:55, Andrey wrote: > Hello! > I have a question about creating native GUI applications for Windows 7 or/and Windows 10. > I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK. DWT _is_ a native GUI, it uses the WinAPI. -- /Jacob Carlborg |
December 18, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Binghoo Dang | On Monday, 18 December 2017 at 08:49:51 UTC, Binghoo Dang wrote:
> On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote:
>> Hello!
>> I have a question about creating native GUI applications for Windows 7 or/and Windows 10.
>> I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK.
>> And what about D? What should I do? Make some kind of wrapper above C WinApi?
>> I also know that on GitHub exists such wrapper (https://github.com/AndrejMitrovic/DWinProgramming) but it is old - last commit was 4 years ago.
>>
>> Could you help me?
>
> You can use libuid which can be found here https://code.dlang.org/packages/libuid.
>
> It wrapped the native os gui for d, and it's cross-platform.
Any chance of having a version that allows static linking?
Zz
|
December 19, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote: > I have a question about creating native GUI applications for Windows 7 or/and Windows 10. > And what about D? What should I do? Make some kind of wrapper above C WinApi? I've used DFL which is a thin wrapper over WinAPI and its native widgets. Links statically, no dependencies, no code bloat. Examples: http://www.infognition.com/VideoEnhancer/autovideoenhance.png http://www.infognition.com/blogsort/blogsort500.jpg https://bitbucket.org/thedeemon/autovideoenhance https://bitbucket.org/infognition/bsort There are several forks of DFL in github, I'm not sure which one is the most fresh today. I think I used this one: https://github.com/Rayerd/dfl |
December 21, 2017 Re: Write native GUI applications for Windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote: > Hello! > I have a question about creating native GUI applications for Windows 7 or/and Windows 10. Hi,here is a very good native d gui lib,it's name is "dgui": https://github.com/FrankLIKE/DguiT/ I fork and modify ,let it work on DMD2.077 for win7 or win10. It can make the x64 lib. You can try it. Injoy it. Frank. |
Copyright © 1999-2021 by the D Language Foundation