Hi All,
I get this error operator == cannot be applied to operands of type 'System.IntPtr' and 'int'
firstly I had this code
private void SNGPH_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.ControlKey)
return;
POINT curpos = new POINT();
User32.GetCursorPos(ref curpos);
IntPtr handle = User32.WindowFromPoint(curpos);
handle = User32.GetAncestor(handle, 2);
for (int i = 0; i < listBoxTables.Items.Count; i++)
if (((PokerTable)listBoxTables.Items[i]).HWND == handle)
{
listBoxTables.SelectedIndex = i;
setFormsAndDoCalc(true, null);
e.Handled = true;
return;
}
pictureBox1.Image = SystemIcons.Error.ToBitmap();
labelWarning.Text = "Couldn't find selected window from pokertables";
}
which is fine when you click control key over a table it then finds the table in the list (listboxtable) and executes it. Now I tried to make this into every foreground window to do the same thing and show handle in text bar.
Heres the code I get an error with
private void GetActiveWindow()
{
const int nChars = 256;
int handle = 0;
StringBuilder Buff = new StringBuilder(nChars);
handle = GetForegroundWindow();
if (GetWindowText(handle, Buff, nChars) > 0)
{
this.textBox1.Text = handle.ToString();
for (int i = 0; i < listBoxTables.Items.Count; i++)
if (((PokerTable)listBoxTables.Items[i]).HWND == handle)
{
listBoxTables.SelectedIndex = i;
setFormsAndDoCalc(true, null);
return;
}
}
}
Can anyone please help, not sure whats wrong the handle im sure is an int in both cases?
Thanks in advance!!