|
Hi Judah,
Thanks for your prompt reply.
I really don't want to add the class to the System.Collections namespace. I will create my own class library and put it in there. I just wondered how to do it!
Don
|
|
|
|
|
Right, and what I described will still work; make your class’s namespace be System.Collections, compile the class as a dll file, and you’ve got what you want.
Tech, life, family, faith: Give me a visit.
I’m currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
Hi All
Can you tell me? how can i create a html file?
|
|
|
|
|
The simplest way is to right-click your desktop, choose "new\text document", right-click on the document, choose rename and set an adecquate name (including the html extension)
An other simple alternative is to open notepad and choose "save as...", there type an "name.html" and click "save".
But I don't think this was what you were missing. Post a better contured question to get a better answer.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
To complement drag-drop of file names into an app i wanted to add copy-paste. I know basic clipboard handling but this seems to be beyond me. After a search i found a solution in Cpp but i am unable to translate it to C#.
http://www.codeguru.com/Cpp/W-P/clipboard/article.php/c2999/
What is the how to in C#? Maybe someone should write a Code Project article about this? Happy Holidays.
|
|
|
|
|
To do copy & paste, I think for pasting you'll just receive a string[] in the DragDrop handler of your UI control.
I haven't done copying arbitrary data into the Windows Shell, so I'm afraid I can't help you out there.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
Thank you. I tried as suggested. The DragDrop event does not trigger when one does a paste- Ctrl+v. I tried calling the DragDrop event from a KeyDown event that traps the Ctrl+v but i am unable to determine the System.EventArgs e that need to be passed to the DragDrop event.
From the looks of the Cpp example and others, i think this requires manipulation of the system clipboard. I read one C# example, a clone of the windows file explorer, and the author confesses that he is using his own array to pass file names via the clipboard and not by the clipbord's normal means. This makes his app's copy-paste incompatible with Explorer. To me, it sounds like C# does not natively support copy-paste of filenames. I could be wrong.
I am going to look up some old VB6 code- from the "classic" days. I am sure there is a solution out there using the Win32 API. It will be easier to convert the VB6 code to C# then the Cpp code i found.
But if any of you out there know how to cut-paste filenames in C#, i will be checking back often!
|
|
|
|
|
It took some trial and error. The big hurdle was getting the Win32 DragQueryFile() PInvoke signature right. I had found a signature on the internet but it was wrong. Below is the code you need to transfer file paths to your app when you do copy-cut-paste of folders and files. I decided to use the Win32 IsClipboardFormatAvailable() instead of the NET equivalent (IDataObject/GetDataPresent) to keep code clean. The NET 1.1 implementation of the clipboard is pretty poor IMO. To make use of the code, you call ClipboardGetFiles() and get returned a string array containing the file paths.
HTH someone. I am amazed i could not find any examples to do this in C#.
// Get an array of the files listed in the clipboard.
private string[] ClipboardGetFiles()
{
string[] fileList = null;
// Make sure there is file data.
if (IsClipboardFormatAvailable(CF_HDROP))
{
// File data exists. Get it.
// Open the clipboard.
System.IntPtr hClipboard = System.IntPtr.Zero;
if (OpenClipboard(hClipboard) == true)
{
// get handle to dropped file list
System.IntPtr hDropList = System.IntPtr.Zero;
hDropList = GetClipboardData(CF_HDROP);
// get the number of dropped files
long fileCount;
fileCount = DragQueryFile(hDropList, -1, null, 0);
// get the file names
fileList = new string[fileCount];
const int MAX_PATH = 260;
for (int i = 0; i < fileCount; i++)
{
// Get the file name.
System.Text.StringBuilder fileName = new System.Text.StringBuilder();
fileName.Capacity = MAX_PATH;
DragQueryFile(hDropList, i, fileName, MAX_PATH);
fileList[i] = fileName.ToString();
}
// Close the clipboard.
CloseClipboard();
}
}
// Assign the return value.
return fileList;
}
// found that NET clipboard functionality is both limited and
// incompatible with clipboard functionality of windows OS;
// will use interoperate with win32 to get needed functionality;
// Clipboard routines.
// OpenClipboard
// CloseClipboard
// IsClipboardFormatAvailable
// GetClipboardData
// DragQueryFile
// file list clipboard format code.
const int CF_HDROP = 15;
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool OpenClipboard(System.IntPtr hwnd);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool CloseClipboard();
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool IsClipboardFormatAvailable(uint format);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern System.IntPtr GetClipboardData(uint uFormat);
[System.Runtime.InteropServices.DllImport("shell32.dll")]
static extern uint DragQueryFile(
IntPtr hDrop,
int iFile,
System.Text.StringBuilder fName,
int fnSize);
|
|
|
|
|
Hi everyone,
Although being a great fan of this site it's only the first time that I write to one of its forums.
The problem I am facing and forced me to do so, is that I cannot understand (find a reference or sth) how I can replicate what "E&xport to Microsoft Excel" is doing. This is an extension of the right-click menu of Internet Explorer, which is set by inserting a new key under [HKCU]->Software->Microsoft->Internet Explorer->MenuExt, and is used to call the Excel's resource 3000 to export html data to an excelsheet. Is it simply a resource in the executable (e.g. a windows form declared as a resource)? How does it take the argument? Is there anywhere any sample code doing the same thing? I would like to do the same with an executable of mine.
I've tried searching around, but I was unable to find sth in relation
Could you please assist me?
Kind Regards,
G.
|
|
|
|
|
I have a collection class that I've derived from List<MyClass>. I've added no extra functionality to this class except a constructor that clears the list. My problem is this: I'm using the collection in MyClass (the same class that the list is typed for) and I'm doing this
col.Add (this);
No problem there it adds the class just fine. The problem arises when I run the code again (it's in a loop), what's happening is that the previous values in the list are changed to the new values that the class has taken on. In effect, if I run the loop, let's say, 5 times the List<> has 5 items in it, but they all have the exact same values.
Does anyone have any ideas as to how I can defeat this? I'm thinking there's something better I could be passing into the Add function, but I'm not sure what it would be. I was also thinking I could override the Add function in my derived collection class and create a deep copy of the this parmeter that I passed in, but I'm not sure if that's the right idea.
Any ideas and/or help is very appreciated. Thanks.
- Aaron
|
|
|
|
|
Can you make MyClass a struct? That way, it'll behave exactly as you want it to. The only other way is to clone the object, using MemberwiseClone or your custom deep cloning code.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
yeah I need to know how to create an instance of a control programatically. I know one can do soemthing like "TextBox tb = new TextBox();" but this has to be done in the initialization section fo the class, and if it's written within a method, it's only available for within that method. But this isn't the main problem, the main thing is that I don't necessarily know how many of a certain control will be needed, so how do I create new control on demand with a name either generated, or taken from user input via a textbox or something?
Thanks,
Stephen
|
|
|
|
|
MSDN[^] has a good article.
|
|
|
|
|
This article doesn't work. I think something between vs '03 and vs '05 has changed. It wants me to create a ButtonArray, which does not exist. Here is what they have in the example:
ButtonArray MyControlArray;<br />
MyControlArray = new ButtonArray(this);<br />
MyControlArray.AddNewButton();<br />
Well seeing how the ButtonArray thing doesn't exist, I can't really do anything with this. How do I go about creating control collections in visual studio 2005?
|
|
|
|
|
Hi all!
I did do a application with Visual C#.My aim is start this application at each beginning windows.
For of this,i am writing value to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" registry key.
My codes is those:
/*line-1:*/if(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true).GetValue("clnv1")==null)
{ Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true).SetValue("clnv1",@"C:\WINDOWS\system32\clnv1.exe");
}
My application is starting at beginning windows.But right now shows warning!!!(on line-1)
Warning is that:
An unhandled exception of type'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not find file "clnv1.exe".
Please help me!!!
-- modified at 20:36 Saturday 24th December, 2005
|
|
|
|
|
Friends,please help me!!!
|
|
|
|
|
I don't get it, does your app run fine if you start it normally? I find it strange that you get a FileNotFoundException on the exact file that you're currently executing. Are you trying to launch it again from within the executable?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi my name is zubair i am making an application for IP telephony
so i want to get input from MIC so how i can accomplish it in C#
thanks
Zubair Asghar
|
|
|
|
|
i'm using MIL-parser libarary which i get this libarary from code project site
i'm trying to select data from the axWebBrowser and trying to find in the parsed tree but some data found and another not found
f any one can help ???
|
|
|
|
|
Is it possible to get .NET types using some C# code? For example:
<br />
private void InitializeTypes()<br />
{<br />
cmbBlah.Items.Clear();<br />
<br />
foreach (NetType nt in GetNetTypes())<br />
cmbBlah.Items.Add(nt.ToString()); <br />
}<br />
?
tnx in advance
|
|
|
|
|
The NetType you're talking about is actually System.Type[^] . You can get it using Object.GetType[^], Assembly.GetTypes[^] etc. For example, if you want to fill a combobox with all public types in your assembly, you can do:
using System.Reflection;
private void InitializeTypes(){
cmbBlah.Items.Clear();
Assembly currentAss = Assembly.GetCurrentAssembly();
Type[] publicTypes = currentAss.GetExportedTypes();
foreach (Type type in publicTypes){
cmbBlah.Items.Add(type.ToString());
}
}
Welcome to the wonderful world of reflection!
Merry Christmas!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
After a bunch of ASync socket calls, I get the exception below. Google-ing it came up with only 4 hits, 2 from the same person, none with answers.
This is happing in a server application, so if no one has a solution, is there another way to run a TCP server (average of 500 simultaneous, sustained connections. Max possible connections is about 5000, but VERY unlikely) without having a thread for each client, that would be great.
-------------------------------------------------------
"The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone).".
at System.Threading.SynchronizationContextSwitcher.Undo()
at System.Threading.ExecutionContextSwitcher.Undo()
at System.Threading.ExecutionContext.runFinallyCode(Object userData, Boolean exceptionThrown)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteBackoutCodeHelper(Object backoutCode, Object userData, Boolean exceptionThrown)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
|
|
|
|
|
Update:
You can see my socket connection class code Here.
The exception occurs while executing a method in another class called from inside "OnDataRecieve".
-- modified at 5:35 Friday 30th December, 2005
|
|
|
|
|
My DataGrid is serviced by a DataTable. Suppose I would like to make a red background for rows 3 and 5 in this DG. How to make it?
|
|
|
|
|
hi all,
iam able to sending mails using SMTP sever..
but now,how can i send my inbox mails to my database?
can any one know it?
thanks in advance...
byeeeeeeeeeee
sree
|
|
|
|