|
Hi!
for a left click I used SendMessage
Example:
public enum Button_Messages
{
BM_CLICK = 245,
BM_GETCHECK = 240,
BM_GETIMAGE = 246,
BM_GETSTATE = 242,
BM_SETCHECK = 241,
BM_SETIMAGE = 247,
BM_SETSTATE = 243,
BM_SETSTYLE = 244,
}
if you create the application, you have the proccess and the handle,
otherwise you can find it with FindWindow then you can find wihch control to Left click.
Button is the Class name, Import Option is the Text of the control.
hControl = FindWindowEx(windowHandle, IntPtr.Zero, "Button", "Import Options");
Once you have the Control´s handle you can simulate the left click, if SendMessage returns True it was successful, if False it was not possible to perform the click.
SendMessage(hControl, (int)Button_Messages.BM_CLICK, (uint)0, (int)0);
|
|
|
|
|
|
I'm working on a research project that closely resembles a UML class diagram creation program. I started out using Java and JHotDraw to create my own figures, tools, etc, but I really would prefer to use C# as I am much more confident in the language and there are a lot of different aspects to this project which would make C# my preferred language.
Are there any drawing frameworks for C# which allow the programmer to create their own models and creation tools?
|
|
|
|
|
When you have Visual Studio 2003 Enterprise Architect, then you can do it using Visio for Enterprise Architect. You can convert Code->UML or UML->Code.
|
|
|
|
|
I am building a C# window app and am trying to 1. Create a DataAccess class which retrievs the connection string from app.config and then 2. call the DataAccess from a form load.
I have successfully created the DataAccess.cs class but am having difficulties creating the retrieval of the app.config connection string.
Does anyone have suggestions or a GOOD site with a simple C# example of how to do this.
|
|
|
|
|
At the top of your file put:
using System.Configuration;
When you want to retrieve the setting use:
string connString = ConfigurationSettings.AppSettings["MyConnectionStringSetting"];
(Change "MyConnectionStringSetting" to the name of the setting in the app.config[^] file)
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I have a question.
Why do the GNU/Linux users recommend C# if it's not Open Source (it's a Microsoft Technology-Programming Language)?
What happend with Python and Java?
|
|
|
|
|
There is Mono[^] which is C# that run on Lunux.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Yes, but C# is not Open Source. You code in C#.
|
|
|
|
|
C# is an ECMA standard, which is open and that allows things like the Mono project to exist.
See: Standard ECMA-334 C# Language Specification[^]
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Does anybody konw how I can databind some XML to a treeview?
/\ |_ E X E GG
|
|
|
|
|
Aha the urgent guy! So now you are back with a different title line.
First of all, do you want only the DATA part of the XML in your tree view? If you go the normal examples shown in MSDN etc, you will get BOTH TAGNAMES AND DATA in your treeview. As you ar repeatedly asking the question, I am assuming that you need ONLY THE DATA (b'coz otherwise you would have altready got your answer from MSDN etc).
Here is the basic idea of how you can do it. The whole code will be too complex to fit in here. First aof all see the MSDN example from (probably your post only): http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=450892&SiteID=1[^].
From that MSDN example, I will modify ONLY THE button1_Click() method. Not the AddNode() method. You have to follow a slightly different approach here:
private void button1_Click(object sender, EventArgs e)
{
try
{
XmlDocument dom = new XmlDocument();
dom.Load(Application.StartupPath + "\\Sample.xml");
treeView1.Nodes.Clear();
if( dom.DocumentElement.Text == null || dom.DocumentElement.Text == "" )
treeView1.Nodes.Add(new TreeNode(dom.DocumentElement.Name));
else
treeView1.Nodes.Add(new TreeNode(dom.DocumentElement.Text));
if (dom.DocumentElement.HasChildNodes)
{
XmlNodeList nodeList = dom.DocumentElement.ChildNodes;
for(i = 0; i<=nodeList.Count - 1; i++)
{
if( ! ( ( nodeList[i].ChildNodes.Count == 1 )
&& ( nodeList[i].InnerXml == nodeList[i].InnerText ) ) )
AddNode(nodeList[i], treeView1.Nodes[0]);
}
}
treeView1.ExpandAll();
}
catch (XmlException xmlEx) { MessageBox.Show(xmlEx.Message); }
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
Note: Instead of calling AddNode once (as shown in MSDN example) I am calling it for all the childnodes in a loop. That eliminates 1 layer - your trr view won't have the level 2 tags. But now in the AddNode() method, what do you do? Answer is you have to follow a similar logic.
Note the catch logic:
if( ! ( ( nodeList[i].ChildNodes.Count == 1 )
&& ( nodeList[i].InnerXml == nodeList[i].InnerText ) ) )
That is the important part. What does that do? It filters out the TEXT NODE. That IF condition (if you remove the '!' part) will evaluate TRUE only for a TEXT node.
You will have to use that IF logic in your modified AddNode(). It won't be simple, but it is ceratinly possible with some time and effort, which I cannot spend now. You may have to make the subsequent recursive calls to AddNode in 2 different modes - TEXT node mode and TAG NODE mode. To enable that, you may need to add a parameter to AddNode() method (for teh mode). That should use the fact that there can only be 1 TEXT child node in a XML node. So when you get that, break out. Add the tree node and then call in TAG mode with the newly created tree node as parameter, but the current XML node (not the TEXT node but its parent) as parameter.
I have done such juggleries before, and I am confident that this is just a brain twister.
Koushik Biswas
who else?
|
|
|
|
|
My app has to render a bitmap by scanning a FP measurement array, using a lookup table type process. In the old C++/MFC app that does more or less the same thing, the rendering runs very noticably faster using the same camera and image size, on the same PC.
In C#, I was using the SetPixel command, but this is still as slow as the infamous GDI SetPixel call. Getting a pointer to the bitmap data in an 'unsafe' code block speeds up the process by a factor of about 2.5, but its still slow.
So my questions are these.
1) Will calling an unmanaged C++ DLL function (derived from my old app) execute faster than the C# code? I'm thinking about DLL load overhead and similar.
2) Is it possible to embed C++ code directly in the C# project? My books and VS help seem to hint at this, but I have yet to find an explicit answer.
Thanks for any ideas.
Stewart DIBBS
|
|
|
|
|
sjdevo3gsr wrote: 1) Will calling an unmanaged C++ DLL function (derived from my old app) execute faster than the C# code? I'm thinking about DLL load overhead and similar.
Yes, in this case. Native pointer math is always faster for bitmaps, all other things being equal. If you're doing a lot of memory access and you're sure your not going to overrun any buffers or anything, unmanaged code can be blazingly faster for bitmap work. You may also have easier access to BitBlt and similar functions, which could save you a lot of math.
sjdevo3gsr wrote: 2) Is it possible to embed C++ code directly in the C# project? My books and VS help seem to hint at this, but I have yet to find an explicit answer.
You can put managed C++ classes in your C# project/solution. They're still managed, though. That may not necessarily be bad.
You can also but "unsafe" C# code inline in your C# files. That will allow you to use pointers. It's not going to be as fast as native Win32 C code, but it'll allow pointer math, which could save you time over ordinary C# code in this case.
|
|
|
|
|
From doing experiments with encryption (Blowfish) in both C# and mixed mode C/C++. The native code performs about 4 times faster (12MB/s vs 50MB/s throughput).
Use MC++ to mixed a little managed code with native code. There are ways to embed it, but it's a difficult process (not suggested). Have a look at the link below if you are interested.
http://blogs.msdn.com/junfeng/archive/2006/05/20/599434.aspx[^]
|
|
|
|
|
sjdevo3gsr wrote: Getting a pointer to the bitmap data in an 'unsafe' code block speeds up the process by a factor of about 2.5, but its still slow.
Have you rechecked if you really used the whole potential of this method? My measurements when I once met this problem where that the difference was factor 5 or more...
|
|
|
|
|
That was my reaction too. Using direct access to the memory area should be much faster than that. I would expect a factor ten at least.
---
b { font-weight: normal; }
|
|
|
|
|
hi,
does any one have an idea about how to show the Gird Lines in the whole DataGridView (VS2005) client area even the binded data list is empty?
Thanks a lot!!
Alan
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
|
I currently have the following RegEx expression that requires the input of 5 alpha numeric characters. I am looking for help on how to modify this to allow 5 or 6 alpha characters. Also, How could this be modified to allow from 1 to 6 alpha characters.
[a-zA-Z0-9]{5}$
|
|
|
|
|
How about ^[a-zA-Z]{5,6}$ for 5 or 6 alpha characters and ^[a-zA-Z]{1,6}$ for 1 to 6.
|
|
|
|
|
Thanks.
BTW, where would be a good source to learn more about the RegEx format styles?
Also, What does the ^ and the $ mean in this expression.
Thanks
|
|
|
|
|
^ means start of line, $ means end of line. IF you did not put them, the [a-zA-Z0-9]{5} expression would validate any alphanumeric of 5 characters or more as OK in your input, while ^[a-zA-Z0-9]{5}$ validates alphanumric strings of exactly 5 characters.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
|
Hello,
I whant to get a list of directorys like "E:" ... for all active USB and Floppy devices on my PC.
Thanks for your help,
Martin
|
|
|
|