Click to See Complete Forum and Search --> : Problem with setwindowtext


ashu kumari
September 7th, 2005, 12:49 PM
I am using the Windows SetWindowText() function, to set the text in an edit control.

The problem is that the string, which I want to set is 255 characters long, and the visible area of the window is 40 char long.

so the window is HScroll.

The problem is when I use SetWindowText() , & after that UpdateWindow()
the text which set on the window visible area is the 'starting of the string to 40 characters' but I want to show the last 40 characters.

Is there any way to do that.

Please suggest me.

Thanks

Darth Hacker
September 7th, 2005, 01:11 PM
Use CEdit::SetSel() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_member_functions_cedit.asp). Set the starting character and ending character values equal to or greater than the length of your string.

ashu kumari
September 7th, 2005, 01:29 PM
I am not using the CEdit control but using the my edit window control which I have created using the CreateWindowEx() function.

Can you suggest what to do.

Thanks
ashu

PeejAvery
September 7th, 2005, 04:02 PM
Sounds like you are using Visual Basic. Is this the case? If you are using any Basic language you should be able to use right$(text$, 40) or right(text$, 40) to solve your problem.

ashu kumari
September 8th, 2005, 12:12 AM
I am not using Visual Basic.
There is a MDI window, in which this is a child control(Edit control), & when I am using the SetWindowText(), on this window, I am getting the problem.

Thanks

PeejAvery
September 8th, 2005, 12:23 AM
So then what language are you using. Unless you specify no one can help you.

ashu kumari
September 8th, 2005, 01:36 AM
I am using C++ with windows programming, & that is a windows control.

Thanks

Ejaz
September 8th, 2005, 01:38 AM
You can get a better answer from Visual C++ Programming (http://www.codeguru.com/forum/forumdisplay.php?f=7) :thumb:

humptydumpty
September 8th, 2005, 01:54 AM
I am not using Visual Basic.
There is a MDI window, in which this is a child control(Edit control), & when I am using the SetWindowText(), on this window, I am getting the problem.

Thanks

can you specify your problem.what's the problem you are .and if possible show your code also.so someone can understand how you are trying to achive it.


tahnx

ashu kumari
September 8th, 2005, 02:59 AM
I am trying to Use SetWindowText() to set the text in a child window control, which is a edit control.

The problem is that, the window visible area is 40 char long, & window is a type of HScroll. The text which i am trying to set is 100 char long. So when I set the text in the window, it shows only the first 40 characters.

I want to show the last 40 charcters.

Please suggest me.

Thanks

humptydumpty
September 8th, 2005, 03:19 AM
yes remaining text is also there but it can't show more then it's visible area.
so if you wann see complete text either extend the size of editbox on the basis of text.just select Multiline Option.and then go ahead you will see that your scroll bar is now working proper and you can move forward and backward.

for reading last 40 character either read complete string from edit box and extract last 40 character by loop.

or use setsel to select a range of text.
now use cut & Paste Method on edit box.

or for more details just check out MSDN for all CEdit available method

PeejAvery
September 8th, 2005, 11:37 AM
Here is Visual C++'s version of Right$. Could this help?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vclrfCStringTRight.asp