Process ProgramDisplay()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Process ProgramDisplay()

Post by IdeasVacuum »

I would like to be able to RunProgram(An.exe,#PB_Program_Hide), if necessary change it's screen location, then un-hide it.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Process ProgramDisplay()

Post by jassing »

Here's something (very simplified) I did for a similar situation... While it's not a "native" PB feature, it may get you by -- based on debugging I did, there is no way to "un hide" the program just based on the process handle...

Code: Select all

Procedure UnHideWindow(hwnd,*cTitle)
	Protected cTitle.s{128}
	Protected bContinue = #True 
  
	SendMessage_(hwnd,#WM_GETTEXT,128,@cTitle) 
  If Len(cTitle) And cTitle = PeekS(*cTitle)
  	ShowWindow(hWnd,#SW_SHOW)
  	bContinue = #False 
  EndIf
  
  ProcedureReturn bContinue
EndProcedure

hProgram = RunProgram("notepad.exe","","c:\temp",#PB_Program_Open|#PB_Program_Hide)
Delay(100) ; Needed to allow notepad to open it's window

EnumWindows_(@UnHideWindow(),@"Untitled - Notepad")

While ProgramRunning(hProgram)
	Delay(10)	
Wend
Post Reply