|
|
SateeshVankayala wrote: urgent please
Urgent for you, not to anyone else.
And you seriously think people will draft an email or call you to provide you with the information you need? If this is your attitude towards learning, I'm sure you wouldn't learn anything in your life.
|
|
|
|
|
In keypress event the character which i press should come after my input which i send using send keys.
here is the code
if asc(e.keychar)=102 then 'ascii value of "f"
system.windows.forms.sendkeys.send("A")
end if
"f" should come after "A",but it is displaying as "fA"
How to solve this guys....
|
|
|
|
|
|
You can set the SuppressKeyPress property of the KeyEventArgs supplied in your event handler to true and then pass on both A and F in the SendKeys.
|
|
|
|
|
Hi,
I have created a custom addIn for outlook 2007 using VS2010.
I have created a custom Ribbon using xml containing a single toggleButton control. This is for new message screen. After clicking the "New Mail Message" from outlook custom ribbon visible along with the toggle button. Once I pressed the toggle button and sent the mail the toggle button remains same (on press) for every new message later. Can anybody please help me how to make toggleButton getPressed status to unchecked for every new mail message click event.
Thanks.
|
|
|
|
|
Why are you even using a toggle button? Why not a normal button??
|
|
|
|
|
byte b1 = 4;
byte b2 = 2;
byte result = b1 - b2 //error here Cannot explicitly convert type 'int' to 'byte'. Are you missing a cast?
Question is : where does the compiler see the 'int' here, where all variables are byte?
|
|
|
|
|
It is a feature of C#. The byte variables are widened to integers before performing the subtraction. Hence, the result is an integer. You can prove this to yourself with this:
object o = b1 - b2;
MessageBox.Show("o is a: " + o.GetType().FullName); So to get rid of that nasty error:
byte result =(byte)(b1 - b2); See: Why do operations on "byte" result in "int"?[^] for an explanation of why this was done.
|
|
|
|
|
|
Guys i am designing a editor,and in this editor i am using keypress event to block the pressed key and adding my input key to the text box.While adding the characters the scroll bar is automatically moving to the top of the page
i have used "textbox1.scrollcaret" also but it is always making the cursor line to be a last line.
Example
after few lines have been entered
if i add
if asc(e.keychar)=102 'For "f" ascii value of f is 102
e.handled =true
textbox1.text=textbox1.text + "c"
end if
How to solve this problem guys....
|
|
|
|
|
You are making it to complex.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = "f"c Then
e.KeyChar = "c"c
End If
End Sub
This will work fine for the user using the keyboard, but have you thought about how you are going to handle the user pasting text? That will not get translated using this method.
|
|
|
|
|
Thanks a lot "TnTinMn" this has solved my problem exactly.
|
|
|
|
|
When I press any character in any editor the corresponding character should not be displayed on the screen and instead of the blocked character i would like to display my own characters in that editor.
i have to do this with my minimized form i.e when my form is in background and when it is closed the inputs should be displayed on the screen as i type.
How to do this process?
|
|
|
|
|
You can't. Minimized forms do not receive input. Further, it'll never work for "all applications"; I doubt that Warcraft lets you modify the contents of the password-textbox.
Did you try the virtual keyboard I linked to in your previous post?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ya i took those two lines of code but i dont know how to use it.
Can you give me any example how to use it......plzzzzzz.
|
|
|
|
|
Hi everybody,
I have a simple project with a form and a class in another file to manage the COM port (from the article "Smart Device Print Engine for Compact Framework" by Orkun GEDiK).
I open the COM port and I start its thread for receiving data.
I want to write the received data in a textbox in the form.
To do this, every byte I receive, I assign the value of this byte to a byte variable of the form called byt and I call from inside the loop of the thread a function in the form that stores all the bytes in a string dati (in hexadecimal format):
Public Sub ScriviTesto2()
Dim str As String
If InvokeRequired Then
Invoke(New Action(AddressOf ScriviTesto2))
Return
End If
Try
str = Hex(byt)
dati &= str & " "
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
This seems to work because if I run the code step by step I see that the string dati grows byte by byte and contains the correct values.
When there are no more bytes to receive, always from inside the loop of the thread, I call another function of the form that should write my string in a text box:
Public Sub ScriviTesto3()
If InvokeRequired Then
Invoke(New Action(AddressOf ScriviTesto3))
Return
End If
TB1.Text &= dati & vbCrLf
End Sub
...this function write nothing in the text box... why?
The string data contains the right values, is not empty.
I tried another way: I don't call the last funcion (ScriviTesto3() ) but, when there are no more bytes to receive, I click a button of the form that do the same:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TB1.Text &= dati & vbCrLf
End Sub
In this case, when I click the button the string dati is empty... I don't know why.
I add the declaration of the involved variables:
Public Class Form1
Public byt As Byte
Protected dati As String
...
Can anyone help me?
Thanks in advance.
|
|
|
|
|
steve_9496613 wrote: I call another function of the form that should write my string in a text box: Pass the data to display there as a parameter.
steve_9496613 wrote: In this case, when I click the button the string dati is empty... I don't know why. Access to the form's field isn't thread-safe. You could lock it in a property, but that slow down things nicely. Hence, I'd suggest to create a list of bytes on your receiver-thread, and to pass this as a paramater to the form, say, once a second.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy.
I have modified the first function as you suggested to do for the second one:
Public Sub ScriviTesto2(ByVal dato As Byte)
Dim str As String
If InvokeRequired Then
Invoke(New Action(Of Byte)(AddressOf ScriviTesto2), dato)
Return
End If
Try
str = Hex(dato)
dati &= str & " "
TB1.Text &= Hex(dato) & " "
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
In the receiver thread I call this function every byte I receive, passing to it the byte just received.
As before the string dati grows byte by byte so I can say that I correctly pass the parameter dato to this function but nothing is written in the text box TB1 .
Writing byte by byte in a textbox is not the fastest way but I just wanted to see if passing data as parameter to the function could be the solution.
Perhaps the text box is not the right objet to use or, more likely, I'm missing something important.
I did another try: as you suggested I created a byte array in the receiver thread, I fill it with the bytes received and at the end of data reception I call another function in form1 passing to it the byte array:
Public Sub ScriviTesto4(ByVal datiIn As Byte())
Dim i As Int32
If InvokeRequired Then
Invoke(New Action(Of Byte())(AddressOf ScriviTesto4))
Return
End If
For i = 0 To (datiIn.Count - 1)
TB1.Text &= Hex(datiIn(i)) & " "
Next
TB1.Text &= vbCrLf
End Sub
Running step by step in debug I see that the array datiIn contains the right bytes and also the TB1.Text contains the right values but I see nothing in the text box in the form!
What I'm doing wrong?
|
|
|
|
|
steve_9496613 wrote: Perhaps the text box is not the right objet to use or, more likely, I'm missing something important. It's not optimal, but it should display some text. That's what it's there for.
steve_9496613 wrote: Running step by step in debug I see that the array datiIn contains the right bytes and also the TB1.Text contains the right values but I see nothing in the text box in the form! Did you create the textbox on the mainthread?
For i = 0 To (datiIn.Count - 1)
string x = Hex(datiIn(i)) & " "
TB1.Text = TB1.Text + x
Next Can you write the string x to the debugger?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Did you create the textbox on the mainthread? I added the textbox to the form1 in the designer, it should be in the main thread.
In form1 I declared an instance of the class to manage the COM:
Dim NewCom As CommDev
In the Load event of the form I create the new object:
NewCom = New CommDev()
In the New function of the class some parameters are set, like baud rate, parity, etc.
When I open the COM port, I call an Init function that opens the COM port, sets buffer sizes, sets the device control block, sets timeouts, creates and starts the receiver thread.
Eddy Vluggen wrote: Can you write the string x to the debugger? I used your code instead of mine and I can see the value of the string x , I mean that I can "add an expression control" (I don't know if this is the right translation of the italian "Aggiungi espressione di controllo" that appear in the right click menu over a variable during debug) to the string x and see its right value in the bottom windows of Visual Studio.
Nothing appears in the textbox...
I made also another try:
Public Sub ScriviTesto4(ByVal datiIn As Byte())
Dim i As Int32
If InvokeRequired Then
Invoke(New Action(Of Byte())(AddressOf ScriviTesto4))
Return
End If
For i = 0 To (datiIn.Count - 1)
TB1.Text &= Hex(datiIn(i)) & " "
Next
ScriviLabel(TB1.Text)
TB1.Text &= vbCrLf
End Sub
Private Sub ScriviLabel(ByVal stringa As String)
Label1.Text = stringa
End Sub
What I can see in the debug is that TB1.Text , stringa and Label1.Text all contains the right values but nothing appear in the window of my application.
It seems to be a "visualization" problem, perhaps related to threads, but I'm not able to see the error.
|
|
|
|
|
Can you add another label on the form?
Private Sub ScriviLabel(ByVal stringa As String)
Label1.Text = "Hello world"
Label2.Text = stringa
End Sub
This is the point where I'd paranoidly check the colour of my font.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy,
thanks for your efforts.
I add the second label but no label takes the right content in the form; in the debug the Text properties contain my string and the "Hello world" string.
I also call the Refresh method of labels and form but nothing changes.
Before I did another project where I used the SerialPort object of .NET, everything was in the form1 and I used the DataReceived event of the COM to write in the textbox the received data, always using the Invoke method, and everything was OK.
In this project I don't use the SerialPort object but the API in coredll.dll (CreateFileW , ReadFile , SetCommMask , etc.) because I need to catch different information from the COM port and all this is in a separate class/file.
This is the main difference between the two projecs, in addition to the fact that one works and the other not...
Sorry but I really don't know what is THE fundamental information I'm missing to solve this problem, if you have any questions, please feel free to ask.
|
|
|
|
|
Greetings,
I have a text file that include english characters and arabic characters as well..These characters are mixed with each others..
I have to read this file chars by chars including even the spaces..Though I used the following code but it didn`t get me the write result:
Dim objReader As New System.IO.StreamReader(pfile)
Dim strAll As String
strAll = objReader.ReadToEnd
In this code I read all the content of the file; But unfortunately the length of the Varaible strALL was less than the number of chars in the file...
Please help me to read this file properly in order to store it in a database correctly...
Thanks in advance..
|
|
|
|
|
dgthecodeproject wrote: But unfortunately the length of the Varaible strALL was less than the number of chars in the file... How did you determine the amount of chars in the file?
Download Notepad++ and check the encoding of your file. Assuming it's saved in Unicode, below should work;
Console.WriteLine(System.IO.File.ReadAllText(pfile, Encoding.Unicode))
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|