473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Sending Mesages

Hi!
I tried to send a simple message to a running window and it doesn't work.
Why???
When I used EndTask function it worked so the handle to a window is right...
Mayby the number of message is wrong? From where should I get it?
Help!

That's the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub
Nov 20 '05 #1
10 1224
Seems is not a NET project...
For NET I heard something like remoting.. I dont have details, but you can
search MSDN for it

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
Hi!
I tried to send a simple message to a running window and it doesn't work.
Why???
When I used EndTask function it worked so the handle to a window is right... Mayby the number of message is wrong? From where should I get it?
Help!

That's the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub

Nov 20 '05 #2
"zurg" <zu**@wp.pl> schrieb
Hi!
I tried to send a simple message to a running window and it doesn't
work. Why???
When I used EndTask function it worked so the handle to a window is
right... Mayby the number of message is wrong? From where should I
get it? Help!

That's the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As
Long
Public Declare Function PostMessage Lib "user32" Alias
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam
As Long, ByVal lParam As Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub


Either you are not using VB.NET (this is a VB.NET (dotnet) group) and you
should please turn to one of the microsoft.public.vb.* groups, or you are
using VB.NET but the declarations are wrong because Long must be replaced by
Integer (and hwnd should be replaced by IntPtr).
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #3
Right, I've checked it...
But I just want to know why SendMessage function doesn't work in my program.
In fackt I want to use it also to close a window and sending WM_Close
message is the easiest way.
Anybody?

Użytkownik "Crirus" <Cr****@datagroup.ro> napisał w wiadomości
news:eB**************@TK2MSFTNGP10.phx.gbl...
Seems is not a NET project...
For NET I heard something like remoting.. I dont have details, but you can
search MSDN for it

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
Hi!
I tried to send a simple message to a running window and it doesn't work. Why???
When I used EndTask function it worked so the handle to a window is

right...
Mayby the number of message is wrong? From where should I get it?
Help!

That's the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA"

(ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub


Nov 20 '05 #4
Be awared that integer in VB.NET means long in C++ so use it acordingly

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...
Right, I've checked it...
But I just want to know why SendMessage function doesn't work in my program. In fackt I want to use it also to close a window and sending WM_Close
message is the easiest way.
Anybody?

Użytkownik "Crirus" <Cr****@datagroup.ro> napisał w wiadomości
news:eB**************@TK2MSFTNGP10.phx.gbl...
Seems is not a NET project...
For NET I heard something like remoting.. I dont have details, but you can
search MSDN for it

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
Hi!
I tried to send a simple message to a running window and it doesn't

work. Why???
When I used EndTask function it worked so the handle to a window is

right...
Mayby the number of message is wrong? From where should I get it?
Help!

That's the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA"

(ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub



Nov 20 '05 #5
I just moved from writing programs in VB 6 to VB.Net so that's I have so
problems...
I just finded a code in MSDN and copied it into my program. It wasn't
woriking so I asked...
I seems that I have to study some basics about VB.Net

Anyway, now everything is working.

Thank you Armin Zingler
Uzytkownik "Armin Zingler" <az*******@freenet.de> napisal w wiadomosci
news:%2***************@tk2msftngp13.phx.gbl...
"zurg" <zu**@wp.pl> schrieb
Hi!
I tried to send a simple message to a running window and it doesn't
work. Why???
When I used EndTask function it worked so the handle to a window is
right... Mayby the number of message is wrong? From where should I
get it? Help!

That's the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As
Long
Public Declare Function PostMessage Lib "user32" Alias
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam
As Long, ByVal lParam As Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub
Either you are not using VB.NET (this is a VB.NET (dotnet) group) and you
should please turn to one of the microsoft.public.vb.* groups, or you are
using VB.NET but the declarations are wrong because Long must be replaced

by Integer (and hwnd should be replaced by IntPtr).
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #6
Thank you, I didn't know... (to many programs written in VB 6 ;)))
And once again - do you have any idea where can I find costant system values
like PM_NOREMOVE or WM_CLOSE ???
I just can't find it...

Użytkownik "Crirus" <Cr****@datagroup.ro> napisał w wiadomości
news:eE*************@TK2MSFTNGP10.phx.gbl...
Be awared that integer in VB.NET means long in C++ so use it acordingly

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...
Right, I've checked it...
But I just want to know why SendMessage function doesn't work in my

program.
In fackt I want to use it also to close a window and sending WM_Close
message is the easiest way.
Anybody?

Użytkownik "Crirus" <Cr****@datagroup.ro> napisał w wiadomości
news:eB**************@TK2MSFTNGP10.phx.gbl...
Seems is not a NET project...
For NET I heard something like remoting.. I dont have details, but you can search MSDN for it

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
> Hi!
> I tried to send a simple message to a running window and it doesn't

work.
> Why???
> When I used EndTask function it worked so the handle to a window is
right...
> Mayby the number of message is wrong? From where should I get it?
> Help!
>
> That's the code
>
> Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"

(ByVal
> lpClassName As String, ByVal lpWindowName As String) As Long
> Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal
> hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As > Long) As Long
>
> Public Sub Main()
> Dim windowadress As Long
> Dim messagenumber As Long
> Const WM_CLOSE = &H10
>
> messagenumber = WM_CLOSE
> windowadress = FindWindow(vbNullString, "Calculator")
> If PostMessage(windowadress, messagenumber, 0, 0) Then
> End If
> End Sub
>
>



Nov 20 '05 #7
"zurg" <zu**@wp.pl> schrieb
Right, I've checked it...
But I just want to know why SendMessage function doesn't work in my
program. In fackt I want to use it also to close a window and sending
WM_Close message is the easiest way.
Anybody?


What does FindWindow return? If it returns zero, the call failed.

I tried your code in VB6 and it worked without a problem.
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #8
Cor
Hi Zurg,

You said you are a beginner in .Net

There are so many functions in the Net that did not exist in vb6 or C++,
that I would first look if there is not a .Net method that can do things for
you 1000 times easier that the route you are now taken.

I did do this also like you do, now I hardly need this.

Just a thougth,

Cor
Nov 20 '05 #9
Well, hane no idea yet, I guess you can still use the VB 6 declaring way

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:uT**************@TK2MSFTNGP11.phx.gbl...
Thank you, I didn't know... (to many programs written in VB 6 ;)))
And once again - do you have any idea where can I find costant system values like PM_NOREMOVE or WM_CLOSE ???
I just can't find it...

Użytkownik "Crirus" <Cr****@datagroup.ro> napisał w wiadomości
news:eE*************@TK2MSFTNGP10.phx.gbl...
Be awared that integer in VB.NET means long in C++ so use it acordingly

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...
Right, I've checked it...
But I just want to know why SendMessage function doesn't work in my

program.
In fackt I want to use it also to close a window and sending WM_Close
message is the easiest way.
Anybody?

Użytkownik "Crirus" <Cr****@datagroup.ro> napisał w wiadomości
news:eB**************@TK2MSFTNGP10.phx.gbl...
> Seems is not a NET project...
> For NET I heard something like remoting.. I dont have details, but you
can
> search MSDN for it
>
> --
> Ceers,
> Crirus
>
> ------------------------------
> If work were a good thing, the boss would take it all from you
>
> ------------------------------
>
> "zurg" <zu**@wp.pl> wrote in message
> news:O%***************@TK2MSFTNGP11.phx.gbl...
> > Hi!
> > I tried to send a simple message to a running window and it
doesn't work.
> > Why???
> > When I used EndTask function it worked so the handle to a window is > right...
> > Mayby the number of message is wrong? From where should I get it?
> > Help!
> >
> > That's the code
> >
> > Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
> > lpClassName As String, ByVal lpWindowName As String) As Long
> > Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" > (ByVal
> > hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal

lParam As
> > Long) As Long
> >
> > Public Sub Main()
> > Dim windowadress As Long
> > Dim messagenumber As Long
> > Const WM_CLOSE = &H10
> >
> > messagenumber = WM_CLOSE
> > windowadress = FindWindow(vbNullString, "Calculator")
> > If PostMessage(windowadress, messagenumber, 0, 0) Then
> > End If
> > End Sub
> >
> >
>
>



Nov 20 '05 #10
You're right - I'm a biginner in VB.Net and I really should start with
basic, use the normal .net functions and so on...
Trust me I usually trying to do so but now I'm ending project, the time is
against me and that's one of the last problems I have to face...
Propobly there're easier ways to do many things I've already written but now
I at the end and need to make everything works...
Then I should have some time to do some "upgrades" in my code...

Thanks for advice,
zurg

Użytkownik "Cor" <no*@non.com> napisał w wiadomości
news:Ol**************@TK2MSFTNGP09.phx.gbl...
Hi Zurg,

You said you are a beginner in .Net

There are so many functions in the Net that did not exist in vb6 or C++,
that I would first look if there is not a .Net method that can do things for you 1000 times easier that the route you are now taken.

I did do this also like you do, now I hardly need this.

Just a thougth,

Cor

Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the...
0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
5
by: Jason | last post by:
I've a c# app that I execute on a remote machine, which works as I expect it to, but when that apps throws an exception on the remote machine how do I know what's going on, since it's a remote...
0
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
4
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I use: Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) And its...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.