So, here is my problem.
I've done a little Today Plugin using VS2005 Beta 2.
This plugin is working really fine, I can load it, unload it, play with it ... etc.
But if I perform a soft reset while the today plugin is loaded, the pocketpc is not "booting up" anymore.
So I assume the OS has some troubles to initialize my dll ... but I really don't understand why.
I don't try to access to the storage card, even to the storage area.
I just load some files (.bmp and text files) on the InitializeCustomeItem ... and only after having checked that myDll::InitInstance has been performed.
All this plugin is based on the "standard" project: Visual C++ / SmartDevice / MFC Smart Device dll (static link)
OS: Windows Mobile 2003
Hardware: QTek 2020
Dev env: Visual Studio 2005 Beta 2
So, if someone has an idea ... it's really frustrating to have a fully functional today plugin ... and to know that a hard reset will have to be performed if a soft one is made ...
I've juste tried with the August community preview ... same issue.
I'll be happy to send the complete source code to anyone who want to help me. But don't forget to make a full backup before testing the today plugin !
just send an email to NiCkO313 at msn dot com
Thanks in advance,
Nicko.
Edit: After 2 days without answers, let me help you with a piece of my main class
Hope it will help someone to find what is going wrong with this plugin:
Edit 2: Let's try another way: Is there anybody able to write a Today Plugin using VisualStudio 2005 Using the following type of project:
Visual C++ / SmartDevice / MFC Smart Device dll (static link)
Piece of Source Code:
HWND APIENTRY InitializeCustomItem(TODAYLISTITEM *ptli, HWND hwndParent);
END_MESSAGE_MAP()
{
// TODO: add construction code here,
_hWndParent = 0;
_hWnd = 0;
_initInstancePerformed = true;
_initializeScreenPerformed = false;
}
CtodayEphemerideApp::~CtodayEphemerideApp()
{
}
// The one and only CtodayEphemerideApp object
CtodayEphemerideApp theApp;
// CtodayEphemerideApp initialization
BOOL CtodayEphemerideApp::InitInstance()
{
CWinApp::InitInstance();
HINSTANCE hInstance = AfxGetInstanceHandle();
UnregisterClass((LPCTSTR)LoadString(hInstance, IDS_TODAY_APPNAME,0,0), hInstance);
InitializeClasses();
_initInstancePerformed = true;
return TRUE;
}
void CtodayEphemerideApp::InitializeScreen()
{
HINSTANCE hInstance = AfxGetInstanceHandle();
// BUTTONS
RECT rt;
_initializeScreenPerformed = true;
}
/*************************************************************************/
/* Create and register our window class for the today item */
/*************************************************************************/
INT InitializeClasses()
{
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
HINSTANCE hInstance = AfxGetInstanceHandle();
wc.style = 0;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszClassName=(LPCTSTR)LoadString(hInstance,IDS_TODAY_APPNAME,0,0);
//register our window
if(!RegisterClass(&wc))
{
return 0 ;
}
return 1;
}
/*************************************************************************/
/* Initilize the DLL by creating a new window */
/*************************************************************************/
HWND APIENTRY InitializeCustomItem(TODAYLISTITEM *ptli,HWND hwndParent)
{
HINSTANCE hInstance = AfxGetInstanceHandle();
HWND hWnd = NULL;
if (ptli->fEnabled==0) return NULL;
((CtodayEphemerideApp*)AfxGetApp())->_currentState = L"Coming Soon :o)\0";
//create a new window
hWnd = CreateWindow(appName,appName,WS_VISIBLE | WS_CHILD,
CW_USEDEFAULT,CW_USEDEFAULT,240,0,hwndParent, NULL, hInstance, NULL) ;
// associate the window handle with the App.
((CtodayEphemerideApp*)AfxGetApp())->_hWnd = hWnd;
((CtodayEphemerideApp*)AfxGetApp())->_hWndParent = hwndParent;
((CtodayEphemerideApp*)AfxGetApp())->InitializeScreen();
return hWnd;
}
/* Main Window Message processing */
/*************************************************************************/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
HWND hWndApp = 0;
PAINTSTRUCT ps;
TODAYLISTITEM *ptli = (TODAYLISTITEM *)wParam;
switch (message)
{
case WM_TODAYCUSTOM_CLEARCACHE :
break;
case WM_TODAYCUSTOM_QUERYREFRESHCACHE:
{
BOOL bReturn = FALSE;
if (NULL == ptli)
bReturn = TRUE;
if (ptli->cyp == 0)
{
ptli->cyp = 40;
bReturn = TRUE;
}
// Updating data (will be performed only if necessary)
((CtodayEphemerideApp *) AfxGetApp())->UpdateData();
return bReturn;
}
case WM_PAINT:
{
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
SetBkMode(hdc,TRANSPARENT);
COLORREF crText;
// determine the theme's current text color
// this color will change when the user picks a ne theme,
crText = SendMessage(GetParent(hWnd), TODAYM_GETCOLOR, (WPARAM) TODAYCOLOR_TEXT, NULL);
// set that color
SetTextColor(hdc, crText);
LPCTSTR currentState = ((CtodayEphemerideApp*)AfxGetApp())->_currentState;
RECT rt_state = rt;
DrawText(hdc, currentState, -1, &rt_state, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
break;
case WM_COMMAND:
break;
// this fills in the background with the today screen image
case WM_ERASEBKGND:
hWndApp = ((CtodayEphemerideApp*)AfxGetApp())->_hWnd;
TODAYDRAWWATERMARKINFO dwi;
dwi.hdc = (HDC)wParam;
GetClientRect(hWndApp, &dwi.rc);
dwi.hwnd = hWndApp;
SendMessage(GetParent(hWndApp), TODAYM_DRAWWATERMARK, 0,(LPARAM)&dwi);
return TRUE;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

Today Plugin: Initialization issue error => Hard Reset ... healp much more appreciated
irrelevant2
If anyone is able to:
- Write a today plugin for Windows Mobile 2003 using VS2005
- Soft-reset his ppc while this plugin is enabled
==> Let me know !
Thanks.
PS: It seems that Microsoft's team are able to answer to some questions on this forum ... perhaps they could have a look to this post ;o) Many thanks in advance.
The next step is to test the "fly capability" of my pocketpc ;o)
dimx
It looks like creating a today screen plugin with MFC was not tested. I know that it is entirely possibly to create today screen plugins (because I spent an hour talking with an MVP at MEDC 2005 on this) using VS 2005, but AFAIK this was always in the context of Win32. Is it possible that you can break your dependency on MFC (yes, I realize that this could require a complete re-write)
If you have access to PB and debug hardware, I'd suggest that you set a breakpoint on LoadLibrary in the OS as the device comes up and see if there is a cycle in the DllMain calls.
I'm sorry that I can't be more help than this,
Jeff Abraham
Visual Studio
OmegaMan
So, I've write a very little plugin using a win32 dll ... and it works fine.
As my skills in Microsoft technologies are pretty poor I don't really know when to use MFC or not. It was confusing because a today screen plugin using MFC is working fine using eVC.
But as it seems that I can "easily" do not use MFC, it was a mistake to use them.
Anyway, thanks a lot.
PS: If anybody want a 'sample' today screen plugin source code, it will be a pleasure (nicko313 at msn dot com)
Nico.
X.K.
Skippy_sc
I can assure you that Pocket PCs fly incredibly well, and when VS2005 releases there may be some additional "stress testing" of devices that occurs in Redmond :)
My best guess at the moment for what is going wrong with your app is that there's a circular dependency in the libraries and that the today screen is being initialized before everything is loaded, which would not be the case if you loaded after the device was fully booted. I don't believe that we ever tested writing an MFC today screen plugin (this isn't a scenario that we thought people would try).
One of my co-workers is tracking this down, and I'll try to respond later today. Thanks,
Jeff Abraham
Visual Studio