PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Help needed for tutorial about Pocket PC

Hi, all

I am very new in this field. I am learning the tutorial by this URL:

http://www.pocket-g.com/prx/winframe.html
Code:

///////////////////////////////////////////////
#include <windows.h>

LRESULT MainWndProc(HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
RECT rcClient;

switch(message){
case WM_PAINT:
hDC = BeginPaint(hWnd,&ps);
GetClientRect(hWnd,&rcClient);
DrawText(hDC,L"Hello",5,&rcClient,DT_CENTER|DT_VCENTER);
EndPaint(hWnd,&ps);
break;

case WM_LBUTTONDOWN:
DestroyWindow(hWnd);
break;

default:
DefWindowProc(hWnd, message, uParam, lParam);
}
return 0;
}

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

memset(&wc,0,sizeof(wc));
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"Hello",WS_VISIBLE,0,0,240,320,0,0,hInstance,0))
{
MSG msg;

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

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

return msg.wParam;
}
}

return 0;
}

/////////////////////////////////////

The code is very simple. But when I build it, after the simulator emerged, an error message is prompt which said:

The Intelnet 80486 CPU does not support the configuaration example1 - Win32 (WCE ARM) Release!
Executable will not run on the device.

example1 is the project name I created.

The configuarations are:
Pocket PC 2002 Win32 (WCE ARM) Release Pocket PC 2002 Emulation

I tried to choose
Win32 (WCE x86) instead but get errors when compiling:

Compiling...
startup.c
C:\ppc\example1\startup.c(28) : warning C4007: 'WinMain' : must be '__stdcall'
C:\ppc\example1\startup.c(28) : error C2373: 'WinMain' : redefinition; different type modifiers
C:\Windows CE Tools\wce300\Pocket PC 2002\include\winbase.h(372) : see declaration of 'WinMain'
Error executing cl.exe.

startup.obj - 1 error(s), 1 warning(s)

Could any one give me a help? Any suggestion?

Many, many, many,... thanks!!!!!

Xiaobo :( :o :( :( :(
Well, I didn't look at your code above. But, I can tell you this much.

You cannot run code compiled for ARM release on the emulator. You have to use the x86 compiled. If you are avoiding compiling for x86 because of errors, then you will have to avoid using the emulator completely until you fix the problem.


JJB
More suitable in the Dev forum methinks.
Try changing line 28 to this:
Code:

int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)


I added the __stdcall.

Also, if you wrap your code in the [ code] [ /code] block it makes it much easier to read.

Dan East
If you look at the prototype for WinMain() in the help files, it will specify what calling convention must be used. (WINAPI/__stdcall in this case)

You *might* need to do the same with MainWndProc(). I can't remember.
As the code your using is wrong despite being simple.

You seem to be using Embedded Visual C++, go to new under file and build a PocketPC application for hello world. You only need supply a name. That will give you a working version of what you are trying to do that is similar to your code your reading.

If you are used to Windows Visual C++ when you build the equivalent app on that you will see the tiny differences PC to PPC.