Home > Software engineering >  How to use the DLL API will MATLAB generated form embedded in VB form??
How to use the DLL API will MATLAB generated form embedded in VB form??

Time:10-17

How to use the DLL API will MATLAB generated form embedded in VB form??

CodePudding user response:

Thinking:
1, use FindWindow lookup Matlab generated form
2, use SetParent set the form to the VB program forms of form,

For example, if: Windows's own calculator window is Matlab generated form, according to the following code processing:
 
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub Command1_Click ()
Dim lngChildHwnd As Long
Dim lngP As Long
LngChildHwnd=FindWindow (vbNullString, "????? Present ")
LngP=SetParent (lngChildHwnd, Me. HWnd)
End Sub

Private Sub Form_Load ()
The Shell "c: \ Windows \ system32 \ calc exe", vbNormalFocus
Me. WindowState=2
End Sub

CodePudding user response:

reference 1st floor Veron_04 response:
:
1, use FindWindow lookup Matlab generated form
2, use SetParent set the form to the VB program forms of form,

For example, if: Windows's own calculator window is Matlab generated form, according to the following code processing:
Visual Basic code? 123456789101112131415 option ExplicitPrivate Declare...

Hello, if in vb.net can't lngP=SetParent (lngChildHwnd, Me. HWnd) Me. HWnd TabControl controls

CodePudding user response:

Public Excel As Excel. Application=Nothing
. Public Workbook As Microsoft Office. Interop. Excel. The Workbook
. Public Worksheet As Microsoft Office. Interop. Excel. The Worksheet

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Int32, ByVal hWndNewParent As Int32) As Int32

Excel=New Excel. Application
Dim ExcelWnd As Integer=Excel. The Hwnd
SetParent (ExcelWnd, Me. TabPage4. Handle)
Excel. Visible=True
Excel. WindowState=XlWindowState. XlMaximized
  • Related