Anyone have any experience with creating dockable windows?

I want to have a dockable dialog window that has a treeview control on it. I would like the window to be able to resize while its docked and while its floating. I basically want something similar to MFC's CDialogBar, but with alot LESS problems!! Plus the CDialogBar doesn't resize while docked and without special overrides wont even support anything other than buttons

Where would I start to create something like this?

And also, when you click on a window thats dockable, you get an empty frame appear that you drag around... How do you make something like that? Basically the same thing when you move a window when you have Show Contents While Dragging turned off. Have never been able to figure that one out.

thanx guys
Posted on 2002-01-20 19:10:58 by Rockinronstar
Well here is a hearty start.. But dont thank me, KetilO put the hard work into getting things working!

:alright:
NaN
Posted on 2002-01-20 21:37:43 by NaN
thanx NaN, I'll check this out. Gona take me a while though - still pretty new to PC Asm coding. Slowly learning. Do you know the theory of Docking Windows? How to make the drag box appear and move it instead of the window?

I think once I figure out how to get this box to appear and move with the cursor and also how to determine when it intersects a "dockable" area then the rest should be a matter of adjusting window styles and window pos/sizes.

well, hope thats it, lol

thanx
Posted on 2002-01-20 22:05:27 by Rockinronstar
Nope, not too much on the Theory, but you got the "rosetta stone" before you!

Just go thu the code, find the various API calls, and then hit the MSDN Serach for the translation to your questions. :)

(( Bring a Note Pad, and write a tut when your done for all us dummies :grin: ))

Have fun..
:alright:
NaN
Posted on 2002-01-20 22:16:35 by NaN
actually that might be a good idea. (Tut). I find this is one area(docking) that doesn't get much attention. Wish it did, since it is such a nice feature to provide to your users. Its even expected now-a-days.

The only docking you got is what MFC provides with its CControlBar derived classes. And in my opinion they are a mess. Very hard to use and there isn't any documentation out there on how to use them properly.

If I get a tutorial up and running , well when I figure this crap out myself, I will have to do it in C++/MFC/API style since this is what I know best. Then maybe someone here who knows MFC and ASM well enough can translate the code into an ASM source or lib for everyone here to use.

Ah, forgot to check the one place that may have something on this subject, Icz's tutorials. Watch him already have written a tutorial on this exact thing.
lol
:stupid:
Posted on 2002-01-20 22:25:52 by Rockinronstar
nope, Iczelion didn't write one, whew! The feel like an idiot feeling is subsiding
:cool:
Posted on 2002-01-20 22:28:01 by Rockinronstar
I once played around with docking windows. I was pretty happy with my results, except I did not get toolbars to work nicely with them, plus a slew of minor issues from activation captions to simplistic docking logic (you can pick which side, but now where a dockling window goes).

Everything was packed up inside a dll to make reuseability easy and simple. While I intended to let the dll be freeware, I'm not releasing the source.

But I'm always open to questions.

Get my docker
Posted on 2002-01-21 22:05:53 by Ernie
Hey Ernie, not a bad little dock manager. A little buggy with the docking logic, but nevertheless, well done. I especially like the VS style when its docked look

I am also working on a docking system as well. I am in the process of crashing the machine all the time, haha. My main problem is how to get the drag box window to come under control of the mouse when you click the dock window Non Client Area. I am not even quite sure if I am on the right path or not.

What I do is when you click on the NC part of the dockable window I create another window that I override the EraseBkgnd and in the NCPaint I draw a simple rect around the border of the window. I then wanted to transfer the capture to this window and take it from the dockable window you clicked on. This is where I am stumped, the window usually crashes my system when I try a force of the LButtonUp on the dock window and a LButtonDown on the drag box window. Does this sound like the right place to start?


thanx
Posted on 2002-01-22 17:02:41 by Rockinronstar
I tried a similar approach once, and got the same results.

Crash crash crash. I don't understand why either.

So I did a search for stuff, found a technique in a back issue of WDJ mag (or something, I bought the archive CD) and came up with a method that works.

It's a bit of work using PatBlt to draw a thick line (which is a rectangle) with a black and white dithered to grey bitmap xor-ed onto the desktop. (Huh? well, follow the code if you want to see).

The routine also remembers the last drawn rectangle and first 'undraws' it. Undrawing with an xor brush just means draw it again.



ropXNor EQU 000a50065H
BadRect EQU -1

.data
LastRect RECT { }
rgwBits DWORD 0AAAA5555H
DWORD 0AAAA5555H
DWORD 0AAAA5555H
DWORD 0AAAA5555H

.code
;-------------------------------------------------------------------------------
DrawGhost PROC pRect:DWORD
; draws the drag rect for tooltabs
LOCAL dwWidth:DWORD, dwHeight:DWORD
LOCAL dxBdr:DWORD, dyBdr:DWORD
LOCAL hdc:DWORD, hbrsDither:DWORD
LOCAL rc:RECT
LOCAL oldBrush:DWORD, hBmp:DWORD

