|
|
i don't want to replace i want to append new text with older text but the text should be appended where the cursor is placed....
|
|
|
|
|
You want to append text or insert text in the middle? They are two different things!
For appending, you could use GetWindowText() followed by a SetWindowText()
For inserting, you could use ReplaceSel(), as Cedric already pointed out.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Did you follow the link and read the information ?
Did you understand this sentence ?
If there is no current selection, the replacement text is inserted at the current cursor location.
Isn't that what you are looking for ?
|
|
|
|
|
Ya actually sorry i didn't read whole sentence.....
thanks...
i'll try it
|
|
|
|
|
sounds like a case of the /. "google makes us dumber" syndrome
|
|
|
|
|
In a Win32 console application a timer should call a member function of a C++ class.
But how can I make the API function SetTimer to call this member function?
Thanks in advance.
|
|
|
|
|
Pass the class pointer as the argument of the timer callback function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
SetTimer() doesn't take a member function as an argument.
You can, however, use a static member function with the right signature:
class MyClass
{
...
static void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
...
};
You can pass &MyClass::TimerProc to SetTimer().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: SetTimer() doesn't take a member function as an argument.
I was afraid of that.
Thanks anyway.
|
|
|
|
|
Steffen Lange wrote: I was afraid of that.
Why is that a problem?
You can pass a function pointer, it just can't be a non-static class
member function.
If making the method static is the problem, you could use a multimedia timer[^]
instead. The multimedia timers let you have a pointer passed to
the callback which you can cast to a pointer to an object of your
class...
class MyClass
{
...
static void CALLBACK MyTimerProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD dw1, DWORD dw2);
...
public:
void SomeFuncThatCreatesATimer();
};
void SomeFuncThatCreatesATimer()
{
...
::timeSetEvent(..., ..., &MyClass::MyTimerProc, this, TIME_PERIODIC);
...
}
void CALLBACK MyClass::MyTimerProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD dw1, DWORD dw2)
{
MyClass *pThis = (MyClass *)dwUser;
...access non-static MyClass members using pThis...
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Using Visual C++ 6.0 MFC in SDI application
I have a view that includes a dialog window from which the user can select different options. I do not want the user to be able to close that window. When the view changes, that dialog window will close automatically. However, I noticed that when the window is displayed, if the user hits the "escape key" esc, the window disappears. How do I prevent that from happening?
Thanks
|
|
|
|
|
Handle OnCancel() (IDCANCEL) in the dialog box.
comment the base class call CDialog::OnCancel().
Regards,
Sandip.
|
|
|
|
|
|
|
I have a CListCtrl, each row has a specified color.
CListCtrl myList;
myList.SetRowColor(j, crRows.GetAt(j));
Then I need to insert some new rows, the latest is at top. Here is source code
CArray<colorref> crRows;
CArray<cstring> newData;
int nNew = newData.GetCount();
for (int i=0; i<nnew; i++="" )="" {<br="" mode="hold" />
CString txt = newData.GetAt(i);
myList.InsertItem(0, txt);
COLORREF aColor = GetRowColor(txt);
crRows.InsertAt(0, aColor)
int nCnt = myList.GetItemCount();
for (int j = 0; j<ncnt; j++="" )="" {<br="" mode="hold" /> myList.SetRowColor(j, crRows.GetAt(j));
}
}
</cstring></colorref>
I works, but because of 2 loop for, the performance speed is very slow, so I have to improve it
Does anyone know what should I do in this case??
Thanks in advance
|
|
|
|
|
Instead of for loop you can just maintain a stack so no movements required.
Does it makes sense.
Regards,
Sandip.
|
|
|
|
|
thank for your reply
but actually, i'm afraid that I don't understand how to maintain a stack??
|
|
|
|
|
why you want to maintain STL is there you just have to use it
Regards,
Sandip.
|
|
|
|
|
STL? is that Standard Template Library?
sorry SandipG, I really don't understand what you mean. Can you explain more detail,
|
|
|
|
|
Yes tataxin i mean Standard template library.
instead of using CArray you can use stack which is LIFO so you dont need to move elements down after every element added.
Regards,
Sandip.
|
|
|
|
|
Nice SandigG, that's what I want,
but I dont know how to implement this.
Can you show me more details.
|
|
|
|
|
can anyone give me more details or give me some document to read about this?
thanks in advance !!
|
|
|
|
|
Look here [^]
Few more.. [^]
[^]
Regards,
Sandip.
|
|
|
|
|
tataxin wrote: but because of 2 loop for, the performance speed is very slow, so I have to improve it
You can call SetRedraw( FALSE ) before the for loop and SetRedraw( TRUE ) in the end or use a virtual list control (http://www.codeproject.com/KB/list/virtuallist.aspx[^]).
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|