|
I assume that you are sending text programatically to the rich edit text box. You need to scroll down using LineScroll . Since LineScroll will not let you scroll past the last line of text you could use MyEdit.LineScroll(MyEdit.GetLineCount(), 0) . That puts the last line of text at the top of the edit control. This probably isn't what you want - I assume that you would want the last line of text at the bottom of the display. To do this you need to the following every time the contents of the edit control is modified:
a) Get the number of visible lines in the edit control
b) Get the number of the first visible line using the GetFirstVisibleLine() method
c) Get the total number of lines in the edit control using the GetLineCount() method
d) If the number of visible lines plus the first visible line is less than the total number of lines then scroll by the difference using the LineScroll() method
The following code will do it
void MakeLastLineVisible(CRichEditCtrl& edit)
{
int LastVisibleLine = edit.GetFirstVisibleLine() - NumberVisibleLines(edit);
if(LastVisibleLine < edit.GetLineCount())
{
edit.LineScroll(edit.GetLineCount() - LastVisibleLine);
}
}
The only problem is how to implement the NumberVisibleLines function. This Microsoft article[^] shows how to do it properly. If the size of the edit control and the font used is fixed then you could just use a constant value (determined by experiment)
Graham
Librarians rule, Ook!
|
|
|
|
|
Hi graham,
Thanks for your resposne.
Sorry, Actually i have Rich text contol present in my dialog. I will get messages from the board, when the messages exceeds the size of the window, scroll bar automatically comes because of i had set the scroll bar(Vertical scroll bar) property of Rich Text Control.
My question is, when message exceeds the window size, the scroll bar automatically goes up. i don want scroll bar to move up rather it should go down, then only i can able to see latest updates form the board at time itself.
Thanks in advance,
Thanks,
Balaji
|
|
|
|
|
This is the question of the program.
Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1.
The function should not make use of any C library function calls.
Can someone help me.Appreciate for your effort
wizard zaw.
|
|
|
|
|
You could find a similar question in this Thread[^] which contains the answer also. Well, you could also look at the C++ implementation of strpos() here[^] and can modify it to match your required stricmp() function.
Well, I have to add one more - getting answers for the assignment by posting in forums will save for only for a while. By doing that you're just spoiling yourself. For this time its okay. But never do it again. I hope, you took it in right sense. Work hard and score marks!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
Hello friends,
As I am beginner in threads utilization in VC++,therefore i need some assignments to go and can help myself.
Thanks In advance!
Sushrut
modified on Sunday, December 7, 2008 4:14 AM
|
|
|
|
|
|
|
sushrut83 wrote: ...i need some assignments to go and can help myself.
Search for a file in more than one location. Create a worker thread for each location that is being searched. Each thread reports back to the primary thread with its results.
Copy a set of files. Create a worker thread for each file to be copied.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi,
I have been trying to use the Vista's new Task Dialog and some how i get this error on when calling the TaskDialogIndirect in my code? I understand that this requires Vista and am doing it on Vista am wondering what could be the problem? Have anyone else seen this on vista?
The comctr32.dll version is not v6 on my vista machine (which as per msdn is required for the task dialog?) the question is how could it be and if how can i get the newer v6 dll???
Thanks in advance
Shoaib
|
|
|
|
|
|
Hey everybody!
I'm looking for a way to get FsContext of a file in the NTFS file system.
All the code I've found about FsContext was always for drivers, which I am not looking for...
I am not trying to do that from the kernel (as a driver), but in user mode, as an application.
Does anyone know how to do that?
Thanks a lot in advance!
|
|
|
|
|
Hi,
Unfortunately the FILE_OBJECT structure associated with open file handles is inside the kernel address space therefore not directly accessible to usermode applications. There is no way to access this information from usermode without requesting it from a device driver. Perhaps you can describe what your trying to accomplish? There may be a better solution.
Best Wishes,
-David Delaune
|
|
|
|
|
I am trying to find a way to uniquely identify files over the system.
|
|
|
|
|
Now you really have me confused. What on earth gave you the idea that you needed the FSRTL_ADVANCED_FCB_HEADER[^] structure to identify unique files? Perhaps you meant unique open files?
The windows kernel keeps track of files which are open with an internel FILE_OBJECT[^] structure which is created when ZwCreateFile[^] is invoked.
Can you be more specific? Are you atte,pting enumerate unique files on the disk? Or are you attempting to enumerate all unique open files.
Best Wishes,
-David Delaune
|
|
|
|
|
I want to find all the sets of files in the system.
In other words, I want to be able to identify all the files that have the same "parent" or "root".
So, I turned up with FsContext2 because, from what I understood about the FsContext2 value, is that it is unique for each new file and it's decedents, so, when I create a new file it receives a new FsContext2 (in NTFS), and that number is unique.
When I create a copy of that file, the FsContext2 remains, so all the file's decedents have the same FsContext2 value.
Am I right? or so very far from being right?
|
|
|
|
|
Green Fuze wrote: Am I right? or so very far from being right?
Yes, you are partially correct but you seem to misunderstand these internel structures. These kernel structures only exist when the file is open as they are used for internel tracking of the file state and synchronizing of file access/locking. Files that are just sitting on your hard drive do not have a corresponding FILE_OBJECT and sub structures, they are stored on the hard drive in NTFS records.
Green Fuze wrote: I want to find all the sets of files in the system.
In other words, I want to be able to identify all the files that have the same "parent" or "root".
Are you actually saying that you want to find all files that have the same parent directory/folder?
Best Wishes,
-David Delaune
|
|
|
|
|
No, I want to find all the files that came from the same file.
So just to see that I understand correctly, to get the FsContext2, I must open the file and to do that in kernel mode because FILE_OBJECT is a kernel mode struct. Moreover, there is no way to get it in user-mode.
Am I correct ??? ( I hope not... )
|
|
|
|
|
Green Fuze wrote: No, I want to find all the files that came from the same file.
Are you referring to NTFS Alternate Data Streams? Can you use standard software engineering terminology so I can figure out what the hell your trying to do, its driving me nuts.
Green Fuze wrote: So just to see that I understand correctly, to get the FsContext2, I must open the file and to do that in kernel mode because FILE_OBJECT is a kernel mode struct.
Each time a file or file-like object is opened the NT kernel creates an internal FILE_OBJECT structure for state tracking. It doesn't matter if the file was opened from usermode or kernelmode. These structures do not exist when the object is not being referenced/opened.
Green Fuze wrote: Moreover, there is no way to get it in user-mode.
Yes. It would be more correct to say that there are no documented methods of obtaining this structure from usermode without a driver.
Best Wishes,
-David Delaune
|
|
|
|
|
Hey,
sorry it took a while to respond, I had to get some sleep .
I think the correct engineering terminology is "mapping" (which I am not sure that it is what its called).
I give an example:
I created a new file A.
I copies A to B, thus B was created.
B was copies to C.
Now, I want to know that C, B and A all came from the same file (A).
Now, I thought of using FsContext2 to do that because it has unique value for each of these groups...
Hope I clearer this time...
|
|
|
|
|
Green Fuze wrote:
I give an example:
I created a new file A.
I copies A to B, thus B was created.
B was copies to C.
Now, I want to know that C, B and A all came from the same file (A).
Thats a very interesting idea. I forgot to ask you what operating system you are developing for. A Microsoft technology similar to what you are describing is called Single-instance storage[^] and seems to be available on some flavors of Windows Server. It seems to work by adding a mapped section to the DataSection field of the SectionObjectPointers structure of File_Object.
One final question... What operating system are you trying to develop this for?
Best Wishes,
-David Delaune
|
|
|
|
|
AND Thanks!
|
|
|
|
|
I've used the following code to determine if TranslateMessage() has produced a WM_CHAR or not.
TranslateMessage( ... );
MSG msg;
while(PeekMessage(&msg, ... , PM_NOREMOVE)
{
if(msg.message == WM_CHAR) do_some_thing();
}
But the problem lies in this that PeekMessage() never returns zero and msg.message always is equal to WM_CHAR?
Am I wrong? (of course I am )
Thank you masters!
|
|
|
|
|
PM_NOREMOVE means that the message is left in the message queue, so the next time you call PeekMessage it's the same WM_CHAR you get, thus, infinite loop.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I believe you need to call the DispatchMessage Function[^] to avoid the infinite loop in that particular piece of code. What are you trying to accomplish? If you are using MFC then perhaps you should instead look for WM_CHAR in CWnd::PreTranslateMessage[^] by calling the CWnd base class and then inspecting the results.
Best Wishes,
-David Delaune
|
|
|
|