Hello,

It´s almost working. I am quite proud to have created a completely
independent implementation of AllocateHWnd =)

Ok, now my problem is that TMethod has 2 informations. A Code pointer,
and a Data pointer, and I can´t seam to find enougth space on
SetWindowLong for 2 extra informations.

GWL_USERDATA seams to work perfectly. Next I tryed both GWL_ID and
DWL_USER, but I always get nil when using GetWindowLong with them.
Maybe I could transform my form into a Dialog to use DWL_USER. What is
the definition of a dialog? How can I make a window that is a dialog?
Just set dialog Window flag?

Any other ideas about how to store 1 more pointer?

Here is part of my code:

Note1: If anyone wants, I can of course provide a full patch

Note2: The Temp variables are only to make debugging easier.

procedure CallbackAllocateHWnd(Ahwnd: HWND; uMsg: UINT; wParam:
WParam; lParam: LParam); stdcall;
var
 Msg: TLMessage;
 Method: TLCLWndMethod;
 Temp: Pointer;
begin
 FillChar(Msg, SizeOf(Msg), #0);

 Msg.msg := uMsg;
 Msg.wParam := wParam;
 Msg.lParam := lParam;

 TMethod(Method).Code := Pointer(Windows.GetWindowLong(ahwnd, GWL_USERDATA));
 TMethod(Method).Data := Pointer(Windows.GetWindowLong(ahwnd, GWL_ID));
 Temp := TMethod(Method).Code;
 Temp := TMethod(Method).Data;

 if Assigned(TMethod(Method).Code) then
  Method(Msg)
 else Windows.DefWindowProc(ahwnd, uMsg, wParam, lParam);
end;

function TWin32WidgetSet.AllocateHWnd(Method: TLCLWndMethod): HWND;
var
 Temp: Pointer;
begin
 Result := Windows.CreateWindow(@ClsName[0],
  '', WS_OVERLAPPED, 0, 0, 0, 0, 0, 0, MainInstance, nil);

 Temp := TMethod(Method).Code;
 Temp := TMethod(Method).Data;
 Self.SetWindowLong(Result, GWL_USERDATA, PtrInt(TMethod(Method).Code));
 Self.SetWindowLong(Result, GWL_ID, PtrInt(TMethod(Method).Data));

 Self.SetWindowLong(Result, GWL_WNDPROC, PtrInt(@CallbackAllocateHWnd))
end;

procedure TWin32WidgetSet.DeallocateHWnd(Wnd: HWND);
begin
 if Wnd <> 0 then Windows.DestroyWindow(Wnd);
end;



--
Felipe Monteiro de Carvalho

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to