Hi,
I know how to open a console window and send output to it, but is it possible to attach that window to my main program window? or completely hide the console window?
Thanks in advance.
Printable View
Hi,
I know how to open a console window and send output to it, but is it possible to attach that window to my main program window? or completely hide the console window?
Thanks in advance.
I tried doing this by retrieving the hWnd of the console window, so I could use SetParent to attach the console to another window. This is what I did:
But, hWnd returns 0, and so does GetLastError, so I don't know where the error is...Code:Randomize Timer ' Create a unique id to find the window
sTitle = "ZBINST: " & Rnd()
SetConsoleTitle sTitle ' Set the console title to a unique string
Sleep 40 ' Wait for the title to be updated
hWnd = FindWindow("", sTitle) ' Find the window
Check with Spy++ and see if the window name shown is what you expect.
stupid mistake... I used "" instead of vbNullString... It now works :D
I'm not too sure because I didn't test it, but I don't think that Sleep line makes a difference. It doesn't look like it makes any difference because it freezes everything your app is doing. So how can the titlebar be getting updated during that time? I think the titlebar is already updated after you set the title. You might not need to have your program wait.
The console runs asynchronously from the main app, so I rather be completely sure the title gets updated :DQuote:
Originally posted by Tygur
I'm not too sure because I didn't test it, but I don't think that Sleep line makes a difference. It doesn't look like it makes any difference because it freezes everything your app is doing. So how can the titlebar be getting updated during that time? I think the titlebar is already updated after you set the title. You might not need to have your program wait.
Well I just tested it out and you're right. It does run asyncronously. I've never realized that before..Quote:
Originally posted by gxpark
The console runs asynchronously from the main app, so I rather be completely sure the title gets updated :D