Recursive queries for SQL Server#
After a quick search in Google, I found this nice page, describing a way to perform recursive queries for hierarchical data in SQL Server 2000 and 2005. So, for everyone interested, here's the link: http://www.yafla.com/papers/sqlhierarchies/sqlhierarchies.htm

Friday, March 31, 2006 9:46:52 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Disabling Double-Click maximizing of windows#

Sometimes, the developers of the .NET framework seem not to have thought things through. This is also the case with the windows.forms namespace concerning the maximizing of windows. When you have a fixed size dialog, you will probably also disable resizing using the SizeGripStyle property. Furthermore, you'll want to disable the maximize button, either by setting the MaximizeBox property to false, or by hiding the titlebar controls altogether using the ControlBox property.

This is all well, but I've noticed, that disabling all of these things doesn't disable maximizing of windows completely. When you double-click the titlebar of the window, you'll still be able to maximize it, probably making the contents of the form quite ugly. If you REALLY want to disable maximizing, you'll have to handle some window messages.

This is actually not that difficult. All you have to do is override the WndProc method and search for some constants in the windows API. What you'll need here are WM_SYSCOMMAND and SC_MAXIMIZE, both found in winuser.h. Then all there's left to do is implement the method as follows:

    private const int WM_SYSCOMMAND = 0x0112;
    private const int SC_MAXIMIZE = 0xF030;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_SYSCOMMAND)
        {
            if (((int)m.WParam & 0xFFF0) == SC_MAXIMIZE)
            {
                if (this.WindowState != FormWindowState.Normal)
                {
                    this.WindowState = FormWindowState.Normal;
                }
                m.Result = new IntPtr(0);
                return;
            }
        }
        base.WndProc(ref m);
    }

That's it! You've now got a window, that WON'T MAXIMIZE.

If you want a window, that can ONLY be maximized or minimized (as in there's no WindowState.Normal), you will follow the same approach. But you'll find that in an article I wrote on codeproject.com a while ago. If you want all the details, just read them here: http://www.codeproject.com/useritems/DisableNormalWindowState.asp

Thursday, March 30, 2006 9:43:02 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

On using SQL Express membership providers#

When using ASP.NET membership, you should always be sure to specify the applicationName attribute on all providers. If you omit it, and deploy your database to the web server, you will find, that all your users have vanished (or at least cannot be found). So make sure your web.config looks similar to this:

<membership>
    <providers>
        <remove name="AspNetSqlMembershipProvider" />
        <add name="AspNetSqlMembershipProvider" applicationName="/" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" />
    </providers>
</membership>

After setting the application name, you can start adding users. If you added users before specifying it, they will probably no longer be available.

 |  |  | 
Monday, March 27, 2006 9:35:22 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Welcome to my blog#

Hi there and welcome to my blog!

As I'm just getting things set up here, you won't see much for now. But be sure to check back once in a while. I hope I'll get to writing some interesting things in here.

Friday, March 24, 2006 10:25:15 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

All content © 2010 , Christoph Herold