Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 26, 2001 @ 5:58pm
by Daywalker
I want to write games for my HPC (SH3) with Windows CE 2.0. Now ive downloaded eMbedded 3.0 and i want to know how to tell eMbedded 3.0 to use the HPC 2.0 SDK.
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 26, 2001 @ 6:13pm
by Moose or Chuck
When you press New to start a new project highlight "WCE Application," not "WCE Pocket PC Application." And make sure you select the processor types you're developing for in the bottom right.
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 26, 2001 @ 7:26pm
by jongjungbu
Be sure to watch out for functions that have different arguments for 2.0 vs. 3.0. Especially when using MFC, but there are plenty of cases running around. For instance, the Random() function..you need to include the header Winuser.h in CE 3.0. For CE 1.0 or above you would include the header Winbase.h.<br><br>Of course, if yer looking at the documentation for the HPC SDK & CE 2.0, then you won't have to worry I suppose.<br><br>
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 3:34am
by Daywalker
My Application run on the HPC as long as im not including any sourcecode in the WinMain() rountine. If im trying to start the Hello World example, i get a fatal application error. Is it possible that it happens because the arguments of the Hello World example are made for CE 3.0?
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 3:43am
by jongjungbu
Hello World is a pretty simple application. I think pretty much all of the functions in it are identical for CE 1.0 and up. Are you sure you are compiling for the right CPU (device)?
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 8:10am
by Dan East
Could you post the source?<br><br>Dan East
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 9:15am
by Daywalker
The source? I click on File->New->WCE Application (processor SH3)->A Typical Hello World Application. Use SH3 Debug or Release, compile and copy the .exe to the HPC. <br>--------------------------------------------------<br>The funny thing is that it doesnt crash as long as im not implementing any Windows stuff:<br><br><br>#include "stdafx.h"<br>int WINAPI WinMain( HINSTANCE hInstance,<br> HINSTANCE hPrevInstance,<br> LPTSTR lpCmdLine,<br> int nCmdShow)<br>{<br> // TODO: Place code here.<br><br> for (int t=0; t<20000; t++) {}<br><br><br> return 0;<br>}<br><br><br>It doesnt crash, but i dont get any feedback

