|
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
|
|
|
|
|
Hi,
I need speech to text examples.pls help me.
|
|
|
|
|
Could you be a little more specific? What library/controls/API package(s) are you using to do the speech recognition?
Microsoft has at least 3 packages that I know of, then there are third party packages...
RageInTheMachine9532
|
|
|
|
|
hi,
I am using Sapi.could u give some guidence.
|
|
|
|
|
Well, SAPI 5.2 is the foundation of the Speech Application SDK, but version one of this SDK is at Beta 3 right now. You can try it out by following the Getting Started for First-Time Users here[^]. There is also a pretty decent tutorial on it here[^].
I haven't used it myself, but I tried out the tutorial with no real problems.
RageInTheMachine9532
|
|
|
|
|
I have a program that needs to have focus all the time but have no idea where to start.
The program is set to form on top but I do not want it to lose focus. Please help!!
|
|
|
|
|
First, your Application never really has the focus. It's title bar changes color because one of it's child controls has the focus. A form is nothing but a control, but a control that can contain other controls.
Individual controls get and lose focus. Its a pain to manage if your trying to retain the input focus to just your app (form). You have to keep track of which control actually has the focus and if none of your child controls has the focus anymore, which control do you give it back to?
A better way would be to redo the form(s) your using and show them as system modal dialog boxes. This way, Windows manages the focus for you and you can't leave the app until the dialog box goes away. Search the documentation for ShowDialog to see what I mean.
Your app needs to have the focus all the time? Why? It kind of make using the rest of the system a pain to use if you can't so much as click on the "Start" button...
RageInTheMachine9532
|
|
|
|
|
I need to validate a password field with RegularExpression Validator. The validation logic is bit complex for me. Can anyone help me out with this
Password must be a minimum of 8 characters and contain a combination of 3 of the following characters:
- numbers
- upper case letters
- lower case letters
- special character (*%$)
I need this urgently. PLEASE SOMEONE PLS HELP.
THANKS in advance
|
|
|
|
|
A regular expression to do this (mostly because of the 3 out of 4 clause, would be incredibly long and would require intensive CPU time and quite a bit of memory. I would recommend that you instead create a custom validator that enumerates the characters and keeps a count, something like this:
' Assume password is in a string variable called "password"
If password.Length < 8 Then Return False
Dim i As Integer = 0
Dim b1 As Boolean
Dim b2 As Boolean
Dim b3 As Boolean
Dim b4 As Boolean
For Each c As Char In password
If Char.IsLetter(c) Then
If Char.IsLower(c) And Not b1 Then
b1 = True
i++
Else If Not b2
b2 = True
i++
End If
Else If Char.IsNumber(c) And Not b3 Then
b3 = True
i++
Else If (c = "*"c Or c = "%"c Or c = "$"c) And Not b4 Then
b4 = True
i++
End If
Next
If i >= 3 Then Return True
Else Return False
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|