|
Consider my code below
Cursor m_OldCursor;<br />
void OnCursorChanged(object sender, EventArgs e)<br />
{<br />
if(m_OldCursor != null)<br />
{<br />
m_OldCursor.Dispose();<br />
}<br />
m_OldCursor = new Cursor(this.Cursor.CopyHandle());<br />
}<br />
<br />
void ProcessMouseMove(EventArgs e)<br />
{<br />
}
I know it is wrong to use a object after it is disposed. but every single
time the CopyHandle() method is invoked, it creates a handle. since there
is a restriction on the number of handles that windows can manage, i need
to dispose this handle after its use. if not then the application will
crash. If instead of Cursor, it was a control then i could have used the DestroyHandle property.
Could you suggest me any other way to do the same.
thanks in advance.
Keshav Kamat
India
|
|
|
|
|
Hi,
two comments:
1.
you should not try to dispose of cursors that you did not create yourself;
that's every Cursor you get from the Cursors class (the system created those, it
will dispose of them too when appropriate, and maybe never !)
2.
who is changing the cursor ? cant you do that with a simple method, something like (inside
your form class):
public static void SetCursor(Cursor newCursor) {
Cursor oldCursor=Cursor;
Cursor=newCursor;
oldCursor.Dispose();
}
no handles involved !
Hope this helps.
|
|
|
|
|
How to create pdf file from reading the data from the dataset and directly convert to the pdf file.
|
|
|
|
|
iTextSharp is a free .NET PDF extension. But even with it, writing pdf files in .NET is not very easy. There are some articles here on CP about iTextSharp, and also other free libraries, but most of them with limited functionality.
Search the "Articles" section.
GL!
|
|
|
|
|
Try CrystalReports... For creating PDF's its easy
|
|
|
|
|
hi all,
In my application iam using datagrid ,in that i want to do navigation but my code is not reflecting .and also i want to edit the row , how to do this
<pre>
private void DataGrid1_PageIndexChanged(object source,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex =e.NewPageIndex ;
//DataGrid1.CurrentPageIndex = e.NewPageIndex;
String connection = "uid=sa; password=sa123; database=usermanagement; server=c113";
SqlConnection con= new SqlConnection (connection);
//SqlCommand cmd=new SqlCommand ("select * from tbl_user_management
SqlDataAdapter da=new SqlDataAdapter ("select * from tbl_user_management",con);
con.Open ();
DataSet ds=new DataSet ();
da .Fill (ds ,"tbl_user_management");
DataGrid1 .DataSource =ds.Tables[0];// ("tbl_user_management");
DataGrid1 .DataBind ();
con.Close ();
}
<pre>
srinivas
|
|
|
|
|
Have you enabled Paging property in Properties?
|
|
|
|
|
|
I really dont have any exp. in web development,
but have some knowledge abt building web pages in asp.net,
I want to know what is difference between web pages which r developed by asp.net and flash player?
|
|
|
|
|
You can't use flash to create web pages. When you create a "web page" in flash, it's just a flash movie that you show as an embedded element in a web page.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hai Everybody,
I want to queue some events in the message queue and it has to be retained even though the system is restarted. I have created a message queue as follows but it is not retaining the messages can any one give a solution to this please it is very very important and urgent.
<br />
private System.Messaging.MessageQueue eventMessageQueue;<br />
if (!System.Messaging.MessageQueue.Exists(System.Net.Dns.GetHostName() + @"\EM"))<br />
{<br />
try<br />
{<br />
eventMessageQueue = System.Messaging.MessageQueue.Create(System.Net.Dns.GetHostName() + @"\EM",true);<br />
}<br />
catch (System.Messaging.MessageQueueException messagingException)<br />
{<br />
schedulerClass.LogError(messagingException, "Scheduler Error", EventLogEntryType.Error);<br />
}<br />
catch (Exception generalException)<br />
{<br />
schedulerClass.LogError(generalException, "Scheduler Error", EventLogEntryType.Error);<br />
}<br />
}<br />
else<br />
{<br />
eventMessageQueue = new MessageQueue(System.Net.Dns.GetHostName() + @"\EM");<br />
}<br />
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
hi,
May i know how to allow shapes drawn(e.g using DrawRectangle) on a window form to be drag and drop to a user control dock on the left side of the form? Can somebody explain briefly the step to do it? So Any help is much appreciated.
Thanks
|
|
|
|
|
Hi all
I cannot match between thread and process. Need to kill a cirtain thread, I know in general to what module the thread belongs but cannot distinct between the diffrent threads. all I get is a list of the threads ID that belong to my process....
|
|
|
|
|
Killing a thread is a bad idea in almost all cases. It can destabilise the entire process.
Steve
|
|
|
|
|
I know...... I have no choise. It's not my module.......
|
|
|
|
|
OK then, but it will end in tears!
Steve
|
|
|
|
|
Can I, at least, configure to what modoule does a cirtin thread belongs to?
|
|
|
|
|
No I dont think so.
AFAIK the managed threads are virtual, i.e. they are not even guaranteed to correspond to
a physical (i.e. a Windows kernel) thread.
This is somewhat illustrated by the fact that managed threads have a ManagedThreadId property,
whose value does not correspond to the kernel's thread IDs; and it has a name, for which
the kernel has no equivalent member at all.
In my experience, there still is a 1-to-1 correspondence between a managed thread and a
kernel thread, but I havent found any way to map them, other than having each managed thread
call some native code to get its own kernel thread ID that is.
Hope this clarifies things a bit.
|
|
|
|
|
I want to have a diagonal Line object as a usercontrol. It can automatic process events as click, drag and drop...Can you help me?
Thank a lot.
QuynhTD
|
|
|
|
|
Hello All,
I need to include a Dialog Box (Visual C++.Net or VC++6 style ) in a Visual C#.Net application at deign time but by default it is Form that is included and you can include by going to Add item.
Please suggest.
Thanks and Regards.
Amar.
|
|
|
|
|
Do you want to include Dialog box which are created in VC++ ? Is it anything like MFC COM (ActiveX) controls ?
|
|
|
|
|
No,
May it be created in C# and generated by the wizard as C# Form is.
Hope this clarifies.
Thanks.
|
|
|
|
|
Hi,
I created a settings file using Visual Studio 2005. The class for the settings file is generated as internal by VS. I need to reach it from another namespace so I want to make it public not internal. Is it good to make a settings file public or does it have any bad effects?
|
|
|
|
|
As it is internal, it's available in the entire assembly, even from a different namespace.
If you need to use the information in another project in the solution, you get a mutual dependency if you access the settings directly. Instead you should send the needed information when calling the method, or creating the object instance, that needs it.
---
single minded; short sighted; long gone;
|
|
|
|
|
I believe the cs file in question is machine generated so its no point making changes to that. Why dont you write your own class which can traverse the settings file using the XML namespace.
try this CP article
http://www.codeproject.com/useritems/SystemConfiguration.asp
|
|
|
|