 |
Bay Six Software Beyond the Basics
|
View previous topic :: View next topic |
Author |
Message |
Alyce Full Member
Joined: 04 Jul 2005 Posts: 91
|
Posted: Aug 13th, 2007, 12:15pm Post subject: MDI |
|
|
Brent,
The MDI features of WMLiberty are very useful. I've created working MDI apps using LB and API calls, but it's a kludge, at best. I hope the next version of WMLiberty includes improvements in this feature. It's one that is often requested in LB-Land. It's also one of the reasons I use other languages. _________________ - Alyce |
|
Back to top |
|
 |
BASICwebmaster Guest
|
Posted: Aug 13th, 2007, 12:53pm Post subject: Re: MDI |
|
|
One of the big problems I see with MDI as implemented is that it's next to impossible to store data 'in' a window. With straight API, you'd just allocate some extra memory per window in the class, trap the WM_NCCREATE and WM_NCDESTROY messages to initialize it, and write a couple helper functions to get/set the information in the form of a struct. Having some way to do this through WMLiberty would be awesome.
Other than that, things are basically kosher as-is. I'm using so many API calls, controls, and callbacks anyway... but that's another topic entirely. |
|
Back to top |
|
 |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 793
|
Posted: Aug 13th, 2007, 10:38pm Post subject: Re: MDI |
|
|
Hi Alyce & Bill,
I've given MDI some thought and I believe it may be possible to clone existing windows; something like this:
Code: | ' THIS IS NOT REAL CODE
' Skeleton of a Very Basic MDI Text Editor
NoMainWin
Global g.hwndMDIFrame
Open "WMLiberty" For DLL As #wmlib
[main.Setup]
WindowWidth = _CW_USEDEFAULT
WindowHeight = _CW_USEDEFAULT
StyleBits #main, 0, _WS_VISIBLE, 0, 0
Menu #main, _
"&File", _
"&New", main.New, _
"&Open...", main.Nothing, _
"E&xit", main.Exit
Menu #main, _
"&Window"
Menu #main, _
"&Help", _
"&About this demo...", main.Nothing
Open "MDI Text Editor" For Window As #main
#main "TrapClose main.Close"
#main "ResizeHandler main.Resize"
hwndFrame = HWnd(#main)
hwndClient = _NULL ' Use the full client area.
CallDLL #wmlib, "CreateMDIFrameClone", _
hwndFrame As ULong, _
hwndClient As ULong, _
g.hwndMDIFrame As ULong
[doc.Setup]
WindowWidth = _CW_USEDEFAULT
WindowHeight = _CW_USEDEFAULT
StyleBits #doc, 0, _WS_VISIBLE, 0, 0
Menu #doc, _
"&File", _
"&New", main.New, _
"&Open...", main.Nothing, _
"&Save", main.Nothing, _
"Save &As...", main.Nothing, _
"&Print...", main.Nothing, _
"E&xit", main.Exit
Menu #doc, "Edit"
Menu #doc, "&Window"
Menu #doc, _
"&Help", _
"&About this demo...", main.Nothing
TextEditor #doc, 0, 0, 320, 300
Open "Document" For Window As #doc
#doc "TrapClose doc.Close"
Wait
Sub main.Close wnd$
Close #doc ' also destroys all clones
Close #main
Close #wmlib
End
End Sub
Sub main.Resize wnd$
End Sub
Sub main.Exit
Call main.Close "#main"
End Sub
Sub main.Nothing
Notice "Not implemented."
End Sub
Sub main.New
hwndDoc = HWnd(#doc)
CallDLL #wmlib, "CreateMDIChildClone", _
hwndDoc As ULong, _
"Document" As Ptr, _
g.hwndMDIFrame As ULong, _
hwndMDIChild As ULong
End Sub
Sub doc.Close wnd$
CallDLL #wmlib, "DestroyActiveChild", _
g.hwndMDIFrame As ULong, _
ret As Long
End Sub |
The hard part may be trying to trap modifications to LB "widgets" like texteditors and graphicboxes. _________________ Brent |
|
Back to top |
|
 |
BASICwebmaster Guest
|
Posted: Aug 22nd, 2007, 6:48pm Post subject: Re: MDI |
|
|
Looking at it now, I've found a work-around to the issue of storing information with windows. Instead of storing the data itself with the window, an app-specific window ID can be stored (using SetWindowLong). That ID corresponds with an entry in a dynamic array. I've also worked out some simple garbage collection: when a new ID is requested, the allocater looks for an entry flagged as closed.
Truth be told, now that this issue is solved, I *like* the current implementation of MDI. Maybe I've been spending too much time doing straight Win32.  |
|
Back to top |
|
 |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 793
|
Posted: Aug 24th, 2007, 9:31am Post subject: Re: MDI |
|
|
Bill, I'm glad you've found a way around your problem. The extra window data can be very useful for storing tidbits. My proposed changes to MDI support would also include "-Ex" versions that would allow you to specify window data blocks and more. _________________ Brent |
|
Back to top |
|
 |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
|