Jump to content
Tuts 4 You
CodeExplorer

Visual C++ 6 maximum textbox len? (improvements?)

Recommended Posts

CodeExplorer

Visual C++ 6 maximum textbox len? (improvements?)

I have a Visual C++ 6 project which will log all memory allocation of a process to textbox,
here is the problem: the log text will be truncated to 5 KB (which is way to small!)
Is there any way to improve maximum key length or
should I log everything to a text file?
 

Share this post


Link to post
Share on other sites
Kurapica

you will have to use "EM_SETLIMITTEXT" to expand the buffer, also pay attention to the type chars you are dealing with.

but I think it's a bad idea to cum-shoot lots of text into one text control, for logging purposes you may consider using

Listbox control which is also available in Visual C++ 6.00 forms editor.

Share this post


Link to post
Share on other sites
CodeExplorer

Finded this:
https://stackoverflow.com/questions/180853/cedit-control-maximum-length-in-characters-it-can-display?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

But it seems there is no way to circumvent 5 KB limit.
The program is also slow but it has to do with other things not textbox.
 

Share this post


Link to post
Share on other sites
CodeExplorer
SetLimitText uses EM_SETLIMITTEXT:
ftp://alpha-t.ru/%D0%A1%D0%BE%D1%84%D1%82/tv-fm/bt878%20wdm%20mini-driver/btwdmdrvinstaller-src5.3.8/WinClasses/GUI/CEditBox.hpp

Anyway it doesn't work!

Share this post


Link to post
Share on other sites
fearless

Maybe use a listview control to store separate line entries (or listbox) to make something like http://www.uvviewsoft.com/logviewer/

Share this post


Link to post
Share on other sites
Kurapica

If you put too much text into a single line edit control you will see your GUI is becoming laggy with time.

consider using a List or a Listview, faster and easier to read and update.

Share this post


Link to post
Share on other sites
CodeExplorer
31 minutes ago, Kurapica said:

If you put too much text into a single line edit control you will see your GUI is becoming laggy with time.

consider using a List or a Listview, faster and easier to read and update.

The code I'm using is lazy, but still the main problem remains: the only 5 KB displayed on textbox!!!

wsprintf versus multiple strcat which one is faster?
 

Share this post


Link to post
Share on other sites
CodeExplorer

Finded a solution: RICHEDIT control
but now after I add it the program doesn't start any more!
 

Share this post


Link to post
Share on other sites
CodeExplorer
Posted (edited)
38 minutes ago, CodeExplorer said:

Finded a solution: RICHEDIT control
but now after I add it the program doesn't start any more!
 

Fixed that, here is the code:

CAlocLogDlg::CAlocLogDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CAlocLogDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CAlocLogDlg)
    m_stringToSet = _T("");
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    AfxInitRichEdit();  // init rich edit
}

    AfxInitRichEdit();  solved the problem!

 

Edited by CodeExplorer (see edit history)

Share this post


Link to post
Share on other sites
CodeExplorer

textbox = RICHEDIT = 5KB truncated,
so unfortunately didn't fix the problem!
Any suggestion will be great!
 

Share this post


Link to post
Share on other sites
Kurapica

Can you give me a snapshot of your EDIT Styles ?

use Spy++ to find this control in your process, and then go to its properties.

you will find a numeric value for its styles :

This is a snapshot of Windows notepad EDIT control which holds too much text !

 

fg7.jpg

Share this post


Link to post
Share on other sites
CodeExplorer
5 hours ago, Kurapica said:

Can you give me a snapshot of your EDIT Styles ?

They are just default Visual C++ 6 styles, tried EM_SETLIMITTEXT and SetLimitText but with no good result.
Tried with a list as you suggested and it seems to work fine.
You can't copy result like you can do it on editbox but well that's it!
 

Share this post


Link to post
Share on other sites
Kurapica

For fun, try to set the edit style to the same value you see in the above image.

you can copy the value of any item in the list easily, a snippet I used


WCHAR buffer[1024];

ZeroMemory(&buffer,sizeof(buffer));

//Get the index of the selected item, or any item you want !
int Index = SendMessage(GetDlgItem(hWnd, IDC_LIST2),LB_GETCURSEL,NULL,NULL);

//Get the text of the selected item
SendMessage(GetDlgItem(hWnd, IDC_LIST2),LB_GETTEXT,(WPARAM)Index,(LPARAM)buffer);

//Set the form caption
SetWindowTextW(hWnd,buffer);

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×