Page 1 of 1
Borderless MDI Child?
Posted: Wed Aug 11, 2004 7:30 pm
by Shannara
Ok, Ive looked in the MDI sample and docs. There is a borderless flag, but its only for the MDI parent, and doesnt work on XP pro (or at least not on my copy, and it's uptodate).
So, how does one get a borderless MDI client? This is a requirement for my game due to skinning, so... Anybody know how?
Posted: Wed Aug 11, 2004 7:47 pm
by localmotion34
ok, use the EnumChildWindows_ API procedure to get the handles of the child windows of the MDI. once you have the handle, use the
setwindowlong_() procedure to set the right flags.
Code: Select all
Structure FindWindowData
childwindowhandle.l
EndStructure
NewList FindChild.FindWindowData()
Procedure.l EnumChildProc(hChild, lParam)
clearlist(findchild()) ;make sure we dont keep adding and adding to it
AddElement(FindChild()) ; add an element for each child window
FindChild()\childwindowhandle= hChild ; store the child handle
ProcedureReturn 1
EndProcedure
EnumChildWindows_(gadgetid(#mdi_gadget), @EnumChildProc(), 0)
foreach findchild() ;cycle through each child window
setwindowlong_(FindChild()\childwindowhandle,blah blah)
next
it is easiest to store the childwindows of a entity in a linked list with a structure. that way, you can have each child window have its own element in the list, and then have lots of "sub elements" in the structure to store position, flags, borders, or whatever. hope this helps.
Posted: Wed Aug 11, 2004 8:02 pm
by localmotion34
GOT IT!!!!!
Code: Select all
Structure FindWindowData
childwindowhandle.l
EndStructure
NewList FindChild.FindWindowData()
Procedure.l EnumChildProc(hChild, lParam)
;ClearList(FindChild()) ;make sure we dont keep adding and adding to it
AddElement(FindChild()) ; add an element for each child window
FindChild()\childwindowhandle= hChild ; store the child handle
ProcedureReturn 1
EndProcedure
If OpenWindow(0,0,0,400,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget,"MDIGadget")
If CreateGadgetList(WindowID(0)) And CreateMenu(0, WindowID(0))
MenuTitle("Menu index 0")
MenuTitle("MDI windows menu")
MenuItem(0, "self created item")
MenuItem(1, "self created item")
MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
AddGadgetItem(0, -1, "child window")
AddGadgetItem(0, -1, "child window")
; add gadgets here...
CloseGadgetList()
EndIf
EnumChildWindows_(GadgetID(0), @EnumChildProc(), 0)
ForEach FindChild() ;cycle through each child window
SetWindowLong_(FindChild()\childwindowhandle,#GWL_STYLE, #WS_CHILD|#WS_DLGFRAME|#WS_CLIPCHILDREN|#WS_CLIPSIBLINGS )
SetWindowPos_( FindChild()\childwindowhandle,0,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE|#SWP_FRAMECHANGED )
ShowWindow_(FindChild()\childwindowhandle,#SW_SHOW)
Next
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
try that for now and see how it goes. Regards!!!!!!!!
Posted: Thu Aug 12, 2004 11:50 pm
by freak
Well, for an MDIGadget, the returnvalue of the "AddGadgetItem()" function is
actually the window handle of the mdi child you just created. So you don't
need to enumerate the child windows, you can just use these handles instead.
And if you do want to enumerate them, there is something you have to know:
There are also hidden child windows other than the real ones, which you
should skip in the enumeration (this is a windows thing), so the procedure
should look like this:
Code: Select all
Procedure.l EnumChildProc(hChild, lParam)
; this skips those child windows that are not the real ones.
;
If GetWindow_(hChild, #GW_OWNER)
ProcedureReturn #TRUE
EndIf
;ClearList(FindChild()) ;make sure we dont keep adding and adding to it
AddElement(FindChild()) ; add an element for each child window
FindChild()\childwindowhandle= hChild ; store the child handle
ProcedureReturn 1
EndProcedure
Timo
Posted: Fri Aug 13, 2004 4:09 am
by localmotion34
had to just throw that in there, huh freak? had to rain on my parade. i finally know the answer to complex API stuff, and you gotta just shoot back.

haha. anyway, i didnt know there were hidden windows to an MDI. just goes to show the engineers of MS have no touch with reality as the rest of humanity knows it. and with the addgadgetitem for the MDI, why not update the help file to reflect that the return of that is the child handle. i.e.
childhandle=addgadgetitem(#MDI,-1,"childwindow)
just a suggestion.
Posted: Sun Aug 15, 2004 10:38 pm
by Shannara
freak wrote:Well, for an MDIGadget, the returnvalue of the "AddGadgetItem()" function is
actually the window handle of the mdi child you just created. So you don't
need to enumerate the child windows, you can just use these handles instead.
Timo
Somehow I do not think the above statement is accurate. For example, try the following code :
Code: Select all
myMDI = MDIGadget(#PB_Any, 0, 0, 0, 0, 1, #MENU_FirstMDI, #PB_MDI_AutoSize)
;Add login window / MDI Child
frmLogin = AddGadgetItem(myMDI, -1, "Login")
SetGadgetItemAttribute(myMDI,frmLogin,#PB_MDI_ItemWidth,200)
The mdi child is not resized.
Posted: Sun Aug 15, 2004 10:56 pm
by freak
Yes, the statement is completly accurate. the result of AddGadgetItem()
is the OS handle for the mdi child window, and you can use it for any
api command you want without problems.
You can't use that value for PB commands though, because they don't work
with the os handles.
Timo
Posted: Sun Aug 15, 2004 10:59 pm
by Shannara
Oh that sucks hardcore, time to add to the wishlist.. erk!