well, it never used to work everytime in pb3.94 (using notepad as the captured window)....
but it seems to work good in pb4.01...
this is the code that was in that topic, but i was playing with it, and i dont comment my code.....and i seem to have commened out the mdigadget stuff and put notepad into a containergadget....
still has a few bugs, but here it is anyway....
Code: Select all
RunProgram("notepad.exe")
hWndNotepad=FindWindow_("Notepad",#Null)
While hWndNotepad=0
Delay(100)
hWndNotepad=FindWindow_("Notepad",#Null)
Wend
hwndMain=OpenWindow(1,0,0,640,480,"Containt Notepad",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#WS_CLIPCHILDREN)
If hwndMain=0
End
EndIf
CreateGadgetList(hwndMain)
hContainer=ContainerGadget(1,3,3,636,470,#PB_Container_Single)
;CreateMenu(0, WindowID())
;MenuTitle("Menu index 0")
; MenuTitle("MDI windows menu")
; MenuItem(0, "self created item")
; MenuItem(1, "self created item")
; mdithing = MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
; --> Add #WS_CLIPCHILDREN to the ContainerGadget
;SetWindowLong_(hContainer, #GWL_STYLE, GetWindowLong_(hContainer, #GWL_STYLE) | #WS_CLIPCHILDREN)
; --> Add #WS_CHILD to Notepad
ShowTitlebar(hwndnotepad, #False)
SetWindowPos_(hWndNotepad, 0, 0, 0, 640, 480, 0)
SetWindowLong_(hWndNotepad, #GWL_STYLE, GetWindowLong_(hWndNotepad, #GWL_STYLE)| #WS_CHILD !#WS_POPUP)
SetWindowLong_(hwndnotepad, #GWL_EXSTYLE, GetWindowLong_(hwndnotepad, #GWL_EXSTYLE) ! #WS_EX_APPWINDOW)
;SetMenu_(hwndmain, GetMenu_(hwndnotepad))
;SetMenu_(hwndnotepad, 0)
notepadwindowproc = GetWindowLong_(hwndnotepad, #GWL_WNDPROC)
;SetWindowLong_(hwndnotepad, #GWL_EXSTYLE, GetWindowLong_(hwndnotepad, #GWL_EXSTYLE) | #WS_EX_MDICHILD)
; --> Set the ContainerGadget as the parent
; --> Remove WS_POPUP style, Now Notepad's menu available,and works better!
SetParent_(hWndNotepad,hcontainer)
; --> Position Notepad
SetWindowPos_(hWndNotepad, 0, 0, 0, 640, 480, 0)
;SendMessage_(hwndnotepad, #WM_PAINT, null, null)
Repeat
event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow