|
Not sure why that is happening. Is there a reason why you are sending data byte by byte? If you use a stream (for example, StreamWriter) then you can call the Flush method on it. Here is an example:
void Send()
{
NetworkStream ns = new NetworkStream(aSocket);
StreamWriter w = new StreamWriter(ns);
w.WriteLine(aString);
w.Flush();
}
When you write to the stream, the stream is sent over the network.
Let me know if further needed.
|
|
|
|
|
Hi CodingYoshi.
Just to make sure I have mentioned it, the program runs on the compact framework V2..
The streamwriter does not solve the problem. I have made this small console app, which does not use the sockets directly. It still closes the connection before all data is send, if I dont add a delay. To add a delay is not good enough for me...
The small program accepts a connection from e.g. iexplorer via standard http port 80. It replies any request... so just type ( http://ip/ ). The program replies with xml: Hello world!
In this exaple no socket communication is made directly...
Im I doing something really wrong? Really hope someone can help me!
Here is the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace TestNetworkConsoleApp
{
class Program
{
static void Main(string[] args)
{
TcpListener m_TCPServer;
try
{
m_TCPServer = new TcpListener(IPAddress.Any, 80);
m_TCPServer.Start();
TcpClient tcpClient = m_TCPServer.AcceptTcpClient();
tcpClient.LingerState = new LingerOption(true, 100);
if (tcpClient != null)
{
try
{
string content = Hello World!";
string now = DateTime.Now.ToLongDateString();
StringBuilder txbuffer = new StringBuilder();
txbuffer.Append("HTTP/1.1").Append(" 200 OK\r\n");
txbuffer.Append("Server:This Computer\r\n");
txbuffer.Append("Content-Type:text/xml\r\n"); // Mime type is always text/xml
txbuffer.Append("Last-Modified:").Append(now).Append("\r\n");
txbuffer.Append("Accept-Ranges:bytes\r\n");
txbuffer.Append("Connection:close\r\n");
txbuffer.Append("Content-Length:").Append(content.Length).Append("\r\n");
txbuffer.Append("\r\n");
txbuffer.Append(content);
String s = txbuffer.ToString();
try
{
using (NetworkStream stream = tcpClient.GetStream())
{
StreamWriter w = new StreamWriter(stream);
w.Write(s);
w.Flush();
//Thread.Sleep(2000);
}
}
catch
{
}
}
catch
{
}
}
}
catch { }
}
}
}
|
|
|
|
|
When I go to the design window and drag some control say label in that, I can't be able to see that.
When I switch to Source control, I can the tag like
"?xml namespace="" prefix="asp" ?"
<asp:label id="Label1" runat="server" text="Label">ABCD"
Also in properties window I can't see the control's property,
Can anybody have any idea?
How can I get the controls visible and see the properties?
Thanks in advance,
|
|
|
|
|
I'm looking for a way to get the proper path name, for example if I have:
"c:\\program files"
I would expect "C:\\Program Files".
Any ideas?
I'm using the code below now, but the use of GetFileSystemInfos is going to be a performance problem some time...
<br />
private string fixPathName(string path) {<br />
string[] pathParts = path.Split(Path.DirectorySeparatorChar);<br />
<br />
string fixedPath = null;<br />
for (int index = 0; index < pathParts.Length; index++) {<br />
string pathPart = pathParts[index];<br />
<br />
if (index == 0) {<br />
fixedPath = pathPart;<br />
fixedPath = Path.GetFullPath(fixedPath);<br />
} else {<br />
fixedPath = Path.Combine(fixedPath, pathPart);<br />
DirectoryInfo parent = Directory.GetParent(fixedPath);<br />
FileSystemInfo[] paths = parent.GetFileSystemInfos(Path.GetFileName(fixedPath));<br />
string pathProperName = paths[0].FullName;<br />
fixedPath = pathProperName;<br />
}<br />
}<br />
return fixedPath;<br />
}<br />
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
There is no "proper name", since path specifications are not case sensitive.
So, it begs the question, why would you care about the case of the characters??
|
|
|
|
|
Well, so it looks right to the user.
I'm working on a bit of autocomplete code (like the Run dialog).
I do know about ComboBox/TextBox autocomplete, but it doesn't meet the specs.
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
AndrewVos wrote: else {
fixedPath = Path.Combine(fixedPath, pathPart);
DirectoryInfo parent = Directory.GetParent(fixedPath);
FileSystemInfo[] paths = parent.GetFileSystemInfos(Path.GetFileName(fixedPath));
If I read this correctly, you can replace all this sutff with this:
FileInfo fileObject = new FileInfo(fixedPath);
fixedPath = fileObject.FullName;
|
|
|
|
|
<br />
string fixedPath = @"c:\program files\";<br />
FileInfo fileObject = new FileInfo(fixedPath);<br />
fixedPath = fileObject.FullName;<br />
MessageBox.Show(fixedPath);<br />
This would return "c:\program files".
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
Ok, I've got everything working.
It seems GetDirectories is actually fast enough when using a search pattern.
Thanks for reading through the code, and here's what I'm using now.
<br />
public List<string> Generate(string generationString) {<br />
List<string> results = new List<string>();<br />
<br />
string[] pathParts = generationString.Split(Path.DirectorySeparatorChar);<br />
DirectoryInfo currentDirectory = null;<br />
<br />
for (int index = 0; index < pathParts.Length;index++ ) {<br />
string pathPart = pathParts[index];<br />
<br />
if (index == 0) {<br />
DriveInfo[] drives = DriveInfo.GetDrives();<br />
foreach (DriveInfo drive in drives) {<br />
if (drive.Name.StartsWith(pathPart, StringComparison.InvariantCultureIgnoreCase)) {<br />
currentDirectory = drive.RootDirectory;<br />
}<br />
}<br />
if (currentDirectory == null) {<br />
break;<br />
}<br />
} else if ((index == pathParts.Length - 1) ) {<br />
try {<br />
results.AddRange(Directory.GetDirectories(currentDirectory.FullName, pathPart + "*"));<br />
results.AddRange(Directory.GetFiles(currentDirectory.FullName, pathPart + "*"));<br />
} catch { }<br />
} else {<br />
DirectoryInfo[] searchResults = currentDirectory.GetDirectories(pathPart);<br />
if (searchResults.Length == 0) {<br />
break;<br />
} else {<br />
currentDirectory = searchResults[0];<br />
}<br />
}<br />
}<br />
<br />
return results;<br />
}<br />
</string></string></string>
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
I have the following event handlers for a button and a text box:
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e)
{ function(0);
}
private: System::Void textBox_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e)
{ if(!CheckIfTextBoxNumeric(textBox))
e->Cancel = true;
}
bool CheckIfTextBoxNumeric(TextBox^ myTextBox1)
{ //checks text input only contains numbers
//returns true if so
}
void function(int select)
{ int result = 0;
//validate text is digit
try
{ result = Convert::ToInt32(insrtMnytxtBox->Text); -- line A
}
catch(Exception^ myException)
{ cstmrInfolabel->Text = "Exception : ",myException->Message;
}
//rest of code
}
When program execution reaches line A in function, program does not pause for text input from user, that is, program does not allow user the chance to enter numbers. In C++ it would be the equivalent of cin >> result; How can I cause the program to pause so that the user has a chance to enter something.
|
|
|
|
|
This question belongs in the Visual C++/CLI forum.
I'm guessing you haven't written code for Windows before, have you? What you mentioned with the cin stream applies to console applications, not Windows.
Windows is follows an event driven model where your code normallly sits idle, waiting for the user to click on things and type. You caannot do what you want, the way you want. The best method for filtering out keystrokes is to create a custom TextBox control that does just that. Another method would be to handle the TextBox's Keydown event and do your filtering in that handler.
|
|
|
|
|
If I use the SetWindowLong in VB, I get the positive return value. Now we are migrating to vb.net and if I tried using SetWindowLong in vb.net, I get negative value. The third parameter in SetWindowLong is dwNewLong, am using delegate here to point to the address of the function I wanted to point to. (for example - AddressOf MyFunction)
I tried using different function definition but no success.
I used following -
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, _
ByVal nIndex As Integer, _
ByVal dwNewLong As MyFunction) As Integer
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, _
ByVal dwNewLong As MyFunction) As Integer
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Int64, _
ByVal nIndex As Int64, _
ByVal dwNewLong As MyFunction) As Int64
Can anyone help me with this?
|
|
|
|
|
This should have been asked in the VB/VB.NET Forum.
Read the Community Content Section at the bottom of this page[^] for information on how to do this.
|
|
|
|
|
Thanks for that. I tried using those function but getting two errors -
Messages.WndProc - Type is not defined
Messages.WindowMessages - Type is not defined
|
|
|
|
|
You have to define those enums yourself. They just represent the message numbers found in the Windows header (*.h) files. You can find an example of some of the window message numbers here[^]. Messages.WndProc is the delegate that's listed in the code.
|
|
|
|
|
Am sorry to trouble you again. I'm confused. I might not getting what you are saying. I am not a much experienced developer. I'm using VB.Net with .Net Framework 1.1. Please see below what have tried -
Public Enum WindowMessage As Integer
WM_ACTIVATE = 6 ' can't use Hex value WM_ACTIVATE = 0x0006 giving error 'End of statement expected so converted that hex value to decimal as 6.
End Enum
Public Delegate Function WndProc(ByVal hWnd As Integer, ByVal msg As Messages.WindowMessages, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Error - Messages.WindowMessages - Type is not defined
Friend Declare Auto Function SetWindowLong Lib "user32.dll" (ByVal hwnd As Int32, ByVal nIndex As WindowProcs, ByVal NewProc As Messages.WndProc) As Boolean
Error - Messages.WndProc - Type is not defined
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, _
ByVal nIndex As Integer, _
ByVal dwNewLong As MyFunctionDelegate) As Integer
My hook function looks like this -
Public Sub Hook()
Try
Dim intError As Integer = GetLastError
MsgBox(intError)
SetLastError(1)
Dim intError1 As Integer = GetLastError
lpPrevWndProc = SetWindowLong(ghW, GWL_WNDPROC, AddressOf MyFunction)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Note - Getting Last Error as 126 which means 'Module not found.'
MyFunction Delegate is like this -
Public Delegate Function MyFunctionDelegate(ByVal hw As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
MyFunction looks like this -
Public Function MyFunction(ByVal hw As Integer, _
ByVal uMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
Select Case uMsg.ToString
Case ABC
do this
Case DEF
do this
Case Else
MyFunction= CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Select
End Function
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Integer, _
ByVal hWnd As Integer, _
ByVal Msg As Integer, _
ByVal wParm As Integer, _
ByVal lParam As Integer) As Integer
|
|
|
|
|
bhawaniprasad wrote: Public Enum WindowMessage As Integer
WM_ACTIVATE = 6 ' can't use Hex value WM_ACTIVATE = 0x0006 giving error 'End of statement expected so converted that hex value to decimal as 6.
End Enum
This is because you have to use VB's syntax to specify a Hex value:
WM_ACTIVATE = &H6
bhawaniprasad wrote: I am not a much experienced developer.
You've taken on something that is a very advanced technique for a beginner.
bhawaniprasad wrote: Messages.WindowMessages - Type is not defined
This means that YOU have to define the enumeration called WindowMessages. You can drop the Messages. part. The values come from the Windows.h C++ header files that describe each window message.
bhawaniprasad wrote: Messages.WndProc - Type is not defined
Again, drop the Messages. part. You have to leave the WndProc part.
|
|
|
|
|
what event happens immediately fater user changes the collection selection.
I want to get access to the selected item collection before it is actually changed so I can either rollback or acces the previous selected collection indexes.
thanks
Shimi
|
|
|
|
|
meanwhile I am using CellMouseEnter
this does the work though it reduces performance
Shimi
|
|
|
|
|
|
|
He actually put it in three forums and then deleted them all. Pathetic.
|
|
|
|
|
leckey wrote: He actually put it in three forums and then deleted them all. Pathetic.
Another entry for the blog of shame.
|
|
|
|
|
if u guys are not interested to help.. jus ass lock and ignore..
you cannot comment on others..
Message boards are intended to discuss.. Not Chat or Comment or stuff..
There are 5,108,764 in the site.. Why it aches on your ass wn others ignores them...
"People gives advice wen there is a need of help..
And wen there s a need of an advice...They do the same"...
Useless creatures..
|
|
|
|
|
Well, thank you for that incoherent babble. It's always a pleasure to insert the missing characters in a sentence.
shabbu wrote: you cannot comment on others..
To quote Dr Cox from Scrubs:
"Wrong wrong wrong wrong, wrong wrong wrong wrong. Wrong"
|
|
|
|