Matlab m file into ocx file.

Can I convert my m file into an .ocx file ? I have converted my m file into a .dll file using the deploytool option. Whether can I do the former ? And I need to register that .ocx file in my Windows Activex Control List ? Please tell me how?

댓글 수: 2

Friedrich
Friedrich 2012년 3월 22일
Do you have the Builder NE? If so, you can create a COM DLL out of your MATLAB code.
Raj Shankar
Raj Shankar 2012년 3월 22일
Hello Friedrich,
Yes I have. But still I want to use my m file as an OCX file. I did used builder NE and got a COM DLL out of that. Rather but I want an OCX file for my application. How could I do this.

댓글을 달려면 로그인하십시오.

 채택된 답변

Friedrich
Friedrich 2012년 3월 22일

1 개 추천

Hi,
you wont be able to create an OCX file out of your MATLAB code.
I guess you want OCX to embed a MATLAB figure or your MATLAB GUI in some other application right? What other application is that?

댓글 수: 5

Raj Shankar
Raj Shankar 2012년 3월 22일
Friedrich
I want to convert my m file and fig as an OCX file and embed it with Visual C++ application. If I cannot create an OCX file from my m file then what other way in which I can do this?
Friedrich
Friedrich 2012년 3월 22일
Luck for you that I am working on this :)
I would say make a basic C++ DLL and use the Windows API (SetParent) in order to force the figure on the C++ Control (e.g. a Panel). Its important that the control has its own Window Handle.
You can get the Window Handle of a figure in MATLAB like this:
function hWnd = hwnd()
plot(1:10);
warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
jFrame = get(gcf,'JavaFrame');
warning('on','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
while isempty(jFrame.fHG1Client.getWindow)
pause(.05)
end
hWnd = jFrame.fHG1Client.getWindow.getHWnd;
This works on Windows only.
I tested this approach in C# (Builder NE), Java (Builder JA), and Excel (Builder EX) and it worked fine.
You maybe need MoveWindow in addition, to resize the figure when the Panel resizes.
Raj Shankar
Raj Shankar 2012년 3월 22일
Thankyou Mr.Friedrich. I think this would help me more. Thanks a lot :)
Jan
Jan 2012년 3월 22일
@Friedrich: Instead of disabling the warning temporarily, you can use:
jFrame = get(handle(gcf), 'JavaFrame');
Friedrich
Friedrich 2012년 3월 23일
nice, thanks :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by