|
Very well done! Thank you! There is only one thing that should be added to
if (toupper(nChar) == 'V' && GetAsyncKeyState(VK_CONTROL))
- its checking for SHIFT-INS combination.
Thank you very much!
|
|
|
|
|
Reunion wrote: There is only one thing that should be added...its checking for SHIFT-INS combination.
Correct. Not once have I ever used that combination to insert text.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
One more and final: in your case the new text replaces the whole text in the control. So it's better to use ReplaceSel function instead of SetWindowText. Now everything is correct. Here is the final code:
<br />
void CRichEditCtrlEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
bool bPasted = false;<br />
if((toupper(nChar) == 'V' && GetAsyncKeyState(VK_CONTROL)) || (nChar == VK_INSERT && GetAsyncKeyState(VK_SHIFT)))<br />
if(IsClipboardFormatAvailable(CF_TEXT))<br />
if(OpenClipboard() != FALSE){<br />
HANDLE h = GetClipboardData(CF_TEXT);<br />
if(h != NULL){<br />
LPTSTR lptstr = (LPTSTR)GlobalLock(h);<br />
if(lptstr != NULL){<br />
ReplaceSel(lptstr);<br />
GlobalUnlock(lptstr);<br />
bPasted = true;<br />
}<br />
}<br />
CloseClipboard();<br />
}<br />
if(!bPasted)<br />
CRichEditCtrl::OnKeyDown(nChar, nRepCnt, nFlags);<br />
}<br />
Thank you once more!
|
|
|
|
|
Hi,
I have a view class derived from CFormView. I have a timer in it which is fired for every 20 seconds. In the timer, I am repainting the form view with some bitmaps in OnPaint handler. When I am in the timer, the form view UI is stuck, i.e I am not able to click any other bottons on the form view. Can any one please give me some suggestions so that my UI responds to events even when the timer code is trying to refresh the view.
Thanks
Madhavi
|
|
|
|
|
Put the timer and the code that belongs to it in a separate thread.
That should do the trick.
|
|
|
|
|
Thanks...my problem is solved...
|
|
|
|
|
i want to create a setup file for
a MFC project ,
do Visual Studio contain any such
software.
thank u
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Which Visual Studio ? Different versions have come with different solutions. I use Advanced Installer[^], it's a great solution, and the free version will probably do all you need ( although I bought it ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
what's wrong with Install Shield?
He is like a one-legged man in a bum kicking competition. -Novjot Sidhu
--[v]--
|
|
|
|
|
I've done installs with install shield. It's probably more powerful than AdvancedInstaller, but as a result, it takes a lot longer to get the same end result.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Install shield
it is very powerful!
|
|
|
|
|
Thank you evryone for ur help
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
How can I add a dialog to Cview?
|
|
|
|
|
Create a new dialog class and make it a member variable for modeless, or create it in the scope of the function that calls it for modal dialogs.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
By that I mean embedded a modal dialog inside a SDI view.
|
|
|
|
|
Embedding in what way ? So the modal dialog is part of the CView window ? Or just so that the modal dialog is shown by the view ? If the former, you can't. If the latter, exactly as I said. In your view, create the dialog class, and call DoModal on it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Use CFormView
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
This is an assignment and we're recommanded not to use CFormView, but somehow to mimic the CFromView ways
|
|
|
|
|
Oh. You said a 'Modal dialog'. Otherwise, I'd have said to use CFormView. CFormView gives you a dialog like view, it does NOT 'add a modal dialog to your CView'.
If you're not allowed to use CFormView, then create your own controls, and embed them into your CView in your view constructor.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
According to assignment specification, It is feasible to add modal dialog to CView, and add controls to this dialog.
|
|
|
|
|
Hmmm - perhaps you can add a dialog, but it can't possible be modal, that's not what modal means.
I'm going to have a play with this.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
OK, if you create a dialog, set it's style to be 'CHILD', and then make it a member variable and do this:
BOOL CVC6CViewView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
BOOL b = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
dlg.Create(IDD_THEDIALOG, this);
dlg.SetParent(this);
dlg.ShowWindow(SW_SHOW);
return b;
}
Then you end up with the dialog embedded in your view. The Create function is registered as a handler for the Create event, obviously.
It's still not modal. You could make it modal by ignoring the rest of the view until OK is clicked, and responding to OK by closing the dialog, but overall, I'd say that's not what's required, I can't imagine why it would be.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I set the background color when I initial the view ? I want to set it black.
|
|
|
|