Click here to Skip to main content
15,894,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks, my code uses Matlab as a COM server and has matlab plot some data in a figure, which is opened up in a new window named 'Figure 1' normally. After it's done plotting I hope to give focus back to the form that calls the sub that execute the matlab commands. I've tried to add two lines after the sub call
VB
PassDataNPlot()
Me.BringToFront()
Me.Focus()

but when it's done plotting the matlab figure is still on top of my form. I wonder what else could do the trick? any suggestions?
Posted
Updated 17-Jul-12 9:37am
v2
Comments
Albert Holguin 17-Jul-12 16:46pm    
Is the call to plot synchronous or asynchronous? I ask because what may be occurring is that you're passing an asynch call to Matlab to do something and before Matlab is even done, you gave yourself focus... meaning that when Matlab is done plotting, it may just give itself focus again. If that's your problem, then you need to either make the events synchronous or kill some time in your app to allow Matlab to finish.

1 solution

create an object of the form and use the Show() method with the object.

eg:
C#
frmNew obj=new frmNew();
obj.show();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900