Maximize MenuMinimize Menu

 

 

TOP

Trajecto's Win32 API Programming Tutorial for Pocket PC

Prototype Windows Application

Let's make a Protoype Windows Application. This is the basic Windows skeleton all other apps will be based on. Enjoy as we also break some of the rules of Pocket PC programming!

1. Start a new Pelles C WinCE Pocket PC Program (EXE) project just like we did before in the "Hello World" lesson. Name the project "Prototype" and add a new Source Code page like before and paste the following code into it:

 

 

#include <windows.h>
#include <aygshell.h>

LRESULT MainWndProc(HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam)
{
   if(message == WM_LBUTTONDOWN)
   {
      DestroyWindow(hWnd);
      return 0;
   }

   return DefWindowProc(hWnd, message, uParam, lParam);
}

//--------------------------------------------------------------------------------------

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
   WNDCLASS wc = {0};

wc.style = CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.hInstance = hInstance;
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszClassName = L"myapp";
if(RegisterClass(&wc))
{
   HWND hWndMain;

   if(hWndMain = CreateWindow(L"myapp",L"Prototype",WS_VISIBLE,0,0,240,320,0,0,hInstance,0))
   {
      MSG msg;

SHFullScreen(hWndMain, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
ShowWindow(hWndMain, SW_MAXIMIZE);
UpdateWindow(hWndMain);

   ShowWindow(hWndMain, SW_MAXIMIZE);
   UpdateWindow(hWndMain);

   while(GetMessage(&msg,hWndMain,0,0))
       DispatchMessage(&msg);

   return msg.wParam;
      }
   }
return 0;
}

 

Save and add to the current project as before.

IMPORTANT!
Under Project | Project Options change the compiler calling convention setting to _stdcall


Compile and run the prototype application.

Isn't it wonderful?

Have you ever been so excited about... well... nothing?

Take a moment right now to admire your beautiful blank canvas, the very place where you will express your unique imagination and amaze all of your friends and family with your amazing skills learned right here! (yeah, right. make sure you don't show off yet at this point, people will think you are nuts.)


What Pocket PC rules have we broken and why?

1. Thou shalt not be full-screen and shall display all toolbars
2. Thou shalt only have and provide for one copy running
3. No Close or Exit buttons shall dare exist

 

Trajecto's Rationale

1. The screen is so tiny, full-screen is the only way to go to show anything graphic
2. Once you start a full-screen app there is no way to start another app running anyways
3. WHY? who cares if I exit my program? It frees up memory

 

Next Tutorial - Let's Draw!

Radiosity Games
See our new game site


©Copyright TrajectoryLabs.com. All Rights Reserved.