|
It would have to be exposed at a COM-based .DLL. You can't get at them otherwise. PInvoke won't do you any good since it only works with function library .DLL's.
|
|
|
|
|
Why are you still using VB6 ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I have an interop assembly being used in VB6 called ConvertOptions that is being used in various .dlls. I have an odd problem occurring. Below is an example of what is occurring.
Sub GetDescriptions
Dim oOpt As New ConvertOptions.ConvertOptions
'Misc VB6 code here...
GetLabelData
'oOpt internal variables are disposed here?
'Misc VB6 code here.
oOpt.dispose
set oOpt = nothing
End Sub
Sub GetLabelData
Dim oOptions As New ConvertOptions.ConvertOptions
'Misc code.
oOptions.dispose
set oOptions = nothing
End Sub
Method GetDescriptions has a local variable called oOpt (of ConvertOptions.ConvertOptions) which then calls GetLabelData. GetLabelData has it's own local ConvertOptions.ConvertOptions variable. At the end of the GetLabelData sub I dispose of the oOptions object.
When execution is returned to the GetDescriptions, the oOpt variable has it's internal objects = nothing.
Each sub has it's own local variable. There is not a module or global variable w/ the same name. The local vars are not passed by reference. The .Net project is not set for single instance. The only place that the variables in question the .Net assembly are destroyed is in the .dispose method.
Am I doing something obviously wrong? If an interop object is diposed of in one method, should it dispose all other interop objects of the same type in other methods?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
This shouldn't be happening. The only case I can think of where it might happen is if you're using static variables in your .NET library.
But, lucky me! I haven't used VB6 in 8 years and don't have it available to me anymore!
|
|
|
|
|
Checked the project, def. no static members. I broke out the code that is declaring and destroying the object (to avoid all code running in between), same thing. If I rem out the .dispose in the 2nd sub, the object remains alive in the sub 1.......but I don't want to start a memory leak.
Regarding VB6, we're in the process of porting everything to .Net - but we have to support the unconverted VB6 stuff in the meantime - not fun~!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Sigh!
I had a var being declare in a module that was being disposed in a class. That was hosing it up.
Thanks Dave.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I know how to make a child form appear in form, set the first form IsMdiContainer to True then, write this when calling the form
Form2.MdiParent = Me<br />
Form2.Show()
Now that is not working when there is ToolStripContainer on the form, it gives error message "{"Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling Show."}"
I add this line before the Show() Form2.TopMost = True, now it does not give any kind of error, but when I press on the button to call the second form(child) nothing happened.
I set the ToolStripContainer.Visible = False and the child windows appear but my ToolStripContainer and its content is not.
Can I show the form as child in form with the existence of ToolStripContainer.
TIA
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
Samir Ibrahim wrote: Form2.MdiParent = Me
Form2.Show()
Now that is not working when there is ToolStripContainer on the form, it gives error message "{"Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling Show."}"
I don't know what you did because you haven't shown a complete code snippet that creates the new child form and displays it. But, MdiChildren CAN have a ToolStripContainer control on them.
|
|
|
|
|
Hi Dave
Dave Kreskowiak wrote: I don't know what you did because you haven't shown a complete code snippet that creates the new child form and displays it
My mistake I did not explain it correctly.
- I have main form (form1) and child form (form2)
- I add a ToolStripContainer to form1 then I clicked on "dock fill in form"
- I add a button on form1
- I have set this property to form1 (IsMdiContainer = True)
- In the button_click I write this code.
Form2.MdiParent = Me
Form2.Show()
- If I did not clicked on ToolStripContainer "dock fill in form" the child form is displayed behind ToolStripContainer
- ToolStripContainer exist on the parent form (form1) not child form.
Thanks in Advance.
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
Samir Ibrahim wrote: If I did not clicked on ToolStripContainer "dock fill in form" the child form is displayed behind ToolStripContainer
Yes it does, and so does the button you dropped on Form1 too. This is because your MdiChild forms are rendered inside a control that's automatically added to an MdiParent form, called MdiClient. This control is docked to fill the MdiParent form. Normally, the only thing that will change the dimensions of this container are other docked controls on the parent form.
You really should not be dropping undocked controls directly on Form1. They should be in docked containers, like the ToolStripContainer.
|
|
|
|
|
I got the idea.
Thank you very much.
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
hello everyone
in my app i need to detect more than one keypresses
like while key "1" is pressed i need to know if key "2" is also pressed
,ie, both keys are pressed at the same time or not?
can any one help me??
TheMrProgrammer
|
|
|
|
|
The only way I know to do this is to use the API call GetKeyboardState() , unless someone knows of a simpler way.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
write your own code using the key_down/key_up events - the below code writes out to the debug window each key has been pressed(down). once you lift up on a key it shows it has been released(up).
Private _KeyDown As New List(Of Int16)
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If Not _KeyDown.Contains(e.KeyCode) Then
_KeyDown.Add(e.KeyCode)
Debug.Print("d:" & Chr(e.KeyValue))
End If
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
If _KeyDown.Contains(e.KeyCode) Then
_KeyDown.Remove(e.KeyCode)
Debug.Print("u:" & Chr(e.KeyValue))
End If
End Sub
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Nice code. I can use this to, but a question: It seem to me that the maximum numbre of simultanious keys is 3. Is this normal?
|
|
|
|
|
Historical.
Ctrl Alt Delete
Ctrl Shift (a Key)
Shift AltGr (a Key)
Any more than three is deemed to be elbows on the keyboard.
I believe this can be altered, but alas not by me. Dave Kreskowiak may know this. Ask him,
------------------------------------
"Possessions make you poor, wealth is measurable only in experience."
Sun Tzu 621BC
|
|
|
|
|
I adapted Larson's code just slightly (you need to disable TextBox1 by the way):
Private WithEvents _KeyDown As New List(Of Int16)
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If Not _KeyDown.Contains(e.KeyCode) Then
_KeyDown.Add(e.KeyCode)
TextBox1.Text &= Chr(e.KeyCode)
End If
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
If _KeyDown.Contains(e.KeyCode) Then
_KeyDown.Remove(e.KeyCode)
TextBox1.Text = TextBox1.Text.Remove(TextBox1.Text.IndexOf(Chr(e.KeyCode)), 1)
End If
End Sub
I managed to press more than 2 keys, but not all combos work, and some combos act like alt+ctrl etc. and other combos somehow work without a hitch.
My advice is free, and you may get what you paid for.
|
|
|
|
|
The is the normal max that will work reliably.
If you want more than that, you're going to have to go to DirectX and it's DirectInput library, or use the XNA Framework (C#) to simplify using all the DirectX stuff.
|
|
|
|
|
|
Hi all,
i used the following code to get the registerd dll full path
Dim ins As RegistryKey
ins = Registry.ClassesRoot.OpenSubKey("RuleProcessor.Processor")
Dim clsid As String = ins.GetValue("").ToString
ins.Close()
Dim clsidKey As RegistryKey = Registry.ClassesRoot.OpenSubKey(clsid)
Dim manifestLocation As String = clsidKey.GetValue("CodeBase").ToString
clsidKey.Close()
RuleProcessor.Processor is the progId
but it doesn't work, i want to know where is the error
Thanks
|
|
|
|
|
What do you mean by it doesn't work?
Does it throw an exception? Does it give an unexpected result?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
yes at this line
Dim manifestLocation As String = clsidKey.GetValue("CodeBase").ToString it get this error
object reference to set to an instance of object
|
|
|
|
|
Almost certainly the error is referring to clsidkey , because it is null.
I could tell you why it is null, but you will learn far more by debugging this section of code. Step through it and observe where one of your variables becomes null, when you don't expect it to be.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i debug the code many and many times
<br />
ins = Registry.ClassesRoot.OpenSubKey("RuleProcessor.Processor")<br />
Dim clsid As String = ins.GetValue("").ToString<br />
the result of these lines is clsis = RuleProcessor.Processor
so i think that the ins will be equal to clsidkey
<br />
<br />
Dim clsidKey As RegistryKey = Registry.ClassesRoot.OpenSubKey(clsid)<br />
clsidkey not null
so it you know any other solution tell me please
Thanks for your help
|
|
|
|
|
OK.
And when you move the mouse pointer over the various terms in the error line:
Dim manifestLocation As String = clsidKey.GetValue("CodeBase").ToString
which one shows up as nothing?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|