Click here to Skip to main content
15,890,579 members
Home / Discussions / Mobile
   

Mobile

 
GeneralRe: Uniquely indentify a Windows Mobile 5.0 device Pin
JGentsch15-Feb-08 6:07
JGentsch15-Feb-08 6:07 
GeneralRe: Uniquely indentify a Windows Mobile 5.0 device Pin
Christopher Fairbairn15-Feb-08 23:24
Christopher Fairbairn15-Feb-08 23:24 
GeneralRe: Uniquely indentify a Windows Mobile 5.0 device Pin
Ravenet16-Feb-08 5:46
Ravenet16-Feb-08 5:46 
QuestionHow can I change the settings of default keys of keyboard in Win ce 6.0 using SDK Pin
Pankaj Kothawade15-Feb-08 0:39
Pankaj Kothawade15-Feb-08 0:39 
GeneralBREW Pin
rowdy_vc++12-Feb-08 23:57
rowdy_vc++12-Feb-08 23:57 
GeneralBREW Pin
rowdy_vc++12-Feb-08 23:56
rowdy_vc++12-Feb-08 23:56 
QuestionDrawing to custom control surface help please Pin
daxfrost12-Feb-08 18:40
daxfrost12-Feb-08 18:40 
GeneralRe: Drawing to custom control surface help please Pin
Mike Dimmick15-Feb-08 0:17
Mike Dimmick15-Feb-08 0:17 
Best practice is to do all your drawing in the OnPaint method or in a handler for the Paint event. You can cause a callback into OnPaint by calling the Invalidate method, to tell Windows what part of the control needs to be repainted.

If you want to perform some immediate painting, rather than waiting for the Paint event to fire (which is deferred, in the Windows messaging model, to allow input to be processed at a higher priority than painting operations) follow this pattern:
using ( Graphics g = ctl.CreateGraphics() )
{
   // do drawing here
}
The documentation for CreateGraphics specifically says, "The Graphics is only valid for the duration of the current window's message." You are not allowed to save it and reuse it.

The technical reason behind this is that Device Contexts - the Windows data structure behind the Graphics object - are expensive, and the system only keeps a small pool of them available. If you were to retain them, the pool would quickly run out and no-one would be able to draw anything. So the Framework automatically gives it back at the end of processing every window message.

You still need to remember everything that you've drawn anyway and be prepared to redraw it in OnPaint. Windows does not save your screen layout when something is drawn on top of it (the start menu, a notification bubble, another application), you have to repaint it when the obscuring object is removed.

The best resource for understanding Windows' drawing and events model is Charles Petzold's book "Programming Windows, Fifth Edition". Yes, it hasn't been updated in 10 years. It targets desktop Windows. It uses the C programming language. The fundamentals are the same between the desktop and CE, and they haven't changed since Win32 was introduced with NT 3.1 in 1993.

If you do turn your hand to the desktop, note that Windows Vista with Aero now does save your drawing because you're not actually drawing to the screen, you're drawing to an off-screen bitmap which the graphics card combines with all the other windows' bitmaps to produce the screen output. You should still do all your drawing in OnPaint so that the drawing can be synchronized properly.


DoEvents: Generating unexpected recursion since 1991

QuestionHow to unbind hardware buttons on ipaq 214 Pin
de1uxe11-Feb-08 0:57
de1uxe11-Feb-08 0:57 
GeneralAccess Database help Pin
kingletas10-Feb-08 6:16
kingletas10-Feb-08 6:16 
Generalbluetooth on pocket pc emulator Pin
sachin19869-Feb-08 2:06
sachin19869-Feb-08 2:06 
GeneralRe: bluetooth on pocket pc emulator Pin
Ravenet9-Feb-08 21:04
Ravenet9-Feb-08 21:04 
QuestionAuto-upgrade through web service Pin
JGentsch8-Feb-08 4:06
JGentsch8-Feb-08 4:06 
AnswerRe: Auto-upgrade through web service Pin
JGentsch8-Feb-08 4:43
JGentsch8-Feb-08 4:43 
GeneralRe: Auto-upgrade through web service Pin
Ravenet9-Feb-08 21:05
Ravenet9-Feb-08 21:05 
QuestionHow to enumerate tray icons? Pin
ocean_g5-Feb-08 5:57
ocean_g5-Feb-08 5:57 
AnswerRe: How to enumerate tray icons? Pin
Ravenet7-Feb-08 15:20
Ravenet7-Feb-08 15:20 
GeneralRe: How to enumerate tray icons? Pin
ocean_g21-Feb-08 4:44
ocean_g21-Feb-08 4:44 
GeneralRe: How to enumerate tray icons? Pin
Ravenet21-Feb-08 4:51
Ravenet21-Feb-08 4:51 
QuestionCompact Framework 2.0 for Visual Studio 2003 Pin
jamesorm5-Feb-08 4:46
jamesorm5-Feb-08 4:46 
GeneralRe: Compact Framework 2.0 for Visual Studio 2003 Pin
Mike Dimmick5-Feb-08 6:42
Mike Dimmick5-Feb-08 6:42 
GeneralRe: Compact Framework 2.0 for Visual Studio 2003 Pin
Ravenet7-Feb-08 15:23
Ravenet7-Feb-08 15:23 
Questionchanging MTU size in Windows mobile 5.0 devices ? Pin
rituparn1-Feb-08 5:03
rituparn1-Feb-08 5:03 
GeneralCOM wrapper registration Pin
gottimukkala30-Jan-08 23:49
gottimukkala30-Jan-08 23:49 
GeneralRe: COM wrapper registration Pin
Christopher Fairbairn31-Jan-08 15:46
Christopher Fairbairn31-Jan-08 15:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.