The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,733 other followers

Archive for October, 2012

.net – WinForms Load vs. Shown events – Stack Overflow

Posted by jpluimers on 2012/10/31

The order of events and what you can do in events is very important in Windows applications.

This includes the WinForms applications – still popular for business applications – the first .NET framework that supported building Windows applications.

WinForms has two important event/method combo’s:

In descendants, you override the methods. In the form designer, you use the events.

Both the methods and events rely on Windows messages to get fired. This means they depends on which message loop is active. And this limits in what you can do during them.

One of the things you should not do in Load or Show is perform a MessageBox, ShowDialog or any other form of message pumping (like in COM).

Hans Passant explains it this way:

Avoid using MessageBox.Show() to debug this [ed: debug Shown/Load behaviour]. It pumps a message loop, disturbing the normal flow of events. The Load event is triggered by Windows sending the WM_SHOWWINDOW message, just before the window becomes visible. There is no Windows notification for “your window is now fully shown”, so the WF designers came up with a trick to generate the Shown event. They use Control.BeginInvoke(), ensuring the OnShown() method gets called as soon as the program goes idle again and re-enters the message loop.

This trick has lots of other uses, particularly when you have to delay the execution of code started by an event. However, in your case it falls apart because you use MessageBox.Show(). Its message loop dispatches the delegate registered with BeginInvoke(), causing the Shown event to run before the window is shown.

Krishnan Sriram explains that if you use proper debug logging (see what Hans wrote), you get this order of events:

  1. Form – Client Size Changed : 8/14/2010 10:40:28 AM
  2. Form – Control Added – button1 : 8/14/2010 10:40:29 AM
  3. Form – Constructor : 8/14/2010 10:40:29 AM
  4. Form – Handle Created : 8/14/2010 10:40:29 AM
  5. Form – Invalidated : 8/14/2010 10:40:29 AM
  6. Form – Form Load event : 8/14/2010 10:40:29 AM
  7. Form – Loaded : 8/14/2010 10:40:29 AM
  8. Form – Create Control : 8/14/2010 10:40:29 AM
  9. Form – OnActivated : 8/14/2010 10:40:29 AM
  10. Form – Shown : 8/14/2010 10:40:29 AM
  11. Form – OnPaint : 8/14/2010 10:40:29 AM
  12. Form – Invalidated : 8/14/2010 10:40:29 AM
  13. Form – OnPaint : 8/14/2010 10:40:29 AM

Finally, Ahmed Said indicates that there can be form size differences in the Load and Shown state:

The Shown event occured after the load event, the main difference is not in the visibility but in state of the form (width,hieght,..etc). I will give you an example to clarify if we create a form with default size 100,200 and set the windowstate = Maximized in the load event the size will be 100,200 but in shown event the size will be your screen size

–jeroen

via: .net – WinForms Load vs. Shown events – Stack Overflow.

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, WinForms | Leave a Comment »

WebSphere MQ Client 5.3, 6.0 and 7.0

Posted by jpluimers on 2012/10/30

Some of the links in my post on WebSphere MQ Client 5.3 and 7.0 last year didn’t work any more, so below an updated  download link list:

One of the reasons for being at least at V6.0, is that it allows you to specify credentials during a MQCONNX call and using MQCNO_VERSION_5 which enables the use of the SecurityParams (a demo is here) of the MQCNO structure.

–jeroen

via: WebSphere MQ Client 5.3 and 7.0 « The Wiert Corner – irregular stream of Wiert stuff.

Posted in Development, MQ Message Queueing/Queuing, Software Development, WebSphere MQ | 1 Comment »

HOW TO: Change the Default Selection in the Active Directory Manager Snap-in

Posted by jpluimers on 2012/10/29

When managing entities in more than one Active Directory, it is very nice to know that the Active Directory Manager Snap-in supports command line parameters select the domain (and if you want the domain controller).

(Further tweaking needs to be done using scripts like this one)

From the HOW TO: Change the Default Selection in the Active Directory Manager Snap-in. documentation:

Specify the Domain Controller Before Starting the Snap-in

To specify the domain controller to be used before starting the Active Directory Users and Computers snap-in, use the “/SERVER=” switch as a parameter to the MMC saved console (.msc) file. In the process of connecting to the server, the domain of which the controller is a member is automatically detected. For example, either from a command prompt or in the Open box, type:

dsa.msc /server=dc-01.domain.com

Specify the Domain Before Starting the Snap-in

To specify the domain to be used before starting the snap-in, use the “/DOMAIN=” switch as a parameter to the MMC saved console (.msc) file. A domain controller for the domain specified is located automatically and used as the default domain controller. For example, either from a command prompt or in the Open box, type:

dsa.msc /domain=childdomain.domain.com

–jeroen

via: HOW TO: Change the Default Selection in the Active Directory Manager Snap-in.

Posted in Power User, Windows, Windows Server 2003, Windows Server 2008 | Leave a Comment »

Research item: duplicate file finders

Posted by jpluimers on 2012/10/26

Some links I need to research to find a duplicate file finder that fits my needs:

–jeroen

Posted in Power User, Windows, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2 | Leave a Comment »

One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll (via: C# 4.0 and .Net 3.5 – Stack Overflow)

Posted by jpluimers on 2012/10/25

If you get any of the two errors below while compiling your .NET app, then one of these things happened:

  1. You moved .NET 4 or higher code that makes use of dynamic into an assembly that does not reference the Microsoft.CSharp.dll and System.Core.dll assemblies.
  2. You tried changing the .NET version of a project back to .NET 3.5 or lower.

Note that it is not so much declaring a variable as dynamic, but using that variable.

Predefined type ‘Microsoft.CSharp.RuntimeBinder.Binder’ is not defined or imported

One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?

–jeroen

via C# 4.0 and .Net 3.5 – Stack Overflow.

Posted in .NET, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

 
%d bloggers like this: