April 29, 2020 Re: Building Win32 application via dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam E. | On Wednesday, 29 April 2020 at 10:26:40 UTC, Sam E. wrote:
>
>
> I took the WinMain from https://wiki.dlang.org/D_for_Win32, should that documentation be updated to use a normal main function instead? Also the details regarding linker flags may be a good addition to that wiki page.
Yeah, it says "WinMain is needed", which has never been true.
|
April 29, 2020 Re: Building Win32 application via dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote:
> On Wednesday, 29 April 2020 at 10:26:40 UTC, Sam E. wrote:
>>
>>
>> I took the WinMain from https://wiki.dlang.org/D_for_Win32, should that documentation be updated to use a normal main function instead? Also the details regarding linker flags may be a good addition to that wiki page.
>
> Yeah, it says "WinMain is needed", which has never been true.
THere's no need for the def file either.
|
April 29, 2020 Re: Building Win32 application via dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Wednesday, 29 April 2020 at 10:46:30 UTC, Mike Parker wrote: > On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote: > >> Yeah, it says "WinMain is needed", which has never been true. > > THere's no need for the def file either. What's the way to get the hInstance without the use of WinMain? From Microsoft documentation: > hInstance is the handle to the application instance. Get this value from the hInstance parameter of wWinMain. https://docs.microsoft.com/en-us/windows/win32/learnwin32/creating-a-window I cannot find a D example using Win32 and the normal main function, and while it is working for simple message boxes, as soon as I want to do something slightly more complex (using a window), an hInstance has to be provided (as far as I understand, I'm not that knowledgeable with Win32). |
April 29, 2020 Re: Building Win32 application via dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam E. | On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote: > On Wednesday, 29 April 2020 at 10:46:30 UTC, Mike Parker wrote: >> On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote: >> >>> Yeah, it says "WinMain is needed", which has never been true. >> >> THere's no need for the def file either. > > What's the way to get the hInstance without the use of WinMain? > > From Microsoft documentation: >> hInstance is the handle to the application instance. Get this value from the hInstance parameter of wWinMain. > > https://docs.microsoft.com/en-us/windows/win32/learnwin32/creating-a-window > > I cannot find a D example using Win32 and the normal main function, and while it is working for simple message boxes, as soon as I want to do something slightly more complex (using a window), an hInstance has to be provided (as far as I understand, I'm not that knowledgeable with Win32). auto hInstance = GetModuleHandleA(null); It's documented to return HMODULE, but HINSTANCE is the same thing (all the HANDLE types are void*). Passing null causes it to return the handle associated with the process, so for the executable "module", that's what you want (e.g., the process handle is the module handle). In a DLL, it wouldn't be, as the DLL would have a different handle than the process. https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlea |
April 29, 2020 Re: Building Win32 application via dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam E. | On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote: > > > I cannot find a D example using Win32 and the normal main function, and while it is working for simple message boxes, as soon as I want to do something slightly more complex (using a window), an hInstance has to be provided (as far as I understand, I'm not that knowledgeable with Win32). FYI, a quick google turned up this example: https://gist.github.com/caiorss/e8967d4d3dad522c82aab18ccd8f8304 It's C++ and not D, but the Win32 calls are the same. You should be able to adapt that to D fairly easily. |
April 29, 2020 Re: Building Win32 application via dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Wednesday, 29 April 2020 at 12:26:02 UTC, Mike Parker wrote:
> On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote:
>>
>>
>> I cannot find a D example using Win32 and the normal main function, and while it is working for simple message boxes, as soon as I want to do something slightly more complex (using a window), an hInstance has to be provided (as far as I understand, I'm not that knowledgeable with Win32).
>
> FYI, a quick google turned up this example:
>
> https://gist.github.com/caiorss/e8967d4d3dad522c82aab18ccd8f8304
>
> It's C++ and not D, but the Win32 calls are the same. You should be able to adapt that to D fairly easily.
Thank you a lot Mike, you were really helpful!
|
Copyright © 1999-2021 by the D Language Foundation