|
-
Apr 7th, 2002, 12:07 PM
#1
Thread Starter
Fanatic Member
Code Condensing.
Code:
#include "stdafx.h"
#include "helloworld.h"
#include <commctrl.h>
#include <aygshell.h>
#include <sipapi.h>
What are they? It's from a sample Helloworld program in WinCE. Can I get rid of some of them?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Apr 7th, 2002, 12:35 PM
#2
PowerPoster
header files that you need to access various functions/api's
i think you need them
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 7th, 2002, 01:03 PM
#3
Thread Starter
Fanatic Member
Code:
// helloworld.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "helloworld.h"
#include <commctrl.h>
#include <aygshell.h>
#include <sipapi.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // The current instance
HWND hwndCB; // The command bar handle
static SHACTIVATEINFO s_sai;
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass (HINSTANCE, LPTSTR);
BOOL InitInstance (HINSTANCE, int);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM);
HWND CreateRpCommandBar(HWND);
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_HELLOWORLD);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// It is important to call this function so that the application
// will get 'well formed' small icons associated with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_HELLOWORLD));
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = szWindowClass;
return RegisterClass(&wc);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd = NULL;
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name
hInst = hInstance; // Store instance handle in our global variable
// Initialize global strings
LoadString(hInstance, IDC_HELLOWORLD, szWindowClass, MAX_LOADSTRING);
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
//If it is already running, then focus on the window
hWnd = FindWindow(szWindowClass, szTitle);
if (hWnd)
{
SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
return 0;
}
MyRegisterClass(hInstance, szWindowClass);
RECT rect;
GetClientRect(hWnd, &rect);
hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
//When the main window is created using CW_USEDEFAULT the height of the menubar (if one
// is created is not taken into account). So we resize the window after creating it
// if a menubar is present
{
RECT rc;
GetWindowRect(hWnd, &rc);
rc.bottom -= MENU_HEIGHT;
if (hwndCB)
MoveWindow(hWnd, rc.left, rc.top, rc.right, rc.bottom, FALSE);
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
TCHAR szHello[MAX_LOADSTRING];
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDOK:
SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
SendMessage (hWnd, WM_CLOSE, 0, 0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_CREATE:
hwndCB = CreateRpCommandBar(hWnd);
break;
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
DrawText(hdc, szHello, _tcslen(szHello), &rt,
DT_SINGLELINE | DT_VCENTER | DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
CommandBar_Destroy(hwndCB);
PostQuitMessage(0);
break;
case WM_SETTINGCHANGE:
SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
HWND CreateRpCommandBar(HWND hwnd)
{
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDM_MENU;
mbi.hInstRes = hInst;
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
if (!SHCreateMenuBar(&mbi))
return NULL;
return mbi.hwndMB;
}
// Mesage handler for the About box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
SHINITDLGINFO shidi;
switch (message)
{
case WM_INITDIALOG:
// Create a Done button and size it.
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hDlg;
SHInitDialog(&shidi);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK) {
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
Are there any that I can condense(remove)? What are they, what do they do?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Apr 7th, 2002, 01:25 PM
#4
Member
That's one hell of a Hello World program. But like he said, you'll probably need everything. Even Microsoft doesn't tend to add extra code.
-
Apr 7th, 2002, 01:40 PM
#5
PowerPoster
look at the comments. i just glanced through there pretty quickly, and it seems like everything is needed.
i have heard that programming for CE is a b***h
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 7th, 2002, 02:11 PM
#6
I think all he needs is <windows.h> and "helloworld.h", but I've never done CE. Shouldn't be too different from normal though.
No, wait, that "command bar" needs the other headers. Never seen those before.
That much stress for a menu bar...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 7th, 2002, 02:21 PM
#7
Lively Member
you can see which ones you don't need by simply taking each one out and compiling it. If it returns an error than you need it, if not, then you can take it out.
-
Apr 7th, 2002, 03:52 PM
#8
Fanatic Member
Sometimes it won't give an error, but later on it might start acting funny.
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 7th, 2002, 07:55 PM
#9
PowerPoster
where did you get the code?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 7th, 2002, 08:35 PM
#10
You could probably remove all of the stuff about the About box (the last function, and the IDM_HELP message handling in the WM_COMMAND handler). That would make it just about the size of a normal Win32 application (the format seems wierd, with window class registration delegated to functions, and such, which probably makes it seem bigger then it really is).
Z.
-
Apr 7th, 2002, 11:01 PM
#11
Fanatic Member
I guess that if you remove the stuff about the about dialog and the status bar, then it wont be a helloworld anymore... just a open and then close app... without any user interaction... but CE deos need alot of crazy things for reasons due to hardware limitations and the design of the system, etc..
-
Apr 8th, 2002, 08:16 PM
#12
Thread Starter
Fanatic Member
Code:
/***********************************************************************
FUNCTION:
lineCallbackFunc
PURPOSE:
This is a callback function invoked to determine status and events on
the line device, addresses, or calls.
***********************************************************************/
VOID CALLBACK lineCallbackFunc (DWORD hDevice,
DWORD dwMsg,
DWORD dwCallbackInstance,
DWORD dwParam1,
DWORD dwParam2,
DWORD dwParam3)
{
BOOL bCloseLine = FALSE;
LPTSTR lpszStatus;
lpszStatus = TEXT(" ");
switch (dwMsg)
{
case LINE_CALLSTATE: // Sent after change of call state
// dwParam1 is the specific CALLSTATE change that is occurring.
switch (dwParam1)
{
case LINECALLSTATE_DIALTONE:
lpszStatus = TEXT("Dial tone");
break;
case LINECALLSTATE_DIALING:
lpszStatus = TEXT("Dialing...");
break;
case LINECALLSTATE_PROCEEDING:
lpszStatus = TEXT("Dialing completed, call proceeding.");
break;
case LINECALLSTATE_RINGBACK:
lpszStatus = TEXT("Ring back");
break;
case LINECALLSTATE_CONNECTED:
lpszStatus = TEXT("Connected");
break;
case LINECALLSTATE_BUSY:
lpszStatus = TEXT("Line busy, shutting down.");
bCloseLine = TRUE;
break;
case LINECALLSTATE_IDLE:
lpszStatus = TEXT("Line is idle");
break;
case LINECALLSTATE_SPECIALINFO:
lpszStatus =TEXT("Special Information, couldn't dial number");
bCloseLine = TRUE;
break;
case LINECALLSTATE_DISCONNECTED:
{
LPTSTR lpszDisconnected;
lpszDisconnected = TEXT(" ");
switch (dwParam2)
{
case LINEDISCONNECTMODE_NORMAL:
lpszDisconnected = TEXT("Remote party disconnected");
break;
case LINEDISCONNECTMODE_UNKNOWN:
lpszDisconnected = TEXT("Disconnected: Unknown reason");
break;
case LINEDISCONNECTMODE_REJECT:
lpszDisconnected = TEXT("Remote Party rejected call");
break;
case LINEDISCONNECTMODE_PICKUP:
lpszDisconnected =
TEXT("Disconnected: Local phone picked up");
break;
case LINEDISCONNECTMODE_FORWARDED:
lpszDisconnected = TEXT("Disconnected: Forwarded");
break;
case LINEDISCONNECTMODE_BUSY:
lpszDisconnected = TEXT("Disconnected: Busy");
break;
case LINEDISCONNECTMODE_NOANSWER:
lpszDisconnected = TEXT("Disconnected: No Answer");
break;
case LINEDISCONNECTMODE_BADADDRESS:
lpszDisconnected = TEXT("Disconnected: Bad address");
break;
case LINEDISCONNECTMODE_UNREACHABLE:
lpszDisconnected = TEXT("Disconnected: Unreachable");
break;
case LINEDISCONNECTMODE_CONGESTION:
lpszDisconnected = TEXT("Disconnected: Congestion");
break;
case LINEDISCONNECTMODE_INCOMPATIBLE:
lpszDisconnected = TEXT("Disconnected: Incompatible");
break;
case LINEDISCONNECTMODE_UNAVAIL:
lpszDisconnected = TEXT("Disconnected: Unavailable");
break;
case LINEDISCONNECTMODE_NODIALTONE:
lpszDisconnected = TEXT("Disconnected: No dial tone");
break;
default:
lpszDisconnected = TEXT("Disconnected: Unknown reason");
break;
} // end switch (dwParam2)
bCloseLine = TRUE;
wcscpy(lpszStatus,lpszDisconnected);
break;
} // end case LINECALLSTATE_DISCONNECTED:
} // end switch (dwParam1)
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE, WM_SETTEXT,
0,(LPARAM)lpszStatus);
if (bCloseLine)
{
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
}
break;
case LINE_LINEDEVSTATE:
switch (dwParam1)
{
case LINEDEVSTATE_RINGING:
lpszStatus = TEXT("Ringing");
break;
case LINEDEVSTATE_OUTOFSERVICE:
lpszStatus = TEXT("The line selected is out of service.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT,0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
break;
case LINEDEVSTATE_DISCONNECTED:
lpszStatus = TEXT("The line selected is disconnected.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT,0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
break;
case LINEDEVSTATE_MAINTENANCE:
lpszStatus = TEXT("The line selected is out for maintenance.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT,0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
break;
case LINEDEVSTATE_TRANSLATECHANGE:
break;
case LINEDEVSTATE_REMOVED:
ErrorBox (
TEXT("The Line device has been removed; no action taken."));
break;
case LINEDEVSTATE_REINIT:
{
// This usually means that a service provider has changed in
// such a way that requires TAPI to REINIT. Note that there
// are both soft REINITs and hard REINITs. Soft REINITs do not
// require a full shutdown but an informational change that
// historically required a REINIT to force the application to
// deal with. TAPI API Version 1.3 applications require a
// full REINIT for both hard and soft REINITs.
switch(dwParam2)
{
// This is the hard REINIT. TAPI is waiting for everyone to
// shut down. Our response is to immediately shut down any
// calls, shut down our use of TAPI and notify the user.
case 0:
if (MessageBox (
g_hwndMain,
TEXT("Tapi line configuration has been changed. ")
TEXT("You have to shut down CeDialer to\n")
TEXT("re-initialize the use of tapi.dll. Do ")
TEXT("you want to shut down CeDialer now?"),
TEXT("Warning"),
MB_YESNO) == IDYES)
{
lineShutdown (g_hLineApp);
DestroyWindow (g_hwndMain);
}
break;
case LINE_CREATE:
lineCallbackFunc (hDevice, dwParam2, dwCallbackInstance,
dwParam3, 0, 0);
break;
case LINE_LINEDEVSTATE:
lineCallbackFunc (hDevice, dwParam2, dwCallbackInstance,
dwParam3, 0, 0);
break;
// There might be other reasons to send a soft REINIT.
// No need to shut down for these reasons.
default:
break;
}
}
default:
break;
}
break;
case LINE_REPLY:
// Reply from the lineMakeCall function.
if ((LONG)dwParam1 == g_MakeCallRequestID)
{
// If an error occurred on making the call.
if (dwParam2 != ERR_NONE)
{
lpszStatus = TEXT("Closing line");
if (dwParam2 == LINEERR_CALLUNAVAIL)
lpszStatus = TEXT("The line is not available.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial,
What the heck is this?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Apr 8th, 2002, 10:17 PM
#13
Looks like modem stuff to me...
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|