Pocket Scribble - Part II

This is the second part of the Pocket Scribble tutorial. If you haven't looked at the first part of this series yet, I will strongly recommend that you take a look.

In part one, I showed you how to install and configure Microsoft Embedded Visual C++ and porting the Scribble MFC tutorial to Pocket Windows. We ended up with an application that worked, but with several flaws. The source code was pretty standard MFC code using the document/view architecture, and did not really exercise any Pocket Windows specifics.

In this part I will fix the problems, and discuss some of the Pocket Windows specific classes and API's that you should use.

Last time I pointed out these problems with Pocket Scribble:
  • Why is everything I have drawn gone when the main window has been covered?
  • How can I save the files with the '.scb' extension so I can open existing files?
  • Is the file format compatible with the PC version of Scribble?
  • How do I save my work? There is no OK button in the corner of the window. I can only choose 'Save As'

So fire up your Embedded Visual C++ IDE, and go get a cup of coffee while it loads.


Before we begin

During the steps in this article you will often recompile the Pocket Scribble to try out new versions. You may experience that you cannot upload new versions of Pocket Scribble to the device, because the file is in use. This is because the application is open and there is no way to close it. Later in this article I will look at adding functionality to the application so it is possible to shut it down gracefully. Until then, just close the application the hard way using either the Memory applet in the Settings folder - or if you're working in the emulator, you can close PocketScribble by using the task manager.

In some circumstances you may experience that the emulator hangs. You cannot restart it by closing it normally, and there is no way out but using the task manager. When doing that, you should kill the process named shell32.exe. You may need to restart Embedded Visual C++ too.

If you want to use the ClassWizard for adding event handlers to the document (scribdoc.*) and the view (scribvw.*) you may need to rebuild the ClassWizard file. In Embedded Visual C++ this file has a .VCC extension. To recreate the ClassWizard information delete the file PocketScribble.vcc and then open the ClassWizard. When asked if you want to build a new one from your source files answer yes, and click the "Add All" in the following dialog before clicking OK.

Redrawing the view

When I got the first build of Scribble running in the Pocket Windows environment it seemed like it actually worked "out of the box". But after playing around with it for a while the problems began to appear.

One problem is, that when you do something that obscures the Pocket Scribble main window, everything you have drawn disappears - or to be correct: it is not redrawn -the data is still there!

When something is not redrawn after being obscured, it is typically something that can be found in the OnDraw() override of the view class.

Before the actually drawing takes place, the device context is prepared with some calls to the API function LPtoDP(). If you take a look at the documentation for this function in MSDN, you will se that they state that this API-function is not available on Pocket Windows, and that it actually does nothing with the data transferred to it.

This is a problem because the Scribble application assumes that the drawing coordinates are prepared with the call and not just left untouched.

Therefore I will remove all references to LPtoDP() from the OnDraw() handler. Doing this will have the unfortunate side effect, that the drawing optimisation done in the original application is lost, and the result is slower screen updates. I will not go into optimising the drawing behaviour here, because it is beyond the scope of this article.

Below is shown how the code for the revised OnDraw() handler.

void CScribbleView::OnDraw(CDC* pDC)
 CScribbleDoc* pDoc = GetDocument();

 // Get the invalidated rectangle of the view, or in the case
 // of printing, the clipping region of the printer dc.
 CRect rectClip;
 CRect rectStroke;

 //rectClip.InflateRect(1, 1); // avoid rounding to nothing

 // Note: CScrollView::OnPaint() will have already adjusted the
 // viewport origin before calling OnDraw(), to reflect the
 // currently scrolled position.

 // The view delegates the drawing of individual strokes to
 // CStroke::DrawStroke().
 CTypedPtrList<CObList,CStroke*>&strokeList = 

 POSITION pos = strokeList.GetHeadPosition();
 while (pos != NULL)
  CStroke* pStroke = strokeList.GetNext(pos);
  rectStroke = pStroke->GetBoundingRect();

  //rectStroke.InflateRect(1, 1); //avoid rounding to nothing
  //if (!rectStroke.IntersectRect(&rectStroke, &rectClip))
  //	continue;


The lines shown in bold are the lines modified to make the drawing behaviour work.

Now try to compile the application and try it out in the emulator. Make sure that the build settings are correct - that is the 'Win32 (WCE x86em) Debug' target and 'Pocket PC Emulation' are chosen.

