I've modified a little to get more better, Now the Notepad's menu available and can focus to it normally .
But there is still a problem: when main window minimize then restore , sometimes the notepad's window can't be displayed correctly yet.
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,#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget,"Containt Notepad") 
If hwndMain=0 
  End 
EndIf 
CreateGadgetList(hwndMain) 
hContainer=ContainerGadget(1,3,3,636,470,#PB_Container_Single) 
; --> Add #WS_CLIPCHILDREN to the ContainerGadget 
SetWindowLong_(hContainer, #GWL_STYLE, GetWindowLong_(hContainer, #GWL_STYLE) | #WS_CLIPCHILDREN) 
; --> Add #WS_CHILD to Notepad 
SetWindowLong_(hWndNotepad, #GWL_STYLE, GetWindowLong_(hWndNotepad, #GWL_STYLE) | #WS_CHILD ! #WS_POPUP) 
; --> 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, 20, 20, 500, 400, 0) 
Repeat 
  event=WaitWindowEvent() 
Until event=#PB_Event_CloseWindow