.
Last modification: Florian Brede - 06/27/01 at 06:15:43
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 9:44am
by Dan East
Right, what you have won't do anything. In WinMain you have to create your window, etc. The Hello World framework should create a function InitInstance, which is called from WinMain. In InitInstance the window is created. Does it work if you create a new Hello World app, and build it without modifying it?<br><br>Try hitting F5 to begin debugging on your device (with a Debug build of course). It will be very slow if you only have a serial connection, but it should show you exactly where it fails.<br><br>Also, leave all the default Processor Type boxes checked when you create a new project. Otherwise you will have to do extra work down the road if you want to build for the other types of processors.<br><br>Dan East
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 12:05pm
by Daywalker
Sorry, i cant debug, eMb 3.0 cant detect my connection.<br>I didnt modify the "Hello World" code.<br>Should programming for a HPC with wince 2.0 using HPC PRO 2.11 SDK normally work?
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 1:26pm
by jongjungbu
That is a really odd loop to be in the WinMain() function. And you say you didn't modify the Hello World at all?<br>You know, what it looks like to me is you chose "A simple Windows CE application" among a choice of "An empty project" and "A typical "Hello World!" application".<br><br>If what you posted is the complete source for your application, then I'm pretty sure that was the option for "A Simple Windows CE application".<br>You could be doing everything right, and I'm wrong..but on my eMbedded 3.0...those are the options. and that is the result.<br><br>
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 1:33pm
by Daywalker
No, what i posted wasnt the Hello World example.<br>The main sourcecode of the hello worls example is this:<br><br><br>// sdf.cpp : Defines the entry point for the application.<br>//<br><br>#include "stdafx.h"<br>#include "sdf.h"<br>#include <commctrl.h><br><br>#define MAX_LOADSTRING 100<br><br>// Global Variables:<br>HINSTANCE hInst; // The current instance<br>HWND hwndCB; // The command bar handle<br><br>// Forward declarations of functions included in this code module:<br>ATOM MyRegisterClass (HINSTANCE, LPTSTR);<br>BOOL InitInstance (HINSTANCE, int);<br>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);<br>LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM);<br><br>int WINAPI WinMain( HINSTANCE hInstance,<br> HINSTANCE hPrevInstance,<br> LPTSTR lpCmdLine,<br> int nCmdShow)<br>{<br> MSG msg;<br> HACCEL hAccelTable;<br><br> // Perform application initialization:<br> if (!InitInstance (hInstance, nCmdShow)) <br> {<br> return FALSE;<br> }<br><br> hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SDF);<br><br> // Main message loop:<br> while (GetMessage(&msg, NULL, 0, 0)) <br> {<br> if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) <br> {<br> TranslateMessage(&msg);<br> DispatchMessage(&msg);<br> }<br> }<br><br> return msg.wParam;<br>}<br><br>//<br>// FUNCTION: MyRegisterClass()<br>//<br>// PURPOSE: Registers the window class.<br>//<br>// COMMENTS:<br>//<br>// It is important to call this function so that the application <br>// will get 'well formed' small icons associated with it.<br>//<br>ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)<br>{<br> WNDCLASS wc;<br><br> wc.style = CS_HREDRAW | CS_VREDRAW;<br> wc.lpfnWndProc = (WNDPROC) WndProc;<br> wc.cbClsExtra = 0;<br> wc.cbWndExtra = 0;<br> wc.hInstance = hInstance;<br> wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SDF));<br> wc.hCursor = 0;<br> wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);<br> wc.lpszMenuName = 0;<br> wc.lpszClassName = szWindowClass;<br><br> return RegisterClass(&wc);<br>}<br><br>//<br>// FUNCTION: InitInstance(HANDLE, int)<br>//<br>// PURPOSE: Saves instance handle and creates main window<br>//<br>// COMMENTS:<br>//<br>// In this function, we save the instance handle in a global variable and<br>// create and display the main program window.<br>//<br>BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)<br>{<br> HWND hWnd;<br> TCHAR szTitle[MAX_LOADSTRING]; // The title bar text<br> TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name<br><br> hInst = hInstance; // Store instance handle in our global variable<br> // Initialize global strings<br> LoadString(hInstance, IDC_SDF, szWindowClass, MAX_LOADSTRING);<br> MyRegisterClass(hInstance, szWindowClass);<br><br> LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);<br> hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,<br> CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);<br><br> if (!hWnd)<br> { <br> return FALSE;<br> }<br><br> ShowWindow(hWnd, nCmdShow);<br> UpdateWindow(hWnd);<br> if (hwndCB)<br> CommandBar_Show(hwndCB, TRUE);<br><br> return TRUE;<br>}<br><br>//<br>// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)<br>//<br>// PURPOSE: Processes messages for the main window.<br>//<br>// WM_COMMAND - process the application menu<br>// WM_PAINT - Paint the main window<br>// WM_DESTROY - post a quit message and return<br>//<br>//<br>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br>{<br> HDC hdc;<br> int wmId, wmEvent;<br> PAINTSTRUCT ps;<br> TCHAR szHello[MAX_LOADSTRING];<br><br> switch (message) <br> {<br> case WM_COMMAND:<br> wmId = LOWORD(wParam); <br> wmEvent = HIWORD(wParam); <br> // Parse the menu selections:<br> switch (wmId)<br> {<br> case IDM_HELP_ABOUT:<br> DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);<br> break;<br> case IDM_FILE_EXIT:<br> DestroyWindow(hWnd);<br> break;<br> default:<br> return DefWindowProc(hWnd, message, wParam, lParam);<br> }<br> break;<br> case WM_CREATE:<br> hwndCB = CommandBar_Create(hInst, hWnd, 1); <br> CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);<br> CommandBar_AddAdornments(hwndCB, 0, 0);<br> break;<br> case WM_PAINT:<br> RECT rt;<br> hdc = BeginPaint(hWnd, &ps);<br> GetClientRect(hWnd, &rt);<br> LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);<br> DrawText(hdc, szHello, _tcslen(szHello), &rt, <br> DT_SINGLELINE | DT_VCENTER | DT_CENTER);<br> EndPaint(hWnd, &ps);<br> break;<br> case WM_DESTROY:<br> CommandBar_Destroy(hwndCB);<br> PostQuitMessage(0);<br> break;<br> default:<br> return DefWindowProc(hWnd, message, wParam, lParam);<br> }<br> return 0;<br>}<br><br>// Mesage handler for the About box.<br>LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)<br>{<br> RECT rt, rt1;<br> int DlgWidth, DlgHeight; // dialog width and height in pixel units<br> int NewPosX, NewPosY;<br><br> switch (message)<br> {<br> case WM_INITDIALOG:<br> // trying to center the About dialog<br> if (GetWindowRect(hDlg, &rt1)) {<br> GetClientRect(GetParent(hDlg), &rt);<br> DlgWidth = rt1.right - rt1.left;<br> DlgHeight = rt1.bottom - rt1.top ;<br> NewPosX = (rt.right - rt.left - DlgWidth)/2;<br> NewPosY = (rt.bottom - rt.top - DlgHeight)/2;<br> <br> // if the About box is larger than the physical screen <br> if (NewPosX < 0) NewPosX = 0;<br> if (NewPosY < 0) NewPosY = 0;<br> SetWindowPos(hDlg, 0, NewPosX, NewPosY,<br> 0, 0, SWP_NOZORDER | SWP_NOSIZE);<br> }<br> return TRUE;<br><br> case WM_COMMAND:<br> if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))<br> {<br> EndDialog(hDlg, LOWORD(wParam));<br> return TRUE;<br> }<br> break;<br> }<br> return FALSE;<br>}<br><br><br>But there are many other files (resources,...).<br>What should be wrong with my other sourcecode?<br><br><br><br>
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 1:39pm
by jongjungbu
Oh. Well, there doesn't seem to be anything wrong with your HelloWorld source. But, the previous source post was definitely incomplete. Ultimately, it lacked any message handling loop and thus is why its unresponsive to your input.
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 1:46pm
by Daywalker
Should this work:<br><br>// 3333e.cpp : Defines the entry point for the application.<br>//<br><br>#include "stdafx.h"<br>#include <string.h><br>#include <mmsystem.h><br>#include "resource.h"<br><br>int WINAPI WinMain( HINSTANCE hInstance,<br> HINSTANCE hPrevInstance,<br> LPTSTR lpCmdLine,<br> int nCmdShow)<br>{<br> <br><br><br> MessageBox(NULL, L"Hello",L"Hello",MB_OK | MB_ICONINFORMATION); <br><br> PlaySound(L"sound.wav",NULL,SND_FILENAME | SND_LOOP); <br> <br><br><br> //exit program <br> return(0); <br><br><br>} <br>//end WinMain <br><br><br>Ive got the wav file in the same directory.
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 1:54pm
by jongjungbu
I don't see that working. Your WinMain should initiliaze the application, yet you have not even touched the handle to the current instance of the application (hInstance). Also, you are not even displaying the main window, nor enter a message retrieval-and-dispatch loop. It's possible to make a dialog-window based application..however..you still need a message loop to capture input from the application and process it.<br>My recommendation is to use the Hello World source code and build your application from there--adding your source to it as there is not much to remove from the original source to make it your own.
Re: Develop for Windows 2.0 using eMbedded 3.0?

Posted:
Jun 27, 2001 @ 2:05pm
by Daywalker
Cant anybody else please post me the source for an app for wince2.0 (using eMB 3.0) that does nothing else than showing a messagebox?