To test that it works choose Tools -> About Pocket Scribble to show the about box and obscure the main window. When the aboutbox has been closed your artwork should still be visible.

How do I save files with the right extension?

If you have played around with Pocket Scribble you may have noticed that it is possible to save your work in a disk file, but the file type is not listed in the Save As dialog. Instead you are presented with the option of saving your work with the type "All Files (*.*)". This is not very intuitive.

It would be desirable, if a file name with the right extension was suggested, and the file type was listed as Scribble document.

The reason that there is not provided a file extension to the filename and a file type, is that the resource identifier IDR_MAINFRAME is not complete. In the application wizard for Visual C++ for PC/Windows, you are presented with the option of customizing you data file properties. This option is missing from Embedded Visual C++, which I consider a serious bug.

The only thing we need to do is to change the string resource entry IDR_MAINFRAME. Go to the string table in your resource file and change the string


PocketScribble\ndefault.scb\nPocketScribble\nScribble Files (*.scb)\n*.scb\nPocketScribble.Document\nPocketScribble Document

Now try to compile everything, load the application into the emulation environment, create a new file and choose Tools->Save As. Now the dialog behaves as expected.

Is the file format compatible with the PC/Windows version of Scribble?

The short answer is yes!

The file formats are compatible because it is the same code that is used for serializing the document. Scribble document files does not need to be converted before they are used in a PC/Windows environment.

How do I close Pocket Scribble?

It is rather inconvenient exiting Pocket Scribble. If you want to close the program you will have to do it from the Memory applet in the Settings folder. The official Pocket Windows way to do it is to add an OK button in the upper right corner of the main window.

The behaviour is not added in the source files that we copied from the original Scribble project in the last article. If you choose to create a project from the scratch by using the project wizard, this behaviour is enabled by default. We will add it manually.

Using the ClassWizard add a WM_CREATE handler to you CScribbleView class. In the implemented function OnCreate() you should add the following code:


That's all. Compile and run the program to verify that everything went OK.

Your Pocket Scribble should now look something like this. Notice that the clicking the OK button will not save your work. I'm not sure I think this is very smart default behaviour.


These two articles should be enough to get you started porting your existing application to Pocket Windows. I have focused on Pocket Windows development using MFC, knowing that MFC does inflict a certain overhead that might not be desirable.

However the speed and memory penalty from using MFC is not really significant on a device with tens of megabytes of memory and 100 to 200 MHz CPU's.

It is a lot simpler creating and porting software to Pocket Windows that one might expect, and I think the future is bright for these small and cool devices running full blown 32 bit operating systems.

If you have comments to the article, please don't hesitate to contact me at csa@codeit.dk. Take a look at another article about Pocket Windows development I've written at http://codeguru.earthweb.com/ce/PocketWine.shtml.


