Click here to Skip to main content
15,884,353 members
Articles / Web Development / HTML

A Comprehensive CE Class Library to Replace ATL and MFC

Rate me:
Please Sign up or sign in to vote.
4.48/5 (14 votes)
4 Oct 2000CPOL 278.3K   998   70  
A collection of classes for CE that do not use ATL or MFC, plus an FTP client, database viewer, and sample application that solves beam deflection equations.
#include "stdafx.h"
#include "CeDebug.h"
#include "CeMisc.h"
#include "CeModule.h"

HWND CeGetAppWindow()
{
	CeAppModule* pApp = CeAppModule::CeGetApp();

	if (NULL == pApp || NULL == pApp->GetMainWindow())
		// this windows in probably the active windows, since the GUI probably
		// wouldn't even be active if it weren't top level
		return GetActiveWindow();
	else
		// the user assigned a main window, use it
		return pApp->GetMainWindow();
}


HINSTANCE CeGetAppInstance()
{
#if (_WIN32_WCE >= 210) || !UNDER_CE

	return (HINSTANCE) GetModuleHandle(NULL);

#elif _WIN32_WCE_EMULATION

	MEMORY_BASIC_INFORMATION mbi={0};
	VirtualQuery(CeGetAppInstance, &mbi, sizeof mbi);
	return (HINSTANCE) mbi.AllocationBase;

#else

	return (HINSTANCE) GetCurrentProcessId();

#endif
}

#ifdef _WIN32_WCE_PSPC

#include <aygshell.h>
BOOL CeShowSip(BOOL bShow)
{
	SIPINFO si;
	memset(&si,0, sizeof(si));    // to initialize si to zero.
	si.cbSize = sizeof(si);
	if ( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0))
	{
		if(bShow)
			si.fdwFlags |= SIPF_ON;
		else
			si.fdwFlags &= ~SIPF_ON;

		return SHSipInfo( SPI_SETSIPINFO, 0, &si, 0);
	}
	return FALSE;
}

BOOL CeSipSizeWindow( HWND hwnd )
{
	SIPINFO si;
	ZeroMemory(&si, sizeof(si));
	si.cbSize = sizeof(si);
	if ( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0) )
	{
		CeRect rc = si.rcVisibleDesktop;
		MoveWindow( hwnd, rc.left, rc.top, rc.Width(), rc.Height(),	TRUE);
		return TRUE;
	}

	return FALSE;
}

BOOL CeSipCenterWindow( HWND hwnd )
{
//	if (GetParent(hwnd))
//		// only top level windows!!!
//		return FALSE;

	SIPINFO si;
	ZeroMemory(&si, sizeof(si));
	si.cbSize = sizeof(si);
	if ( SHSipInfo( SPI_GETSIPINFO, 0, &si, 0) )
	{
		CeRect rc;
		GetWindowRect(hwnd, &rc);

		// center within open screen coordinates
		CeRect rcArea = si.rcVisibleDesktop;

		// find dialog's upper left based on rcCenter
		int xLeft = (rcArea.Width()) / 2 - rc.Width() / 2;
		int yTop = (rcArea.Height()) / 2 - rc.Height() / 2;

		// if the dialog is outside the screen, move it inside
		if (xLeft < rcArea.left)
			xLeft = rcArea.left;
		else if(xLeft + rc.Width() > rcArea.right)
			xLeft = rcArea.right - rc.Width();

		if (yTop < rcArea.top)
			yTop = rcArea.top;
		else if(yTop + rc.Height() > rcArea.bottom)
			yTop = rcArea.bottom - rc.Height();

		MoveWindow(hwnd, xLeft, yTop, rc.Width(), rc.Height(), TRUE);
		return TRUE;
	}

	return FALSE;
}

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions