| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
| 
 | 
| January 01, 2009[WINAPI] Window in D | ||||
|---|---|---|---|---|
| 
 | ||||
| My english is not good. Apologize for this.
I start programming in D and i have a problem.
When I try make a window procedure and register class window. Compiler show error:
"Error: cannot implicitly convert expression (& WindowProcedure) of type intWindows function(HANDLE, uint, uint, int) function(HANDLE hwnd, uint message, uint wParam, int lParam) to intWindows function(HANDLE, uint, uint, int)"
Window Procedure:
"WNDPROC WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     switch (message)
     {
         case WM_DESTROY:
             PostQuitMessage (0);
             break;
         default:
             return cast(WNDPROC) DefWindowProcA (hwnd, message, wParam, lParam);
     }
     return cast(WNDPROC) 0;
}"
How must look window procedure in order to it's work?
 | ||||
| January 02, 2009Re: [WINAPI] Window in D | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Daniel Wojdak | Daniel Wojdak wrote:
> My english is not good. Apologize for this.
> 
> I start programming in D and i have a problem.
> When I try make a window procedure and register class window. Compiler show error: "Error: cannot implicitly convert expression (& WindowProcedure) of type intWindows function(HANDLE, uint, uint, int) function(HANDLE hwnd, uint message, uint wParam, int lParam) to intWindows function(HANDLE, uint, uint, int)"
> 
> Window Procedure:
> 
> "WNDPROC WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
>      switch (message)
>      {
> 
>          case WM_DESTROY:
>              PostQuitMessage (0);
>              break;
>          default:
>              return cast(WNDPROC) DefWindowProcA (hwnd, message, wParam, lParam);
>      }
> 
>      return cast(WNDPROC) 0;
> }"
> 
> How must look window procedure in order to it's work?
> 
This should do the trick:
extern(Windows) int WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 | |||
| January 02, 2009Re: [WINAPI] Window in D | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Daniel Wojdak | On Thu, 01 Jan 2009 19:34:42 +0300, Daniel Wojdak <danielwojdak@gmail.com> wrote:
> My english is not good. Apologize for this.
>
> I start programming in D and i have a problem.
> When I try make a window procedure and register class window. Compiler show error:
> "Error: cannot implicitly convert expression (& WindowProcedure) of type intWindows function(HANDLE, uint, uint, int) function(HANDLE hwnd, uint message, uint wParam, int lParam) to intWindows function(HANDLE, uint, uint, int)"
>
> Window Procedure:
>
> "WNDPROC WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
>      switch (message)
>      {
>
>          case WM_DESTROY:
>              PostQuitMessage (0);
>              break;
>          default:
>              return cast(WNDPROC) DefWindowProcA (hwnd, message, wParam, lParam);
>      }
>
>      return cast(WNDPROC) 0;
> }"
>
> How must look window procedure in order to it's work?
>
Ouch! What does this function return? Shouldn't typeof(return) be LRESULT?
extern(Windows):
LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
    case WM_DESTROY:
        PostQuitMessage (0);
        break;
    default:
       break;
}
return DefWindowProcA (hwnd, message, wParam, lParam);
}
 | |||
| December 28, 2012Re: [WINAPI] Window in D | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Denis Koroskin | > Ouch! What does this function return? Shouldn't typeof(return) be LRESULT? > > extern(Windows): What he says is good, but I believe you should add nothrow to that: extern( Windows ) nothrow: > LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) > { > switch (message) > { > case WM_DESTROY: > PostQuitMessage (0); > break; > default: > break; > } > > return DefWindowProcA (hwnd, message, wParam, lParam); > } | |||
| December 28, 2012Re: [WINAPI] Window in D | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Phil Lavoie | On Friday, 28 December 2012 at 16:25:30 UTC, Phil Lavoie wrote:
>> Ouch! What does this function return? Shouldn't typeof(return) be LRESULT?
>>
>> extern(Windows):
> What he says is good, but I believe you should add nothrow to that:
> extern( Windows ) nothrow:
>> LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
>> {
>> switch (message)
>> {
>>    case WM_DESTROY:
>>        PostQuitMessage (0);
>>        break;
>>    default:
>>       break;
>> }
>>
>> return DefWindowProcA (hwnd, message, wParam, lParam);
>> }
haha! Never mind that I did not realized the thread was started that long ago!
 | |||
Copyright © 1999-2021 by the D Language Foundation
  Permalink
Permalink Reply
Reply