|
Yes, you are right, SetSel function does not scroll the contents...
However, I think that the user will be annoyed if he decides to scroll up and see for example history of messages and at that time another message arrives and your code will scroll down. I think it's not right.
So, think about it: maybe you don't have to scroll. Just append new message to the end. In that case SetSel helps.
Not insisting of course:
void CChatView::AddString(LPCSTR lpszStr, COLORREF color )<br />
{<br />
LONG nStart, nEnd;<br />
GetRichEditCtrl().GetSel( nStart, nEnd );
LONG nLength = GetTextLength( );<br />
<br />
long lPos = GetRichEditCtrl().GetTextLength( );<br />
GetRichEditCtrl().SetSel( lPos, lPos );
<br />
GetCharFormatSelection();<br />
m_charformat.dwMask = CFM_COLOR;<br />
m_charformat.dwEffects = NULL;<br />
m_charformat.crTextColor = color;<br />
GetRichEditCtrl().SetSelectionCharFormat(m_charformat);<br />
Edit_ReplaceSel(m_hWnd, lpszStr);<br />
<br />
if((nStart != nEnd)&&<br />
(nLength > nEnd + 10))<br />
GetRichEditCtrl().SetSel( nStart, nEnd );
}
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
The user won't be annoyed, because I want this scrolling to take place only when HE enters the message (and not his chat partner), so that he doesn't have to scroll down to the last line and then enter his message.
Thanks anyway!
|
|
|
|
|
This doesn't work.
From SetSel()'s help:
"This function does not scroll the contents of the CRichEditCtrl so that the caret is visible."
Other ideas?
|
|
|
|
|
Here's a really late response for you, and I understand that you will probably already have a solution. But my searching around on the net didn't find much more than your question and a lack of an answer. Hope this helps someone else.
This works for me:
CRichEditCtrl results(myEditBoxHWND);
LONG lLen = results.GetWindowTextLength();
results.SetSel(lLen, lLen);
results.ReplaceSel(_T("My new bit of text\n"));
int nFirstVisible = results.GetFirstVisibleLine();
int nTotalLines = results.GetLineCount();
results.LineScroll(nTotalLines - nFirstVisible); Phil
--
All things considered, you can't really consider all things ...
|
|
|
|
|
When I select various items in a CListCtrl they are obviously selected because the background colour changes.
However, when the CListCtrl looses focus, the items are not obviously in focus. Is there anyway I can change this so it behaves more like Windows Explorer and leaves the selected items selected, but a different colour when the window is out of focus.
Many thanks,
Alan Dugdall
|
|
|
|
|
Check the list control's "Show selection always" property in the resource editor. You can also set this style programatically by doing:
DWORD dwStyle = ListView_GetExtendedListViewStyle (m_listCtrl.GetSafeHwnd());
dwStyle |= LVS_SHOWSELALWAYS;
ListView_SetExtendedListViewStyle (m_listCtrl.GetSafeHwnd(), dwStyle);
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I need a way to make my app (a dialogproject in VC++) to bee maximized at startup when running my app.
Thanks
APe
|
|
|
|
|
Add this in your OnInitDialog():
ShowWindow (SW_MAXIMIZED);
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello, all,
I am working on a project which needs to capture the mouse movement in IE browser window. How can I do it?
I think I can create a class and use SubclassWindow of IE. Is that right?
I this case, which class should my new class derive from?
And how can I get the HWnd of IE.
Or there is other ways to do it?
Thanks a lot.
bin
|
|
|
|
|
You can't subclass a window in another process without injecting code into that process.
You can however use a Windows hook. See SetWindowsHookEx in the Platform SDK documentation. You probably want one of WH_CALLWNDPROC , WH_CALLWNDPROCRET or WH_GETMESSAGE .
|
|
|
|
|
It sounds like you need to do soenthing limilar to what this article describes:
Mouse gestures in IE[^]
I have not read it, but it probably does something like you need.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
Hi
Can i do so that my MFC dialog launch from WinAPI dll.
Or i can to do it only in MFC dll project????
Actually i do this but after loading of my dialog AfxGetThread()->PumpMessage was invoked from MFC code and application failed.AfxGetThread return NULL,but in my code i set AFX_MANAGE_STATE(AfxGetStaticModuleState()) and change _WINDLL to _AFXDLL macro.
Thank.
|
|
|
|
|
Hi
I recently ran into a strange problem. I used the new function myDoublePtr = new double[some_number]. However, I used 570000000. The compiler gave me an array too big error. I have 1 gig of ram. Is it a compiler thing? Or maybe the language. Thanks
|
|
|
|
|
The computer did not have 570,000,000 bytes of contiguous RAM to offer.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
You cant expect 570000000*sizeof(double) = 4.56x10^9 bytes = 4.2 GB from the heap.
If you really need that much memory (I doubt it! Revise your algorithms), you probably need to look into memory mapped files.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Nothing strange about it.
The most the memory manger can allocate for one buffer is around 1 gig not 4 gig. Look up virtual memory management in the MSDN library for more info..
You should be breaking up your storage requirments into multiple smaller buffer, how many and how small is up to you. You could use GlobalAlloc() to allocate the individual buffers, but now days the MSDN recommends using the heap allocation management routines instead.
INTP
|
|
|
|
|
I know that it can be a silly question but I would use a function to pass from text string "1234" to float 1234.
thanks in advance
|
|
|
|
|
atof or sscanf .
If you're using the Standard C++ Library, you could also use a stringstream and extract the data out using the >> operator.
Finally, you could consider Boost's lexical_cast[^] template.
|
|
|
|
|
use atof() function inside ur func.
Thanks
The chosen One
|
|
|
|
|
Hi!
I have tried to clear a buffer, but it do not work.
I have tried clear().
Can someone help me
|
|
|
|
|
memset( buffer, 0, sizeof( buffer ) );
or, if using Windows.h, you can also use
ZeroMemory( buffer, sizeof( buffer ) );
although that's a macro which expands to memset in recent SDK releases.
The sizeof trick only works if your buffer was statically allocated as an array (so that the compiler knows the size). Otherwise, you'll need to record the size when you allocate so you know how many bytes to zero.
|
|
|
|
|
Hi
I use PKZIP(R) Version 2.50 for zipping some files.
I use this to make a file with all DBF, SDF, MDF files in it
PKZIP -add -nozipextension -span -pass=mypass "N:\TEST\TEST.HI" *.DBF *.SDF *.MDF
I implemented this in C coding too, works great when you want to write to the local drive. To the network share like 'N' is .. it doesn't work.
It gives me this error:
Encryping files
Creating. zip: N:/TEST/TEST.HI
PKZIP: <e7> Can't create: PKBACK# 001
Anyone got any ideas? Was this a bug that got fixed by the latest release?
Best regards
Anoy
|
|
|
|
|
I was forgotten something to mention:
I have all permittions on the sharedirectory.
I can place a file, delete it, append it etc.
Jens
|
|
|
|
|
i have no more ideas, i lodge! Here's what i want to do:
Every time the kernel32.dll is loaded, it should load a arbitrary dll, which then should create a log file to capture the name and the process id of the process which has loaded the kernel32.dll (and so the injected dll).
Here's a brief summary of what my code does:
It searches for the section which can be executed, copies my code to the end of this section and changes the entry point in order to jump to my code, and after my code has been executed (and the dll has been loaded - which only should happen if the dllmain retrieves DLL_PROCESS_DETACH) it jumps back to the original entry point (which has been saved before).
The difference between a normal dll and the kernel32.dll is the calculation of the address of the LoadLibraryA function!
I have tried this whole thing with Windows 98, and if someone now says that i am crazy and the stuff mentioned before won't work, even not if a miracle happens, i can say you are wrong. Windows 98 executes my infected kernel32.dll like it does with the original one, without a sinlge error. And YES, my code is executed too, BUT and that's my problem, the injected code doesn't load the DLL, and I DON'T KNOW WHY!!!!!!!!!!!!
Can someone help me ?
Thanks in advance!
|
|
|
|
|