|
James T. Johnson wrote:
a cross between my solution and Paul's would probably be best
I was about to say that
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
I did a mix between paul's and mine and it worked like a charm Thanks guys.
My next step is to get this into an array or something (I need to store it in a database)
"word1,word2,word3 and four,word5"
Will regular expressions work well for this, or is it better if I use conventional string parsing?
Jeremy.
Jeremy Pullicino
Professional C++ Developer
Done any hacking lately?
|
|
|
|
|
I think string parsing would be better for that. Use the Split method of the string class to get the initial array, then do parsing on each item to see if it contains more keywords (like 3 and 4 above).
James
Sig code stolen from David Wulff
|
|
|
|
|
If it's always going to look like that ("word1,word2,word3 and four,word5") then use String.Split on "," because it's a LOT more efficient.
If there's randomly spaces (like "word1, word2 , word3 and four,word5") then use Regex.Split on "\s*,\s*".
Paul
Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop
|
|
|
|
|
The easiest thing is probably to write two separate regular expressions, and see if either of them match.
For using regex, you might want to download my utility:
http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=regular%20expression%20workbench
|
|
|
|
|
Hi,
Does anyone know the equivalent APIs or mechanisms of doing
InvokePaint or InvokePaintBackground in Controls?
I want to tell a parent control to redraw itself inside the
control's client area, so it looks like a control can be
have "transparent" background (of course, not real transparent).
However InvokePaint is a protected method. There is no chance for
me to use these methods if I'm not inheriting the control class.
Thanks
Li-kai Liu
|
|
|
|
|
Ummm. If you are writing a control, you should be inheriting from the control class. Thus, you should have the ability to call the InvokePaint method.
Some more specifics might be nice if we're going to solve your problems.
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
That's what I don't want it to be at the moment...
I know I have to inherit the control class in order to
use it (because it's protected method...)
Currently, I'm writing many custom controls that each of
them requires this functionality. Therefore, I think
it's a good idea to "extract" this method as an external
one so that every control I've written could use it by
calling this external function, something like:
public static void DrawParentBackground(Graphic g, Control parent, Control callerControl)
No inheritance is involved in order to use these protected method...
Thanks again
|
|
|
|
|
Well, maybe still not very clear in my previous reply.
I included a picture of the button control I've been
writing for fun.
http://www.ykliu.com/problem.png[^]
It's a small button that draw everything from scratch. I plan a
few features for this button:
- support theme automatically. done! (Thanks for help from James T. Johnson)
- support shadowed text. done! (Thanks for great tutorials from Christian Graus)
- to able to draw underlying control, so it looks like transparent background is supported.
Well, that's why I come up with this question.
Though, I am able to use InvokePaint, InvokePaintBackground to redraw the
underlying parent control. Suddenly this question comes to my mind. If
I want to write another custom control that use this feature by using
InvokePaint. There is no way but inheriting it from Control Class.
Wouldn't it be better if I can write a static function, passing the caller
control and caller's parent control as parameter, then the function will
repaint caller control with the underlying parent's background.
Thanks in advance...
P.S. there's also another painting problem I found. illustrated in the included image.
Li-kai Liu
|
|
|
|
|
Can anyone show an example of using the Win32 SendInput function in C#? It seems to be missing from dotnet and I need to send a keyboard event,
thanks
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Google!
link[^]
How low can you go ? (MS retrofuck)
|
|
|
|
|
I saw that google link, and I've been working on it, but I still can't get it to work. I've reached the point where it neither throws errors, nor works.
My definitions are like this:
<br />
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]<br />
private static extern uint SendInput(<br />
uint nInputs,
INPUT[] pInputs,
int cbSize
);<br />
<br />
public struct INPUT {<br />
public int type;<br />
public short wVk;<br />
public short wScan;<br />
public int dwFlags;<br />
public int time;<br />
public UIntPtr dwExtraInfo;<br />
private int _pad0, _pad1;<br />
}<br />
<br />
I call it like this:<br />
<br />
INPUT[] ipar=new INPUT[1];<br />
INPUT m=new INPUT();<br />
ipar[0]=m;<br />
m.type= 1;
m.wVk= 0x41;
m.wScan= 0; <br />
m.dwFlags=0;<br />
m.time=0;<br />
uint u=0;<br />
m.dwExtraInfo=(System.UIntPtr)u;<br />
tbx.Focus();
uint ui=SendInput(1,ipar,System.Runtime.InteropServices.Marshal.SizeOf(m));<br />
<br />
the result is that ui = 1. But the Textbox stays empty.
I also tried it by doing the union inside the INPUT and making structs for hardware and mouse input, and I got that to the same point, where ui=1 but the textbox stays empty. This always what happens to me with com interop I get to the point where there's no errors but doesn't work.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Hi
I think your txtbox is not getting the focus. I have had problems before. You mite need to invoke the Focus method.
Hope this helps
"There are no stupid question's, just stupid people."
|
|
|
|
|
er I did invoke the Focus method, take another look at the code. Also, I know it's focused because i can see the cursor blinking in it, and the border etc..
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Bog wrote:
er I did invoke the Focus method, take another look at the code.
tbx.Focus(); only calls the function.
You will need to do something like this I suspect.
if (tbx.InvokeRequired) tbx.Invoke(tbx.Focus);
else tbx.Focus();
Also I see that there is no KEYEVENTF_KEYUP for the SendInput. This I presume you will need to do after the first SendInput you are sending.
"There are no stupid question's, just stupid people."
|
|
|
|
|
I tried a Console.WriteLine(tbx.InvokeRequired) and it was false. Also, I know the textbox is getting focus because I can see it. The curosor is blinking in the textbox, and when I type text goes into it.
I don't think sending a KEYUP is required, because it's not required in normal keyboard activity either. For example, when you press a key here in a web form, the letter appears on keydown, not on keyup. Also, I've seen examples of this in C++ (non dotnet) and non of the examples have a subsequent KEYUP.
Thanks for your responses anyway tho.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Hello,
i am very new to c#.
i made a program to download a web page.
Now I want to parse out the meta keyword tags:
Done any hacking lately?
|
|
|
|
|
Add the Microsoft.mshtml namespace (add a reference to this primary assembly that you'll find in the program files \ .NET folder).
Then the IHTMLMetaElement interface is the right stuff for you.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Thanks - that pointed me in the right direction.
I have managed to get the keywords out, but I think that regular expressions could do it much quicker for me. I am looking into those right now If you have any experience with regular expressions, please look at my new post
Cheers,
Jeremy
Jeremy Pullicino
Professional C++ Developer
Amature C# Software Architect
Done any hacking lately?
|
|
|
|
|
My C# app calls a COM server but does not release it. What's Wrong? Urgent!
Please help!
Here is how I call it:
<code>
...
void SomeFunc1()
{
for (int i; i<10; i++)
{
SomeFunc2();
}
}
void SomeFunc2()
{
MyCOMLib.MyIFace mf = null;
try
{
mf = new MyCOMLib.MyIFace();
string myParam = "Here is some param";
MyCOMLib.MyIFace2 mf2 = mf.MyMethod(myParam);
mf2.MyProperty = 1;
}
catch()
...
}
</code>
|
|
|
|
|
Not really surprising.
Anyway, help the GC by doing stuff like mf2.Release() and mf = null;
(may be the issue is on your part btw : if you have a wrong apartment model, then the COM server is not released that easy).
How low can you go ? (MS retrofuck)
|
|
|
|
|
The problem is that for some reason, even when COM interface
IUnknown derived C# compiler throuws at me:
MyCOMLib.MyIFace2 does not contain a definition for 'Release'
and assigning to null does not release it right away for sure.
How do I work this appartment thing?
|
|
|
|
|
O! So GC does not release objects right away, does it?!
It looks like if I call GC.Collect(); objects do get released (not right there but in a couple of milsecs).
I'm assuming that means that my COM objects are fine and can be released just fine, right? Or is this GC.Collect(); a kind of cheating?
If not, why GC doesn't clear local vars right there on the spot like VB does (I think ) ? When does it do it?
|
|
|
|
|
GC.Collect() is kinda hardcore. This method is not normally called by a client app, except in critical scenarios (huge memory needs, and so on). It's true that, from what I know from the Java GC, the GC has no good reason to release objects as soon as they are out of scope.
The fact that GC.Collect() has actually released your COM object is that it was a weak-reference in scope.
COM are normaly finely released.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Interesting! Thanks a lot.
Curious : what's "weak-reference"?
And what do you mean by "COM are normaly finely released"?
May be my english is not that good yet
Do you think I still have to hunt for problem or it looks like it's fine. What do I do?
|
|
|
|