|
I found an MSDN article that demonstrated how to call SHGetFileInfo (using InterOperability services) to retrieve system icons. I am in the process of building a kind of management class (manages a large and small imagelist, and retains a list of extensions already handled etc.) with the eventual aim of putting it all up here for others to use in their C# apps.
However, it doesn't like the new XP icons with alpha channels. (as far as I can make out).
When you retrieve the icon for an Excel spreadsheet it looks fine, same for Word etc. However, if you add a text file, the notepad icon appears but with a black border around the edge, this is also true when retrieving folder icons.
I've found some examples of people producing MFC classes to retrieve icons and they work fine so I'm guessing its something I've mashed myself.
Does anybody know what might be causing this to happen?
The code looks like:
Shell32.SHGetFileInfo( name, Shell32.FILE_ATTRIBUTE_NORMAL, ref shfi, (uint) System.Runtime.InteropServices.Marshal.SizeOf(shfi), flags );
System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(shfi.hIcon).Clone();
The icon is cloned so that DestroyIcon can be called to remove the handle -- since I'm adding it to an imagelist DestroyIcon can be called as soon as its been added, however a clone must be made so as not to make the reference to the icon invalid.
If anyone has any suggestions as to how I might sort this out I'd very much appreciate it.
Regards,
Paul
|
|
|
|
|
Paul,
As far as I can tell, the black border is a .Net Framework problem. In my article just posted yesterday, I too retreive this icons. I am dealing with disk drive icons, but I obtain them the same way. In my other article also posted yesterday, I show a control that uses these system icons. The way that I get around the black borders is to resize the image. In my control, I use the 32x32 image and resize it to 16x16 using a soft resampling. That actually works quite nicely. If you need the 32x32, I'm not sure I can help much unless upsampling and then downsampling/averaging works there too. I sure can't tell you why the bug is there...
Hope that helps a little.
Jared Bienz
jbienz@hotmail.com
|
|
|
|
|
Hi,
I know it is a C# forum, but i really need help!!! Let's see my code first:
*****************************************************************************
void operation(int[], char[]);
void waitprocess(int);
void main(void)
{
int i, j;
static char buffer[BUFSIZE+10], X_value[5], message[BUFSIZE];
int f_des[2];
if (pipe(f_des) == -1)
{
perror("Pipe");
exit(2);
}
if (fork()==0)
{
}
else
{
for (j=1; j<=5; j++)
{
if (fork()==0)
{
static char temp[BUFSIZE];
sprintf(temp, "Thread %d", getpid());
operation(f_des, temp);
}
}
while (X>0)
{
close(f_des[1]);
if (read(f_des[0], message, BUFSIZE) != -1)
{
sprintf(buffer, " - X = %d \n", X);
strcat(message, buffer);
write(1, message, sizeof(message));
waitprocess(getpid());
X--;
}
else
{
printf("error");
}
}
}
}
****************************************************************************
I have to create 5 "threads" but using fork() because i have to use pipe() to communicate with "server". This program is doing that 5 "threads" are trying to decrement the global X until X=0. I use pipe as a mechanisam to protect this "critical section". I don't know whether i did it right or wrong. Please help me to check!!!
Also, I found that the output looks strange. The output is always in a pattern. For example, the output looks liked:
Thread 1001 - X = 20
Thread 1003 - X = 19
Thread 1002 - X = 18
Thread 1005 - X = 17
Thread 1004 - X = 16
Thread 1001 - X = 15
Thread 1003 - X = 14
Thread 1002 - X = 13
Thread 1005 - X = 12
Thread 1004 - X = 11
*
*
*
You can see the sequence is 1,3,2,5,4,1,3,2,5,4...etc. I think the output should be in random sequence. Why it's happened???
Thanks!!!!!
|
|
|
|
|
What in the hell is WRONG with you ? The VC++ forum was a stretch, but asking here is just plain rude.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
The VC++ forum was a stretch
And the managed C++ forum
James
|
|
|
|
|
Yeah, but someone beat me to that one
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
She left out the lounge, so some credit goes to her.
|
|
|
|
|
Christian Graus wrote:
What in the hell is WRONG with you ? The VC++ forum was a stretch, but asking here is just plain rude.
I think you are being a bit harsh.
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
You're entitled to your opinion. Would you suggest we post ALL questions and discussions in the lounge ? IF not, why have different sections at all ? He's asked this twice in the VC forum, once in the MC++ and once in the C#.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
You're entitled to your opinion. Would you suggest we post ALL questions and discussions in the lounge ? IF not, why have different sections at all ? He's asked this twice in the VC forum, once in the MC++ and once in the C#.
You should ignore it then. I responded to his post in the VC++ forum and directed him to a newsgroup that would help him. He is probably desperate for an answer and doesn't need anymore stress.
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
Martin Marvinski wrote:
He is probably desperate for an answer and doesn't need anymore stress.
Yeah, that's fair. I'm pretty stressed about my Oracle problem. I might just spam all the forums, what do you think ?
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
Yeah, that's fair. I'm pretty stressed about my Oracle problem. I might just spam all the forums, what do you think ?
What's your Oracle problem?
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
It sucks. I posted details yesterday, basically a stored procedure that worked fine for ages now hangs. It's a simple, vanilla insert. Doing it as text results in a 'invalid char' error, but passing the same text into SQL+ works fine.
My screensaver reads 'die, larry, die'
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
I'm pretty stressed about my Oracle problem.
It's not yet solved. ? Did you check the network share stuff which I told you.
|
|
|
|
|
I am not at work, so I can't try it, but I will first thing tomorrow.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
How do events MouseUp and Paint become available to derived classes?
I have a control that extends Control and is then further extended by another set of controls like so:
<br />
Class BaseImpl: Control, IBaseEdit<br />
{<br />
public virtual event EventHandler ValueChanged;<br />
...<br />
}<br />
and extending that-
<br />
Class MyTextEdit: BaseImpl<br />
{...}<br />
but this class does not have ValueChanged as an available event.
whats the missing link?
-dull
[.. if you've enjoyed today's post, you'll love previous posts including: "..im an idiot." and "way to go, youre dumb." ...]
|
|
|
|
|
Okay, so ive deduced that declaring an event virtual makes it invisible to it's derived classes unless it is overridden.
if you make the OnEvent method that fires the event virtual, you can re-route what happens when the event would otherwise be called by overriding [base.OnEvent].
so there's no obvious reason to make an event virtual. since you cant mutate it in any way, you might as well just declare it as public. unless you wish to selectivly hide it.. but then youre breaking your own abstract class model.
this is so much cheaper than therapy.
|
|
|
|
|
I have to agree, I believe the recommended practice is to have a protected virtual method that is called; in the default implementation it fires the event list.
public class Base
{
public event MyObjectChangedEventHandler MyObjectChanged;
protected virtual void OnObjectChanged(MyObjectChangedEventArgs e)
{
if( MyObjectChanged != null )
{
MyObjectChanged(this, e);
}
}
} Now if someone wants to change what happens when the event happens in a child class they override the OnObjectChanged method to add their implementation.
James
|
|
|
|
|
poodull wrote:
so there's no obvious reason to make an event virtual.
Except I would think that making an event virtual means that you want to overload it's add and remove accessors.
public event Event1
{
add
{
}
remove
{
}
}
So if someone add's an handler you may want to keep a count or something like that.
|
|
|
|
|
Hello!
Using SMTPMail class to send mail.. Having problem with finding out how to find host name of the server that I am running on... If I am typing host name myself -- it works, but I am not expecting user to know what to type...Can I find it automatically?
Please help!
|
|
|
|
|
in short: NO, but if you know there ISP, u could hardcode it into your program.
|
|
|
|
|
try running from the command prompt :
netsh diag show mail , the output is the default configured pop3/smtp servers
works only on win2k and xp
|
|
|
|
|
Hello Friends,
I am using following code to get the information about the table in access database :
string con = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\\Documents and Settings\\Kalpesh\\My Documents\\trialdb.mdb";
String query = "Select * from Emp";//'Emp' is tablename
DataTable accessDataTable = new DataTable();
OleDbConnection dbConn = new OleDbConnection(con);
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query, dbConn);
adapter.Fill(accessDataTable);
foreach(DataColumn dataColumn in accessDataTable.Columns)
{
columnHeaderValues.Add(dataColumn.Caption);
}
Actually, I want to get names of all tables present in access database.So, that I can get the information
of tables dynamically.
Anyone knows the solution??
Thanks in advance.
Pranoti
|
|
|
|
|
Have a look on MSDN for SQLTables.
Quote:
"Summary
SQLTables returns the list of table, catalog, or schema names, and table types, stored in a specific data source. The driver returns the information as a result set.
"
|
|
|
|
|
What you want is the tables schema rowset...
<br />
OleDbConnection conn = new OleDbConnection();<br />
<br />
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; ...etc. ";<br />
conn.Open();<br />
<br />
DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,<br />
new object[] {null, null, null, "TABLE"});<br />
<br />
foreach (DataRow table in schemaTable.Rows)<br />
{<br />
}<br />
conn.Close();<br />
|
|
|
|
|