|
Calling a Dialup connection
|
|
|
|
|
I am developing an ActiveX in VB6 control to be used in a html page. The control is downloaded and installed from the web (there is a codebase tag in html). The control then calls servlets, the servlet address is a parameter in html.
I wold like to avoid an url parameter in the object tag. Can the control in any way retrieve the url from the browsers session?
|
|
|
|
|
I have a windows apllication ,I want to connect to the SQL Server database which is in the web server at USA .Can any one please tell me how to connect the database using VB.NET.
Any response with source code will be highly appreciated.
Thanks in advance
|
|
|
|
|
Hi Friends,
when i call a MSMAPI object from a standalone exe in VB .NET, i am able to send a mail. But when i spawn this exe as a process from a windows service, i get an error message while signing on using the MAPI session SignOn() method. I tried using windows service logon as both local system and using my NT logon too. The error message thrown is
System.Runtime.InteropServices.COMException (0x800A7D1A): Not supported
at MSMAPI.MAPISessionClass.SignOn()
at ProcTryMail.tryMail.Pr_SendMail() in D:\Projects\Ems\Backup_Nov17OutSeq\ProcTryMail\tryMail.vb:line 20
My feeling was that some security access is required.
The code i have used is:
Public Class tryMail
Private objMapiSession As MSMAPI.MAPISession
Private objMapiMsgs As MSMAPI.MAPIMessages
Private i As Boolean
Public Sub Pr_SendMail()
Try
objMapiSession = New MSMAPI.MAPISession()
objMapiMsgs = New MSMAPI.MAPIMessages()
objMapiSession.SignOn()
objMapiMsgs.SessionID = objMapiSession.SessionID
objMapiMsgs.Compose()
objMapiMsgs.RecipDisplayName = "--give some mail id here--"
objMapiMsgs.MsgSubject = "From .NET MAPI"
objMapiMsgs.Send()
objMapiSession.SignOff()
Catch
End Try
End Sub
End class
Will be grateful if anyone of u is able to find out the problem.
Thanks
Alex
|
|
|
|
|
OK. When you run the project as a standalone .EXE, do you get a dialog box when you execute the SignOn method? You should, because that is the default behavior for the Session control. Problem is, as a service, there is no desktop, and therefor no user interface to display a dialog box.
You might want to try setting the LogonUI property of the control to FALSE and setting the UserName and Password properties before you call SignOn.
RageInTheMachine9532
|
|
|
|
|
Thanx RageInTheMachine9532. Setting the LogonUI property to false solves the problem.
|
|
|
|
|
Hi folks, my problem is too dificult for me to parse. I need to translate this code snipet to VB.NET :
public RECT SetTVItemRECTHandle(IntPtr hItem,RECT RC){
RECT rc1=new RECT();
unsafe
{
*(IntPtr*)&rc1 = hItem;
}
return rc1;
}
The part that bugs me and got me lost is the '*(IntPtr*)&rc1 = hItem;' thing. For now I'm relying on a C# function in a DLL to accomplish the work but I'd like to know if it can be done in VB so that I can discard this extra dependency from my solution. For your information, this function is used to retrieve the rectangle for a list view column header for owner drawing.
Thanks
The_Warlord
|
|
|
|
|
I could be wrong, but it looks like rc1 is being declared as a RECT class and a new object is being created. Then it changes the address of the rc1 class to point to a segment of memory that hItem is pointing to. As far as I know, VB doesn't support this.
RageInTheMachine9532
|
|
|
|
|
Could you post the code that leads up to this? I'm looking for the code that generates the 'hItem' and 'RC' parameters so I can play with it and see what the possiblities are.
Thanks,
RageInTheMachine9532
|
|
|
|
|
The context is custom draw a treeview, in particular a tree node. Here is the WndProc from my Component:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim intLeft As Integer
Dim RC As RECT
Dim RC2 As CantDoInVBButInCSharp.RECT
Dim RCF As RectangleF
Dim nm1 As NMHDR
Dim nmcd As NMTVCUSTOMDRAW
Dim hNode As IntPtr
Dim PU As New CantDoInVBButInCSharp.PointerUtils()
If m.Msg = ReflectedMessages.OCM_NOTIFY Then
nm1 = m.GetLParam((nm1.GetType))
If nm1.code = NotificationMessages.NM_CUSTOMDRAW Then
nmcd = m.GetLParam(nmcd.GetType)
If nmcd.nmcd.dwDrawStage = CustomDrawDrawStateFlags.CDDS_PREPAINT Then
m.Result = New System.IntPtr(CustomDrawReturnFlags.CDRF_NOTIFYITEMDRAW)
End If
If nmcd.nmcd.dwDrawStage = CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT Then
hNode = New IntPtr(CInt(nmcd.nmcd.dwItemSpec.ToString))
RC2 = PU.SetTVItemRECTHandle(hNode, Nothing)
SendMessage2(Handle, TreeViewMessages.TVM_GETITEMRECT, 1, RC2)
mvarTextBrush = New LinearGradientBrush(New Rectangle(RC2.left, RC2.top, RC2.right - RC2.left, RC2.bottom - RC2.top), mvarTextGradientColor1, mvarTextGradientColor2, mvarGradientMode)
Graphics.FromHdc(nmcd.nmcd.hdc).DrawString("Test", Me.Font, mvarTextBrush, New RectangleF(RC2.left, RC2.top, RC2.right - RC2.left, RC2.bottom - RC2.top))
hClickedItem = IntPtr.Zero
m.Result = New System.IntPtr(CustomDrawReturnFlags.CDRF_SKIPDEFAULT)
End If
If nmcd.nmcd.dwDrawStage = CustomDrawDrawStateFlags.CDDS_ITEMPOSTPAINT Then
End If
ElseIf nm1.code = TreeViewNotifications.TVN_ITEMEXPANDEDW Then
Me.Invalidate()
m.Result = IntPtr.Zero
ElseIf nm1.code = TreeViewNotifications.TVN_ITEMEXPANDINGW Then
Me.Invalidate()
m.Result = IntPtr.Zero
ElseIf nm1.code = TreeViewNotifications.TVN_SELCHANGINGW Then
Me.Invalidate()
m.Result = IntPtr.Zero
End If
ElseIf m.Msg = Msg.WM_ERASEBKGND Then
'If Not (hClickedItem.Equals(IntPtr.Zero)) Then
MyBase.CreateGraphics.FillRectangle(mvarBackBrush, ClientRectangle)
ControlPaint.DrawBorder3D(MyBase.CreateGraphics, ClientRectangle, mvarBorderStyle)
'End If
m.Result = New System.IntPtr(CustomDrawReturnFlags.CDRF_SKIPDEFAULT)
ElseIf m.Msg = Msg.WM_SIZING Then
mvarBackBrush = New LinearGradientBrush(ClientRectangle, mvarGradientColor1, mvarGradientColor2, mvarGradientMode)
ElseIf m.Msg = ReflectedMessages.OCM_VSCROLL Then
'm.Result = IntPtr.Zero
Else
MyBase.WndProc(m)
End If
End Sub
Thank you for your time.
The_Warlord
|
|
|
|
|
Sorry, but I haven't been able to get a solution to this problem to work. I'm still working on it, but It's been slow since I've been moving my girlfriend! 8)
RageInTheMachine9532
|
|
|
|
|
Has anyone out there created an application using "dynamic" function calls. By dynamic I mean that you can instanciate an ActiveX object using the CreateObject() function and then make a call to a function using another variable. Maybe the following example will illustrate my questions.
Let's say there is an ActiveX DLL called TestDll, that contains a class called Test, which has a method called GetText() and it returns a String. In the following code I want to access the GetText method "dynamically". See below...
...
Dim obj as Object
Dim sFunctionName as String
Dim sResult as String
' Create my Test object
Set obj = CreateObject("TestDll.Test")
' Set the name of the function that I want to call "dyanmically"
sFunctionName = "GetText"
'Now dynamically call GetText
'The following line obviously doesn't work and what I'm trying to do is make a call to obj.GetText()
sResult = obj.[sFunctionName]
...
If anyone has any constructive ideas, I'd be appreciated.
|
|
|
|
|
|
How about using the CallByName function?
|
|
|
|
|
The CallByName function would do this. But I have to ask why you would want to go through such a hassle? There is no type checking of data being passed to the function or for the type of call your making. On top of that, using this function does not support return values from functions using ByRef passing and there is also a performance penalty.
RageInTheMachine9532
|
|
|
|
|
I'm in research mode and am not yet sure if I do want to go through the hassle. However, I'm trying to develop a class that is flexible enough to read different "lookup" tables from a database into a "collection" (I don't necessarily mean the Collection class). Normally, I would structure the lookup tables so that one set of code would read them all. But in this instance I don't have that luxury. Thanks for your help.
|
|
|
|
|
I created the class called myClass as following in vb.net
<br />
public Class myClass <br />
Public Function add(num1 As Integer, num2 As Integer)<br />
Dim result As Integer<br />
result = (num1+num2)<br />
set add=result<br />
End Function<br />
<br />
End class<br />
<br />
I saved it as myClass.vb
And I go back to the form1.vb
<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
Dim pf As New myClass<br />
pf.PrintWord("c:\pckm\101.doc/name_/format_autodate/autodate_/end_")<br />
End Class<br />
<br />
but I have error C:\DotNetProgs\myProg\myProg\Form1.vb(60) : error BC30188: Declaration expected.
|
|
|
|
|
First, your myClass doesn't have a PrintWord method, unless there is extra code in there your not showing us. Also, from the code you have shown us, myClass is a keyword and can't be used as the name of a class. Plus, your class can be greatly simplified like this:
Public Class testClass
Public Function add(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Return num1 + num2
End Function
End Class
Second, we need to see line 60 of Form1.vb and the code surrounding it to be able to tell you what is going on.
RageInTheMachine9532
|
|
|
|
|
OK. I am confused. I thought deployment was suppose to be easier.
I have a VB.NET app that uses 3rd party DLL's to display a map on the UI and create routes for fleet tracking.
The data is loaded from a web service that uses SOAP to return XML data points that are used to map the routes.
I am getting DLL registration errors on the client's PC when they try to install the app. I used the VS.NET template to create the msi.
What gives???
I should add that the target system had the SOAP SDK and the .NET framework installed on it prior to the app being installed.
Any ideas why the install is getting errors? I thought .NET was not suppose to register DLL's.
|
|
|
|
|
What registration errors for what .DLL's?
Compared to the Package and Deployment Wizard in VB6, the new Deployment Projects are easier and FAR more flexible. Since your using 3rd party DLL's, you still have to make sure that those DLL's get into the .MSI and are registered properly, if needed. The new Deployment Projects DO make deployment easier, but it can't follow the dependancy trail of every single DLL, that MIGHT be called by your app.
RageInTheMachine9532
|
|
|
|
|
They are getting errors on MSSOAP30.DLL and MSXML4.DLL.
The errors say "COM Object with CLSID = "...."... unable to register.
When the client tries to register the DLL's manually (those that were copied during the install into the app's subdirectory) the REGSVR32 reports a "no entry point" error.
I am assuming that the DLL's do "get into the .MSI" because they are copied to the target machine during the install.
What am I missing?
|
|
|
|
|
Hey fellow coders.
I'm writing a program in VB that is designed to take the question and answer file for IRC trivia bots and convert the file format over to be used with another type of trivia bot. As an example of what I need to do here is an example of text I need to parse
I need to convert the line below:
What band got their name from the sixties movie Barbarella?*Duran Duran
To this line:
Duran Duran|What band got their name from the sixties movie Barbarella?
Now, this program opens a text file and copies the entire file to one string variable. That code looks like this:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim currsep As String, newsep As String, lineoftext As String, filetext As String
Private Sub mnu_file_open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_file_open.Click
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt"
OpenFileDialog.ShowDialog()
If OpenFileDialog.FileName <> "" Then
FileOpen(1, OpenFileDialog.FileName, OpenMode.Input)
Do Until EOF(1) 'read file into RAM
lineoftext = LineInput(1)
filetext = filetext & lineoftext & vbCrLf
Loop
lbl_open.Text = "File is open and ready to be converted"
FileClose(1)
End If
End Sub
Private Sub cmd_conv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_conv.Click
'this procedure takes the file (in variable filetext) and performs the parsing.
End Sub
End Class
any ideas for cmd_conv_click?
|
|
|
|
|
Don't read the entire file into a string variable. That isn't necessary at all an makes you job that much harder. What you do is open 2 files. 1 is the file you want to convert, 2 is the file you want to convert to. You do the same thing you did in your sample code with the LineInput but you look for the '*' character and split the string into two strings. Then recombine the strings into the new format and write that into the second file.
Private Sub Convert()
Dim SourceString As String
Dim TargetString As String
Dim Parsed() As String
FileOpen(1, "C:\Source.txt", OpenMode.Input)
FileOpen(2, "C:\Target.txt", OpenMode.Output)
Do Until EOF(1)
SourceString = LineInput(1)
Parsed = SourceString.Split("*")
TargetString = Parsed(1) & "|" & Parsed(0)
PrintLine(2, TargetString)
Loop
FileClose(1, 2)
End Sub
RageInTheMachine9532
|
|
|
|
|
That code works.....for the most part. The problem is if the question/answer set is not all on one line it will crash with a "Index was outside the bounds of the array". error. one condition that will cause this is having a question/answer run over onto another line. Here's the current code:
Private Sub mnu_file_convert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_file_convert.Click
currsep = txt_current.Text
newsep = txt_desired.Text
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt"
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt"
OpenFileDialog.ShowDialog()
SaveFileDialog.ShowDialog()
If OpenFileDialog.FileName <> "" And SaveFileDialog.FileName <> "" Then
FileOpen(1, OpenFileDialog.FileName, OpenMode.Input)
FileOpen(2, SaveFileDialog.FileName, OpenMode.Output)
'Stop
Do Until EOF(1)
SourceString = LineInput(1)
Parsed = SourceString.Split(currsep)
If lst_current.SelectedIndex = 1 And lst_desired.SelectedIndex = 0 Then
TargetString = Parsed(1) & newsep & Parsed(0)
PrintLine(2, TargetString)
Else
TargetString = Parsed(0) & newsep & Parsed(1)
PrintLine(2, TargetString)
End If
Loop
End If
End Sub
End Class
|
|
|
|
|
OK. Then when you parse the string (TargetString=...). Check to see if the array that is returned has 2 elements in it. If not, then you have to go back and read the next line and append it to the one you already have, then parse it again and it should work. Thing is, this will only work if you have 1 question and 1 answer per line or two. If the second line contains the rest of a question, then and answer, then starts another question, you'll run into problems. I know '*' comes between a question and its answer, but is there a second seperator that appears between answer followed by a question?
RageInTheMachine9532
|
|
|
|