View mode: basic / threaded / horizontal-split · Log in · Help
September 16, 2012
Importing dwmapi.dll
I'm new to D(really new, just learned it today) and I'm making a 
little program that I want to extend the aero glass into I've 
written this:
struct MARGINS {
  int cxLeftWidth;
  int cxRightWidth;
  int cyTopHeight;
  int cyBottomHeight;
}
HRESULT extendaeroglass(HWND handle,int left,int right,int 
top,int bottom){
	MARGINS aeromargins = {left,right,top,bottom};
	HRESULT hr = IDOK;
	hr = DwmExtendFrameIntoClientArea(handle,aeromargins);	
	return hr;
}
But I can't seem to figure out how to import dwmapi, I googled 
and there was something that said I'd have to translate the 
header file(dwmapi.h) which is 532 lines long, which I can't do 
that well because I'm not that good at D and my C/C++ is even 
worse and another page said I need to include the .lib 
file(converted from COFF) in it, which I did and it still won't 
work:
Error:undefined identifier DwmExtendFrameIntoClientArea

Is there any easier way to import a Win32 dll like dwmapi? Any 
help will be GREATLY appreciated because I have been searching 
for hours.
September 16, 2012
Re: Importing dwmapi.dll
On Sunday, 16 September 2012 at 00:27:19 UTC, Ian Martinez wrote:
> I'm new to D(really new, just learned it today) and I'm making 
> a little program that I want to extend the aero glass into I've 
> written this:
> struct MARGINS {
>   int cxLeftWidth;
>   int cxRightWidth;
>   int cyTopHeight;
>   int cyBottomHeight;
> }
> HRESULT extendaeroglass(HWND handle,int left,int right,int 
> top,int bottom){
> 	MARGINS aeromargins = {left,right,top,bottom};
> 	HRESULT hr = IDOK;
> 	hr = DwmExtendFrameIntoClientArea(handle,aeromargins);

This line should be

hr = DwmExtendFrameIntoClientArea(handle,&aeromargins);

> 	return hr;
> }
> But I can't seem to figure out how to import dwmapi, I googled 
> and there was something that said I'd have to translate the 
> header file(dwmapi.h) which is 532 lines long, which I can't do 
> that well because I'm not that good at D and my C/C++ is even 
> worse and another page said I need to include the .lib 
> file(converted from COFF) in it, which I did and it still won't 
> work:
> Error:undefined identifier DwmExtendFrameIntoClientArea

The functions need to be declared if you want to use them. For c 
libraries you usually import modules that contain the 
declarations, but when there isn't one already written, you need 
to declare them yourself. You don't need to translate all of 
dwmapi.h, just the parts that you use. For 
DvmExtendFrameIntoClientArea you would do this:

extern(Windows)
    HRESULT DwmExtendFrameIntoClientArea(HWND, MARGINS*);

This tells the compiler that there is a functions with this name, 
parameter types, return type and using Windows name mangling and 
calling convention. The implementation of this function needs to 
be available when linking, which is why the .lib file is also 
needed.
September 16, 2012
Re: Importing dwmapi.dll
On Sunday, 16 September 2012 at 02:22:42 UTC, jerro wrote:
> On Sunday, 16 September 2012 at 00:27:19 UTC, Ian Martinez 
> wrote:
>> I'm new to D(really new, just learned it today) and I'm making 
>> a little program that I want to extend the aero glass into 
>> I've written this:
>> struct MARGINS {
>>  int cxLeftWidth;
>>  int cxRightWidth;
>>  int cyTopHeight;
>>  int cyBottomHeight;
>> }
>> HRESULT extendaeroglass(HWND handle,int left,int right,int 
>> top,int bottom){
>> 	MARGINS aeromargins = {left,right,top,bottom};
>> 	HRESULT hr = IDOK;
>> 	hr = DwmExtendFrameIntoClientArea(handle,aeromargins);
>
> This line should be
>
> hr = DwmExtendFrameIntoClientArea(handle,&aeromargins);
>
>> 	return hr;
>> }
>> But I can't seem to figure out how to import dwmapi, I googled 
>> and there was something that said I'd have to translate the 
>> header file(dwmapi.h) which is 532 lines long, which I can't 
>> do that well because I'm not that good at D and my C/C++ is 
>> even worse and another page said I need to include the .lib 
>> file(converted from COFF) in it, which I did and it still 
>> won't work:
>> Error:undefined identifier DwmExtendFrameIntoClientArea
>
> The functions need to be declared if you want to use them. For 
> c libraries you usually import modules that contain the 
> declarations, but when there isn't one already written, you 
> need to declare them yourself. You don't need to translate all 
> of dwmapi.h, just the parts that you use. For 
> DvmExtendFrameIntoClientArea you would do this:
>
> extern(Windows)
>     HRESULT DwmExtendFrameIntoClientArea(HWND, MARGINS*);
>
> This tells the compiler that there is a functions with this 
> name, parameter types, return type and using Windows name 
> mangling and calling convention. The implementation of this 
> function needs to be available when linking, which is why the 
> .lib file is also needed.

Thank you so much!!
Top | Discussion index | About this forum | D home