|
I guess when you try all day and finally decide to go to the message boards you find the answer.
There is a public Method (EnsureVisible) that will auto scroll the ListView if necessary to make visible the ListView Item of your choice:
lstVwResults.Items[lstVwResults.Items.Count - 1].EnsureVisible();
The above code will ensure the last item added to the ListView control will be displayed.
|
|
|
|
|
I have writen a dll in VC++ project. how can I call the function in the dll from a C# console project?
I think there must be a way. I just don't know how to do it. BTW, I am newbie of C#. I use Visual Studio .Net.
Thank you.
|
|
|
|
|
xianwuluo,
It would help to see the signature of the unmanaged function you want to call, so instead all I can do it point you at the documentation online in the .NET Framework SDK, entitled Consuming Unmanaged DLL Functions[^].
A simple example follows:
EXTERN_C __declspec(dllexport) HRESULT Foo(LPCTSTR pszA, DWORD cchA);
[DllImport("mydll.dll", CharSet=CharSet.Auto)]
static extern int Foo(string pszA, uint cchA);
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
OK, so you want to strip the <b> and </b> tags, you want ALL the other text, including the text inside the bold tags ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
simply i don't want the or in the above i want to exclude them, any help plzz...
regards
|
|
|
|
|
simply i don't want the <b> or </b> in the above i want to exclude them, any help plzz...
thanx and regards
|
|
|
|
|
sorry i didn't see your replys , only when i whent out of the message bord and then returned i found out that i've repeated myself.....
ya actually i just want to exclude the <b> and </b>: eg. (.+(not <b>nor</b>))
|
|
|
|
|
If your just want to remove a fixed part of your string, you could simply use string.Replace("<b>", ""); followed by string.Replace("</b>", ""); to strip out the bold tags.
What remains can then be parsed with regex, of course.
mav
|
|
|
|
|
thanx mav but this will replace the tags witch a space i suppose i just want exclude the tags from appearing with the group when i use this expression:
<td.+><font.+><a.+>(.+)"
i get results desired like:
<prog>Hi to All
but also get undesired extras some times():
<prog>Bob Harris
thanx and regards
|
|
|
|
|
ignore the above i've forgoten to disable html:
<td.+><font.+><b><a.+>(.+)</a></b></font></td>"
i get results desired like:
<Prog>Hi to All</Prog>
but also get undesired extras some times(</b>):
<Prog>Bob Harris</b></Prog>
thanx and regards
|
|
|
|
|
hi there how wud i exclude a certain tag or character using regular exp.:
<a.+>(every character but not the <b> or </b>tag )</a>
!!!!
thanx and regards..
|
|
|
|
|
Match all either side of the tag, and then return the matches ( so the tab is left out ).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
<a.*><b>(.*+)not any </b><b>or</b></a>
what "expressions" can i use to do the above
|
|
|
|
|
Oh, I see. You want to find inside the tag. Just use non greedy evaluators, and end up with an expression that matches the end. Or use look ahead.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
can u please show me this with an expressions, i'm quite ignorant in regex ....
thanx
|
|
|
|
|
ignore above message:
<a.*>(.*+)not any or
what "expressions" can i use to do the above ..cheers
|
|
|
|
|
You forgot to turn off HTML tags, so I can't see your correction....
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
<a.*>((.*+)not any <b>or</b>)</a>
what "expressions" can i use to do the above
cheers
|
|
|
|
|
Hi Folks
I've got a seperate thread running in my application, that is processing a tree search. This works fine.
My OnPaint event draws the image generated by the enviroment by passing in the graphics handle of the window. The invalidated region since the previous onPaint call, is requested, and then the screen is invalidated. This also works fine.
My problem comes when right clicking or double clicking on the window in the task bar when hidden, or clicking on it while visible to minimise it, which throws an ArgumentException, with 'Invalid Parameter Used'.
As my derived thread does not call any of the windows components, and simply works on a recursive stack function which manipulates an enviroment. So, as far as I can see the threads are completely seperate and do not rely on each other for information. So i do not know why these errors are being raised.
Can anyone explain why this is happening?
Cheers
Cat
|
|
|
|
|
Catalyst,
Please post some sample code. That would help disabiguate what you mean by "tree" and "environment".
If I understand correctly, it sounds like the threat is still interacting with OnPaint . Like nearly every other member of a Control class, painting must be done - unless double buffered - in the same thread on which the control was created using Control.Invoke . The OnPaint is actually a message handler for the Windows WM_PAINT message. When you force and update from a separate thread this message may be sent to the wrong thread and would cause problems that Control.Invoke solves by making sure messages (which are event sent to set text, like setting TextBox.Text ) are sent on the right thread.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
All the graphics are double buffered on a seperate thread.
The OnPaint event of the control calls the enviroment with a graphics handler:
My enviroment contains the following code:
<br />
public void RenderEnviroment(Graphics g, int width, int height)<br />
{<br />
Image i = new Bitmap(width,height);<br />
Graphics gfx = Graphics.FromImage(i);<br />
<br />
int buffer = 5;<br />
gfx.FillRectangle(new SolidBrush(Color.Black),0,0,buffer+(buffer+100)*WIDTH, buffer+(buffer+100)*HEIGHT);<br />
<br />
for (int x=1;x<WIDTH-1;x++)<br />
{<br />
for(int y=1;y<HEIGHT-1;y++)<br />
{<br />
Tile t = this.g_Enviroment[x,y];<br />
if (t != null)<br />
gfx.DrawImage(t.TileImage,buffer + (100*(x-1)) + (buffer*(x-1)),buffer + (100*(y-1)) + (buffer*(y-1)));<br />
}<br />
}<br />
<br />
gfx.DrawString("Permutations Tested: " + permChecked.ToString(),<br />
new Font(FontFamily.GenericMonospace,14),<br />
new SolidBrush(Color.White),<br />
buffer,height-100);<br />
<br />
g.DrawImage(i,0,0);<br />
}<br />
This is called from the OnPaint method of my form, where env is a gloval Enviroment variable:
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
env.RenderEnviroment(e.Graphics,this.ClientRectangle.Width,this.ClientRectangle.Height);<br />
Thread.Sleep(100);<br />
<br />
Region r = env.GetInvalidatedRegion();<br />
this.Invalidate(r);<br />
}<br />
The Tree is largely irellevant, as it runs on a seperate thread and does not interact with the form at any point. Enviroment contains a 2D grid, which is modified by the spawned thread, but is only read by the Painting thread.
Hope that helps
Cata
|
|
|
|
|
Never block the painting handler. This can severely cause the application to hang since painting messages are sent almost continually. So long as RenderEnvironment doesn't do anything in a separate thread, execution is blocked until it's done then GetInvalidatedRegion will run. The Thread.Sleep(100) should not be necessary.
Even though you're not modifying the control you are modifying the 2D grid (I assume a multi-dimensional array) in another thread. If OnPaint or it's callers access that while it's being written this could very easily cause a problem. Use an object (same reference; typically a static reference property will do) to lock between writing and reading the grid.
Depending on how often it's written or read, you might consider even using a ReaderWriterLock , which is documented in the .NET Framework SDK. The important thing is that something isn't reading the grid while something else (the other thread) is writing it.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi Heath,
Cheers for the reply. I changed the 2D array to volatile, as i only have 1 thread writing to it 3.5 million times a second, and it's read from only 60, an exactly up to date reading is not essential. It seems to have speeded the program up slightly.
I added a try / catch block on the on the RenderEnviroment, and discovered that when the program is minimised, the client area that I was using to base my rectangle off was 0,0, which threw an error when trying to construct a bitmap, the error that was thrown without the try block always reverted back to the Main method of the application.
I should have thought of it earlier, but it's sorted the problem out now.
Cheers
Tris
|
|
|
|
|
It would seem that you're forcing a repaint, then. Windows will send a visible window the WM_PAINT message (which in Windows Forms translates to the OnPaint handler, which fires the Paint event) along with the clipping rectangle that needs to be redrawn (redrawing only this rectangle or just objects that intersect it yields better performance for your application). If you force an update you will run into problems like you are now.
I recommend not forcing an update, but simply invalidate. Windows will send a WM_PAINT message ASAP if your window is visible. If it's not visible, then there's no point to send the message and you won't run into problems that you had when the app was minimized.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Well, I do have a problem then.
I don't want the screen to refresh continuously without pause, because this will pull processor time from my other thread which is more important. My display is purely so I can see what is going on.
If i don't force the on paint, the screen will only ever refresh if i do something to it manualy, like resize or min/maximise. I see no point in running a seperate thread that invalidates my screen 15-20 times a second, because it will simply eat more cpu time.
Can you suggest another solution to this problem?
|
|
|
|