* * *

Author Topic: How to get the x11 XID handle of TCustomControl equvalent to HWND on windows  (Read 2041 times)

sainimu78

  • Full Member
  • ***
  • Posts: 117
scn:TCustomControl;

The scn.Handle will retrurn a PGtkWidget.

Code: Pascal  [Select]
  1. procedure TMyPanel.Paint;
  2. var
  3.   pW:PGtkWidget;
  4.   pDW:PGDKWindow;
  5.   w, h:Integer;
  6.   attrs:TXWindowAttributes;
  7. begin
  8.   pW := PGtkWidget(Handle);
  9.   pDW := pW^.window;// gtk_widget_get_window(pW);
  10.   if(pDW = nil)then
  11.     Exit;
  12.   if(fGC <> nil)then
  13.     Exit;
  14.   fWindow := gdk_x11_drawable_get_xid(pDW);
  15.   fDisplay := gdk_x11_drawable_get_xdisplay(pDW);
  16.   //if(fGC <> nil)then
  17.   //  XFreeGC(fDisplay, fGC);
  18.   fGC := XCreateGC(fDisplay, fWindow, 0, nil);
  19.   XGetWindowAttributes(fDisplay, fWindow, @attrs);
  20.  
  21.   w := attrs.width;
  22.   h := attrs.height;
  23. end;
The w and h seems wrong, it is the w and h of the whole form, how to get the correct fWindow with lclgtk2 ?
Is pDW here equvalent to HWND on windows ? I can do custom paint a TCustomControl using windows native api on windows, I think I just get a wrong pDW and I don't know how to.

benohb

  • Full Member
  • ***
  • Posts: 162
Code: Pascal  [Select]
  1. fWindow := GDK_WINDOW_XWINDOW(PGtkWidget(PtrUInt(Handle))^.window);


Curiosity killed me :) . what do you want to do ??

sainimu78

  • Full Member
  • ***
  • Posts: 117
Code: Pascal  [Select]
  1. fWindow := GDK_WINDOW_XWINDOW(PGtkWidget(PtrUInt(Handle))^.window);


Curiosity killed me :) . what do you want to do ??
This is still not good still gets a wrong w & h.
I want to paint using a third party library, it creates a render context on TCustomControl, I need to pass a correct fWindow to it.

benohb

  • Full Member
  • ***
  • Posts: 162
I can not help you without understanding..

what is "The third party library" ??? cario ??


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus