|
For windows I change the color of the cursor depending on what background color is now.
Code below. Unfortunately, from time to time (too often) gets an exception:
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI +
At System.Drawing.Bitmap.GetHicon ()
and the end of the program.
A year ago I wrote an earlier version, a mechanism to change the cursor the same, the same code, but then I used VisualStudio 2005, at 32bit Vista. And never once I had such an exception.
vs2008 and now the win7 x64.
I don't checked yet whether to build VS2005 help ...
However, it may be any known explanation and a solution to this problem.
I use IntPtr as a handle to the icon, and 64 bit systems, it is 64 bit and 32-bit Win 32 .. but not further Jazee what the problem ...
Shows the error both on and win764 win xp32 ...
private void changeCursor(int type)
{
int _cursorSizePx = Convert.ToInt32(((200.0 * _cursorSize) / _calibration));
Bitmap b = new Bitmap(_cursorSizePx + 1, _cursorSizePx + 1);
Graphics g = Graphics.FromImage(b);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
switch (type)
{
case 0:
g.FillEllipse(new SolidBrush(_cursorColor), 0, 0, _cursorSizePx, _cursorSizePx);
break;
case 1:
g.DrawEllipse(new Pen(new SolidBrush(_figureColor), 3), 1, 1, _cursorSizePx - 3, _cursorSizePx - 3);
g.FillEllipse(new SolidBrush(_sqreenColor), 1, 1, _cursorSizePx - 3, _cursorSizePx - 3);
break;
}
IntPtr ptr = b.GetHicon();
Cursor c = new Cursor(ptr);
this.Cursor = c;
}
modified on Monday, January 25, 2010 4:21 AM
|
|
|
|
|
I have a treeview and when I hit a title that has is something like this
Title = "Berenstains' B Book"
Obviously it has the ' in it and needs to be escaped.
I tried putting the @ infront of the this.treeview........
but that didn't help..
I'm trying to pass it to my navigation filter as follows.
<pre>
this.bookListBindingNavigator.BindingSource.Filter = string.Format(@"Title LIKE '*{0}*'", this.treeview.SelectedNode.Text.Trim());</pre>
thanks for the help
i thought I might be able to do something like
string escaped = treeview.selectednode.text.trim();
escaped = escaped.replace("'","\'");
but that doesn't work because of course \ is looked as an escape character in that string
I'm confused. Knockin on the door but evidently I can't come in yet :P
|
|
|
|
|
You answered this yourself:
tonyonlinux wrote: have a treeview and when I hit a title that has is something like this
Title = "Berenstains' B Book"
Obviously it has the ' in it and needs to be escaped
tonyonlinux wrote: escaped = escaped.replace("'","\'");
Puttin the backslash in front of the quote provides the escape mechanism.
So your string becomes:
Title = "Berenstains\' B Book";
You can also use the atsign in front of the string:
Title = @"Berenstains' B Book";
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
tonyonlinux wrote: Obviously it has the ' in it and needs to be escaped.
That isn't obvious to me, in C# a single quote is not a special character inside a string literal, the following statement is correct:
string s="abc'123";
so what is the problem?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
how to change the modified date of a file?
|
|
|
|
|
Hope the following link can help you.
http://msdn.microsoft.com/en-us/library/aa365539(VS.85).aspx[^]
This API is available in Windows VISTA onwards. You can get the same in WIN XP and 2003 server, by installing Windows SDK.
Please import the API and the required structures using DllImport in to C# so that you can call it.
|
|
|
|
|
Use the FileInfo object
System.IO.FileInfo oFI = new System.IO.FileInfo("FileName.txt");
oFI.LastWriteTime = DateTime.Now;
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Modify it.
|
|
|
|
|
how to have tooltip like anti-viruses that only gives alerts and automatically disable after seconds!(for windows application)
modified on Monday, January 25, 2010 12:57 AM
|
|
|
|
|
notifyIcon1.BalloonTipText="....";
notifyIcon1.showballoonTip(1000);
|
|
|
|
|
I wanna something like windows alert that pop-up in right conner of screen then gives alert and after a moment disappears and this alertation box in rectangle !
|
|
|
|
|
OK make a form that show your message and close after while
|
|
|
|
|
Wont tooltip do this for me!
|
|
|
|
|
if you want example:
create form2 and put a lable1 and add:
public form2(string s)
{
InitializeComponent();
lable1.Text=s;
timer1.Interval=100;
timer1.enable=true;
}
double x=0;
privete void timer1_Tick(object sender,EventArgs e)
{
if(x==10)
this.close();
x++;
}
you can make the form as tooltip
is it solve what you want
|
|
|
|
|
No dear you didnt get it?
I want a tooltip(or something like that ) that pops up in right corner of screen and give alert (something like kaspersky alert that pops a rectangle box with alert text and after a moment disappears) !
PLEASE HELP!
|
|
|
|
|
jojoba2010 wrote: I want a tooltip(or something like that )
The or something is a NOTIFYICON as you have already been told, a tooltip is for a control - on a form you know part of your application. The NotifyIcon lives in the tool tray where you want it to pop from and YOU control it's functonality. Do some reading on NotifyIcon.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
do you want me to do all the work!!!!!!
make the background of the form for example trancprancy and hide the title of the form
so the only thing will show is the lable
|
|
|
|
|
We need a spoon smiley!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Can a java application call a WCF service?If Yes can any one help me how to do it?
I have created a WCF service in .net .
I have simple java application.
I want to use WCF service in Java application..
|
|
|
|
|
Yes, it can. You are communicating via SOAP and the language used in implementing the web service does not matter.
However, you cannot set up the duplex call feature of WCF.
|
|
|
|
|
Thank you for Replying.....
Can you elaborate a bit more on this topic .An example or something.
|
|
|
|
|
Hi,
I need to crawl a website of below url format and store the content locally in a csv file
now, I only need to crawl URL of below format. I should be able to do a loop with query string ranging from 0 to 1000000(or a max value present).
http://www.mysite.com.au/products/products.asp?p=101
the only way i think will be to do a loop from 0 to 1000000 but again there are some id that doesnt exists and redirects to main page which i need to exclude from crawl list i.e it redirects to http://www.mysite.com.au/products page.
below is the code so far i have coded. please assist me how can i achieve this.
public static void CrawlSite()
{
Console.WriteLine("Beginning crawl.");
CrawlPage("http://www.mysite.com.au/products/products.asp?p="); Console.WriteLine("Finished crawl.");
}
private static void CrawlPage(string url)
{
for(int i=0; i<=100000; i++)
{
Console.WriteLine("Crawling " + url+i.tostring());
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.UserAgent = "blah!";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string htmlText = reader.ReadToEnd();
using (StreamWriter sw = File.AppendText(@"c:\logs\data.txt"))
{
sw.WriteLine(htmlText);
sw.Close();
}
}
}
|
|
|
|
|
Look into Regex, that would be the way to go.
|
|
|
|
|
I am trying to set an integer variable to null if no vaue but it's not accepting? how can I set the variable to null if the value in the database is null?
This is what I am trying:
if (sql_reader["company_id"] != null)
company_id = Convert.ToInt32(sql_reader["company_id"]);
else
company_id = null;
and this is what I am getting:
Cannot convert null to 'int' because it is a non-nullable value type
I also tried DBNull.Value but getting:
Cannot implicitly convert type 'System.DBNull' to 'int'
|
|
|
|
|
use nullable types
ex:
int? something = null;
if(something.HasValue)
So all you have to do is declare your company_id as int? instead of int
|
|
|
|