Page 1 of 2

run a program and get his handle to embedded in my window

Posted: Tue Jan 11, 2005 4:40 pm
by porfirio
how do i embedded a window in other window?

i want to make a litle aplication and i want to make a main window and multy subwindows inside the main window like in many programs i know

if it is possibele please reply and help!!! :D

Posted: Tue Jan 11, 2005 7:45 pm
by Pupil
You should read up on the MDIGadget()..

Posted: Thu Jan 13, 2005 4:06 pm
by porfirio
Pupil wrote:You should read up on the MDIGadget()..

ok thanks :D

Posted: Thu Apr 28, 2005 1:54 pm
by porfirio
OK i get it ;)

but now i want to know if is there a way to get the handle of the window when you run it like

Code: Select all

RunProgram("notepad.exe")
and then embedded it to my window or other things
i have seen some program in internet that with a path to a exe in parameters he run it and send it to systray
i want to do something like that please help me ;) 8)

Posted: Fri Apr 29, 2005 6:40 am
by goomoo

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

Posted: Fri Apr 29, 2005 9:24 am
by porfirio
goomoo wrote:

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
Thank's man that work good!

But i dont want only notepad i want to be able to get other's programs, even pb programs :?:

Posted: Fri Apr 29, 2005 11:46 am
by goomoo
you can get other app's window handle by it's caption string.

Posted: Fri Apr 29, 2005 12:27 pm
by porfirio
goomoo wrote:you can get other app's window handle by it's caption string.
yeah i know that ....

but if i dont know the caption it will never work :cry:

Posted: Fri Apr 29, 2005 1:05 pm
by ColBoy
Is it possible to get this to work with DOS apps. It would be great to be able to do this, to implement a method of ensuring the single instance of an app, where I no longer have the source.

I tried doing it, but I just get the DOS app launch in it's own window as normal.

Colin

Posted: Fri Apr 29, 2005 1:43 pm
by Edwin Knoppert
forget the whole thing

Posted: Fri Apr 29, 2005 2:17 pm
by ColBoy
I know somthing like this can be done, as I've done it using MultiMediaBuilder.

Colin

Posted: Fri Apr 29, 2005 2:30 pm
by GedB
Colin,

MMB and PB are very different tools. They do things differently, with different results.

MMB uses Activex for embedding applications.

PB can do embedding, but it has to be done low level, like in this flash example:
viewtopic.php?t=11465&highlight=swf

If you really need to do this easily, then stick with MMB.

Posted: Fri Apr 29, 2005 2:32 pm
by ColBoy
OK, that's fine. I'm just the eternal tinkerer, I always like to find new ways to do stuff as it helps to further my understanding.

Posted: Fri Apr 29, 2005 4:32 pm
by porfirio
Ok thank's you all

I am not talked only in Embebded it in window i am talking in get his handle for do somethings with it like hide the taskbar icon or some other things

please try this code

Code: Select all

win.l=runprogram('notepad.exe')
show_message("",str(win))
( i write the code here so mabe there is some spell errors )

and i get "404" always that and if i run mspaint it give me other thing

that's why i have that idea that it can be done

oh well.....

i am so n0000b :(

Posted: Fri Apr 29, 2005 4:56 pm
by Pupil
Maybe this help?
viewtopic.php?t=6753