Hi All,
I get this error operator == cannot be applied to operands of type 'System.IntPtr' and 'int'
firstly I had this code
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.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"; }
Heres the code I get an error with
also used this to gain top window info (the text box displays each window handle fine btw)Code: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?Code:[ DllImport("user32.dll") ] static extern int GetForegroundWindow(); [ DllImport("user32.dll") ] static extern int GetWindowText(int hWnd, StringBuilder text, int count);
Thanks in advance!!



LinkBack URL
About LinkBacks



