Hi Friends...............

I want to change the font color and font type(font-face) of title bar text in C# windows form.....

Please help me.....

6 Years
Discussion Span
Last Post by nssltd

The font size etc. of a windows form is controlled by the operating system settings.
One way to overcome this is to create a frame-less form with you own custom title bar (and frame etc.) and manage all the user interactions yourself (click and drag to move the form etc.).
This is not an easy thing to do so think carefully before you start.


Hey i think i can help you move on with what nick.crane said. I too experienced such a problem and i developed a solution so here is what i used to make the form drag able.

private static class NativeMethods
            public const int PBT_APMQUERYSUSPEND = 0x0;
            public const int BROADCAST_QUERY_DENY = 0x424D5144;
            public const int WM_NCLBUTTONDOWN = 0xA1;
            public const int HT_CAPTION = 0x2;

            public static readonly int QueryCancelAutoPlay = RegisterWindowMessage("QueryCancelAutoPlay");
            public static readonly int WM_POWERBROADCAST = RegisterWindowMessage("WM_POWERBROADCAST");

            /// <summary>
            /// Exectuion state enum for disabling standby.
            /// </summary>
            public enum EXECUTION_STATE : uint
                ES_AWAYMODE_REQUIRED = 0x00000040,
                ES_CONTINUOUS = 0x80000000,
                ES_DISPLAY_REQUIRED = 0x00000002,
                ES_SYSTEM_REQUIRED = 0x00000001,
                ES_USER_PRESENT = 0x00000004,
            /// <summary>
            /// The send message method for allowing the window to be dragable.
            /// </summary>
            /// <param name="hWnd">The window handle.</param>
            /// <param name="msg">The message to send.</param>
            /// <param name="wParam">The wParam value.</param>
            /// <param name="lParam">The lParam value.</param>
            /// <returns>The hResult of the call.</returns>
            public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

            /// <summary>
            /// Releases the window caputre.
            /// </summary>
            /// <returns>True on success.</returns>
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool ReleaseCapture();

            /// <summary>
            /// Sets the execution state for allowing the tool to disable standby (Vista and higher).
            /// </summary>
            /// <param name="esFlags">The flags indicating the thread execution state.</param>
            /// <returns>The execution state that was set.</returns>
            public static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);

            /// <summary>
            /// Gets the integer value for the given window message.
            /// </summary>
            /// <param name="msgString">The window message to lookup.</param>
            /// <returns>The integer value for the message.</returns>
            [DllImport("user32", CharSet = CharSet.Auto)]
            private static extern int RegisterWindowMessage([In, MarshalAs(UnmanagedType.LPWStr)] string msgString);

This is what i have used to set up the methods for the dragging and then to enable the form to be dragged i have used this method.

Rectangle dragrect = new Rectangle(0, 0, this.Width, 40);
            if (e.Button == MouseButtons.Left)
                if (dragrect.Contains(e.Location))
                    NativeMethods.SendMessage(this.Handle, NativeMethods.WM_NCLBUTTONDOWN, new IntPtr(NativeMethods.HT_CAPTION), new IntPtr(0));

This should be enough to get you on your way...


Votes + Comments
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.