|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Win32 - Console simulation with edit box |
|
![]() dimovich Member since: 7/23/2005 From: Ialoveni, Moldova, Republic of |
||||
|
|
||||
| I'm writting a game under Win32, and have a console window. You can enter commands, change various options from it in "realtime" :) The console window is composed of 2 edit boxes. One for the input line, and the other for the command history. The later one is a multi-line, read-only edit box. My question: how can I add new lines of text to the command history to the bottom (not to the top), and have it automatically scroll vertically. (Well, like in a IRC chat :) ) Thanks! |
||||
|
||||
![]() Colin Jeanne Member since: 8/13/2001 |
||||
|
|
||||
| The trick is to use EM_SETSEL to set the selection to after the last character in the edit. Then you can use EM_REPLACESEL with the text you want to add. This will append data to the edit. |
||||
|
||||
![]() vovansim Member since: 3/25/2003 |
||||
|
|
||||
| It depends on what you are using for the UI library. Is it MFC? Or some other library? The specific answer will depend on that. Vovan |
||||
|
||||
![]() yadango Member since: 7/24/2005 From: Los Angeles, CA, United States |
||||
|
|
||||
| Why use an edit control? Why not render it and program scrolling in yourself? This way your console can have an alpha and pretty flashing colors -- like Serious Sam -- which has one of the most beautifully written consoles in a game (and much of it's GUI source code, from their modding SDK, is free to look at). |
||||
|
||||
![]() dimovich Member since: 7/23/2005 From: Ialoveni, Moldova, Republic of |
||||
|
|
||||
Quote: I'm using pure Win32. |
||||
|
||||
![]() eq Member since: 11/8/2004 |
||||
|
|
||||
| Sorry for hijacking the thread with a new question, they are somewhat related though. I can't tell from your post if you're running command line applications and have their output redirected to your window (edit box)? I'm trying to acomplish this. It's not that hard to capture output that goes to the stdout and stderr, got that working. All built in commands such as: dir, type etc works fine. All my custom applications that use conio.h (i.e cprintf) works fine as well. Program that use printf doesn't work though! Their output isn't captured by my redirection code! How do you capture such output? The easy solution seems to be: "Why don't you recompile your applications using cprintf?" The problem is that most of the applications that I use isn't my own and I don't have the source for it. I've read a lot on the net but I still can't manage to catch all the output. |
||||
|
||||
![]() dimovich Member since: 7/23/2005 From: Ialoveni, Moldova, Republic of |
||||
|
|
||||
I've found the solution in the Quake3 source code (win_syscon.c).HWND hWndEdit; //command history edit box handle TCHAR *szBuff; //command history text buffer ... //Scroll down to the last line SendMessage( hWndEdit, EM_LINESCROLL, 0, 0xffff ); //Put the caret in view SendMessage( hWndEdit, EM_SCROLLCARET, 0, 0 ); //Insert text at the end SendMessage( hWndEdit, EM_REPLACESEL, 0, (LPARAM)szBuff ); And yadango, thanks for your advice with SeriousSam SDK. I've found a lot of useful code there. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|