473,471 Members | 4,095 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Project converted from VB6 to VB.Net gets subclassed WndProc -- why?

Greetings!

I have a VB.Net 2003 project that was originally written in VB6, converted
to VB.Net 2002, and then converted to VB.Net 2003. I am trying to handle a
form's Resize event. I put a breakpoint in it and saw that that event got
fired four times before the form's Load event got fired! I then saw that I
have the following routine in the form's code:

Private Const WM_SHOWWINDOW = &H18
Private m_loaded As Boolean
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_SHOWWINDOW Then
If Not m_loaded Then
MyBase.OnLoad(New System.EventArgs())
End If
End If
MyBase.WndProc(m)
End Sub

And my form's Load event sets the m_loaded flag to true.

I never put that routine in. I presume it was added at some point in one of
those conversions. Why is it here?

Thanks!

Rob
Nov 20 '05 #1
2 1440
It's because of the legacy way VB6 handled forms... VB6 was not
Object-Oriented, not even Object-Based.... At a push, I'd call it
Object-Aware....

Stepping off the Soap Box, The code is designed to emulate the functionality
of the 'Load' keyword in '6:

<VB6>
Form1.Show()
</VB6>

This will load the form, if not already loaded then show it. So, provided
the Form hasn't been 'Load'ed yet, showing the window will cause the 'Load'
event to occur. Whether you keep it or not is a personal decision... do you
need the functionality that comes with this?

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"Rob Richardson" <th*****@n2net.net> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Greetings!

I have a VB.Net 2003 project that was originally written in VB6, converted
to VB.Net 2002, and then converted to VB.Net 2003. I am trying to handle a form's Resize event. I put a breakpoint in it and saw that that event got
fired four times before the form's Load event got fired! I then saw that I have the following routine in the form's code:

Private Const WM_SHOWWINDOW = &H18
Private m_loaded As Boolean
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_SHOWWINDOW Then
If Not m_loaded Then
MyBase.OnLoad(New System.EventArgs())
End If
End If
MyBase.WndProc(m)
End Sub

And my form's Load event sets the m_loaded flag to true.

I never put that routine in. I presume it was added at some point in one of those conversions. Why is it here?

Thanks!

Rob

Nov 20 '05 #2
Thanks, Tom. That gives me enough to decide whether or not I want it. More
accurately, it gives me enough to understand what's likely to happen after I
rip it out.

Rob
Nov 20 '05 #3

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

Similar topics

6
by: Beach Potato | last post by:
Hi: I've searched newsgroups and various archives, including MSDN & MFC sources, but at this point failed to locate an accurate and simple implementation of WndProc function for MSWindows window...
2
by: Ed Sutton | last post by:
How can a WndProc be created inside a component? Currently I have a WndProc in my frmMain. It looks for WM_DEVICECHANGE messages for connection and removal events for a USB/Serial device. My...
0
by: Kerem Gümrükcü | last post by:
Hi, i subclassed a window (in C#) via WndProc and i catch the messages SC_MINIMIZE and SC_CLOSE from the WM_SYSCOMMAND Message. How can i remove them from the message queue of the window or at...
4
by: Christopher C. Bernholt | last post by:
We have a solution which contains 2 projects. The first project is a windows control and it references an assembly. The second project is a test windows application used to test the windows...
5
by: GaryDean | last post by:
(my original post was inaccurate but this post accurately describes what I think is a very bad vs2005 bug) short description... Deleting a dataset and recreating it from the dataadapter causes...
0
by: cappa | last post by:
Hi, i've a problem with a visual basic .net application that use excel. In local everything is fine, but i've to install this application in sometoher computer, and theese pc don't have the same...
8
by: Lee | last post by:
Hi all, I'm trying to programatically change the background color of lines of text and running into a few difficulties, anyone got any suggestions? my relevant code is as follows: public void...
2
by: chris | last post by:
Hi, I've developed a Windows Forms Application in Visual Studio 2003. I built an MSI package using the setup and deployment projects setup wizard. I ran the MSI package on my machine (where I...
0
by: rmgalante | last post by:
I was developing a large web site in VS 2005 as a web site project. I was having problems with the VS 2005 publish tool. It was slow, and provided no feedback. It has other issues as outlined...
0
marktang
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,...
0
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...
0
Oralloy
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,...
1
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.