Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I imported this project from VB(v.6 1

Status
Not open for further replies.

JorgeL

Programmer
Oct 29, 2002
10
US
I imported this project from VB(v.6) into VB.net and received this message:
'UPGRADE_WARNING: Add a delegate for AddressOf WinProc1"

I would appreciate any assistance in defining a delegate for AddressOf WinProc1.

I have this Function WinProc1 defined in my Main module called Main1.
'MessageBox Positioning logic
Function WinProc1(ByVal lMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

If lMsg = HCBT_ACTIVATE Then
'Show the MsgBox at a fixed location ( 2,445)
SetWindowPos(wParam, 0, 2, 445, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE)
'Release the CBT hook
UnhookWindowsHookEx(hHook)
End If
WinProc1 = False
End Function

I have this click event defined in my form called frmInput, which displays a calculated monthly payment in a messagebox:

Private Sub cmdCalc_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCalc.Click
'Set up the CBT hook (positioning logic for the message box).
'This message box has been positioned at (2
,445[top])
hInst = GetWindowLong(frmMDI.DefInstance.Handle.ToInt32, GWL_HINSTANCE)
Thread = GetCurrentThreadId()

'UPGRADE_WARNING: Add a delegate for AddressOf WinProc1"
hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProc1, hInst, Thread)
MsgBox("The monthly payment will be " & strPayment)
End Sub

Thank you ahead of time for your assistance, JorgeL.
 
Hello adsc,
I looked at the Microsoft site for upgrade guidelines but didn't find anything there that addressed the defining of a delegate. I appreciate your response to my post and input on the delegate matter, JorgeL.
 
Instead of using an API, it might bbe easier to use the .Net Framework MessageBox Class. You can pass the Handle of the control in front of which the Box should display.
Dim msgResult As DialogResult
msgResult = MessageBox(Control.Handle,"My Message", "Caption")


[Visual Basic]
Overloads Public Shared Function Show( _
ByVal owner As IWin32Window, _
ByVal text As String, _
ByVal caption As String _
) As DialogResult
Parameters
owner
The IWin32Window the message box will display in front of.
text
The text to display in the message box.
caption
The text to display in the title bar of the message box.
Return Value
One of the DialogResult values.

Remarks
You can use the owner parameter to specify a particular object, which implements the IWin32Window interface, to place the message box in front of. A message box is a modal dialog, which means no input (keyboard or mouse click) can occur except to objects on the modal form. The program must hide or close a modal form (typically in response to some user action) before input to another form can occur.By default, the message box displays an OK button.

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Hello JohnYingling,
I appreciate your response to my post and input on the delegate matter.
JorgeL.
Hello JoshuaL,
Thank you for your response to my post, I went to the:
msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbup1048.asp website and found some delegate logic that I feel can work with my Function WinProc1 defined in my Main1 module, I'll go ahead and give it a try and generate another post with the results. Thank you again for your input, JorgeL.
 
Hello adsc, JohnYingling & JoshuaL,
I inserted the delegate logic into my Main1 module and resolved the delegate definition problem, the following is the solution to this delegate post.


I defined the Winproc1delegate delegate in my Main1 module:
Public Delegate Function Winproc1delegate(ByVal lMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

I assigned Winproc1delegate to the lpfn valuein my Main1 module:
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As Winproc1delegate, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer

I left this click event defined in my form called frmInput, which displays a calculated monthly payment in a messagebox unchanged:
Private Sub cmdCalc_Click(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles cmdCalc.Click
'Set up the CBT hook (positioning logic for the message box).
'This message box has been positioned at (2
,445[top])
hInst = GetWindowLong(frmMDI.DefInstance.Handle.ToInt32, GWL_HINSTANCE) Thread = GetCurrentThreadId()
hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProc1, hInst, Thread)
MsgBox("The monthly payment will be " & strPayment)
End Sub

Thank you again for your response to my post and your appreciated input, JorgeL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top