CompuServe Thread

Dynamic Button Bitmaps

2 messages in this thread
#30471From: Brian KuJul 11, 1994 3:22 AM
Russell, > The scenario is a Dialog with 27 CbitmapButton's positioned such that > they butt up to each other. Using Autoload it works fine – at the > screen resolution I normally work at, (1024×768). > Change to 640×480 and each button's bitmap is substantially larger > causing them to overlap. I don't want to resize the buttons and > dialog to fit because it will all be too large. > I attempted to overload my button's DrawItem function using a similar > method to the Superpad demo's – CAboutbox – CBigIcon routines. This > was successful, unfortunately the response between the button being > pressed and it's depressed bitmap being displayed is too slow. What > can I do.? Have you tried building in release mode? > Presently, I load the bitmaps in OnInitdialog and use the following > code in DrawItem << void CAnimButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); ASSERT(pDC != NULL); CRect rect; GetClientRect(rect); CBitmap* pcbmpTemp = (lpDrawItemStruct->itemState & ODS_SELECTED) ? pcbmpFrogDown : pcbmpFrogUp; // Pre loaded bitmaps size 30×40 pixels CDC* pDisplayMemDC = new CDC; pDisplayMemDC->CreateCompatibleDC(pDC); CBitmap* pOldBitmap = (CBitmap*)pDisplayMemDC->SelectObject(pcbmpTemp); pDC->StretchBlt( 0, 0, rect.Width(), rect.Height(), pDisplayMemDC, 0, 0, 30 ,40 , SRCCOPY); pDisplayMemDC->SelectObject(pOldBitmap); delete pDisplayMemDC; } >> > Is there any way I can speed this up. i.e a Global DC? or loading and > resizing the bitmaps at initialisation? Or what and how??? I'm sorry, but I am unaware of anything that would speed this up. However, I did find an article (below) on some efficient animation techniques, which I hope may apply do what you are trying do to. To get the entire article type "GO MSKB" and search on Q75431. Hope it helps! Brian Ku -Microsoft Developer Support INF: An Efficient Animation Algorithm ID: Q75431 An application that shows an animated image cannot rely solely on Windows graphical device interface (GDI) functions because they will be too slow. Instead, the application must create its own set of bitmaps. This article discusses the process required and provides tips to improve performance and memory use. This information applies to any type of animation or fast drawing, from painting the game pieces in Reversi to updating the time each second in Clock.
#30673From: Russell CurgenvenJul 12, 1994 10:48 AM
Thanks for the help Brian. I'll go and get the article. – Russell Curgenven, Written 12-Jul-1994 @ 16:37:59 Using: Windows NavCIS SE v.1.2