|
Thanks guys,
Here is an approach that works well.
Kyle
using System.Management;
string drive = "\"c:\"";
string filename = "\"test\"" ;
string extension = "\"exe\"";
string qry = String.Format( "select * from cim_logicalfile where drive={0} and filename={1} and extension={2}", drive, filename, extension);
ManagementObjectSearcher query = new ManagementObjectSearcher(qry); ManagementObjectCollection queryCollection = query.Get();
foreach(ManagementObject mo in queryCollection)
{
Console.WriteLine( "Name '{0}' :Path: '{1}' ",mo["Name"], mo["Path"]);
}
[Edit: The : P shows up as a smily face. Although I am happy with this result the smily face was unintentional. ]
|
|
|
|
|
I am trying to recreate the sidebar used in Explorer in Win XP in one of my programs. You know, the cute blue (or silver or green) thing with all the pretty icons and animations? Okay, I know, the first thing you did was probably turn that thing off. But I really want to have that look in a few of my C# forms.
I've had marginal success recreating the look using my own controls that call the UxTheme library. This is messier than I'd like, however, and doesn't include all the neat animation and other features that Explorer has.
This being Microsoft, I'm sure they abstracted that side bar into an object, possibly even a control of some sort. Does anyone know if this is accessable? Has anyone found any sort of documentation on the subject, even a little snippet? (I built my version of the sidebar using barely a few lines of information on UxTheme.dll, so I'm used to having a lack of documentation for these new XP display styles.)
Or has someone on Code Project already addressed this, and I missed it?
Thanks.
---------------
Jeremy Fuller
|
|
|
|
|
Does anyone know if you can make winforms skinnable? If so are there samples that I can look at? I have a control that I bought from softshape.com that allowed me to write skinnable software in vb 6 and I'm looking for the same tool or method within .NET to do the same thing.
|
|
|
|
|
Hi. there
Well, Now I'm make some kind of HTML editor with C#.
I'm try to drag-drop some HTML tag in DHTMLEdit control.
But I can't...
How can I drag-drop "HTML tag" in DHTMLEdit...
I wrote source like this...
that is what I want drag(HTML tag) in DHTMLEdit contol.
---------------------------------------------------------------------------
private void schemaTreeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
string s = e.Item.ToString();
switch (s){
case "TreeNode: VATDOC" :
s = "<input type='checkbox' checked value='ON'> </input>";
break;
default:
break;
}
DoDragDrop(s , DragDropEffects.All);
}
---------------------------------------------------------------------------
and you know, Drop in DHTMLEdit control, It will be work automatically so...
When I try to drop "<input type='checkbox' checked value='ON'> </input>", but it will be work like this "& lt;input...... & gt;......"
I think, DHTMLEditor has some kind of parser that work change "<" to "& lt;"...
somebody know How can I drag-drop HTML tag in DHTMLEdit control?
PS) sorry for my poor english.. ^^;;;
=^.^=
|
|
|
|
|
We have our own abstract class, inherited from Windows.Forms.control,and has some base methods we will use in it. Now we create our user control, which inherited from this abstract class, then we found our new user control can not use some features from Windows form designer, does anyone have the same situation, and how to deal with this?
Thanks.
|
|
|
|
|
Sometimes when you manually edit the code, the form designer gets confused and stops working. Happens to me all the time
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
I have that problem too!
And I don't like it!
One time I had to increase the size of my window but when I compiled it was the old size of the window!!!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Anonymous wrote:
then we found our new user control can not use some features from Windows form designer
What kind of features?
|
|
|
|
|
Actually, the abstract class our user control inherited is Windows.Forms.UserControl ( I say Windows.Forms.Control before, don't know if it makes any difference). When our new created usercontrol inherited this abstract class, you can not see it totally from design view.(The error shows the abstract class can not be loaded, etc. But we referenced this abstract class in the project, there is no compile error). Interestingly, when you remove inheritance, it can be shown in design view correctly.
Any idea?
|
|
|
|
|
This is a known "bug" with VS.NET; a couple solutions available but each require you to change the design.
First is to take all of the methods that would normally be left to be implemented and put it into an interface; then make the end usercontrol implement that.
Second is to provide dummy implementations that just throw a NotSupportedException or some other exception. Make sure to mark these methods as virtual
James
Simplicity Rules!
|
|
|
|
|
|
I have a problem with ReadCallback when I'm using sockets. Here's my problem: i'm writing an internet chat program. When user sends me a messages at large time intervals, everything is OK, but if he's flooding me, ReadCallback gets lots of calls. This causes that many Readcallback is calling and this causes overlapping messages in socket. Socket treats some messages as a one big message (they were sent as a separate messages). As a result of this the message is not easy readable... My ReadCallback begins with Monitor.Enter(RecQueue) and ends Monitor.Exit(RecQueue) [RecQueue = new Queue()]. How to force socket not to overlap multi messages into one?
Here is my ReadCallback code:
public void ReadCallback(IAsyncResult ar)
{
Monitor.Enter(RecQueue);
StateObject state = (StateObject) ar.AsyncState;
state.workSocket.Blocking = false;
Socket handler = state.workSocket;
handler.Blocking = false;
int read;
read = handler.EndReceive(ar);
if (read > 0) //display a message
{
DisplayMessageProcedure("the message");
}
else
{
//close the connection
handler.Close();
}
if (handler.Connected == true)
{
handler.BeginReceive(state.buffer,0,StateObject.BufferSize, 0,
new AsyncCallback(ReadCallback), state);
}
Monitor.Exit(RecQueue);
}
public class StateObject
{
public Socket workSocket = null;
public const int BufferSize = 1024;
public byte[] buffer = new byte[BufferSize];
public StringBuilder sb = new StringBuilder();
}
public void ListenProcedure()
{
IPAddress ipAd = IPAddress.Parse("0.0.0.0"); //all interfaces
IPEndPoint localEP = new IPEndPoint(ipAd, System.Convert.ToInt32(PortEdit.Text));
sock = new Socket(localEP.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
sock.Blocking = false;
sock.Bind(localEP);
sock.Listen(1);
sock.BeginAccept(new AsyncCallback(AcceptCallback), sock);
}
HELP!!!
|
|
|
|
|
Hi,
It seems as .NET uses double for all math calculations. I do not actually need the precision used by double and as such was thinking about using float. I guess .NET will cast all my values to doubles, which will mean a performance impact. Any suggestions?
Thanks,
Jurgen
|
|
|
|
|
Anonymous wrote:
It seems as .NET uses double for all math calculations
Do you mean in the Math class or C#?
In C# you can use floats in expressions and floats will be returned, just make sure you use the f (or F) suffix on literals when appropriate.
float size = 10.1f;
|
|
|
|
|
Hi all - I'm toying around with the events and I'm having some trouble.
I have a series of events I want to fire asynchronously, one after the other. That is, once one completes asynchronously, I want it to fire the next appropriate event.
I've been looking at the "bed time story" for events offered by Chris Sells (http://www.codeproject.com/csharp/delegate_bedtime.asp)
but I'm a bit confused.
Can someone explain these lines of code to me:
foreach( WorkCompleted wc in completed.GetInvocationList() ) {
wc.BeginInvoke(new AsyncCallback(WorkGraded), wc);
}
WorkCompleted is a delegate defined as: delegate int WorkCompleted();
completed is an event of type WorkCompleted
The rest I'm a bit confused about. I think that what's happening is that we're looping through each method that's been added to the event. We invoke each method on a seperate thread, and as soon as that thread is invoked, we call the "WorkGraded" method. What I'm not sure of is what thread WorkGraded is called on. Is it on the same thread as the method that has just been invoked? Or on the thread that called the method? Also, I don't understand the puprose of the second parameter in the BeginInvoke function. What does it do?
Thanks in advance.
- Sabran
|
|
|
|
|
Just to keep this simple...
I want to draw a circle in my about box that writes over all the text, bitmaps, etc.
So, I override OnPaint and do a ...
e.Graphics.DrawEllipse( Pens.Black, 0, 0, 500, 500 );
... but the circle is more of a background graphic and the text gets written over it. I've also overrode the OnPaint method to get the same results.
Sure I can set transparency on text, but I want this circle to overwrite anything in it's way... toolbars, status bars, etc.
Any thoughts??!
|
|
|
|
|
I am creating a very simple console application to read a portion of the registry into a class object called TrxRegistry under a TrxRegistry namespace. The registry access is working with no problems using hardcoded strings. I've now added a resource file called TrxRegistry.resx where I've associated the names of the registry values with descriptive names. The program compiles with no errors, but when I run it, I'm getting a resource exception.
I create a Resource Manager:
ResourceManager rm = new ResourceManager("TrxRegistry",this.GetType().Assembly);
and then access it by opening the registry key (which is defined in the resource file):
RegistryKey key = Registry.LocalMachine.OpenSubKey(rm.GetString("TRXKEY"));
I get this exception:
Could not find any resources appropriate for the specified culture (or the neutral Culture) in the given assembly. Make sure "TrxRegistry.resources" was correctly embedded or linked into assembly "TrxRegistry".
baseName: TrxRegistry locationInfo: <null> resource file name: TrxRegistry.resources assembly: TrxRegistry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
The Build Action property for the TrxRegistry.resx resource file is set to Embedded Resource.
I didn't think I had to do anything for an embedded resource file. I thought you only had to use a command line assembly program for multiple language DLLs.
Does anyone have an idea what might be wrong?
Thanks in advance!
Derek
|
|
|
|
|
Instead of calling the constructor where you pass in the root namespace (which I think is telling it to look for culture specific resources) what happens if you call the constructor that gets its information from a type (ala Windows Forms) new ResourceManager(typeof(TrxRegistry));
Just a shot in the dark
James
Simplicity Rules!
|
|
|
|
|
I just tried your solution and it works! I figured out that I wasn't including the namespace when creating the Resource Manager:
Before:
ResourceManager rm = new ResourceManager("TrxRegistry",this.GetType().Assembly);
After:
ResourceManager rm = new ResourceManager("TrxRegistry.TrxRegistry",this.GetType().Assembly);
I like your code much better - no strings and less typing!
Thanks!
Derek
|
|
|
|
|
Cool
I think your method will need to be used if you want to use culture-specific resources; if you want .NET to automagically load them for you anyway.
James
Simplicity Rules!
|
|
|
|
|
How can I create form inside second ? I dont see anything such Create(HWND hParent)
In MFC e.g.:
CDialog dlg;
dlg.Create(IDC_DIALOG1,this);
dlg.ShowWindow();
I think programing using MFC or/and API is more logical than C#.
Wiizi
|
|
|
|
|
|
no, only create form inside second. e.g. you have treectrl and when you select item -> show form with setting ....
Wiizi
|
|
|
|
|
Will this work
In the event handler for the tree control
public /* some tree event handler*/
{
Form2 form2 = new form2();
form2.Show(); // or form2.ShowDialog() - for modeless
}
Form2 is the class you created for the second form? I might be missing something here so let me know.
|
|
|
|
|
ok...and how can i dock it into parent form ?
Wiizi
|
|
|
|