Lock device for a moveable, preferably pivotably mounted, leaf of a door or of a window having a lock case which can be mounted on the leaf side having a lock mechanism housed therein, having an upper locking bar connection device and a lower locking bar connection device, - wherein the lock device has an actuation device, wherein the upper locking bar connection device and/or the lower locking bar connection device can be actuated for locking and/or unlocking, - wherein an upper locking bar is connected to the upper locking bar connection device and/or a lower locking bar is connected to the lower locking bar connection device, - wherein a switching lock having a latching device (6, 7) is assigned to the upper locking bar and/or a switching lock having a latching device (6, 7) is assigned to the lower locking bar, wherein it is provided that a) the latching device (6, 7) has a pivotably mounted latch which can be pivoted between a first pivot position of the latch and a second pivot position of the latch, b) the latching device (6, 7) has a supporting body on which the latch is pivotably mounted and wherein the supporting body is mounted to be moveable along the direction of extension of the locking bars, such that the latch can be shifted between an extended locking position and a retracted unlocking position, c) the latching device (6, 7) has a switching device for controlling the latch, d) wherein the latch and the switching device are formed in such a way that, in the first pivot position of the latch, the pivotability of the latch can be optionally blocked and released depending on the switching device, characterised in that the switching device acts on the latch via the actuation device (8, 8d) and/or an auxiliary latch, the switching lock has the auxiliary latch which is formed for the detection of the open and/or closed position, and the auxiliary latch interacts with the switching device in such a way that the switching device can be brought into a position which blocks the pivotability of the latch and a position which does not block the pivotability of the latch, and the latching device (6, 7) has an elastic element, preferably a spring element, which pushes the latch into the first pivot position of the latch. - wherein the lock device has an actuation device, wherein the upper locking bar connection device and/or the lower locking bar connection device can be actuated for locking and/or unlocking, - wherein an upper locking bar is connected to the upper locking bar connection device and/or a lower locking bar is connected to the lower locking bar connection device, - wherein a switching lock having a latching device (6, 7) is assigned to the upper locking bar and/or a switching lock having a latching device (6, 7) is assigned to the lower locking bar, a) the latching device (6, 7) has a pivotably mounted latch which can be pivoted between a first pivot position of the latch and a second pivot position of the latch, b) the latching device (6, 7) has a supporting body on which the latch is pivotably mounted and wherein the supporting body is mounted to be moveable along the direction of extension of the locking bars, such that the latch can be shifted between an extended locking position and a retracted unlocking position, c) the latching device (6, 7) has a switching device for controlling the latch, d) wherein the latch and the switching device are formed in such a way that, in the first pivot position of the latch, the pivotability of the latch can be optionally blocked and released depending on the switching device,