|
Anyone know how to determine the font that a custom draw listview item is using?
|
|
|
|
|
In the OnInitialUpdate function, you could call GetFont() and then analyze the members of the pointer it returns (CFont*). Something like this:
CFont* font = GetFont();
if (font)
{
LOGFONT lf;
font->GetLogFont(&lf);
TRACE("Typeface name of font = %s\n", lf.lfFaceName);
}
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
I am not using MFC so how would I do this just using the windows API? I am actually trying to determine whether the item is bold or not in the Outlook Express message list. Thank you for your response.
|
|
|
|
|
WM_GETFONT
An application sends a WM_GETFONT message to a control to retrieve the font with which the control is currently drawing its text.
To send this message, call the SendMessage function with the following parameters.
SendMessage(
(HWND) hWnd, // handle to destination window
WM_GETFONT, // message to send
(WPARAM) wParam, // not used; must be zero
(LPARAM) lParam // not used; must be zero
);
Parameters
This message has no parameters.
Return Values
The return value is a handle to the font used by the control, or NULL if the control is using the system font.
Requirements
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
After you get the HFONT, you can probably build a logfont to retrieve the info.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
That method will return the listview font not the font of the item.
|
|
|
|
|
Custom-draw listview is free to choose as many fonts as it wants for painting different parts of the item area (in such case it skips the default drawing completely). Are you subclassing the listview in question?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
No I am not subclassing the listview but using hooks.
|
|
|
|
|
Well, assuming that this control only sets the font and lets COMCTL32 draw the items, you may try to install WH_CALLWNDPROCRET hook and inspect the font selected into DC after NM_CUSTOMDRAW. You'll have to check for correct custom-draw stage, probably CDDS_ITEMPREPAINT.
BTW: why do you need this functionality?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I was hoping there was an easier way. Thanks for your help
|
|
|
|
|
A Quick one:
Given a path such as this: "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE"
is there a ready made function to replace %ProgramFiles% with the relevant directory? and the same for all the other %...% tags frequently found.
Thanks in advance
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
If you want to replace text between %s with corresponding environment variable, use ExpandEnvironmentStrings. On my W2K machine there's a variable named ProgramFiles, not sure about other Windows versions. If the string containing %s comes from the OS, then there's probably such a variable.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
It does indeed come from the OS. That function is exactly what i'm looking for. Thanks Tomasz!
This is a fine example of the irritation of learning to program in windows... You get stuck for something that you know is there, but no matter how hard you look, you can't find it in MSDN. Still, soon I'll know everything!!!!
)
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi forum,
I want to record my voice to file by *.wma (Windows Media Audio), and *.rm (Real) format. My program is personal purpose.
I need some informations and help from you!
Best regards,
BUNG
|
|
|
|
|
I need to send the message WM_MOUSEMOVE (or possibly other messages?) to a certain window to make it appear i am moving the mouse. How do i do this? Do i have to get the handle to that window first and then use SendMessage() ? if so, how do i get the handle? Any help is welcome.
Thanks
Kuniva
|
|
|
|
|
Is there maybe a way to actually make the mouse move over the screen?
Kuniva
|
|
|
|
|
|
SendInput on Win98/NT4SP3 or later. On Win95 you'll have to use mouse_event.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I am having problems scrolling a particularly large view.
At the moment I set up a memory device context with the dimensions of the screen.
I perform all my drawing to the memory device context. I then handle the scrolling and in OnDraw I bitblt the memory device context to the screen using the scroll offset.
I only need to scroll Vertically and this gives smooth scrolling but a problem occurrs when the drawing required by the view is to big for the Memory devicwe context. I dont want to increase the size of the Memory DC because the drawing for the view can be anything up to 10 times the size of the screen.
So far I have tried to offset the entire Mem DC and redraw the required section of the view as the srolling passes the point the Mem DC ends. This is no way seamless and looks quite jumpy in places.
CAN ANYONE SUGGEST A SOLUTION OR EVEN POINT ME IN THE RIGHT DIRECTION??? ???
|
|
|
|
|
You shouldn't set the size of a bitmap selected into memory DC to the size of the screen - instead, use GetClipBox function which gives you the area that actually needs to be repainted (which is never greater than the size of the screen, at least with single-monitor system).
There was good article about that in June 1997 issue of MSJ - "Wicked Code" by Jeff Prosise. It should be in the 'Periodicals' section of your VC++ help; if it's not here, go to MSDN Online, then MSDN Magazine and search for past issues.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I create custom draw text in ClistCtrl. But i get problems because
the item's i selected were not highlighted. Do anybody know how i can do
this?
Please help!
Here is the code i wrote:
void CMyList::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<nmlvcustomdraw*>( pNMHDR );
*pResult = 0;
CDC *pDC= CDC::FromHandle(pLVCD->nmcd.hdc);
CRect rect;
switch(pLVCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
int iRow = pLVCD->nmcd.dwItemSpec;
CString sItem = GetItemText(iRow, 0);
CString sNo = sItem.SpanIncluding("1234567890");
CString sLetter= sItem.Right(4);
GetItemRect(iRow, rect, LVIR_LABEL);
pDC->SetTextAlign ( TA_RIGHT | TA_TOP | TA_UPDATECP );
pDC->MoveTo ( rect.right , rect.top );
if ( sLetter.Find("B") != -1 )
{
pDC->SetTextColor ( RGB(255,0,0) );
pDC->TextOut ( 0, 0, sLetter );
}
else if ( sLetter.Find("E") != -1 )
{
pDC->SetTextColor ( RGB(0,0,255) );
pDC->TextOut ( 0, 0, sLetter );
}
else if ( sLetter.Find("V") != -1 )
{
pDC->SetTextColor ( RGB(0,170,0) );
pDC->TextOut ( 0, 0, sLetter );
}
else if ( sLetter.Find("U") != -1 )
{
pDC->SetTextColor ( RGB(255,0,255) );
pDC->TextOut ( 0, 0, sLetter );
}
else if ( sLetter.Find("AR") != -1 )
{
pDC->SetTextColor ( RGB(0,255,255) );
pDC->TextOut ( 0, 0, sLetter );
}
pDC->SetTextColor ( RGB(0,0,0) );
pDC->TextOut ( 0, 0, sNo );
*pResult= CDRF_SKIPDEFAULT;
break;
default:
*pResult = CDRF_DODEFAULT;
break;
}
}
|
|
|
|
|
You're returning CDRF_SKIPDEFAULT from CDDS_ITEMPREPAINT, and this means that list control doesn't draw items. You have to check the item state with GetItemState and draw the item in appropriate color/font if it's selected.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How can i do that
Have you an example?
|
|
|
|
|
How to change the caption of a dialog at run time ??
Thanx
|
|
|
|
|
setWindowText("New title")
|
|
|
|
|
Just call SetWindowText()
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|