473,770 Members | 6,713 Online
Bytes | Software Development & Data Engineering Community
+ 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(N ew System.EventArg s())
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 1454
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******** ******@TK2MSFTN GP09.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(N ew System.EventArg s())
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
6634
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 objects. Something like: class BaseWindow { virtual LRESULT WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
2
21468
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 frmMain uses a component to communicate with a USB/Serial device. I would prefer that this component handle the WM_DEVICECHANGE messages internally and only fires events to my frmMain when my USB device connects or disconnects. In case anyone...
0
891
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 least prevent them from reaching the Message Handler of the Window? It looks something like this:
4
2893
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 control from the first project. As such, it references the windows control using a project reference. In addition, it also references the same assembly that the first project references. The assembly which is referenced by both projects contains...
5
1996
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 VS.Net 2005 to render the associated .resx and .vb file inoperative. detail... I converted an asp 1.1 vb.net app using the vs2005 conversion wizard and then retested the app after conversion.
0
1318
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 version of excel that i've :S In the installation packet .net automatically add 2 files "EXCEL.exe" and the dll associated with it "MS0.dll". When i install my application theese 2 files are in the installation folder, when i try to call excel...
8
2387
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 colorLines() { //_Paint = false; //don't want to update while we are doing this //loop thru lines like addText() does
2
1182
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 developed the application) to install it and I can run the application just fine. I deployed it on another machine but when I ran the application I get an error: Login Failed for user OFFICE\Display Wenzl. I have Sub Main as my startup project and...
0
2559
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 below. Here is my solution. I converted the application from a Web Site Project (WSP) to a Web Application Project (WAP). Go to http://webproject.scottgu.com/ and read about the Web Application Project in VS 2005. Why?
0
9591
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, 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...
0
9425
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,...
0
8880
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
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...
0
5312
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
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
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.