Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toolbar: How to make it non-dockable 2

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
535
0
16
MU
Dear friends,

This is actually in continuation with one of my previous regarding On Screen Keyboard.
I managed to make one on my own (with help of inputs from Tek-Tips and other sources) based on ToolBar and it works fine.

Now, I am not able to make it Non-Dockable. If the On Screen Keyboard (a toolbar in fact) gets dragged by mistake, many times it goes to one of the edges of screen and gets docked there. I want to prevent this. However, I am not able to find a property or a way to achieve this.

Any idea?
Thanks in advance

Rajesh
 
The best I can think of is puttin this into the AfterDock event:

Code:
If this.docked
   this.Dock(-1)
EndIf

the help on the BeforeDock event tells you, that neither NODEFAULT nor RETURN .F. from it prevents docking, so all you seem to be able to do is undock, right after docking. It will still have an effect on the button positions, especially if you dock a toolbar to the left or roght side. To get that back to normal you would also need to reset width and height to keep the keyboard aspect ratio.

Chriss
 
Rajesh,

What Mike said is exactly right - that's what we do.
 
Dear Chriss & Mike,

Fantastic!

I modified both AfterDock and DblClick events. In the INIT of form, in which the keyboard is invoked, I saved the initial position of the keyboard and I reset the keyboard position there in the AfterDock method.

Thanks dears
Rajesh
 
Rajesh Karunakaran said:
I reset the keyboard position there in the AfterDock method

good idea, that's always a valid position. you could also store the current Left and Top values in beforeDock and depending on DockPosition restore one of them, i.e. when the docking is left or right, you can restore the last top value and at least keep the keyboard toolbar in the height the user wanted it to be. At the same time position the keyboard so it just touches the side it was docked to.

It's not as trivial as storing the last top and left in the BeforeDock event, because a) beforedock also happens when you undock by doingthis.dock(-1) and you overwrite what you wanted to reset to and b) the last top and left values are the last position the window started to be dragged, not the last top and left drag position before docking.

It's a simple solution to put the keyboard in its home position. The user may try to move it once more, avoiding the dock and position reset.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top