Re: amazing function behavior

2009-10-21 Thread Zarathustra
I resolved my access violation problem by including at the begin of wndProc inside Window class, the following code: // private dword wndProc(ptr o_hwnd, dword o_msg, ... { asm{ push 0x; push [o_hwnd]; call [user

Re: amazing function behavior

2009-10-21 Thread Don
Zarathustra wrote: Don Wrote: It isn't. Tfunc2 is a function pointer, which is typically the same as size_t. So any int can be stored inside it. It's generally a very bad idea to do so, of course. Never mind what is stored inside func2. 0x00 is only to simplify the code. Tfunc1 - pointer to f

Re: amazing function behavior

2009-10-20 Thread Zarathustra
Phil Deets Wrote: > I don't know what the problem is, but I would try checking to see if the > pointer at window construction and the this pointer before calling > onMouseDown are the same. Maybe there is a problem with using the result > of getWindowLong as a pointer. For example, one value

Re: amazing function behavior

2009-10-20 Thread Phil Deets
On Mon, 19 Oct 2009 02:39:57 -0500, Zarathustra wrote: Function is never called but why? look at: window.Window.wndProc : case WM.LBUTTONDOWN //__ module window; private import base; private import structs; private static import user32; private st

Re: amazing function behavior

2009-10-20 Thread Zarathustra
Don Wrote: > It isn't. Tfunc2 is a function pointer, which is typically the same as > size_t. So any int can be stored inside it. It's generally a very bad > idea to do so, of course. Never mind what is stored inside func2. 0x00 is only to simplify the code. Tfunc1 - pointer to function without

Re: amazing function behavior

2009-10-20 Thread Don
Kagamin wrote: Zarathustra Wrote: Oh, I just find out cause of this behaviour in other module I had: extern (Windows) alias dword function() Tfunc1; extern (Windows) alias dword function(wstr) Tfunc2; const Tfunc2 func2; static this(){ func2 = cast(Tfunc1)0x0; // for DMD2 It is not error!!!

Re: amazing function behavior

2009-10-20 Thread Kagamin
Zarathustra Wrote: > Oh, I just find out cause of this behaviour in other module I had: > extern (Windows) alias dword function() Tfunc1; > extern (Windows) alias dword function(wstr) Tfunc2; > const Tfunc2 func2; > static this(){ > func2 = cast(Tfunc1)0x0; // for DMD2 It is not error!!! >

Re: amazing function behavior

2009-10-19 Thread Zarathustra
Oh, I just find out cause of this behaviour in other module I had: extern (Windows) alias dword function() Tfunc1; extern (Windows) alias dword function(wstr) Tfunc2; const Tfunc2 func2; static this(){ func2 = cast(Tfunc1)0x0; // for DMD2 It is not error!!! // but it do

Re: amazing function behavior

2009-10-19 Thread Zarathustra
In addition I tested the code in DMD1.050 and DMD2.035. In DMD 1 It works correctly, but in DMD2 line: 'this.onMouseDown(l_mea);' works like 'break' (no exceptions, neither compilation nor linking warnings, just like break). Is it DMD2 bug?

Re: amazing function behavior

2009-10-19 Thread Zarathustra
Daniel Keep Wrote: > It shouldn't even COMPILE. > > You can't use member functions as Windows callbacks. You haven't even > used the correct calling convention on it. > > Callbacks for Win API functions have to be, I believe, extern(Windows), > and they have to be free functions or static membe

Re: amazing function behavior

2009-10-19 Thread Daniel Keep
Zarathustra wrote: > Function is never called but why? It shouldn't even COMPILE. You can't use member functions as Windows callbacks. You haven't even used the correct calling convention on it. Callbacks for Win API functions have to be, I believe, extern(Windows), and they have to be free f

amazing function behavior

2009-10-19 Thread Zarathustra
Function is never called but why? look at: window.Window.wndProc : case WM.LBUTTONDOWN //__ module window; private import base; private import structs; private static import user32; private static import kernel32; private static import gdi32; private: