473,385 Members | 1,907 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,385 software developers and data experts.

Windows Messages!

when I was working with VB 6.0 I used to use API function "SendMessage" to
sending windows messages to forms and controls. Now In VB.net it seems that
VB doean't support API functions as usual and the function was replaced with
"Message" object. in message object there is "lparam" and "wparam" arguments
which are declared as "intptr" datatype. intptr is some kind of pointer. So,
I can not use API viewer constants like "HTCAPTION" in that case.

I don't understand how can I get the correct arguments and how can I use
"message" object instead of "SendMessage" function?

is there somebody who can help?
thanks
Afshin
Nov 20 '05 #1
7 2029
Hi,

You can still use sendmessage. Instead of using as any like in vb6
declare it with the specific type for the argument you are using. You
can declare have more than one version of sendmessage. Here is a quick
example.

Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As
Integer, _
ByVal lParam As Integer) As Integer

Const WM_FONTCHANGE As Integer = &H1D
Const HWND_BROADCAST As Integer = &HFFFF

SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)

Ken
---------------
"Afshin Eftekhar" <af****@negareh.com> wrote in message
news:ui**************@TK2MSFTNGP11.phx.gbl:
when I was working with VB 6.0 I used to use API function "SendMessage" to

sending windows messages to forms and controls. Now In VB.net it seems
that
VB doean't support API functions as usual and the function was replaced
with
"Message" object. in message object there is "lparam" and "wparam"
arguments
which are declared as "intptr" datatype. intptr is some kind of pointer.
So,
I can not use API viewer constants like "HTCAPTION" in that case.

I don't understand how can I get the correct arguments and how can I use

"message" object instead of "SendMessage" function?

is there somebody who can help?
thanks
Afshin


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.1.2 - Release Date: 6/7/2004
Nov 20 '05 #2
* "Afshin Eftekhar" <af****@negareh.com> scripsit:
when I was working with VB 6.0 I used to use API function "SendMessage" to
sending windows messages to forms and controls. Now In VB.net it seems that
VB doean't support API functions as usual and the function was replaced with
"Message" object. in message object there is "lparam" and "wparam" arguments
which are declared as "intptr" datatype. intptr is some kind of pointer. So,
I can not use API viewer constants like "HTCAPTION" in that case.
You can still use API calls in a similar way.
I don't understand how can I get the correct arguments and how can I use
"message" object instead of "SendMessage" function?


Continue using 'SendMessage'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
in using API calls I have another problem, I can not find "hwnd" and
"Handle" property is an object deferent. I am using ".Handle.ToInt32" but it
seems it is not working yet.

SendMessage(Me.lblCaption.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0)

Af,
"Afshin Eftekhar" <af****@negareh.com> wrote in message
news:ui**************@TK2MSFTNGP11.phx.gbl...
when I was working with VB 6.0 I used to use API function "SendMessage" to
sending windows messages to forms and controls. Now In VB.net it seems that VB doean't support API functions as usual and the function was replaced with "Message" object. in message object there is "lparam" and "wparam" arguments which are declared as "intptr" datatype. intptr is some kind of pointer. So, I can not use API viewer constants like "HTCAPTION" in that case.

I don't understand how can I get the correct arguments and how can I use
"message" object instead of "SendMessage" function?

is there somebody who can help?
thanks
Afshin

Nov 20 '05 #4
Hi,

Here I placed a button and label on a form. When you click on the
button it sends a wm_lbuttondown message to the label. You receive the
mousedown event for the label.
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Private Const HTCAPTION As Integer = 2
Private Const WM_LBUTTONDOWN As Integer = &H201

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

SendMessage(Label1.Handle, WM_LBUTTONDOWN, HTCAPTION, 0)

End Sub

Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown

MessageBox.Show("Mouse Down")

End Sub

Ken
----------------------

"Afshin" <af****@negareh.com> wrote in message
news:ee**************@TK2MSFTNGP10.phx.gbl:
in using API calls I have another problem, I can not find "hwnd" and
"Handle" property is an object deferent. I am using ".Handle.ToInt32" but
it
seems it is not working yet.

SendMessage(Me.lblCaption.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION,
0)

Af,
"Afshin Eftekhar" <HYPERLINK
"mailto:af****@negareh.com"af****@negareh.com> wrote in message
news:ui**************@TK2MSFTNGP11.phx.gbl...
when I was working with VB 6.0 I used to use API function "SendMessage"
to
sending windows messages to forms and controls. Now In VB.net it seems


that
VB doean't support API functions as usual and the function was
replaced


with
"Message" object. in message object there is "lparam" and "wparam"


arguments
which are declared as "intptr" datatype. intptr is some kind of
pointer.


So,
I can not use API viewer constants like "HTCAPTION" in that case.

