|
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
|
|
|
|
|
|
How do you set a window's font using Win32 (NOT MFC!!!)?
I have been trying to use the WM_SETFONT message but it doesn't seem to work...
Thanks,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
by window's font do you mean the font on the title bar? or do you mean the font of all the controls on that window? I am not sure you can use WM_SETFONT to change the font of the title bar unless you do some painting on your own...
for the individual controls you can use WM_SETFONT
Nish
|
|
|
|
|
Could you post an example, I've been unable to get it to work.
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
|
|
|
|
|
I tried it out and it worked fine
medit is a global HWND
medit=CreateWindow("EDIT","",WS_VISIBLE|WS_CHILD|WS_BORDER,10,10,300,30,hWnd,NULL,
hInstance,NULL);
HFONT hfont;
hfont=CreateFont(25,12,0,0,700,TRUE,0,0,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,
"Times New Roman");
SendMessage(medit,WM_SETFONT,(WPARAM)hfont,0);
|
|
|
|
|
Are you sure that lifetime of HFONT is long enough? You can't just pass a HFONT to a Window with WM_SETFONT and destroy the font - the window doesn't copy the font.
The second thing is that not all Windows support this message. Standard controls do, but your own Window classes do not unless you explicitly handle this message.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
the HFONT is only a handle to the font
the HFONT variable need not last the life time of the control
once you send the WM_SETFONT message to the font then you can forget your HFONT variable
even if the HFONT variable is destroyed the font is not destroyed
for that, you may use DeleteObject
Nish
|
|
|
|
|
Sorry, you're wrong. HFONT needs to last as long as the window which uses it. If you destroy the HFONT with DeleteObject, the window painting will fail (SelectObject somewhere inside WM_PAINT handler will not work and subsequent calls to TextOut or DrawText will use default font).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello tomasz
I wasnt wrong
I clearly said that if the HFONT variable gets destroyed there is no problem as the CreateFont created front is still alive. I clearly said that for the font to be destroyed you need to call DeleteObject. But if you dont call DeleteObject your font is alive and well and you can forget about the HFONT variable
Nish
|
|
|
|
|
Let's clear things: by 'lifetime of a HFONT' I mean the time between CreateFont[Indirect] and DeleteObject. I'm not talking about local variable of type HFONT.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
oh!
sorry tomasz....
got you wrong
my fault
Nish
|
|
|
|
|
This is my fault as well - instead of technobabble like 'lifetime of a HFONT' I should just write 'you can't immediately delete a font you've set with WM_SETFONT'.
Cheers,
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
maybe...
Nish
|
|
|
|
|
Nish is talking about a deliberate memory leak.
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
|
|
|
|
|
Hello folks,
I know that a service process (under NT/Win2k) should not communicate with GUI, since no user has to be logged in so no shell is available.
But...
When my service is crashing (unhandled exception), I want my general exception handler sends a messagebox to the user in case there's a user logged in.
So...
How can I detect if a shell exist (aka: a user is logged in), so I can safely shoot a messagebox.
Thanks,
EiSl
|
|
|
|
|
hi
this might be a dumb technique but I think you can use GetDesktopWindow() and if that returns NULL, that probably means there is no user logged in
nish
|
|
|
|
|
I think you should rather write this info to the Windows Event Log.
Anyway, if you need to interact with the desktop, first read 'Interactive Services' in your VC++ help. It should be under Platform SDK/DLLs, Processes, and Threads.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|