|
Is it possible to activate a winform using its handle?
For example, if you know the handle (intptr) and the window is minimized or behind another window. Is it possible to Activate the winform using that handle?
|
|
|
|
|
you could use interop to use the user32 dll
example here http://www.codeproject.com/vb/net/ActivateSingleAppInstance.asp
|
|
|
|
|
Is there a way without doing it with using the WinHelper? I've seen that link before...but I'm trying to look for another solution without using the WinHelper.
Any suggestions?
|
|
|
|
|
You don't have to put that stuff in it's own class. You can just put the same code into your form code if you want. But, keeping all of your Win32 wrappers in a seperate class like that makes it very easy to reuse without having to copy and paste gobs of code everywhere.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I have 20 or so VB6.0 macros, including an AutoExec macro that I use in Word. Once in a while Users complain that as they type characters into a new, or existing doc, the characters are slow to appear on the screen. My macros only run at the opening of new documents, or the saving/closing of documents. All macros are called by Users via function keys. Only AutoExec is run when Word opens (if I understand the docs correctly). So I "think" none of my code is actually running while a User is in a new, or existing doc, and typing away.
What object do I test to see the current state of the char buffer that Word stores the characters as the User types them in ? I assume the chars are stored somewhere in an object in Word, question is what is it and can I access it and flush it to the screen if it's getting too big ?
Any ideas what is going on here ?
Ed
|
|
|
|
|
Ed Mansky wrote:
What object do I test to see the current state of the char buffer that Word stores the characters as the User types them in ?
There isn't one. The keystrokes are queued up in Word's window message queue waiting to be processed.
Since the message queue isn't being processed very quickly, the keystrokes aren't getting to the application code, so it looks like it's dragging. This can be caused by your macro code hanging up in a long running loop or some other code, even in Word itself, that is taking all this time to process.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Any way to query and/or flush the message queue of pending keystrokes ?
|
|
|
|
|
Nope.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Tell them to turn off background auto-save.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Thanks, I hadn't thought of that.
|
|
|
|
|
I have created a VB.Net application running on Win XP prof and when I run the program, all seems fine, but all of a sudden the program seems to shutdown. I have added Try-catch statements to all of my functions hoping to catch where it is failing, but no error message comes up. Can anyone help me with this?
Thanks
|
|
|
|
|
The only thing you can do is instrument your code and have it log what it's doing, like entering functions, function parameter values and return values. You'll get a better idea of where this sudden quit is occuring.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Having trouble deciphering the following code. Am I leaving something out or do I need to subtract something or am I way off in left field? Bold area is my main problem at this moment. Thanks
Private Sub Number_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Number.TextChanged
Number.MaxLength = 12
Dim Mystr As String
Dim ok As Boolean = (Number.IndexOf("-") = 3 And Number.LastIndexOf("-") = 7)
If Number.Text.Length = 3 OrElse Number.Text.Length = 7 Then
Number.Text = Number.Text & "-"
Number.Select(Number.Text.Length, 0)
End If
Mystr = Format(222 - 22 - 2222, "###-###-####")
If Number.Text.Length = 12 Then
Number.Visible = True
End If
End Sub
Believe me guys, I am totally confused.
|
|
|
|
|
What are you asking? Are you trying to figure out what the highlighted code does?
If so, it's checking two things. First, does the index of the first "-" character = 3, returning true or false. Then it AND's that to a check to see if the last index of "-" character is 7. The results is a boolean value, true of false saying if these characters are at those positions.
But, it has a serious flaw. What if there is more than two "-" characters in the string?
A better way to do this would be to accept only number characters, or to accept any characters and use the textbox's Validating event to reformat the text in the box.
When the Validating event fires, take the string in the textbox and strip out everything that isn't a numeric character. Then take the end result and make sure there are 9 characters (for an SSN anyway), if not, throw up a messagebox. If you have 9 characters, build a new string with the formatting "-" in it and set the textbox's Text property to that.
For example, I've seen something like this for text entry of a Social Security Number:
Private Sub SSN_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SSN.Validating
Dim tempSSN As String = String.Empty
' Create a temporary string that contains only the
' numbers in the original string as typed by the user.
For i As Integer = 0 To SSN.Text.Length - 1
If IsNumeric(SSN.Text.Chars(i)) Then
temp &= SSN.Text.Chars(i)
End If
Next
If tempSSN.Length = 9 Then
' We should have a string of numbers that looks like this: 295048397
' Reformat it to look like this: 295-04-8397
SSN.Text = String.Format("{0}-{1}-{2}", _
tempSSN.SubString(0, 3), _
tempSSN.SubString(3, 2), _
tempSSN.SubString(5, 4))
SSN.BackColor = Color.White
e.Cancel = False
ElseIf tempSSN.Length <> 0 Then
' If the length is now anything other than 0 or 9, clear
' the textbox and color it red to point out that we need a valid
' SSN in this box to continue.
SSN.Text = String.Empty
SSN.BackColor = Color.Red
e.Cancel = True
Else
' Since the SSN length is 0, it's OK to not have an SSN. Clear
' the textbox and return it to normal.
SSN.Text = String.Empty
SSN.BackColor = Color.White
e.Cancel = False
End If
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok let me see if I can transalte this to my telephone validater program and will repost because I know I will still be confused. Don't know how you guys got so good at this.
Believe me guys, I am totally confused.
|
|
|
|
|
Another question. Just how do you place a Masked Edit Control on a form. I see where you code the code but how do you actually place a masked edit control on the form itself i.e. a form that will only allow numbers to be typed in. Think the code would be:
With MaskEdBox1
.Mask = "###-###-####"
.PromptChar =""
End With
End Sub
I just can't get past the MaskedBox1 saying that it's not declared.
Believe me guys, I am totally confused.
|
|
|
|
|
Right-click in the ToolBox and select Add/Remove Items. You can then click on the COM tab and find the Microsoft MaskedEdit Control. Click the checkmark next to that line, then click OK. YOu can then drag the control out from the ToolBox onto your form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks again guy, you're the greatest. Hate being a pain though. On my previous code after adding a mask edit box, should it not prevent numbers from being type in. Btw, when I added the maskeditbox it loaded as AxMaskEdBox1 so I changed the code to that also but it still allows other characters. Here it is again.
Private Sub Form1_Load()
With AxMaskEdBox1
.Mask = "############"
.PromptChar = ""
End With
End Sub
Believe me guys, I am totally confused.
|
|
|
|
|
Forget it. No longer a problem.
Believe me guys, I am totally confused.
|
|
|
|
|
Maybe I need to be a little more specific. Here's what I'm trying to do. I'm trying to limit my text box to 12 numeric characters whereas two of the characters are dashes(-). I feel if I can get this taken care of I might be able to further produce the code I need but without this box functioning correctly all the other codes will be mute. Thanks
Believe me guys, I am totally confused.
|
|
|
|
|
Do the dashes have to be in the exact same place every time? Are you talking about a North American phone number?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes but after working on it I was able to figure that one out. Still having problem with the code but at least I got that part. For some reason, my message box does not appear when I click on the validate button but when I click on the exit button. These projects are killing me, guess that's what school is all about. Once I get that worked out, the only thing left will be to break it down into area code, prefix and suffix substrings textboxes. Getting there.
Private Sub Button1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Button1.Validating<br />
<br />
If Phone.Text.Length = 12 Then<br />
MsgBox("You have entered a valid phone number")<br />
ElseIf Phone.Text.Length <> 0 Then<br />
Phone.Text = String.Empty<br />
Phone.BackColor = Color.Red<br />
e.Cancel = True<br />
Else<br />
Phone.Text = String.Empty<br />
Phone.BackColor = Color.Plum<br />
e.Cancel = False<br />
End If<br />
End Sub
Believe me guys, I am totally confused.
|
|
|
|
|
I've got MSDN integrated help installed with my copy of VS.net. The mouseover function descriptions work fine in C#, but don't even want to know in VB.
Where can i enable this feature so that mousovers in VB will display a description of the function / object, etc.
Cheers
Tris
|
|
|
|
|
It should be enabled by default. I don't know where it is, but you might want to check under Tools/Options/Environment.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well, i checked all these settings first. It was odd because it's enabled and works fine with C#. I'm not sure if it's a problem with VB, or VS.net?
Any more ideas? Is this a known issue? Or shouldn't it happen?
Cheers
Tris
|
|
|
|