|
|
And I appreciate the comment. It's important to stress good practice on the forums.
|
|
|
|
|
1.1 has Double.TryParse(). If that's not good enough, this is the fastest way to determine if a string contains an integer, and it can easily be adapted to work for any other type of numeric:
<br />
bool TryParseInt(string value) <br />
{<br />
for (int i = 0; i < value.Length; i++) <br />
{<br />
if (i == 0 && value[i] == '-')<br />
continue;<br />
if (!Char.IsNumber(value[i]))<br />
return false;<br />
}<br />
return value.Length < Int32.MaxValue.ToString().Length;<br />
}<br />
|
|
|
|
|
Hello!
I would like to know how to retrieve a text from a selected item in a ListView.
I have "translated" a code that does it, from old VB to C#, but I think my problem is how to reference my structure LV_ITEM to the SendMessage.
some pieces of my Code:
[DllImport("user32.dll")]
public static extern int SendMessageA(IntPtr hwnd, int Msg, int wParam, LV_ITEM LV);
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, int Msg, int wParam, int lParam);
private const int LVM_FIRST = 0x1000;
private const int LVM_GETITEMSTATE = (LVM_FIRST + 44);
private const int LVM_GETITEMTEXT = (LVM_FIRST + 45);
private const int LVIS_STATEIMAGEMASK = 0xF000;
public struct LV_ITEM
{
int mask;
int iItem;
int iSubItem;
int state;
int stateMask;
string pszText;
int cchTextMax;
int iImage;
int lParam;
int iIndent;
}
private void button1_Click(object sender, EventArgs e)
{
int r;
LV_ITEM LV = new LV_ITEM();
string b;
b = "The following ListView items are checked: " + "\r\n";
for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
r = SendMessage(listView1.Handle, LVM_GETITEMSTATE, i, LVIS_STATEIMAGEMASK);
if (r == 8192) // r returns 8192 if the current item is selected
{
LV.cchTextMax = MAX_PATH;
LV.pszText = " ";
SendMessageA(listView1.Handle, LVM_GETITEMTEXT, i, LV); //here appears the error
b = b + LV.pszText + "\r\n";
MessageBox.Show(LV.pszText);
}
}
MessageBox.Show(b);
}
I have read something about in, out, I don´t remember exactly if it has something to do with these.
Thanks!
|
|
|
|
|
I have read about "Cross-Process Data Extraction" but it doesn´t make sense to me in C# =/
here´s the link in VB: http://www.xtremevbtalk.com/t114019.html[^]
he shows how to retrieve texts from buttons, list view thru memory allocation, but I got no idea in c#.
=/
|
|
|
|
|
Is this what you're looking for?
string strText;
if (myListView.SelectedItems.Count > 0)
strText = myListView.SelectedItems[0].Text;
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I need help trying to figure out how to modify an existing password in a Microsoft Access Document from one and change it to a completely different password all together all in C#. All I know on the topic is how to specify the password for an MS Access document to gain access to it, but I don't know how to change it. Thanks!
-Nebuchadnezzar
|
|
|
|
|
Hello all,
I've written a .Net 2.0 Windows application in C# which allows a baby to bash the keyboard without affecting other applications. The keyboard class might be useful as an article here, so I'd like someone with more experience of C# to have a look at how the code is organised and maybe I'll learn something in the process!
Thanks!
|
|
|
|
|
Write the article and someone will probably pick it appart.
|
|
|
|
|
dan neely wrote: Write the article and someone will probably pick it appart
That's true, though mostly, they seem to post replies saying they can't get the code to work!
|
|
|
|
|
I know for a fact Marc Clifton, and I are looking for something like that for cats
An article, even short would be nice, thanks.
|
|
|
|
|
Yes, having only known cats before having a baby, I can see how similar they are. The only difference is that the baby will hopefully grow out of it!
I think I'll definitely write an article. But I'd still like someone to have a quick look at how the code is actually organised. I'm mostly self-taught and having learned programming with procedural variants of Basic, I'm not sure I use objects the way I should in a good OO language like C#.
|
|
|
|
|
Emma Burrows wrote: I've written a .Net 2.0 Windows application in C# which allows a baby to bash the keyboard without affecting other applications
I've now completed the code and written an article on enabling low-level keyboard hooks using the Windows API in C#. As the saying goes, "publish and be damned", but it would still be nice if someone could have a look at it, so I'd be grateful for any volunteers!
|
|
|
|
|
Hi everyone.
I'm looking for a good way to let one process know that another process has made changes in
a shared database, so that the first process can update its view, if it is currently open.
After alot of searching on inet I've come to the conclusion that PostMessage from the Win32 api might
be the solution, but I haven't managed to find a guide as how to do it.
I think I can manage the PostMessage part, but how do I retrieve it in target process?
Any help or links to tutorials would be greatly appreciated.
-Larantz-
|
|
|
|
|
Override your target process form's WndProc() to handle the message.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
[Solved it]
Hi Ravi.
Thx for reply.
I tried overriding the WndProc() and just added a debugger to
see if it fires when I run the 2nd process with PostMessage(..).
WndProc() process compiles, but when I fire it up, I get an error
along the lines of "Error creating windows referance". (I got it in norwegian...)
How can I preserve / inherit original WndProc() and just extend it with
the code I want to fire?
-Larantz-
-- modified at 9:10 Friday 2nd June, 2006
|
|
|
|
|
Hi again ravi.
I was hoping you might explain to me why the messages I send from
"senderclass" isn't picked up by the "recieverclass".
All I can think of is that the pointer to the process is wrong.
But I know that Process.GetprocessByName("processname") finds the right process.
Here's the code for the PostMessage routines:
[DllImport("User32.Dll")]
public static extern long PostMessage(IntPtr hWnd, long wMsg, long wParam, long lParam);
public const long WM_PAINT = 0x0F;
public const long WM_DISPLAYCHANGE = 0x7E;
System.Diagnostics.Process[] procs = Process.GetProcessesByName("processname_here");
foreach(System.Diagnostics.Process proc in procs)
{
Helpers.PostMessage(proc.Handle, Helpers.WM_PAINT, 0, 0);
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_PAINT)
{
MessageBox.Show("Got message");
}
}
Thanks in advance,
-Larantz-
|
|
|
|
|
i'm not sure whether somebody is still interested in this question, but the mistake is the using of proc.Handle. This is a process handle, but for sending messages you need a window handle. So take proc.MainWindowHandle.
|
|
|
|
|
Hi... I have added programaticly to a DataSet two DataTables by the DataSet.Tables.Add() Method.
When I use the DataSet.GetXml() method I get just a line "<New DataSet />".
Why does that happen and how can I have the DataSet with it's tables?
|
|
|
|
|
Hi
Have you tried adding a new DataRow to one of the tables and then calling DataSet.GetXml()? I know that the XML serialiser doesn't generate XML for "empty" columns (where all the values are System.DBNull), so perhaps it's the same for "empty" tables?
Cheers
Andy
|
|
|
|
|
But then I would have 2 tables with a row in each that I don't need, and it will make my project go nuts, it's just an idiotic thing to do...
Can't I do something else instend of inserting a new row with Data I don't need?
|
|
|
|
|
It might be idiotic(?) but it works. If you don't like the way the GetXml call goes about it's business, write your own! Or you could simply build the XML; if it's just the case of a dataset with a couple of empty tables then why not just string-build it? You get a string back from GetXml anyway...
|
|
|
|
|
You have to put data in the tables.
|
|
|
|
|
But then I would have 2 tables with a row in each that I don't need, and it will make my project go nuts, it's just an idiotic thing to do...
Can't I do something else instend of inserting a new row with Data I don't need?
|
|
|
|
|
The only way you're going to see the structure of an empty dataset is to view the schema:
ds.WriteXml(aStream, XmlWriteMode.WriteSchema);
-or-
string s = ds.GetXmlSchema(); Last modified: Friday, June 02, 2006 8:47:59 AM --
|
|
|
|