|
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
|
|
|
|
|
Hi Tim, and thanks for reply ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Maybe I'm coming down a bit hard here, but this is my opinion.
Some think there are legitimate resons to disable ALT-TAB, I'm not one of them.
Perhaps the first priority would be to handle the DX "surface lost" stuff. There's not much that is more annoying than a game that crashes because I had to ALT-TAB out of it (to do something else), and then when trying to get back it crashes. If it was, it would be the neverending story of kernel-memory we can do nothing about, forcing reboots every now and then...
I am the one owning my machine, and as such I should be the one making decisions of when and how I'm allowed to do what with my machine.
|
|
|
|
|
That is where you are wrong, there are reasons to disable the computers ALT-TAB and other keys, the application that I am developing at the moment is for a network cafe. He doesn't want the people to be able to use the computer until he enables it. Being able to ALT-TAB out of the dialog makes that a pretty pointless exercise doesn't it.
|
|
|
|
|
Prompt as in the program to learn(find out) how many pages it is transmitted on the printer from other program
|
|
|
|
|
Hi, I´ve made a meteo program that draws 4 graphs, I´ve included a function detecting screen resolution, and it changes lines coordinates to fit them into the window, but when you change Windows screen configuration to 'big fonts' the draw exceed the window. Any solution to this problem? or, Is there any MFC function detecting if Windows has big or small fonts selected?
Thank you.
|
|
|
|
|
there is reg-key changing with font size change but it is not directly font size
see http://www.codeproject.com/dialog/cresizeablefiledialog.asp bottom
t!
|
|
|
|