|
mflefel wrote: i want to convert it automatically auto
Not gonna happen!
A windows forms application is stateful while an ASP.NET application is stateless and needs to simulate statefulness to work.
However, if the application is well designed then the move from WinForms to ASP.NET should be realatively easy and will be a matter of adding an ASP.NET project (or projects) to your solution that mirror the UI layer calling in to the same business layer (which in turn uses the same data layer) which means that the main logic and data access portion of your application is already written.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I am translating parts of a C++ Code Project article to C# and ran into a problem when i started working with SetCapture. Here is the article i am working on:
http://www.codeproject.com/dialog/windowfinder.asp
The program sets up capture of mouse events with this:
SetCapture (hwndDialog);
Mouse events are redirected to hwndDialog and a callback function then processes:
BOOL CALLBACK SearchWindowDialogProc
However, i do not understand how SearchWindowDialogProc is set up as a callback function. No where is it specified that it is to be a callback function for SetCapture. But it works. So i am at a loss as how to translate this to C#. Any C++/C# gurus out there who can give me some direction? How do these SetCapture callbacks work and how would i translate to C#?
|
|
|
|
|
Did you look at the last parameter of the DialogBox function (WindowFinder.cpp)? That is the window procedure for that dialog, so any messages for that dialog will result in calls to that function.
In C#, you can create a new Form and override WndProc[^] to achieve the same effect.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you Senthil, that was simple to do. My lack of understanding makes a bigger problem then it is. C++ is foreign to me as i come from a VB6 background. One item that puzzled me in my testing was that SetCapture only redirects mouse events when a mouse button is pressed down. I did not know this and expected all mouse events to be redirected. A source of fustration for a couple hours!
|
|
|
|
|
I try to Read Data from a file then write it to another File
source => destination
so I choosed the Binary Read ,write Methods ,
to Control the speed and amount of data read and write to make progress >>>
it write 1st trial then gives me this error in the second sycle :
{"Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection." }
here is My Code :
public string File_Copy(string strSource,string strDestination,FileMode mode,int bufferSize,int Action)
{
byte[] readFile ;
FileStream Sfs = File.OpenRead(strSource);
FileStream Dfs = File.Open(strDestination,mode);
FileInfo Sinfo = new FileInfo(Sfs.Name);
FileInfo Dinfo=new FileInfo(Dfs.Name);
readFile= new byte[bufferSize];
#region If sfs.CanRead And Dfs.CanWrite
if (Sfs.CanRead && Dfs.CanWrite)
{
Form1.progCurrentFile.Text = strSource;
while (Sfs.Length - Sfs.Position>=bufferSize)
{
#region reading and writing Buffer
try
{
Sfs.Read(readFile,int.Parse(Sfs.Position.ToString()),bufferSize);
Dfs.Write(readFile,int.Parse(Dfs.Length.ToString()),bufferSize);
System.Windows.Forms.Application.DoEvents();
}
#region Damaged File Found
catch(System.Exception ex)
{
messageBox(ex.Message);
{
}
}
}
welcome for any comments , Questions
|
|
|
|
|
First question, why are you doing int.Parse(Sfs.Position.ToString())? Sfs.Position returns a long. Basically what you're doing is taking a long, creating a string representation of that long (which allocates memory on the heap), then parsing that string into an integer. Terribly inefficient. Use
(int)Sfs.Position
to cast it to an integer instead.
The reason for your error is because the second parameter passed to Sfs.Read and to Dfs.Write is the offset into the readFile array, NOT into the FileStream. Pass zero instead:
Sfs.Read(readFile, 0, bufferSize);
Dfs.Write(readFile, 0, bufferSize);
|
|
|
|
|
thank u Very Much for care And replay , it Worked very Fine
<br />
Sfs.Read(readFile, 0, bufferSize);<br />
<br />
Dfs.Write(readFile, 0, bufferSize);<br />
<br />
I just Want to know How it Work With 0 In the offset ???
now 0 in while .., I thought it will always copy the 1st part .., from 0 byte to => 0+bufferSize
and will not move and copy from position => position + buffer size for each loop round...
this what U understand form MSnd about this Method .
=================
welcome for any comments , Questions
|
|
|
|
|
Well, you could use the offset as you did, but then you would have to declare a buffer that is as large as the entire file.
The second parameter is the offset in the buffer, not the offset in the files. The stream objects will keep track of where in the files you are reading and writing.
---
b { font-weight: normal; }
|
|
|
|
|
great thank u about this More than Enough and perfect Answer , now I konw how it work fine
welcome for any comments , Questions
|
|
|
|
|
Hi All,
I have a problem in C# Remoting. I am doing as given below code. I am also giving different Computername and Portname. Every time m_DisplayComputerName and m_lDisplayPort read from the Database. But Still I am getting error.
"Only one usage of each socket address (protocol/network address/port) is normally permitted"
//This is client and connection() funtion in Constructor
private void Connection()
{
try
{
// First check if a Channel with the computername already exists.
IChannel oChannel = ChannelServices.GetChannel(m_DisplayComputerName);
if (oChannel == null)
{
// then we need to create.
IDictionary props = new Hashtable();
props["name"] = m_DisplayComputerName;
props["port"] = m_lDisplayPort;
BinaryClientFormatterSinkProvider clientSink = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider serverSink = new BinaryServerFormatterSinkProvider();
oChannel = new TcpChannel(props,clientSink,serverSink);
//oChannel = new TcpChannel(props,null,null);
ChannelServices.RegisterChannel(oChannel);
}
/*else
{
// do nothing
}*/
}
catch(System.Net.Sockets.SocketException ex)
{
MessageBox.Show(ex.Message);
}
m_remoting = (RFDisplayStation_Remoting_Interface.IRFDisplaystation_Remoting_Interface)Activator.GetObject(
typeof(RFDisplayStation_Remoting_Interface.IRFDisplaystation_Remoting_Interface),
GetURL());
}
private string GetURL()
{
return "Tcp://" + m_DisplayComputerName + ":" + m_lDisplayPort + "/RemotingKeyWord";
}
///////Server side And also in Constructor
try
{
ChannelServices.RegisterChannel(new TcpChannel((int)(m_ResourceDetailsArray[0].DisplayPort)));
}
catch(System.Net.Sockets.SocketException ex)
{
MessageBox.Show(ex.Message);
}
Thanks
-- modified at 21:14 Saturday 7th January, 2006
|
|
|
|
|
Is that code being run after you're running a server locally that uses the same port? Usually that error occurs when you've got 2 apps using the same port simultaneously.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
It is a bug in .Net 1.1 which has been removed in .Net 2.0. It only happens in case of abnomal shutdown of ur server. There are some tools available on .Net that will release the specifed port for u.
Hope it will help u
Akif
|
|
|
|
|
we had same problems. our solution was to wrap all channel and communication jobs in to a disposable class. That means after the container is shut untidily, with container disposition all goes disposing. you should contact this class with yor process as acontainer so if it goes also your class goes disposing...
Mikail Çetinkaya . The C# DEveloper
|
|
|
|
|
Thanks for all. Yes I fixed it. Now it is running.
Thanks a lot.
-- modified at 13:29 Sunday 8th January, 2006
|
|
|
|
|
ei guys... juz wanna thank you for the reply. it really help. hehehe... i'm sori if anyone get offended, its juz so new to me. i tried to read some books but our library is a limited resources about C#. i tried to look at the internet but its not enough. can you suggest a web site that can help me with my prob. thanks!!!
pls and thank you...
|
|
|
|
|
What problem are you having?
If you need samples, check this[^] out. If it's learning materials in general, go buy some books, and if possible, take some .NET training courses.
|
|
|
|
|
How to add a control of type TextBox or ComboBox to a ToolBar in Runtime
Is It Possible too !!
Ahmad Shaban
|
|
|
|
|
Candseeme wrote: How to add a control of type TextBox or ComboBox to a ToolBar in Runtime
You already are adding controls to the form at run time - Take a look at the designer written code to see how it is done.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
use forms' topmost property to true or bring forward type methods
Mikail Çetinkaya . The C# DEveloper
|
|
|
|
|
What do I use instead of addressof.I am trying to p/invoke Win32 API CreateThread in a C# application.One of the API's parameter is the address of the function which the thread will execute.
|
|
|
|
|
|
|
And problably one based on some incorrect assumptions.
By using the unmanaged Win32 thread functions, you introduce garbage collection issues with your managed code being executed from an unmanaged thread.
There is no reason I can think of that would be good enough to justify this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
So was I. Bummer....
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|