K
knikkix
Hi,
I created a form in VB.Net with only one button. This is the code in
button click event
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
AppGlobals.SetHandles(Me.Handle.ToInt64())
Call OpenModel()
End Sub
appglobals.sethandles set the handle to window to be used by
postmessage function
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
String) As IntPtr
'Private m_xlWindowHandle As IntPtr
Private m_xlWindowHandle As Long
Private m_xlMessageID_SC As IntPtr
Private m_xlMessageID_C As IntPtr
Public Const c_RegistryKey As String =
"Software\Pzena\StockAnalyzer.NET\Client"
Public Const r_RegistryKey As String =
"Software\Pzena\StockAnalyzer.NET\Report"
Public Sub SetHandles(Optional ByVal WndHandle As Long = 0)
If WndHandle <> 0 Then
xlWindowHandle = WndHandle
Else
'Modified by nikki
'xlWindowHandle = oParentForm.ActiveMainForm.Handle.ToInt64
End If
'xlWindowHandle = oParentForm.ActiveMainForm.Handle
xlMessageID_SC = RegisterWindowMessage("WM_EXCEL_SAVE_CLOSE")
xlMessageID_C = RegisterWindowMessage("WM_EXCEL_CLOSE")
End Sub
Public Property xlWindowHandle()
Get
Return m_xlWindowHandle
End Get
Set(ByVal Value)
m_xlWindowHandle = Value
End Set
End Property
Public Property xlMessageID_SC()
Get
Return m_xlMessageID_SC.ToInt64
End Get
Set(ByVal Value)
m_xlMessageID_SC = Value
End Set
End Property
Public Property xlMessageID_C()
Get
Return m_xlMessageID_C.ToInt64
End Get
Set(ByVal Value)
m_xlMessageID_C = Value
End Set
End Property
Public ReadOnly Property xlMessageID32_SC()
Get
Return m_xlMessageID_SC.ToInt32
End Get
End Property
Public ReadOnly Property xlMessageID32_C()
Get
Return m_xlMessageID_C.ToInt32
End Get
End Property
OpenModel function calls VBA routine in EXCEl like. This Open Model
function is defined in another class as Class1. There is one more
function call SaveModel defined in same Class1
xlApp.Run("OpenModel", "In Excel", CType(xlWindowHandle, Integer),
CType(xlMessageID_SC, Integer), CType(xlMessageID_C, Integer))
I added one menu in excel at runtime called Menu1 and has one submenu
submenu1
When I click on submenu1 then I am calling this routine
PostMessage(hwnd,wmsave,0,0).
The point is when this Postmessage is executed then it should execute
SaveModel in Class1 in VB.Net but somehow the control is not returned
to it. I don;t know what exactly is the problem. If somebody please
let me know then I will really appreciate them.
Thanks
Nikki
I created a form in VB.Net with only one button. This is the code in
button click event
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
AppGlobals.SetHandles(Me.Handle.ToInt64())
Call OpenModel()
End Sub
appglobals.sethandles set the handle to window to be used by
postmessage function
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
String) As IntPtr
'Private m_xlWindowHandle As IntPtr
Private m_xlWindowHandle As Long
Private m_xlMessageID_SC As IntPtr
Private m_xlMessageID_C As IntPtr
Public Const c_RegistryKey As String =
"Software\Pzena\StockAnalyzer.NET\Client"
Public Const r_RegistryKey As String =
"Software\Pzena\StockAnalyzer.NET\Report"
Public Sub SetHandles(Optional ByVal WndHandle As Long = 0)
If WndHandle <> 0 Then
xlWindowHandle = WndHandle
Else
'Modified by nikki
'xlWindowHandle = oParentForm.ActiveMainForm.Handle.ToInt64
End If
'xlWindowHandle = oParentForm.ActiveMainForm.Handle
xlMessageID_SC = RegisterWindowMessage("WM_EXCEL_SAVE_CLOSE")
xlMessageID_C = RegisterWindowMessage("WM_EXCEL_CLOSE")
End Sub
Public Property xlWindowHandle()
Get
Return m_xlWindowHandle
End Get
Set(ByVal Value)
m_xlWindowHandle = Value
End Set
End Property
Public Property xlMessageID_SC()
Get
Return m_xlMessageID_SC.ToInt64
End Get
Set(ByVal Value)
m_xlMessageID_SC = Value
End Set
End Property
Public Property xlMessageID_C()
Get
Return m_xlMessageID_C.ToInt64
End Get
Set(ByVal Value)
m_xlMessageID_C = Value
End Set
End Property
Public ReadOnly Property xlMessageID32_SC()
Get
Return m_xlMessageID_SC.ToInt32
End Get
End Property
Public ReadOnly Property xlMessageID32_C()
Get
Return m_xlMessageID_C.ToInt32
End Get
End Property
OpenModel function calls VBA routine in EXCEl like. This Open Model
function is defined in another class as Class1. There is one more
function call SaveModel defined in same Class1
xlApp.Run("OpenModel", "In Excel", CType(xlWindowHandle, Integer),
CType(xlMessageID_SC, Integer), CType(xlMessageID_C, Integer))
I added one menu in excel at runtime called Menu1 and has one submenu
submenu1
When I click on submenu1 then I am calling this routine
PostMessage(hwnd,wmsave,0,0).
The point is when this Postmessage is executed then it should execute
SaveModel in Class1 in VB.Net but somehow the control is not returned
to it. I don;t know what exactly is the problem. If somebody please
let me know then I will really appreciate them.
Thanks
Nikki