Jump to content
Sign in to follow this  

Window hooking

Recommended Posts


Do you believe it is feasible to show some python graphics, say from matplotlib, and the "hook" the window and make it "live" inside a panel of a Delphi application? (when the panel moves/resizes the window moves/resizes with it)? If so is any code for doing this available? (if not I will write it)

Thanks for any suggestion

Share this post

Link to post
Posted (edited)

Thank you so much for your reply. I was aware of the possibility of using the SVG output of matplotlib (which I will use as an intermediate solution), however this is not what I am looking for. matplotlib was just an example of a more general type of approach I am pursuing, i.e. "embedding"/"controlling" graphical output of python applications in order to make it appear more integrated within a Delphi application. Anyhow thank you again for your time and suggestion.

Edited by pier

Share this post

Link to post

In case somebody is interested this is how I managed to nicely integrate matplotlib figures inside my delphi app.


1)   the pythons script shows the plot with "plt.show(block=False)"


2) this is the code which executes the script and embeds the plot

procedure TForm1.Button1Click(Sender: TObject);

var plotwnd:HWND;
  PythonEngine1.ExecStrings( Synedit1.Lines );

 plotwnd:=Findwindow(nil,'Figure 1');
 if plotwnd<>0 then
 Windows.SetParent(plotwnd,(PageControl1.Pages[1] as TTabSheet).Handle);
 SetWindowLong(plotwnd, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and not WS_BORDER and not WS_SIZEBOX and not WS_DLGFRAME );



the plot is displayed inside a tabsheet which has an event handler to automatically resize the plot

procedure TForm1.PlotResize(Sender: TObject);
   movewindow(plotwnd,0,0,(PageControl1.Pages[1] as TTabSheet).Width,(PageControl1.Pages[1] as TTabSheet).Height,True);





  • Like 4

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this