I don't understand how can I get the correct arguments and how can I
use
"message" object instead of "SendMessage" function?

is there somebody who can help?
thanks
Afshin


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.1.2 - Release Date: 6/7/2004
Nov 20 '05 #5
It looks like you're trying to move a borderless form with the aid of a
label.
If you use API then you'll also need to use the ReleaseCapture API before
SendMessage.
You do not need to use InterOp although there's no reason that you can't.
You'll find the non InterOp way here:
http://homepage.ntlworld.com/mdaudi1...nate/misc.html

Just for information.

If you need an IntPtr but only have an Integer then use:
\\\
IntPtr.Op_Explicit(Integer)
///

Handle is an IntPtr

VB6 did not understand pointers and so Handles were declared as Longs.
VB.net does understand pointers and so Handles are declared as IntPtr.

VB6 Long is VB.net Int32
VB6 Integer is VB.net Int16

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi1...nate/home.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 20 '05 #6
thanks

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
Hi,

Here I placed a button and label on a form. When you click on the
button it sends a wm_lbuttondown message to the label. You receive the
mousedown event for the label.
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Private Const HTCAPTION As Integer = 2
Private Const WM_LBUTTONDOWN As Integer = &H201

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

SendMessage(Label1.Handle, WM_LBUTTONDOWN, HTCAPTION, 0)

End Sub

Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown

MessageBox.Show("Mouse Down")

End Sub

Ken
----------------------

"Afshin" <af****@negareh.com> wrote in message
news:ee**************@TK2MSFTNGP10.phx.gbl:
in using API calls I have another problem, I can not find "hwnd" and
"Handle" property is an object deferent. I am using ".Handle.ToInt32" but it
seems it is not working yet.

SendMessage(Me.lblCaption.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION,
0)

Af,
"Afshin Eftekhar" <HYPERLINK
"mailto:af****@negareh.com"af****@negareh.com> wrote in message
news:ui**************@TK2MSFTNGP11.phx.gbl...
when I was working with VB 6.0 I used to use API function "SendMessage" to
sending windows messages to forms and controls. Now In VB.net it seems


that
VB doean't support API functions as usual and the function was
replaced


with
"Message" object. in message object there is "lparam" and "wparam"


arguments
which are declared as "intptr" datatype. intptr is some kind of
pointer.


So,
I can not use API viewer constants like "HTCAPTION" in that case.

I don't understand how can I get the correct arguments and how can I
use
"message" object instead of "SendMessage" function?

is there somebody who can help?
thanks
Afshin


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.1.2 - Release Date: 6/7/2004

Nov 20 '05 #7
thanks the comments and link was so useful.

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:uL*************@TK2MSFTNGP10.phx.gbl...
It looks like you're trying to move a borderless form with the aid of a
label.
If you use API then you'll also need to use the ReleaseCapture API before
SendMessage.
You do not need to use InterOp although there's no reason that you can't.
You'll find the non InterOp way here:
http://homepage.ntlworld.com/mdaudi1...nate/misc.html

Just for information.

If you need an IntPtr but only have an Integer then use:
\\\
IntPtr.Op_Explicit(Integer)
///

Handle is an IntPtr

VB6 did not understand pointers and so Handles were declared as Longs.
VB.net does understand pointers and so Handles are declared as IntPtr.

VB6 Long is VB.net Int32
VB6 Integer is VB.net Int16

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi1...nate/home.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004

Nov 20 '05 #8

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

Similar topics

0
by: piyush | last post by:
Sorry for repeated posting but I couldnt get things right/completely in the first post. I am in the process of deciding the IPC mechanisms to use for communication between 1) An application...
4
by: davidstummer | last post by:
I was wondering if anyone could point me to an example. Currently i have a c++ program which calls and c++ dll (i created both). The dll uses SendMessage to pass messages back to the calling .exe,...
1
by: Artur Kowalski | last post by:
I have a NotifyIcon in my Windows Service project and I am trying to add a ContextMenu to this NotifyIcon or use some of the mouse events. Everything isn't working. I think so base class of the...
0
by: piyush | last post by:
Sorry for repeated posts, I couldnt get things right and complete in the previous post. I am in the process of deciding the IPC mechanisms to use for communication between 1) An application...
14
by: Brian Keating EI9FXB | last post by:
I wonder can anyone reccomment a solution to this problem. Let me explain, I've services running on my system, my application receives diagnostic messages from these services, what i want to do...
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
3
by: Javaman59 | last post by:
I've spent the last 3 years programming VC++, and learnt that Windows programming is all about messages. Now I'm doing C#, and there isn't a windows message to be seen! Now, I don't miss those...
14
by: | last post by:
Hi All, I am little confused here, hope you can help me. While processing WM_POWERBROADCAST (wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy operation(30 sec) before system Suspends or...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.