Download demo project - 78 Kb


  • cheap snapbacks

    Posted by xxds1iq on 03/29/2013 01:30am

    [url=http://cheapsnapbackshat.webs.com]cheap snapbacks hats[/url] cheap snapbacks hats x axab [url=http://cheaphatsmall.webs.com]snapbacks for cheap[/url] snapbacks for cheap x exru[url=http://cheaphatsmall.webs.com]snapbacks for cheap[/url] snapbacks for cheap y lymk[url=http://snapbackswholesalezone.webs.com]snapback hats wholesale[/url] snapback hats wholesale s tqpk[url=http://bestbaseballcap.webs.com]wholesale baseball caps[/url] wholesale baseball caps r iptb[url=http://snapbackhatwholesale.webs.com]wholesale beanies[/url] wholesale beanies n dhop [url=http://cheapsnapbackshat.webs.com]cheap hats online[/url] cheap hats online f pjpa [url=http://wholesalefittedhat.webs.com]fitted hats wholesale[/url] fitted hats wholesale q mlln[url=http://wholesalefittedhat.webs.com]snapbacks wholesale[/url] snapbacks wholesale p ahdu[url=http://cheapsnapbackshat.webs.com]cheap hats[/url] cheap hats v ebix[url=http://cheapsnapbackshat.webs.com]cheap hats[/url] cheap hats u vzoy[url=http://snapbackswholesalezone.webs.com]hats wholesale[/url] hats wholesale q qdvw [url=http://cheaphatsmall.webs.com]cheap snapbacks[/url] cheap snapbacks w gkzw [url=http://bestbaseballcap.webs.com]wholesale baseball caps[/url] wholesale baseball caps v iamh[url=http://goodsnapbackhatscheap.webs.com]cheap snapbacks free shipping[/url] cheap snapbacks free shipping y msza[url=http://wholesalefittedhat.webs.com]snapbacks wholesale[/url] snapbacks wholesale e ycsj[url=http://snapbackswholesalezone.webs.com]fitted hats wholesale[/url] fitted hats wholesale g ywtj[url=http://cheaphatsmall.webs.com]cheap hats[/url] cheap hats v tlvy

  • cheap sun glasses

    Posted by vgliliImpumpfrc on 03/28/2013 10:22pm

    http://wholesalesunglasseschic.webs.com - wholesale sunglasses discount oakleys http://wholesalesunglasseschic.webs.com - sunglasses wholesale cheap oakleys for sale http://cheapsunglassesshop.webs.com - oakley sunglasses cheap oakley sunglasses discount http://discountsunglassessale.webs.com - discount oakley sunglasses,,,,,o discount sunglasses http://sunglasssaleulow.webs.com - cheap oakleys cheap oakleys

  • cheap wayfarer sunglasses

    Posted by wgliliImpumpcvx on 03/28/2013 09:58pm

    http://wholesalesunglasseschic.webs.com - sunglasses wholesale fake oakleys http://discountsunglassesfinewebs.com - oakley discount fake ray ban wayfarer http://sunglassdicountsaleu.webs.com - ray ban wayfarer cheap replica sunglasses http://fakeguccisunglasses.webs.com - fake oakley sunglasses fake oakley sunglasses http://discountsunglassesfinewebs.com - discount oakleys fake ray ban

  • wholesale hats

    Posted by xxds8bd on 03/28/2013 07:20am

    [url=http://snapbackswholesalezone.webs.com]snapback hats wholesale[/url] snapback hats wholesale l vudq [url=http://snapbackswholesalezone.webs.com]snapbacks wholesale[/url] snapbacks wholesale n zayv[url=http://snapbackswholesalezone.webs.com]snapbacks wholesale[/url] snapbacks wholesale e nnql[url=http://cheaphatsmall.webs.com]cheap snapbacks[/url] cheap snapbacks w gghn[url=http://snapbackswholesalezone.webs.com]snapbacks wholesale[/url] snapbacks wholesale y qssz[url=http://wholesalefittedhat.webs.com]snapback wholesale[/url] snapback wholesale b acog [url=http://bestbaseballcap.webs.com]wholesale hats[/url] wholesale hats r pbab [url=http://goodsnapbackhatscheap.webs.com]cheap snapbacks[/url] cheap snapbacks f dtkg[url=http://cheapsnapbackshat.webs.com]cheap snapbacks online[/url] cheap snapbacks online u qzta[url=http://cheapsnapbackshat.webs.com]cheap hats[/url] cheap hats v njgu[url=http://cheapsnapbacksforsalezone.webs.com]cheap snapbacks free shipping[/url] cheap snapbacks free shipping c pads[url=http://snapbackhatwholesale.webs.com]snapback hats wholesale[/url] snapback hats wholesale g kgxn [url=http://cheapsnapbackshat.webs.com]cheap hats for sale[/url] cheap hats for sale q cyql [url=http://goodsnapbackhatscheap.webs.com]cheap snapback hats[/url] cheap snapback hats e ybww[url=http://cheapsnapbackshat.webs.com]cheap hats for sale[/url] cheap hats for sale q vatj[url=http://goodsnapbackhatscheap.webs.com]cheap snapbacks free shipping[/url] cheap snapbacks free shipping f nhoh[url=http://cheapsnapbacksforsalezone.webs.com]cheap snapbacks for sale[/url] cheap snapbacks for sale w gueh[url=http://cheaphatsmall.webs.com]cheap snapback hats[/url] cheap snapback hats v cxhk

  • wholesale snapback hats

    Posted by etexpenueMoxjef on 03/27/2013 09:47am

    wholesale snapbacksToday he made too many accidents, he never believe anyone can pose a threat to his own life, even if Chen south in vivo eight soul showed exceptional rule, Swire men although surprised, know that the body could be severely impaired, but did not think that can completely eliminate him [url=http://www.bestcheapsnapbacks.com]cheap snapbacks free shipping[/url] In comparison with different console producers, Nintendo Firm began life being an entertainment company since it was popularly known for its games"Jade still shakes his head, then starts to morph, and this time it did not change, just out of the pure white wings, long out of the crystal jade angle, finally launched small wings to fly out the window, suddenlyThe air, a foot SG closer, Tai Chi mythical figure from the deep sea flying back, it quickly into the Chen Nandan tanaka [url=http://www.cheapforsunglasses.com]cheap oakley[/url] Once concern that many women have regarding birth control capsules is the chance that the tablet may current to their child if they do happen to become pregnantIf you want extra facts concerning kitchen remodel los angeles, pay a visit to Kayleigh Vicketigs Site without hesitationYoure having the jitters"Boar seminal affirmed his problem [url=http://www.bestcheapsnapbacks.com]cheap snapbacks free shipping[/url] He wanted to get his own secretly want to know a secretChen south in kamikaze college roughly turned bad, although he wanted to go to the dean and the faculty residence of a turn, but reason tells him that is dangerous, he must miss those elderly people, in such a famous mainland college, everyone must be master of master [url=http://www.cheapforsunglasses.com]oakleys cheap[/url] Because pregnancy will normally change your metabolism, this will make it easy for you to eat a lot of food if you are not mindful of it It makes taking out the stumps easier Ionized alkaline water will be created in your very own residence with using a water ionizer Emotional seeing speaks about our recognition of the eyes as both a way to express how we feel and a way to connect to other people

  • oakley sunglasses cheap

    Posted by gcexpenueMoxjef on 03/27/2013 07:30am

    snapback hats wholesaleForets blog now for even more data on pilates Manhattan promptly [url=http://www.bestcheapsnapbacks.com]cheap snapbacks[/url] In case your pc were to put in some updates and reboot itself, you may be fully out of luck Making a resource area for individuals and encouraging them to link to your website will generate a certain variety of links back to you Zits may be managed and prevented by proper skin care, however it cannot be cured [url=http://www.bestcheapsnapbacks.com]cheap snapbacks for sale[/url] They advise an everyday consumption of 650 mg of DHA and EPA, and fourHe is based in Lingshan near a peak above, already there Qianxiu thousands of loadC cos [url=http://www.bestcheapsnapbacks.com]cheap snapbacks[/url] But Shangdi still in the scales fall off These include: the panic of shedding your erection that could make you hurry during sexual encounters; well being worries that make youre feeling nervous when having sex and have more chances to rush to ejaculate; and stress, which doesnt allow you to calm down and luxuriate in of your sex encounter Pipe and pipe marking tapes go hands-in-hands with each other considering the fact that pipe identification for provision continues being implemented like a compulsory common for each industrial facility [url=http://www.bestcheapsnapbacks.com]cheap snapbacks for sale[/url] Once let the black Guangyuan are eager to sell kill Speculation is that Apple is preparing a significant celebration on Oct 4th studies are now hinting that this will be the launch event for not only the iPhone 5, but also the iPhone 4S and new iPod 3G All its important to do is be purely a marketing machine and ship visitors to Amazons site

  • ugg outlet

    Posted by Clableengeddy on 11/09/2012 08:22pm

    genuine uggs ,ugg boots sale uk cheap uggs uk ,ugg boots uk buy cheap ugg boots ,buy cheap uggs uk ugg boots australia ,ugg boots sale uk cheapest ugg boots uk ,discount ugg boots. http://www.siteuggboots.co.uk/

  • Incorrect IDR_MAINFRAME string table entry

    Posted by Legacy on 05/30/2003 12:00am

    Originally posted by: Ancient Dragon

    The string table entry that you showd for IDR_MAINFRAME is not correct and causes an ASSERT error because the default extension contains an asterisk. Below is a corrected version:

    Pocket Scribble\ndefault.scb\nPocket Scribble\nScribble Files (.scb)\n.scb\nPocket Scribble.Document\nPocket Scribble Document \n\n

  • Help needed...

    Posted by Legacy on 05/11/2003 12:00am

    Originally posted by: viona

    Is it possible to open a .jpg file and apply scribble on it? I have no idea on how I should go about doing it.

    Any help will be greatly appreciated.


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date