I get the following VB6 sample and it doesn't work in VB .Net. Can anyone
help to make it work in VB .Net?
Structure POINTAPI
Dim x As Long
Dim y As Long
End Structure
Structure MSG
Dim hwnd As Long
Dim message As Long
Dim wParam As Long
Dim lParam As Long
Dim time As Long
Dim pt As POINTAPI
End Structure
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessag eA"
(ByVal lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal
wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long 3 6454
John,
One and a half year ago and before that this newsgroup was sometimes full of
replies that a 'long' in VB6 is an Integer in VBNet.
Now we see those messages less, probably because most people try to avoid
API's now, however can it not be that?
I hope this helps,
Cor
Hello,
That should work:
' When translating from VB6 you should always consider that Long's are
Integer's now
'Note the Auto modifier. Now it's PeekMessageW on WinNT and PeekMessageA
on Win9x
'lpMsg is ByRef, not ByVal
'Is more convenient to declare hwnd as IntPtr, not Integer
Friend Declare Auto Function PeekMessage Lib "user32.dll " ( _
ByRef lpMsg As MSG, _
ByVal hWnd As IntPtr, _
ByVal wMsgFilterMin As Integer, _
ByVal wMsgFilterMax As Integer, _
ByVal wRemoveMsg As Integer _
) As Boolean 'you can use Integer as return value type, but since it is
BOOL in winuser.h, Boolean type is more appropriate
'StructLayoutAt tribute with Sequential layout kind should be appended to
PInvoke structs
<StructLayout(L ayoutKind.Seque ntial)> Friend Structure MSG
Public hWnd As IntPtr
Public message As Integer
Public wParam As Integer
Public lParam As Integer 'Maybe you will want to put IntPtr
here
Public time As Integer
Public pt As POINT
End Structure
<StructLayout(L ayoutKind.Seque ntial)> Friend Structure POINT
Public x As Integer
Public y As Integer
End Structure
Roman
Hello
if your task is to catch the messages that windows sends to your app in the
message queueyou might be interested the IMessageFilter interface that
..net provides
i can provide you with an example that uses this technique , you can see it
here http://www.freevbcode.com/ShowCode.Asp?ID=5635
this will prefilter all messages send to the form and optionally cancel them
Michel Posseth [MCP]
"Dragon" <no@spam.please > wrote in message
news:em******** *****@TK2MSFTNG P10.phx.gbl... Hello,
That should work:
' When translating from VB6 you should always consider that Long's are Integer's now
'Note the Auto modifier. Now it's PeekMessageW on WinNT and PeekMessageA on Win9x 'lpMsg is ByRef, not ByVal 'Is more convenient to declare hwnd as IntPtr, not Integer Friend Declare Auto Function PeekMessage Lib "user32.dll " ( _ ByRef lpMsg As MSG, _ ByVal hWnd As IntPtr, _ ByVal wMsgFilterMin As Integer, _ ByVal wMsgFilterMax As Integer, _ ByVal wRemoveMsg As Integer _ ) As Boolean 'you can use Integer as return value type, but since it is BOOL in winuser.h, Boolean type is more appropriate
'StructLayoutAt tribute with Sequential layout kind should be appended to PInvoke structs <StructLayout(L ayoutKind.Seque ntial)> Friend Structure MSG Public hWnd As IntPtr Public message As Integer Public wParam As Integer Public lParam As Integer 'Maybe you will want to put IntPtr here Public time As Integer Public pt As POINT End Structure
<StructLayout(L ayoutKind.Seque ntial)> Friend Structure POINT Public x As Integer Public y As Integer End Structure
Roman
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jonas |
last post by:
This works fine in Win XP but does not work at all in Win 98.
Private WithEvents objIExplorer As InternetExplorer
I have to do it like this to get it to work in Win 98
Dim objIExplorer As InternetExplorer But then I cant see when a user exit my
objIExplorer and than an error will show up when I try to open a link in the
IE window that does not exist...
What can I do about this and way does it not work in win 98?
|
by: JR |
last post by:
Hi folks,
How can I implement the following in C#?
while(AppExitFlag == false)
{
if(AppPausedFlag == true)
{
GetMessage();
// Process messages.
|
by: Jeff |
last post by:
What is the .Net Framework equivalent of the Windows API function
PeekMessage? Or any other method that will do the same thing. I simply
need to check to see if there are messages waiting to be processed.
Thanks!
|
by: Jozsef Bekes |
last post by:
Hi All,
I am trying to implement a general threading approach in C#, and I have
faced this problem:
I have the function f_main running in thread th1. I want to invoke two
functions f1 and f2 in th_2. From f_main I want to do two distinct function
calls, the first results only in invoking f1 in the context of th_2, the
second function call would invoke only f2 in the context of th_2. f1 and f2
must run in the same thread context.
My...
|
by: Anoop |
last post by:
Hi,
I am new to this newsgroup and need help in the following questions.
1. I am workin' on a GUI application. Does C# provides Layout Managers the
way Java does to design GUI? I know that it can be done using the designer
but I intentionally don't want to use that. The one reason is that you
cannot change the code generated by the designer. The other could be that
you have more free hand and control to design your GUI.
2....
| |
by: Cuthbert |
last post by:
After compiling the source code with gcc v.4.1.1, I got a warning
message:
"/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the
'gets' function is dangerous and should not be used."
Could anybody tell me why gets() function is dangerous??
Thank you very much.
Cuthbert
|
by: Bruce |
last post by:
I worte an OCX with events. In order to allow the dialog box (or
whatever) to be updated by the event, I had to add a messagepump to the
event.
void MessagePump()
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT) {
|
by: webEater |
last post by:
I have a problem, it's not browser specific, and I don't get a
solution. I have an (X)HTML document, I show you a part of it:
....
<!--<div class="pad">-->
<div id="eventImages"><img src="" id="eventImage0"
class="eventImage"><img src="" id="eventImage1"
class="eventImage"></div>
|
by: SeeSharp Bint |
last post by:
Hi
I'm using some of the definitions I found pinvoke.net for PostMessage and
PeekMessage as follows
public static extern bool PostMessage(
HandleRef hWnd,// handle to destination window
UInt32 Msg, // message
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |