Home
Page
About
ToolBook
ToolBook
Tips
ToolBook
Projects
ToolBook
Links
Guest
Book


How to drag window without caption bar
This is not serious problem in traditional languages as C++ or Delphi. 
You need to catch message WM_NCHITTEST and return parameter HTCAPTION instead of HTCLIENT. 
But in ToolBook we have some problems. ToolBook viewer really consists of two windows:
Parent Window and Client Window. When you use WM_NCHITTEST in client window you drag 
client window within parent window! This effect is very interesting and may be you can 
use it some way but usually people want to drag parent window. 
But we can use WM_NCLBUTTONDOWN message with parameter HTCAPTION instead. 
(ButtonDown in caption area)
Here's a solution:

-- You need Windows API function "SendMessage" linkDLL "USER" INT SendMessage(WORD,WORD,WORD,DWORD) end -- Put this ButtonDown script into any object which must work like caption bar -- 1. Dragging a viewer "Viewer1" (not mainWindow) to handle ButtonDown -- WM_NCLBUTTONDOWN(HTCAPTION, X, Y) get SendMessage(windowHandle of viewer "Viewer1", 0x00A1, 2, 0, 0) -- Now Windows thinks that we push mouse button on caption bar and hold it -- Refresh a screen activeWindowHandle = sysWindowHandle activeWindowHandle = windowHandle of viewer "Viewer1" end -- 2. Dragging a mainWindow to handle ButtonDown -- WM_NCLBUTTONDOWN(HTCAPTION, X, Y) get SendMessage(sysWindowHandle, 0x00A1, 2, 0, 0) -- Now Windows thinks that we push mouse button on caption bar and hold it -- Refresh a screen -- You need any viewer "Viewer1" to be opened -- (It's not very good but I don't know how else refresh a screen when button is up) if isOpen of viewer "Viewer1" = false open viewer "Viewer1" end if activeWindowHandle = windowHandle of viewer "Viewer1" activeWindowHandle = sysWindowHandle end
Back to Tips Menu