|
To all:
After calling Process.GetProcessById, I can get specific process. But how to get its window, and set the window position and size?
Below is my code.
Process selectedProcess = Process.GetProcessById(Int32.Parse(lvwWindows.SelectedItems[0].Text));
NativeWindow nw = NativeWindow.FromHandle(selectedProcess.MainWindowHandle);
Here, the second line return nothing. Why?
The target window is not managed coded.
Thanks a lot.;)
|
|
|
|
|
Hey
I would like to know if there is somekind of a possibilty to create an array WITHOUT knowing its size.
lets say I want to load an array from a file, but I do not know the size of the array that I am loading.
so my solution for this, is creating a huge array (like myarray[1000]), and load to it.
but if I'm just using 2 or 3 slots, its a waste of memory.
is there a way to do it a bit better? to tell what is the size of the saved array before I load it (the array is serialized)?
Thanks!
|
|
|
|
|
You can use the ArrayList-class
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks!
|
|
|
|
|
You can use a hash table for this as well. Here is an example:
<br />
Hashtable hash = new Hashtable(); <br />
for (int i=0; i<10; i++){ <br />
hash.Add(KeyHere, ValueHere); <br />
}<br />
Replace the KeyHere and ValueHere...
Dirk Watkins
|
|
|
|
|
now, thats a nice.
I''ve never used a hashtable, but I guess I will now
thx!
|
|
|
|
|
You do take a fair amount of memory overhead with a hashtable. The runtime keeps it at roughly 50% capacity for speed reasons. The advantage is that if you're modifying data regularly you don't need to resort with each insert. Search times are comparable with a sorted array.
|
|
|
|
|
dan neely wrote: Search times are comparable with a sorted array.
Not really, Hashtable search times are constant on average.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
What about if you use an ArrayList? It should automatically change size when adding data to it. And when you declare the array you don't have to specify the size.
ArrayList list = new ArrayList();
|
|
|
|
|
Hello,
I need to know how to only match if a word does not appear before the selected word.
For example, I have the sentence "there is a brown fox over there".
The word I'm trying to match would be, say "fox". However, I only want to match "fox" if the word "brown" does not appear directly before it. Any help would be greatly appreciated.
So the sentence above would not match, however the sentence "there is a fox over there" would match.
Thanks folks!
Brian Van Beek
Here's my boring blog! [^]
-- modified at 11:15 Monday 17th October, 2005
|
|
|
|
|
[^brown](\s|\t)+fox
That works
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
|
Well, to be honest I was not completely sure about that.
How to do this correctly? I tried (word){0} , but that doesn't work.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You need to use a Negative Lookbehind.
(?<!brown)\s+fox
|
|
|
|
|
|
I have a c# program I've been writing which dynamically loads an image. It also dynamically loads an xml file which defines rectangles within the image. Each xml entry defines the upperleft coordinate on the image, and the width and height of the rectangle.
What I need to do, is create outlines on the picturebox for each entry in the xml file. I'm not sure how to do this.
Basically, over my loaded image, if there is an entry in the xml file, for example: 10,10, 50, 50 ...
I need to draw a rectangle (outline, or full but semitransparent) over the picturebox at coordinates 10,10 width a height of 50 and width of 50.
I've no idea where to start.
Any help?
Thanks.
|
|
|
|
|
Here is some code used in a paint event. If it is not in an event with PaintEventArgs you will need to get a Graphics object in another way.
private void Image_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Rectangle selRect = new Rectangle(0,0,0,0);
Graphics selGraphics = null;
int lineThickness = 2;
selGraphics = e.Graphics;
selRect.X = 10;
selRect.Y = 10;
selRect.Width=50;
selRect.Height=50;
Pen selPen = new Pen(Color.Black, lineThickness);
selGraphics.DrawRectangle(selPen, selRect);
}
|
|
|
|
|
I'm using a FileSystemWatcher to detect changes made to files in a shared directory and have the app update it's internal copy of them. Rarely it detects a change and attempts to open the file to read the update before the instance of the app doing the changes has closed the file and throws an exception. I'd like to have the app wait a few seconds, and then retry loading the file, but am not sure how to do so.
|
|
|
|
|
You can try using Thread.Sleep[^] to "wait" for a few seconds before retrying. Something like
while (conditionNotMet)
{
Thread.Sleep(time);
conditionNotMet = evaluateCondition();
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
That should work I guess, but I was hoping to keep the app singlethreaded for simplicity.
|
|
|
|
|
It still is single threaded, Thread.Sleep suspends the current thread for a particular amount of time.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I need to update a C# form with values read to it from another program in addition to changes from C# code while retaining the ability to edit text/combo boxes on a different part of the form from the updates. Right now, I can get the updates running, but am denied access to the form while the updates are occurring. How can I achieve this functionality?
|
|
|
|
|
Hi Guys,
How can we create an object for vb dll without reference and reflection in c#.
In VB.Net we have a method CreateObject(), but in C# we don't have such method. How can we achieve this in C#.
Raghuram
|
|
|
|
|
AFAIK, CreateObject also uses reflection like techniques to do its job.
I'm not sure how you can do without adding a reference, because C# is a statically typed language, which means that you have to have a type definition to compile.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|