|
how do static functions affect the performence and memory of our program ?
|
|
|
|
|
If the function doesn't use any data from the instance of the class, it should be static, so that you don't have to create an object just to call the function.
Declaring a function as static also supplies the information that the function is self-contained and doesn't need any data from an object.
---
b { font-weight: normal; }
|
|
|
|
|
Hi together!
I'm currently searching a way to get a Process by it's window title, not by it's classname...
in following code, the GameName would be, e.g. "sol" (means Processname of game "Solitär")
<br />
static ProcessMemoryReaderLib.ProcessMemoryReader pReader;<br />
static Process[] myProcesses;<br />
<br />
public static void InitRWCode(string GameName)<br />
{<br />
pReader = new ProcessMemoryReaderLib.ProcessMemoryReader();<br />
myProcesses = Process.GetProcessesByName(GameName);<br />
}<br />
that's the code i'm currently using...
but i'm looking for something like that:
in this case GameName would be "Solitär" instead of "sol"
<br />
static ProcessMemoryReaderLib.ProcessMemoryReader pReader;<br />
static Process[] myProcesses;<br />
<br />
public static void InitRWCode(string GameName)<br />
{<br />
pReader = new ProcessMemoryReaderLib.ProcessMemoryReader();<br />
myProcesses = Process.GetProcessesByWindowTitle(GameName);<br />
}<br />
Has someone an idea
I've already tried the GetWindowThreadProcessId together with the FindWindow, but it returns the wrong ID...
Thx for any suggestions!!!
Greets Ralf
FreewareFire
|
|
|
|
|
|
Hi! Thanks for your reply!
Yes of course - and that's the problem. In my case it's too slow - i'm working with hotkeys. And every time a hotkey is pressed, it needs to get the excact handle of the window. So every time GetProcesses is called. And that's very slow. So i have to get the window handle directly by it's window name - that's a lot faster!!! than GetProcesses!!!. So if anyone have a suggestion... Please let me know...
Thx!
FreewareFire
|
|
|
|
|
Hi everyone!!
Is anyone know how th change the background of a toolbar ?
Thank you?
|
|
|
|
|
Hello,
I am new here as far as posting goes.
Maybe someone can see what I'm Missing.
I keep getting build errors see the tut here.
I'm new to this Smartphone Development and vs2005.
http://www.microsoft.com/seminar/shared/asp/view.asp?url=/seminar/en/smartphone_apps_medua/manifest.xml[]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
namespace TOYOURSPACE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void menuItem1_Click(object sender, EventArgs e)
{
Microsoft.WindowsMobile.Forms.CameraCaptureDialog cameraDialog = new Microsoft.WindowsMobile.Forms.CameraCaptureDialog();
cameraDialog.Owner = this;
cameraDialog.Title = "Take a Picture";
if ((cameraDialog.ShowDialog() != DialogResult.OK)(cameraDialog.FileName == ""))
{
return;
}
string account = "ActiveSync";
string to = "";
string subject = "";
string body = "";
string[] attachments = new string[] { cameraDialog.filename };
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.DisplayComposeForm(account);
label1.Text = "Image sent sucessful!";
PictureBox1.image = new Bitmap(cameraDialog.filename);
}
private void linkLabel1_Click(object sender, EventArgs e)
{
Process.Start(" http://www.microsoft.com ")
}
}
}
-- modified at 17:10 Sunday 27th November, 2005
|
|
|
|
|
Hi, I'm using SgmlReader to obtain the XML data from a web page and I have an IndexOutOfRangeException exception when I execute the Load method from the XmlDocument class.
I had no problems before but now it started to happen.
Here is part of the code:
string path = @"C:\....";
StreamWriter w = new StreamWriter(path+"file.txt",false,System.Text.Encoding.Unicode);
SgmlReader r = new SgmlReader();
r.DocType = "HTML";
r.Href = "http://www.webpage.com/page.htm";
XmlDocument xml = new XmlDocument();
xml.Load(r); <-- Here the exception is threw.
|
|
|
|
|
ok, i'm almost done with what i am trying to do. 1 LAST question. heh. ive searched the articles this time, and google. i've found 1 thing on google, but i cant understand it. so heres the question: how can i send a mouse click (to something outside my application, such as windows or another program)?
thanks in advance,
sam kline
<a href="http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450">YES</a>
-- modified at 14:15 Sunday 27th November, 2005
|
|
|
|
|
Sam,
You might want to read "Test Run: Low-Level UI Test Automation," specifically the section "Manipulating the App and Checking App State." by James McCaffrey.
In that section, he has the following code:
public void ClickOn()
{
uint WM_LBUTTONDOWN = 0x0201;
uint WM_LBUTTONUP = 0x0202;
PostMessage( this.ptrToWindow, WM_LBUTTONDOWN, 0, 0 );
PostMessage( this.ptrToWindow, WM_LBUTTONUP, 0, 0 );
} where this.ptrToWindow is an IntPtr that stores the target window's handle.
He then explains about the two last parameters to the PostMessage call.
When processing the WM_LBUTTONDOWN and WM_LBUTTONUP messages, the wParam value indicates whether various key-state masks like MK_SHIFT are down. The lParam value represents the x and y coordinates of the cursor relative to the upper-left corner of the window. Here I pass 0,0 to WM_LBUTTONDOWN and WM_LBUTTONUP in order to simulate mouse clicks on the upper-left corner of the target window without any keys pressed. Hope that helps.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
hmm. is there a way i can just click at the point where the mouse is located (cursor.position)?
thanks for the reply,
sam kline
<a href="http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450">YES</a>
-- modified at 18:43 Sunday 27th November, 2005
|
|
|
|
|
Unfortunately, the only way that I know how to send those mouse-click messages is through the Win32 API methods SendMessage and PostMessage. I mean, to click where the mouse is, you could use the EnumWindows Win32 API call, find which window the mouse is under, do some quick math to get the position relative to the window's (0,0) coordinate, and then send the PostMessage/SendMessage to that relative coordinate.
In .NET, I just don't know any other way because of the security involved. Sorry. Hopefully someone else will give you a more satisfying answer. <grimace>
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
How to create manually DataSet with 3 columns and 3 rows and then make gridView from it?
I have such a code:
DataSet myDataSet = new DataSet();<br />
myDataSet.Tables.Add();<br />
myDataSet.Tables[0].Columns.Add();<br />
myDataSet.Tables[0].Columns.Add();<br />
myDataSet.Tables[0].Columns.Add();<br />
myDataSet.Tables[0].Rows.Add(true,"aaa", "bbb");<br />
myDataSet.Tables[0].Rows.Add(true, "aaa", "Bbb");<br />
dataGrid.DataSource = myDataSet;
Where is myDataSet is DataSet, and dataGrid is gridview with 3 columns, first is checkbox column and other two is text columns.
But this code dont work.
|
|
|
|
|
How about the following code?
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add();
myDataSet.Tables[ 0 ].Columns.Add();
myDataSet.Tables[ 0 ].Columns.Add();
myDataSet.Tables[ 0 ].Columns.Add();
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true,"aaa", "bbb" } );
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true, "aaa", "Bbb" } );
dataGrid.DataSource = myDataSet.Tables[ 0 ];
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
thank you. It helped.
But I still have one little problem. How to make the first column with checkboxes?
I've tried first to make gridView with three columns. and the first was checkboxes. But when I make:
DataSet myDataSet = new DataSet();<br />
myDataSet.Tables.Add();<br />
myDataSet.Tables[ 0 ].Columns.Add();<br />
myDataSet.Tables[ 0 ].Columns.Add();<br />
myDataSet.Tables[ 0 ].Columns.Add();<br />
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true,"aaa", "bbb" } );<br />
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true, "aaa", "Bbb" } );<br />
dataGrid.DataSource = myDataSet.Tables[ 0 ];
Thats adds 3 more columns to my gridView.
-- modified at 12:10 Sunday 27th November, 2005
And i want to make in gridView 3 columns total. And first checkboxes.
|
|
|
|
|
How about this?
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add();
myDataSet.Tables[ 0 ].Columns.Add( "My Bool", typeof( bool ) );
myDataSet.Tables[ 0 ].Columns.Add( "My String 1", typeof( string ) );
myDataSet.Tables[ 0 ].Columns.Add( "My String 2", typeof( string ) );
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true,"aaa", "bbb" } );
myDataSet.Tables[ 0 ].Rows.Add( new object[] { true, "aaa", "Bbb" } );
dataGrid.DataSource = myDataSet.Tables[ 0 ];
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
super! thank you very much!
|
|
|
|
|
No problem, 'gator. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
how can i call a function, run code, etc. when the mouse moves? i looked at on mousemove, but it is only activated when the mouse is over the control.
thanks in advance,
sam kline
http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450
YES
|
|
|
|
|
I don't know if such thing is possible (I never neaded to do something like this). But you can check for mouse movement with the position of the curssor.
Either do a procedure that checks if the current mouse position differs from the previous (and act in consequence) and run it at a timer elaped interval, or try running it on a separate thread that may communicate with your main thread on mouse move (determined by the initial pocedure).
Momentaly I have no time avaliable in order to give you a code example...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
|
i looked at that article, and used the class. it works perfectly. thanks for the link.
sam kline
http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450
YES
|
|
|
|
|
Sam,
Glad the suggestion worked out for you. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
If you target windows platforms only, it's very easy to use DirectInput.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have 1 form, 1 class and 1 table(from access).
I loaded the info from the table into the class and then added it all to an array list(on the form).
Now on the form i have a list box, with city names(which comes from the dataTable), nd in the dataTable i have some numbers next to each city name.
My question is how can i access these numbers that are stored in my arrayList to put into a formula(or to display when i select a city from the list).
If some can help me i would really appreciate it - this is really important.
|
|
|
|