how to use system api ,the follow code is for vb6,how to enable it in vb.net
http://msdn.microsoft.com/library/de...ialogBoxes.asp
thanks.
Printable View
how to use system api ,the follow code is for vb6,how to enable it in vb.net
http://msdn.microsoft.com/library/de...ialogBoxes.asp
thanks.
My code as follow, I got 3 ERROR as marked.
thanks.Quote:
'Common Dialog DLL Calls
Private Declare Function FindText _
Lib "comdlg32.dll" _
Alias "FindTextA" (ByVal pFindreplace As FINDREPLACE) _
As Long
Private Declare Function ReplaceText _
Lib "comdlg32.dll" _
Alias "ReplaceTextA" (ByVal pFindreplace As FINDREPLACE) _
As Long
'''''''''''''
Private Structure FINDREPLACE
Dim lStructSize As Long
Dim hwndOwner As Long
Dim hInstance As Long
Dim flags As Long
Dim lpstrFindWhat As String
Dim lpstrReplaceWith As String
Dim wFindWhatLen As Integer
Dim wReplaceWithLen As Integer
Dim lCustData As Long
Dim lpfnHook As Long
Dim lpTemplateName As String
End Structure
'''''''''''''''''''
'Delcaration of the type structure
Dim frText As FINDREPLACE
''''''''''''''''''''''''''
Private Sub Form_Load()
'Set the Find/Replace Type properties
With frText
.lpstrReplaceWith = "Replace Text"
.lpstrFindWhat = "Find Text"
.wFindWhatLen = 9
.wReplaceWithLen = 12
.hInstance = App.hInstance
'''''''''''''ERROR:app is not declared
.hwndOwner = Me.hWnd
''''''''''''ERROR:hWnd is not a member of form
.lStructSize = LenB(frText)
''''''''''''''''''''ERROR:name 'LenB' is not declared
End With
End Sub
'''''''''''''''''''
Public Function m_find()
'Call the find text function
FindText(frText)
End Function
Public Function m_replace()
'Call the replace text function
ReplaceText(frText)
End Function
VB6 -->VB.NET
First rule : change all long types to integer so :
VB Code:
Long = Integer Any = Object App = Application Me.hWnd = Me.Handle LenB = Len
many thanks
but where to put line:(Quote:
any=object
.hInstance = Application.?????
how to write this line,thanks
I can't see it anywhere but if you ever face it , just replace the As Any by As Object because there is no such data type in .NET .Quote:
Originally posted by iqueen
many thanks
but where to put line
:(
What does 'hInstance' do ?Quote:
Originally posted by iqueen
.hInstance = Application.?????
how to write this line,thanks
In msdn :
how to rewrite it in vb.netQuote:
You create and display a Find dialog box by initializing a FINDREPLACE structure and passing the structure to the FindText function. You create and display a Replace dialog box by initializing a FINDREPLACE structure and passing the structure to the ReplaceText function.
The FINDREPLACE structure contains information that the FindText and ReplaceText functions use to initialize the Find and Replace dialog boxes. The FINDMSGSTRING registered message uses this structure to pass the user's search or replacement input to the owner window of a Find or Replace dialog box.
Syntax
typedef struct {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
DWORD Flags;
LPTSTR lpstrFindWhat;
LPTSTR lpstrReplaceWith;
WORD wFindWhatLen;
WORD wReplaceWithLen;
LPARAM lCustData;
LPFRHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
} FINDREPLACE, *LPFINDREPLACE;
That's C++ . The thing is some of C\C++\C# data types have no upgrade or transform path to VB .lp...is a pointer . There is no pointers in VB.NET . If you can find VB version or find another way .
that means I cannt use system comdlg32.dll in vb.net ? :(Quote:
Originally posted by Pirate
That's C++ . The thing is some of C\C++\C# data types have no upgrade or transform path to VB .lp...is a pointer . There is no pointers in VB.NET . If you can find VB version or find another way .
then how can I enable find/replace function in my app in richtextbox like system function does.
Apparently , with this code (below), it would be quite difficult . But the code you posted in the second post might be transformed to work with .NET . Do you have working example in VB6 ?
VB Code:
typedef struct { DWORD lStructSize; HWND hwndOwner; HINSTANCE hInstance; DWORD Flags; LPTSTR lpstrFindWhat; LPTSTR lpstrReplaceWith; WORD wFindWhatLen; WORD wReplaceWithLen; LPARAM lCustData; LPFRHOOKPROC lpfnHook; LPCTSTR lpTemplateName; } FINDREPLACE, *LPFINDREPLACE;