0

I'm creating a Windows Mobile custom SIP and as the user presses or "hovers" over a button on the keyboard I draw it's corresponding selected image (iPhone-esque) to the screen's DC using ::GetDC(NULL). It is developed in Win32 C++.

My problem is that I can never get the screen to repaint itself, erasing the previously drawn key. I've tried everything I could think of to force it, ::RedrawWindow() with all different combos of params using NULL or any of the Get..Window functions as the HWND, and all combo of flags (INVALIDATE | UPDATENOW | ERASENOW | ALLCHILDREN etc). I've also tried invalidating the rect and forcing a repaint of the underlying app using ::GetActiveWindow and ::GetForegroundWindow, variations using ::GetDesktopWindow, etc. I've essentially run out of ideas and it's the last thing holding me up from using it on my Windows Mobile device. Does anyone have any ideas? Any help would be greatly appreciated.

I've included some screenshots to illustrate my dilemma.

Before Screenshot
After Screenshot

Before http://img13.imageshack.us/img13/9861/cezoom1.png After http://img3.imageshack.us/img3/7481/cezoom2.png

Thanks in advance!

2 Answers2

1

Rather than drawing to the background DC, why don't you create a temporary window and draw into that? When you destroy the window, the background should get repainted automatically.

I'm just guessing, because I don't know Windows Mobile, but it could be that Windows is caching the last thing that was drawn into the DC and repainting it every time you invalidate the window.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
  • That is an interesting approach, I'll give it a shot thanks. I don't believe the DC is caching because the problem only occurs when the buttons get drawn outside my sip panel (above it). I don't have this prob with buttons inside the panel even though they are also drawn to the screen. –  Mar 07 '09 at 19:41
  • When I say buttons inside the panel I mean the blue selected popup buttons. (all other buttons are drawn to a bitmap and then blt to the my sip panel's DC not the screen) –  Mar 07 '09 at 19:43
1

Have you tried InvalidateRect on the screen hWnd?

Chris Hynes
  • 9,999
  • 2
  • 44
  • 54
  • by screen hWnd I assume you mean ::GetDesktopWindow(), correct? If that is what you mean then yes I've tried all the usual calls against the screen wnd. –  Mar 07 '09 at 19:37