digitalmars.D.learn - Window procedure declaration
- V (31/31) Mar 22 2005 I can't seem to assign my WNDCLASSA structures wndproc field the same
- John C (4/35) Mar 23 2005 Use the address of the function instead.
- Chris Sauls (7/13) Mar 23 2005 You need to use D's extern attribute. I believe this is the correct way...
- John Reimer (5/22) Mar 23 2005 Actually this should be "extern(Windows)", but the idea was correct.
- Chris Sauls (6/7) Mar 23 2005 I realized that about... three seconds ago. :) Alas.
- V (7/19) Mar 23 2005 Thank you all for the help :D
- John Reimer (4/29) Mar 23 2005 There are many win32 functions missing from std.c.windows.windows.
- Stewart Gordon (6/8) Jan 06 2009 That one's old and, by the looks of it, no longer maintained. You want
- Stewart Gordon (4/12) Jan 06 2009 Silly me, should've realised I was replying to an old thread. I guess
- Regan Heath (12/43) Mar 23 2005 Try:
- John Reimer (2/16) Mar 23 2005 Oops. Good point, Regan. I missed the CALLBACK. Don't need that there...
- Regan Heath (3/14) Mar 23 2005 Is it extern (C) or extern (Windows) though? I'm not sure.
- Carlos Santander B. (4/25) Mar 23 2005 Windows
I can't seem to assign my WNDCLASSA structures wndproc field the same way I did in C. <code> WNDCLASSA wcex; wcex.style = 0; wcex.lpfnWndProc = cast(WNDPROC) wndProc; </code> Compiler errors: App.d(40): function app.wndProc (HANDLE,uint,uint,int) does not match argument types () App.d(40): Error: expected 4 arguments, not 0 Also how do I declare the procedure? This causes errors: <code> LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) </code> app.d(62): semicolon expected, not 'wndProc' app.d(62): found 'hWnd' when expecting ')' app.d(62): semicolon expected, not 'message' app.d(62): no identifier for declarator message app.d(62): semicolon expected, not 'wParam' app.d(62): no identifier for declarator wParam app.d(62): semicolon expected, not 'lParam' app.d(62): no identifier for declarator lParam app.d(62): semicolon expected, not ')' app.d(62): Declaration expected, not ')' app.d(70): Declaration expected, not 'case' app.d(77): Declaration expected, not 'case' app.d(81): Declaration expected, not 'case' app.d(91): Declaration expected, not 'default' app.d(93): unrecognized declaration
Mar 22 2005
"V" <v pathlink.com> wrote in message news:d1r499$1jh3$1 digitaldaemon.com...I can't seem to assign my WNDCLASSA structures wndproc field the same way I did in C. <code> WNDCLASSA wcex; wcex.style = 0; wcex.lpfnWndProc = cast(WNDPROC) wndProc; </code>Use the address of the function instead. wcex.lpfnWndProc = &wndProc;Compiler errors: App.d(40): function app.wndProc (HANDLE,uint,uint,int) does not match argument types () App.d(40): Error: expected 4 arguments, not 0 Also how do I declare the procedure? This causes errors: <code> LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) </code> app.d(62): semicolon expected, not 'wndProc' app.d(62): found 'hWnd' when expecting ')' app.d(62): semicolon expected, not 'message' app.d(62): no identifier for declarator message app.d(62): semicolon expected, not 'wParam' app.d(62): no identifier for declarator wParam app.d(62): semicolon expected, not 'lParam' app.d(62): no identifier for declarator lParam app.d(62): semicolon expected, not ')' app.d(62): Declaration expected, not ')' app.d(70): Declaration expected, not 'case' app.d(77): Declaration expected, not 'case' app.d(81): Declaration expected, not 'case' app.d(91): Declaration expected, not 'default' app.d(93): unrecognized declaration
Mar 23 2005
V wrote:Also how do I declare the procedure? This causes errors: <code> LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) </code>You need to use D's extern attribute. I believe this is the correct way: -- Chris Sauls
Mar 23 2005
Chris Sauls wrote:V wrote:Actually this should be "extern(Windows)", but the idea was correct. His problem seems to have arisen from an absence of both the "&" operator and the extern(Windows). -JJRAlso how do I declare the procedure? This causes errors: <code> LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) </code>You need to use D's extern attribute. I believe this is the correct way: -- Chris Sauls
Mar 23 2005
John Reimer wrote:Actually this should be "extern(Windows)", but the idea was correct.I realized that about... three seconds ago. :) Alas. Also would be helpful to check out these two pages from the specs: http://www.digitalmars.com/d/windows.html http://www.digitalmars.com/d/dll.html -- Chris Sauls
Mar 23 2005
Chris Sauls wrote:John Reimer wrote:Thank you all for the help :D I've noticed that some functions are missing from std.c.windows.windows like BOOL DestroyWindow(HWND hWnd) and BOOL UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance) and some of the defines like WS_EX_CLIENTEDGE. Are any of these going to be added or do I have to define each function as an extern?Actually this should be "extern(Windows)", but the idea was correct.I realized that about... three seconds ago. :) Alas. Also would be helpful to check out these two pages from the specs: http://www.digitalmars.com/d/windows.html http://www.digitalmars.com/d/dll.html -- Chris Sauls
Mar 23 2005
V wrote:Chris Sauls wrote:There are many win32 functions missing from std.c.windows.windows. Check www.dsource.org/projects/core32 for a more complete D win32 import. -JJRJohn Reimer wrote:Thank you all for the help :D I've noticed that some functions are missing from std.c.windows.windows like BOOL DestroyWindow(HWND hWnd) and BOOL UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance) and some of the defines like WS_EX_CLIENTEDGE. Are any of these going to be added or do I have to define each function as an extern?Actually this should be "extern(Windows)", but the idea was correct.I realized that about... three seconds ago. :) Alas. Also would be helpful to check out these two pages from the specs: http://www.digitalmars.com/d/windows.html http://www.digitalmars.com/d/dll.html -- Chris Sauls
Mar 23 2005
John Reimer wrote: <snip>There are many win32 functions missing from std.c.windows.windows. Check www.dsource.org/projects/core32 for a more complete D win32 import.That one's old and, by the looks of it, no longer maintained. You want this one: http://www.dsource.org/projects/bindings/wiki/WindowsApi Stewart.
Jan 06 2009
Stewart Gordon wrote:John Reimer wrote: <snip>Silly me, should've realised I was replying to an old thread. I guess it's one of the natural consequences of switching newsreaders. Stewart.There are many win32 functions missing from std.c.windows.windows. Check www.dsource.org/projects/core32 for a more complete D win32 import.That one's old and, by the looks of it, no longer maintained. You want this one: http://www.dsource.org/projects/bindings/wiki/WindowsApi
Jan 06 2009
On Tue, 22 Mar 2005 22:51:06 -0800, V <v pathlink.com> wrote:I can't seem to assign my WNDCLASSA structures wndproc field the same way I did in C. <code> WNDCLASSA wcex; wcex.style = 0; wcex.lpfnWndProc = cast(WNDPROC) wndProc; </code> Compiler errors: App.d(40): function app.wndProc (HANDLE,uint,uint,int) does not match argument types () App.d(40): Error: expected 4 arguments, not 0Try: wcex.lpfnWndProc = cast(WNDPROC)&wndProc;Also how do I declare the procedure? This causes errors: <code> LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) </code> app.d(62): semicolon expected, not 'wndProc' app.d(62): found 'hWnd' when expecting ')' app.d(62): semicolon expected, not 'message' app.d(62): no identifier for declarator message app.d(62): semicolon expected, not 'wParam' app.d(62): no identifier for declarator wParam app.d(62): semicolon expected, not 'lParam' app.d(62): no identifier for declarator lParam app.d(62): semicolon expected, not ')' app.d(62): Declaration expected, not ')' app.d(70): Declaration expected, not 'case' app.d(77): Declaration expected, not 'case' app.d(81): Declaration expected, not 'case' app.d(91): Declaration expected, not 'default' app.d(93): unrecognized declarationRemove "CALLBACK". Add extern(C) eg. extern (C) LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { } CALLBACK is typically a define for __stdcall which is replaced in D with extern (C), see: http://www.digitalmars.com/d/interface.html Regan
Mar 23 2005
Regan Heath wrote:Remove "CALLBACK". Add extern(C) eg. extern (C) LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { } CALLBACK is typically a define for __stdcall which is replaced in D with extern (C), see: http://www.digitalmars.com/d/interface.html ReganOops. Good point, Regan. I missed the CALLBACK. Don't need that there!
Mar 23 2005
On Wed, 23 Mar 2005 15:08:00 -0800, John Reimer <brk_6502 yahoo.com> wrote:Regan Heath wrote:Is it extern (C) or extern (Windows) though? I'm not sure. ReganRemove "CALLBACK". Add extern(C) eg. extern (C) LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { } CALLBACK is typically a define for __stdcall which is replaced in D with extern (C), see: http://www.digitalmars.com/d/interface.html ReganOops. Good point, Regan. I missed the CALLBACK. Don't need that there!
Mar 23 2005
Regan Heath wrote:On Wed, 23 Mar 2005 15:08:00 -0800, John Reimer <brk_6502 yahoo.com> wrote:Windows _______________________ Carlos Santander BernalRegan Heath wrote:Is it extern (C) or extern (Windows) though? I'm not sure. ReganRemove "CALLBACK". Add extern(C) eg. extern (C) LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { } CALLBACK is typically a define for __stdcall which is replaced in D with extern (C), see: http://www.digitalmars.com/d/interface.html ReganOops. Good point, Regan. I missed the CALLBACK. Don't need that there!
Mar 23 2005