Double Clicking on Title Bar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • schmendrick

    Double Clicking on Title Bar

    Does anyone know how to disable the dbl click on the title bar?

    I have a full screen progam that I dont want moved or closed or
    anything. Took care of everything except for the fact that if you
    double click on the title bar, the form sets itself to half size.

    Can we disable that somehow??

    Thanks!
    David
  • J French

    #2
    Re: Double Clicking on Title Bar

    On Fri, 01 Jul 2005 05:43:27 GMT, schmendrick <schmendrick@my way.com>
    wrote:
    [color=blue]
    >Does anyone know how to disable the dbl click on the title bar?
    >
    >I have a full screen progam that I dont want moved or closed or
    >anything. Took care of everything except for the fact that if you
    >double click on the title bar, the form sets itself to half size.
    >
    >Can we disable that somehow??[/color]

    One method is to intercept WM_SYSCOMMAND and burn off SC_RESTORE

    unit Unit1;

    // Keep Maximized 1/7/05 JF

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    Dialogs,
    StdCtrls;

    type
    TForm1 = class(TForm)
    procedure WMSysCommand(va r Msg: TWMSysCommand); message
    wm_SysCommand;
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}


    procedure TForm1.WMSysCom mand(var Msg: TWMSysCommand);
    begin
    If (Msg.CmdType And SC_RESTORE) = SC_RESTORE Then
    Begin
    msg.Result := 0;
    Exit;
    End;
    Inherited;
    end;

    end.

    Comment

    • J French

      #3
      Re: Double Clicking on Title Bar

      On Fri, 1 Jul 2005 07:06:32 +0000 (UTC), erewhon@nowhere .uk (J French)
      wrote:


      Whoops - wrong NG

      But the general method should work

      Comment

      • Dikkie Dik

        #4
        Re: Double Clicking on Title Bar

        schmendrick wrote:[color=blue]
        > Does anyone know how to disable the dbl click on the title bar?
        >
        > I have a full screen progam that I dont want moved or closed or
        > anything. Took care of everything except for the fact that if you
        > double click on the title bar, the form sets itself to half size.
        >
        > Can we disable that somehow??
        >
        > Thanks!
        > David[/color]
        Do you need the titlebar? In a full-screen window, I can imagine you
        want to drop it altogether. You should be able to do that with just form
        properties.

        Best regards

        Comment

        • schmendrick

          #5
          Re: Double Clicking on Title Bar



          Dikkie Dik wrote:[color=blue]
          > schmendrick wrote:
          >[color=green]
          >> Does anyone know how to disable the dbl click on the title bar?
          >>
          >> Thanks!
          >> David[/color]
          >
          > Do you need the titlebar? In a full-screen window, I can imagine you
          > want to drop it altogether. You should be able to do that with just form
          > properties.
          >
          > Best regards[/color]
          Well, here's the weird thing about that... When I set it to full screen,
          the status bar at the bottom is hidden by the taskbar. not a big deal,
          i can handle that... BUT If I remove the title bar and run the app full
          screen, it covers the taskbar, and I need that showing.

          Comment

          • Steve Gerrard

            #6
            Re: Double Clicking on Title Bar


            "schmendric k" <schmendrick@my way.com> wrote in message
            news:SYcxe.2920 4$IL3.6453@torn ado.ohiordc.rr. com...[color=blue]
            >
            >
            > Dikkie Dik wrote:[color=green]
            >> schmendrick wrote:
            >>[color=darkred]
            >>> Does anyone know how to disable the dbl click on the title bar?
            >>>
            >>> Thanks!
            >>> David[/color]
            >>
            >> Do you need the titlebar? In a full-screen window, I can imagine you want to
            >> drop it altogether. You should be able to do that with just form properties.
            >>
            >> Best regards[/color]
            > Well, here's the weird thing about that... When I set it to full screen, the
            > status bar at the bottom is hidden by the taskbar. not a big deal, i can
            > handle that... BUT If I remove the title bar and run the app full screen, it
            > covers the taskbar, and I need that showing.[/color]

            Try the handy and overlooked Microsoft SysInfo Control 6.0. It gives you the
            work area of the desktop, and an event if it changes. Without a border, you need
            some way to close the form, so I used a button.

            Option Explicit

            Private Sub Form_Load()
            'set to no border
            Me.BorderStyle = 0
            'set initial size
            SetSize
            End Sub

            Private Sub Command1_Click( )
            'no control box, so have something
            Unload Me
            End Sub

            Private Sub SysInfo1_Displa yChanged()
            'reset size if display changes
            SetSize
            End Sub

            Private Sub SetSize()
            'set size to system work area
            With SysInfo1
            Me.Move .WorkAreaLeft, .WorkAreaTop, _
            .WorkAreaWidth, .WorkAreaHeight
            End With
            End Sub


            Comment

            • schmendrick

              #7
              Re: Double Clicking on Title Bar

              PERFECT! Thanks!!!

              Steve Gerrard wrote:
              [color=blue][color=green]
              >>
              >>Dikkie Dik wrote:
              >>[color=darkred]
              >>>schmendric k wrote:
              >>>
              >>>
              >>>>Does anyone know how to disable the dbl click on the title bar?
              >>>>
              >>>>Thanks!
              >>>>David
              >>>
              >>>Do you need the titlebar? In a full-screen window, I can imagine you want to
              >>>drop it altogether. You should be able to do that with just form properties.
              >>>
              >>>Best regards[/color]
              >>
              >>Well, here's the weird thing about that... When I set it to full screen, the
              >>status bar at the bottom is hidden by the taskbar. not a big deal, i can
              >>handle that... BUT If I remove the title bar and run the app full screen, it
              >>covers the taskbar, and I need that showing.[/color]
              >
              >
              > Try the handy and overlooked Microsoft SysInfo Control 6.0. It gives you the
              > work area of the desktop, and an event if it changes. Without a border, you need
              > some way to close the form, so I used a button.
              >
              > Option Explicit
              >
              > Private Sub Form_Load()
              > 'set to no border
              > Me.BorderStyle = 0
              > 'set initial size
              > SetSize
              > End Sub
              >
              > Private Sub Command1_Click( )
              > 'no control box, so have something
              > Unload Me
              > End Sub
              >
              > Private Sub SysInfo1_Displa yChanged()
              > 'reset size if display changes
              > SetSize
              > End Sub
              >
              > Private Sub SetSize()
              > 'set size to system work area
              > With SysInfo1
              > Me.Move .WorkAreaLeft, .WorkAreaTop, _
              > .WorkAreaWidth, .WorkAreaHeight
              > End With
              > End Sub
              >
              >[/color]

              Comment

              • Randy Birch

                #8
                Re: Double Clicking on Title Bar

                Here's another way to make the form immovable and imrestorable (TM).

                'FORM CODE
                -------------------------------------------
                Option Explicit

                Private Sub Form_Load()

                'position form
                Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 3

                'nail form
                If defWindowProc = 0 Then
                Call SubClass(Me.hwn d)
                End If

                End Sub


                Private Sub Form_Unload(Can cel As Integer)

                If defWindowProc <> 0 Then
                Call UnSubClass(Me.h wnd)
                End If

                End Sub

                Private Sub Command1_Click( ) 'un-nail code

                If defWindowProc <> 0 Then
                Call UnSubClass(Me.h wnd)
                End If

                End Sub



                'BAS MODULE CODE
                -------------------------------------------

                Option Explicit

                Public Const GWL_WNDPROC As Long = (-4)
                Public Const WM_NCHITTEST = &H84

                Public defWindowProc As Long

                Public Declare Function SetWindowLong Lib "user32" _
                Alias "SetWindowLongA " _
                (ByVal hwnd As Long, _
                ByVal nIndex As Long, _
                ByVal dwNewLong As Long) As Long

                Public Declare Function CallWindowProc Lib "user32" _
                Alias "CallWindowProc A" _
                (ByVal lpPrevWndFunc As Long, _
                ByVal hwnd As Long, _
                ByVal uMsg As Long, _
                ByVal wParam As Long, _
                ByVal lParam As Long) As Long



                Public Sub SubClass(hwnd As Long)

                'assign our own window message
                'procedure (WindowProc)
                On Local Error Resume Next
                defWindowProc = SetWindowLong(h wnd, _
                GWL_WNDPROC, _
                AddressOf WindowProc)

                End Sub


                Public Sub UnSubClass(hwnd As Long)

                'restore the default message
                'handling before exiting
                On Local Error Resume Next
                If defWindowProc Then
                SetWindowLong hwnd, GWL_WNDPROC, defWindowProc
                defWindowProc = 0
                End If

                End Sub


                Public Function WindowProc(ByVa l hwnd As Long, _
                ByVal uMsg As Long, _
                ByVal wParam As Long, _
                ByVal lParam As Long) As Long

                On Local Error Resume Next

                Select Case hwnd

                Case frmMain.hwnd

                Select Case uMsg

                Case WM_NCHITTEST:
                WindowProc = 1
                Exit Function

                Case Else

                End Select

                End Select

                WindowProc = CallWindowProc( defWindowProc, _
                hwnd, _
                uMsg, _
                wParam, _
                lParam)
                End Function

                --

                Randy Birch
                MS MVP Visual Basic

                ----------------------------------------------------------------------------
                Read. Decide. Sign the petition to Microsoft.

                ----------------------------------------------------------------------------



                "schmendric k" <schmendrick@my way.com> wrote in message
                news:3K4xe.2852 0$7X1.26721@tor nado.ohiordc.rr .com...
                : Does anyone know how to disable the dbl click on the title bar?
                :
                : I have a full screen progam that I dont want moved or closed or
                : anything. Took care of everything except for the fact that if you
                : double click on the title bar, the form sets itself to half size.
                :
                : Can we disable that somehow??
                :
                : Thanks!
                : David

                Comment

                Working...