.IF !pRect
.IF LastRect.left == BadRect
; taint nothin to do here
ret
.ENDIF
.ENDIF

invoke GetDC, NULL ; desktop screen DC
mov hdc, eax
invoke CreateBitmap, 8, 8, 1, 1, ADDR rgwBits
mov hBmp, eax
invoke CreatePatternBrush, hBmp
mov hbrsDither, eax
invoke SetBrushOrgEx, hdc, 0, 0, NULL
invoke SelectObject, hdc, hbrsDither
mov oldBrush, eax


invoke GetSystemMetrics, SM_CXFRAME
mov dxBdr, eax
invoke GetSystemMetrics, SM_CYFRAME
mov dyBdr, eax


.IF LastRect.left != BadRect
mov ecx, OFFSET LastRect
mov eax, [ecx].RECT.right
mov rc.right, eax
mov edx, [ecx].RECT.left
mov rc.left, edx
sub eax, edx
mov dwWidth, eax

mov eax, [ecx].RECT.bottom
mov rc.bottom, eax
mov edx, [ecx].RECT.top
mov rc.top, edx
sub eax, edx
mov dwHeight, eax

invoke PatBlt, hdc, rc.left, rc.top, dwWidth, dyBdr, ropXNor
mov edx, rc.bottom
sub edx, dyBdr
invoke PatBlt, hdc, rc.left, edx, dwWidth, dyBdr, ropXNor
mov eax, dwHeight
sub eax, 2
imul eax, dxBdr ;dy - 2 * dxBdr
mov eax, dyBdr
sub dwHeight, eax
sub dwHeight, eax
mov eax, dyBdr
add rc.top, eax
invoke PatBlt, hdc, rc.left, rc.top, dxBdr, dwHeight, ropXNor
mov edx, rc.right
sub edx, dxBdr
invoke PatBlt, hdc, edx, rc.top, dxBdr, dwHeight, ropXNor
.ENDIF
.IF pRect
mov ecx, pRect
mov eax, [ecx].RECT.right
mov LastRect.right, eax
mov rc.right, eax
mov edx, [ecx].RECT.left
mov LastRect.left, edx
mov rc.left, edx
sub eax, edx
mov dwWidth, eax

mov eax, [ecx].RECT.bottom
mov LastRect.bottom, eax
mov rc.bottom, eax
mov edx, [ecx].RECT.top
mov LastRect.top, edx
mov rc.top, edx
sub eax, edx
mov dwHeight, eax

invoke PatBlt, hdc, rc.left, rc.top, dwWidth, dyBdr, ropXNor
mov edx, rc.bottom
sub edx, dyBdr
invoke PatBlt, hdc, rc.left, edx, dwWidth, dyBdr, ropXNor
mov eax, dwHeight
sub eax, 2
imul eax, dxBdr ;dy - 2 * dxBdr
mov eax, dyBdr
sub dwHeight, eax
sub dwHeight, eax
mov eax, dyBdr
add rc.top, eax
invoke PatBlt, hdc, rc.left, rc.top, dxBdr, dwHeight, ropXNor
mov edx, rc.right
sub edx, dxBdr
invoke PatBlt, hdc, edx, rc.top, dxBdr, dwHeight, ropXNor
.ELSE
mov LastRect.left, BadRect
.ENDIF

invoke SelectObject, hdc, oldBrush
invoke ReleaseDC, NULL, hdc ; release desktop DC
invoke DeleteObject, hBmp
invoke DeleteObject, hbrsDither
ret
DrawGhost ENDP

;-------------------------------------------------------------------------------



A similar method will draw a resizing line.
Posted on 2002-01-22 20:09:23 by Ernie
Thanx Ernie, that bit of info just sent me miles ahead on my goal!!!!

Had lots of fun with it too, haha. Never seen such a messed up Desktop in my life. Boy did I dirty it up while testing stuff, haha

now all thats left is the Docking logic and then the resize based on docking position. Would be cool to draw a nice caption bar like you did in yours

thanx again
Posted on 2002-01-22 20:49:27 by Rockinronstar
How are you holding the docked windows? I took the 'simple' way out and stuck em into rebars.

"Simple' is in quotes because I had to subclass the rebars to teach em a few new tricks. But they do handle multiple docked windows quite nicely once they are there.
Posted on 2002-01-22 21:03:27 by Ernie
I was actually gonna take my own path on that. Just reposition the window manually within the frame. But I do like the reBar idea. Reuse a known, working technology. In reality , I would have to create something like a ReBar to hold the docked windows. Plus the ReBar allows multi docking onto the same bar, which I wasn't looking forward to implementing.

I'll have to see, I may still go solo on that and create my own "control bar" system
Posted on 2002-01-23 06:10:18 by Rockinronstar