home *** CD-ROM | disk | FTP | other *** search
- Multiple-Pane Splitter Bar
- by lord lucifer
- August 12, 1999
-
- This bit of code will show you a very easy way to implement a vertical splitter
- (as in explorer). Using this method, the parent window handles all of the
- resizing. The child windows are positioned so that only the space between them
- shows through. This space (which is part of the parent) is the splitter bar.
-
- When you create the main window's class, you may want to change the hCursor
- member to IDC_SIZEWE or something similar so it changes when the mouse is put
- over it. The iSeparatorPos variable holds the current x-position of the splitter
- bar.
-
- Of course, this is not the only (or best) way to implement these splitter bars.
- For instance, this method may have difficulty with more than 2 panes, or when
- there are horiontal and vertical splitters...
-
- Note this is only a sample of how it might be implememnted, and is not an
- actual, working implementation.
-
-
- ; These go into the MainWindow Procedure:
- mov eax, uMsg
- cmp eax, WM_MOUSEMOVE
- je wmmousemove
- cmp eax,WM_LBUTTONDOWN
- je wmlbuttondown
- cmp eax,WM_LBUTTONUP
- je wmlbuttonup
- ...
-
- ; mouse is moved
- wmmousemove:
- test wParam, MK_LBUTTON
- jz return
- ; left button is down, move the splitter
- mov eax, lParam
- and eax, 0000FFFFh ;LOWORD(lParam = xpos)
- mov iSeparatorPos, eax
- ; get the dimensions of the application window
- invoke GetWindowRect, hWndMainApp, addr rect
- ; re-size the left pane
- mov eax, iSeparatorPos
- dec eax
- invoke MoveWindow, hWndLeftPane, 0, 0, eax, rect.bottom, TRUE
- ; now re-size the right pane
- mov eax, iSeparatorPos
- inc eax
- invoke MoveWindow, hWndLRightPane, eax, 0, rect.right, rect.bottom, TRUE
- jmp return
-
- ; Left mouse button is pressed
- wmlbuttondown:
- invoke SetCapture, hWnd
- jmp return
-
- ; Left mouse button is released
- wmlbuttonup:
- invoke ReleaseCapture
- jmp return