|
You're welcome. The idea was to give an example, and let you run with it.
Next, pass it forward, when you see a question that you have an answer for, give them a hand.
|
|
|
|
|
hello
can anyone tell me how to clear
or reset to the default value of the
combo box in winforms?
|
|
|
|
|
I'm not sure if you want to delete all items, or just reset the text.
To delete all items you do:
combobox.Items.Clear()
to set a value displayed:
combobox.Text = "text value";
|
|
|
|
|
Hi,
how can I get the number of running threads on the machine. Not just the ones I have created but all threads.
I have googeled a little but didn't find anything useful ...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
You could use Process.GetProcesses to get all the processes on the system, enumerate them, and use Process.Threads.Count to tally a count. Depending on your privileges, though, this might not represent all the threads in the system (only those for which you have access to the processes).
There's also a way using WMI, but it's more difficult to implement and will be slower. Besides, your credentials are typically used when accessing the WMI host so you'll most likely run into the problem described above.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanx, I will look into that.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
|
Nice find...I just wish they would have had that up a few years ago .
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Cool!
But I need an interface similar to "Api Viewer" of the Visual Basic 6.0.
Any suggestions?
Alexsander "Axia" Antunes
|
|
|
|
|
Hia!
I need to hide the border of a win button keeping at the same time the text of it. I think tha the best way to solve my problem is to asign the Form color to the button´s border but there is the problem:
It´s possible to change the border color of a Win Button without changing at the same time the color of the text shown?
By now i´ve only found 2 variables to manage that stuff (ForeColor & BackColor), the ForeColor manage both tge text and the border.
Can somebody help me?
Thanx in advance.
|
|
|
|
|
Why don't you just set Button.FlatStyle to FlatStyle.Flat ?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath, but the flat style include the border too.
The problem is that the border color and the text color are controlled by the same property, no matter the FlatStyle selected.
I think that i need to override a Paint method or something similar.
Cheers!
|
|
|
|
|
I'm trying to run the GetDisplayName method of a folder (in this case, the desktop folder). It all executes perfectly as far as I can see, until it reaches the StrRetToStr method, where it crashes with a null pointer error.
I'm slightly confused as its practicaly identical to the tutorial on this site, and all values forwarded are allocated succesfuly by previous functions.
The code follows:
IntPtr desktopPIDL = new IntPtr();<br />
<br />
COMStuff.SHGetDesktopFolder(out desktopPIDL);<br />
<br />
Type shellType = typeof(IShellFolder);<br />
<br />
IShellFolder shellFolder = (IShellFolder)<br />
Marshal.GetTypedObjectForIUnknown(desktopPIDL, shellType);<br />
<br />
<br />
IntPtr interfacePtr = new IntPtr();<br />
IntPtr relativePIDL = new IntPtr();<br />
<br />
Guid myGUID = Marshal.GenerateGuidForType(shellType);<br />
<br />
result = COMStuff.SHBindToParent(desktopPIDL,<br />
myGUID,
out interfacePtr,<br />
out relativePIDL);<br />
<br />
IShellFolder myShellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(interfacePtr,shellType);<br />
<br />
mySTRRET = new STRRET();<br />
result = myShellFolder.GetDisplayNameOf(relativePIDL,SHGDN_Flags.SHGDN_NORMAL | SHGDN_Flags.SHGDN_FORPARSING<br />
,ref mySTRRET);<br />
<br />
<br />
myFileName = new string(' ',128);<br />
<br />
result = COMStuff.StrRetToStr(mySTRRET, relativePIDL, out myFileName);
The calling code above gets to the last line before crashing.. STRRET has all it's values set to the same PIDL, which is expected, as the type is identifiened by the type value. However, the type value remains 0 regardless of the flags on the STRRET structure returned by the GetDisplayName of.
The STRRET struct and the StrRetToStr method are declared as follows:
<br />
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Auto)]<br />
public struct STRRET<br />
{<br />
[FieldOffset(0)]<br />
public uint uType;
<br />
[FieldOffset(4)]<br />
public IntPtr pOleStr;
<br />
[FieldOffset(4)]<br />
public UInt32 uOffset;
<br />
[FieldOffset(4)]<br />
public IntPtr cStr;
<br />
}<br />
<br />
<br />
<br />
[DllImport("shlwapi.dll", CharSet=CharSet.Auto)]<br />
public static extern int StrRetToStr(<br />
ref STRRET pstr,<br />
IntPtr pidl,<br />
[MarshalAs(UnmanagedType.BStr)]<br />
out string pbstring);<br />
I'm certain that the error lies in either the declaration of my STRRET structure, or the implementation of StrRetToStr.
I'm going to experiment with the alternative method as well, StrRetToBuf, but I susspect a similar problem will occur.
If anyone could shed some light on this subject, it would be most grateful.
regards
Cata
|
|
|
|
|
You're not calling StrRetToStr with a ref . A struct - like I've said to you many times - is a value type. StrRetToStr requires it's address, so either use ref when declaring AND PASSING the parameter, or use GCHandle to get the address and free it when finished.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My bad, I copied and pasted some code i had beed playing with and edited the ref out of, I am actualy calling it as a Ref. Like this:
result = myShellFolder.GetDisplayNameOf(relativePIDL,SHGDN_Flags.SHGDN_NORMAL | SHGDN_Flags.SHGDN_FORPARSING<br />
,ref mySTRRET);<br />
<br />
<br />
myFileName = new string(' ',128);<br />
<br />
result = COMStuff.StrRetToStr(ref mySTRRET, relativePIDL, out myFileName);
And it's still not working, the object is assigned a value to the union members, but it's type value remains 0. I'm not sure, if this is a problem with the strucure or the GetDisplayNameOf method.
Cata
|
|
|
|
|
Don't use out for the last parameter. A String is already a reference type. Also, when alloc'ing your myFileName variable, use '\0' (null) instead of a space. This makes sure that everything is properly null-terminated in case StrRetToStr does something differently.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I see, thanks Heath, it's running without incident now. However, my string is still unasigned after the StrRet call. The STRRET still comes out of the getName function with a type value of 0, and i'm sure that's wrong.
I played around with setting it manualy, but for values 1 and 2, it crashes, and for 3 I get a null string. I didn't think it would work, but had to try.
I can only think it would be the GetName method that's not working properly....
What are your thoughts?
Cata
|
|
|
|
|
Is there an easy way to draw a text on a path? Specifically if I have a curve and I want this text to go along that curve, how can I do that?
Thanks.
|
|
|
|
|
Werdna wrote:
Is there an easy way to draw a text on a path?
No. Lots of calculations and direct font manipulation (if you want to scew fonts) is required. Otherwise, you must trace along the path perpendicular to the normal and draw your fonts with the correct width (of each character, which requires quite a bit of calculations) and space between characters.
It's not as easy as it sounds (if you think this sounds easy). Photoshop CS just added text path support. It hadn't had it previously and there were only a few plugins available that provided such functionality. Just as an example.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks. That's what I thought. I got it to work on drawing on ellipse by using some math. It was a pain. Had to brush up on my trig.
|
|
|
|
|
I am designing an html redirector page now since the ip of my computer keeps on changing i developed an application to detect whenever there is a change in my computers ip address this ip address is stored in a variable in my application now i want to put this variable in html redirector page is it possible.
|
|
|
|
|
VIJAYPAPUPAGER wrote:
I am designing an html redirector page now since the ip of my computer keeps on changing i developed an application to detect whenever there is a change in my computers ip address this ip address is stored in a variable in my application now i want to put this variable in html redirector page is it possible.
If you are writing an application that requires a static IP then you should pay the extra money and get it, DHCP shouldn't be used when a static IP is required. That said, I suppose you could write a quick app that would poll your system for its IP address and store it in a hard file, whatever style you want, be it HTML, XML or your own flavor. It just doesn't appear to be a sound solution to your problem though.
- Nick Parker My Blog
|
|
|
|
|
In addition to what Nick said, you don't need to tell the ASP.NET application what your IP address is. It already knows. From with your page or control, just call Page.Request.ServerVariables["SERVER_NAME"] . This gets the hostname or IP address. There's other ways to get this, too, like Page.Request.Url.Host . If you like, the best place to store this would be in the Page.Application property - kind of like a session variables only they apply to the whole application so that the application can query the variables (like Page.Application["IPAddress"] ) and get the same thing everywhere.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i want to distribute my C# app to a win98 platform... i installed the framework 1.1 redist on it and ran that app and this is what i get...
" ...some exception... cannot be handled.....[some process value]...[some thread value]..."
whats the conventional way of compiling an app to distribute?
isnt it simply , setting the mode to release instead of debug and then compile?
|
|
|
|
|
You can distribute a debug assembly. You just shouldn't. You compile like you normally would. C# compiles to Intermediate Language, which all .NET languages compile to. This is JIT'd into native code and executed on the machine, essentially like Java does. This is a fundamental concept of .NET.
Your error message helps none. Changes are you're using a class that only works on Windows NT. If you actually read the documentation as you develop (now there's a concept), the docs state which operating systems are supported. If you can't give us the full details to try to help you, then please don't post. This is as informative as something stupid like, "It doesn't work".
Microsoft MVP, Visual C#
My Articles
|
|
|
|