Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
AnswerRe: Send Text Message to Phone Pin
Ravi Bhavnani7-Feb-06 11:52
professionalRavi Bhavnani7-Feb-06 11:52 
Questionhow to set textbox1.text in one form from other forms ? Pin
hdv2127-Feb-06 11:24
hdv2127-Feb-06 11:24 
AnswerRe: how to set textbox1.text in one form from other forms ? Pin
DigitalKing7-Feb-06 15:28
DigitalKing7-Feb-06 15:28 
GeneralRe: how to set textbox1.text in one form from other forms ? Pin
hdv2127-Feb-06 17:22
hdv2127-Feb-06 17:22 
GeneralRe: how to set textbox1.text in one form from other forms ? Pin
DigitalKing7-Feb-06 20:14
DigitalKing7-Feb-06 20:14 
Questionupdate problem Pin
Ado_bado7-Feb-06 11:22
Ado_bado7-Feb-06 11:22 
QuestionDatagrid Context Menu Pin
OrbeaOrca7-Feb-06 10:11
OrbeaOrca7-Feb-06 10:11 
QuestionSendMessage problems Pin
sowhatman007-Feb-06 9:21
sowhatman007-Feb-06 9:21 
Hello everyone, Ive been trying to get my program to function for quite some time now and havent been able to get any clear answers. its a simple practice app basically, when I click a button on my form, I want the app to press a button in another form. that simple. seemed like it at least, but when I try to use this it doesnt work.
int a = Win32.FindWindow(txtClassName2.Text, Title.Text);
int b = Win32.SendMessage(a, Win32.BM_CLICK, 0, 0);

when I replace Win32 with Win32API, then theres a problem with SendMessage not being part of the current selection, also there is a problem with FindWindow with Win32API. FindWindowEx doesnt work either. When I use Win32, they work work but BM_CLICK doesnt work. its like I have to choose which problem to go with, I havent been able to figure this out. this is actually the whole code in the form.cs file:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace test
{
public partial class Form1 : Form
{
[DllImport("user32", EntryPoint = "GetNextWindow")]
public static extern int
GetWindow(IntPtr hwnd, int wFlag);
public Form1()
{
InitializeComponent();
}
public class Win32
{
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
public const int BM_CLICK = 0xF5;
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClass, string lpWindow);

[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
}
private void button1_Click(object sender, EventArgs e)
{



int hWnd;
//Thread.Sleep(5000);
if ((txtWindowCaption.Text == "") && (txtClassName.Text == ""))
{
hWnd = Win32API.FindWindowAny(0, 0);
}
else if ((txtWindowCaption.Text == "") && (txtClassName.Text != ""))
{
hWnd = Win32API.FindWindowNullWindowCaption(txtClassName.Text, 0);

}
else if ((txtWindowCaption.Text != "") && (txtClassName.Text == ""))
{
hWnd = Win32API.FindWindowNullClassName(0, txtWindowCaption.Text);
}
else
{
hWnd = Win32API.FindWindow(txtClassName.Text, txtWindowCaption.Text);
}
if (hWnd == 0)
{
MessageBox.Show("Specified window is not running.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
// Set the window foreground.
Win32API.SetForegroundWindow(hWnd);
// if window is minimized, simply restore, otherwise show it. Notice the
// declaration of Win32API.IsIconic defines the return value bool
// allowing .NET to marshall the integer value to a bool.

if (Win32API.IsIconic(hWnd))
{
Win32API.ShowWindow(hWnd, Win32API.SW_RESTORE);
}
else
{
Win32API.ShowWindow(hWnd, Win32API.SW_SHOW);
}
int a = Win32.FindWindow(txtClassName2.Text, Title.Text);
int b = Win32.SendMessage(a, Win32.BM_CLICK, 0, 0);
}
}
}
}
anyone got any advice? thanks
AnswerRe: SendMessage problems Pin
sowhatman007-Feb-06 23:54
sowhatman007-Feb-06 23:54 
QuestionCan't get "TreeNodeCollection.Contains" to validate node Pin
JstDaNuGuy7-Feb-06 9:15
JstDaNuGuy7-Feb-06 9:15 
AnswerCan a guy get some help over here??? Pin
JstDaNuGuy8-Feb-06 4:41
JstDaNuGuy8-Feb-06 4:41 
QuestionGroupbox border color Pin
VPMahank7-Feb-06 8:53
VPMahank7-Feb-06 8:53 
AnswerRe: Groupbox border color Pin
DigitalKing7-Feb-06 15:32
DigitalKing7-Feb-06 15:32 
QuestionCustom Object that has 'nested' collections Pin
kloepper7-Feb-06 8:52
kloepper7-Feb-06 8:52 
AnswerRe: Custom Object that has 'nested' collections Pin
Guffa7-Feb-06 9:16
Guffa7-Feb-06 9:16 
GeneralRe: Custom Object that has 'nested' collections Pin
kloepper7-Feb-06 9:46
kloepper7-Feb-06 9:46 
AnswerRe: Custom Object that has 'nested' collections Pin
Guffa7-Feb-06 10:56
Guffa7-Feb-06 10:56 
QuestionInclude files Pin
dvsr7-Feb-06 8:51
dvsr7-Feb-06 8:51 
AnswerRe: Include files Pin
Guffa7-Feb-06 9:21
Guffa7-Feb-06 9:21 
GeneralRe: Include files Pin
dvsr8-Feb-06 4:43
dvsr8-Feb-06 4:43 
AnswerRe: Include files Pin
Guffa8-Feb-06 6:07
Guffa8-Feb-06 6:07 
QuestionHRESULT E_FAIL Error? Pin
Mertli Ozgur Nevres7-Feb-06 6:36
Mertli Ozgur Nevres7-Feb-06 6:36 
AnswerRe: HRESULT E_FAIL Error? Pin
Dave Kreskowiak7-Feb-06 7:01
mveDave Kreskowiak7-Feb-06 7:01 
GeneralRe: HRESULT E_FAIL Error? Pin
Mertli Ozgur Nevres8-Feb-06 1:05
Mertli Ozgur Nevres8-Feb-06 1:05 
GeneralRe: HRESULT E_FAIL Error? Pin
Dave Kreskowiak8-Feb-06 2:01
mveDave Kreskowiak8-Feb-06 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.