|
This is the first time I've ever had to do printing within the MFC framework. I have a CRichEditView that does not stop spewing out pages. I started debugging in OnPrint and I notice that the CRichEditView calls GetTextLength() to get the length of the text in the control, it then compares it to the amount of text printed PrintPage(), but those numbers never match. The return from GetTextLength is ALWAYS greater by a couple hundred bytes than the call from PrintPage. Has anyone else seen this problem? I tried doing my own pagination, but I never know when the end of the document is because of the seeminly erroneous return from either GetTextLength or PrintPage. Are the RTF formatting characters in the control being counted as characters in the GetTextLength call and PrintPage?
Any help is appreciated.
Bill
http://www.ratebeer.com
|
|
|
|
|
I write a program which used database and use Multi View in splitter window,
when I switch the view,I must check if the database is empty first.If so, how can I show a message,such as the database is empty ..
|
|
|
|
|
How about ....
AfxMessageBox("The Database is empty");
Some how, I don't think this is the answer you want, but thats how I read it
|
|
|
|
|
When should I show this message when I switch the view?
|
|
|
|
|
What about showing it when the view gets the focus ?
Or better showing it directly in the view. And disabeling any edit buttons handled
by the view.
In general ist much better to disable operations not possible at the moment, instead
of popping up message boxes all over the app.
The user hates to click them away and doesn't read the text in the message box
(Most usrers I know of)
|
|
|
|
|
I have a simple Win32 program that creates an overlapped window containing an edit control. Can somebody please tell me the correct way to set the focus on the edit control when the main application window is selected. I have tried to call SetFocus(hEdit) in response to the WM_ACTIVATEAPP message but this doesn't work.
Thanks for any information you can provide.
Steve.
|
|
|
|
|
Call SetFocus(hEdit) when the main window gets a WM_SETFOCUS.
Oliver
|
|
|
|
|
Hi Gurus
I'm facing a problem using a CListView derived class ( in report style ) in wich I need to draw a particular CHeaderCtrl element in a different color...
Any Idea ?
Thank's in advance )
New to MFC
|
|
|
|
|
Handle NM_CUSTOMDRAW sent from the header, and change the colors in response to that message.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
Hi Mike,
Thank's for your answer
I've already tried it, but it still do not work, here's what I've done...
BEGIN_MESSAGE_MAP(CAgendaView, CListView)
//{{AFX_MSG_MAP(CAgendaView)
//}}AFX_MSG_MAP
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
END_MESSAGE_MAP()
/****************************************************************************
*
*
*
*
****************************************************************************/
void CAgendaView::OnCustomDraw( NMHDR* pNMHDR, LRESULT* pResult )
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW )pNMHDR;
if( lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT )
*pResult = CDRF_NOTIFYITEMDRAW;
else
{
if( lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT )
{
if( lplvcd->nmcd.dwItemSpec == 2 )
{
lplvcd->clrText = RGB( 0, 0, 255 );
*pResult = CDRF_NEWFONT;
}
else
*pResult = CDRF_DODEFAULT;
}
else
*pResult = 0;
}
}
Thank's
Bernard
New to VC++
|
|
|
|
|
ON_NOTIFY_REFLECT will handle notifications from the list control, not the header. Change that to ON_NOTIFY(NM_CUSTOMDRAW, 0, OnHeaderCustomdraw) to handle WM_NOTIFY sent from the header to the list.
The reason is a control sends WM_NOTIFY to its parent, so the header sends WM_NOTIFY to the list control. The ID of a list header is always 0, so that's why you use 0 in the ON_NOTIFY macro.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
Tank's Mike
I'm almost at it, but I still have a problem...
My function handles the NM_CUSTOMDRAW well, but even if I change the color ( lplvcd->clrText = RGB( 0, 0, 255 ); ), the HeaderCtrl still paint's my foreground in black.
New to VC++
|
|
|
|
|
You don't use NMLVCUSTOMDRAW with a header, it's just a plain NMCUSTOMDRAW. Here's a snippet that works:
BEGIN_MESSAGE_MAP(CNewListCtrl, CListCtrl)
ON_NOTIFY(NM_CUSTOMDRAW, 0, OnHdrCustomdraw)
END_MESSAGE_MAP()
void CNewListCtrl::OnHdrCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
NMCUSTOMDRAW* pNMCD = (NMCUSTOMDRAW*) pNMHDR;
*pResult = CDRF_DODEFAULT;
switch ( pNMCD->dwDrawStage )
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
::SetTextColor ( pNMCD->hdc, RGB(0,0,255) );
break;
}
} Where CNewListCtrl is derived from CListCtrl.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
Thank's Mike, you're a genious
Hello chérie, was it written in the stars, that we were supposed to fraternize ( Pepé Le Pew )
|
|
|
|
|
Is there a way to use a toolbar button to activate a hyperlink in a new window???
Thank-you
Sincerely,
RAH
|
|
|
|
|
If you have the hyperlink, call ShellExecute with the "open" verb and the url to show. Or if you have the IWebBrowser2 object you can call the IWebBrowser2::Navigate with a Target of "_BLANK" which will open it in a new window.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
I really need somebody to help me!!! HOW can I change the text color from a CRichEditCtrl
I've tried everything but I can't !!!
|
|
|
|
|
Look at SetCharFormat in the CRichEditView class. In the CRichEditCtrl class you have a little more flexibility as you can use the SetDefaultCharFormat, SetSelectionCharFormat or SetParaFormat for character, selected text or current paragraph respectively. To actually set the color, look at the crTextColor member in the CHARFORMAT structure.
http://www.ratebeer.com
|
|
|
|
|
Can you tell me How to get all machine's MAC Address at Winnt LAN?
thanks in advance!
liuty
2001.9.5
|
|
|
|
|
There was somewhere an article about that on CodeProject
Use the CodeProject's search-function to find the article.
"MAC address" should be enough as a keyword
regards
|
|
|
|
|
I just wrote a code to select multiple files via the CFileDialog.
But it seems that in every case the while-loop is executed only 3 times even if more than three files have been selected
CFileDialog selfiles(TRUE,"mp3","*.mp3",OFN_ALLOWMULTISELECT | OFN_ENABLESIZING,"MP3 Files (*.mp3) | *.mp3 ||",NULL);
CStringArray array;
if(selfiles.DoModal() == IDOK)
{
POSITION pos=selfiles.GetStartPosition();
int counter=0;
while(pos)
{
CString file = selfiles.GetNextPathName(pos);
array.Add(file);
counter++;
}
UpdateData(FALSE);
}
i.e. for example if I selected 7 files and try to get the fifth filename with array.GetAt(4) I get a debug assertion
|
|
|
|
|
Oh sorry, I just found out by myself.
Was a stupid mistake
Don't care about this code anymore, it's correct, I just inserted GetNextPathName accidently two times and didn't notice it
|
|
|
|
|
Try to give some buffer for paths, it better for OFN_ALLOWMULTISELECT style.
Try! It long time when I did it last time.
Good luck.
For example like this:
CFileDialog selfiles(TRUE,"mp3","*.mp3",OFN_ALLOWMULTISELECT |
OFN_ENABLESIZING,"mp3 Files (*.mp3) | *.mp3 ||",NULL);
TCHAR* buffer;
buffer = new TCHAR[1024*5];
selfiles.m_ofn.nMaxFile = 1024*5;
selfiles.m_ofn.lpstrFile = buffer;
CStringArray array;
if(selfiles.DoModal() == IDOK)
{
POSITION pos=selfiles.GetStartPosition();
int counter=0;
while(pos)
{
CString file = selfiles.GetNextPathName(pos); array.Add(file);
counter++;
}
UpdateData(FALSE);
}
delete []buffer;
Viliam Dolinay
|
|
|
|
|
How can i disable or skip ALT-TAB in API project(not MFC) ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
HOWTO: Disable Task Switching on Win32 Platforms
ID: Q226359
|
|
|
|