home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Movie Guide 3.5
/
MEGA_MOVIE_.iso
/
_assist
/
ddetest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-08
|
22KB
|
667 lines
// DDETEST.C
//
// Written by Albert J. Lee alee@spyglass.com
//
// (C) Copyright Spyglass Inc., 1995. All rights reserved.
//
// You have a royalty-free right to use, modify, reproduce and
// distribute the files used to build DDETEST.EXE in
// any way you find useful, provided that you agree that
// Spyglass has no warranty obligations or liability. The source
// code is provided "as is". Your use of the source code indicates
// your acceptance of these terms.
#include <windows.h>
#include <ddeml.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include "ddetest.h"
#ifdef _WIN32
#undef _export
#define _export
#endif
static HANDLE ghInst;
static HWND hwndDialog;
static HWND hModeless;
static DWORD dwInst = 0;
static HCONV hConv = (HCONV) NULL;
static LONG lProc;
static HSZ hszService;
static HSZ hszMosaicService;
static char *pTopic;
static char *pCommand;
static FARPROC lpfnMLEProc;
static FARPROC lpfnResponseProc;
//static FARPROC lpfnDDEProc;
static PFNCALLBACK lpfnDDEProc;
static FARPROC lpfnRegisterProc;
static char szService[256];
static HSZPAIR ahszp[CTOPICS + 1];
static char pDataBuffer[256];
LRESULT CALLBACK _export WndProc(HWND, UINT, UINT, LONG);
LRESULT CALLBACK _export MLEProc(HWND hwnd, UINT message, UINT wParam, LONG lParam);
BOOL CALLBACK _export ResponseProc(HWND hwnd, UINT message, UINT wParam, LONG lParam);
BOOL CALLBACK _export RegisterProc(HWND hwnd, UINT message, UINT wParam, LONG lParam);
HDDEDATA CALLBACK _export DdeCallBack(uType, uFmt, hconv, hsz1, hsz2, hdata, dwData1, dwData2)
UINT uType; /* transaction type */
UINT uFmt; /* clipboard data format */
HCONV hconv; /* handle of the conversation */
HSZ hsz1; /* handle of a string */
HSZ hsz2; /* handle of a string */
HDDEDATA hdata; /* handle of a global memory object */
DWORD dwData1; /* transaction-specific data */
DWORD dwData2; /* transaction-specific data */
{
DWORD length;
char *pBuffer;
long bExiting;
char szTemp[1000];
long i;
HDDEDATA hReturn;
long lReturn;
DdeQueryString(dwInst, hsz1, szTemp, sizeof(szTemp), CP_WINANSI);
switch(uType)
{
case XTYP_REQUEST:
if( ! _strnicmp( szTemp, "DIALER_", 7 ) )
{
long lDoesNotMatter = 1;
SendMessage(GetDlgItem(hwndDialog, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) (char *) szTemp);
ShowWindow(GetDlgItem(hwndDialog, IDC_PROGRESSVALUE), SW_HIDE);
i = (int) SendMessage(GetDlgItem(hwndDialog, IDC_LIST), LB_GETCOUNT, 0, 0);
SendMessage(GetDlgItem(hwndDialog, IDC_LIST), LB_SETCURSEL, (WPARAM) i - 1, 0);
hReturn = DdeCreateDataHandle(dwInst, (LPBYTE) &lDoesNotMatter, sizeof(lDoesNotMatter), 0,
hszService, CF_TEXT, 0);
return( hReturn );
}
lReturn = DDE_FACK;
hReturn = DdeCreateDataHandle(dwInst, (LPBYTE) &lReturn, sizeof(lReturn), 0,
hszService, CF_TEXT, 0);
return( hReturn );
//return DDE_FACK;
case XTYP_POKE:
break;
case XTYP_CONNECT:
hReturn = (HDDEDATA)(hszService == hsz2 );
return hReturn;
case XTYP_WILDCONNECT:
ahszp[0].hszTopic = hsz1;
ahszp[0].hszSvc = hszService;
// null terminate the array
ahszp[1].hszTopic = NULL;
ahszp[1].hszSvc = NULL;
return( DdeCreateDataHandle(dwInst, (LPBYTE) &ahszp, sizeof( ahszp), 0,
(HSZ)NULL, 0, 0));
default:
break;
}
return 0;
}
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
static char szServiceName[] = "ddetest" ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
pCommand = lpszCmdParam;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szServiceName ;
RegisterClass (&wndclass) ;
}
ghInst = hInstance;
#ifdef _WIN32
lpfnMLEProc = MLEProc;
lpfnResponseProc = ResponseProc;
//lpfnDDEProc = DdeCallBack;
lpfnDDEProc = MakeProcInstance( (PFNCALLBACK)DdeCallBack, ghInst);
lpfnRegisterProc = RegisterProc;
#else
lpfnMLEProc = MakeProcInstance((FARPROC) MLEProc, ghInst);
lpfnResponseProc = MakeProcInstance((FARPROC) ResponseProc, ghInst);
lpfnDDEProc = MakeProcInstance((FARPROC) DdeCallBack, ghInst);
lpfnRegisterProc = MakeProcInstance((FARPROC) RegisterProc, ghInst);
#endif
hwnd = CreateWindow (szServiceName, // window class name
"DDE Test", // window caption
WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,
0, 0, 200, 400,
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow(hwnd, nCmdShow);
//WinExec( "d:\\dev\\win\\dialer\\dialer\\airdial.exe", SW_MINIMIZE );
while (GetMessage (&msg, NULL, 0, 0))
{
if (!IsWindow(hModeless) || !IsDialogMessage(hModeless, &msg))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
#ifndef _WIN32
FreeProcInstance(lpfnMLEProc);
FreeProcInstance(lpfnResponseProc);
FreeProcInstance(lpfnDDEProc);
FreeProcInstance(lpfnRegisterProc);
#endif
return msg.wParam ;
}
BOOL CALLBACK _export DialogProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
char szTopic[256];
char szMessage[256];
char szTemp[100];
char szArg[1000];
static HSZ hszTopic = (HSZ) NULL;
static HSZ hszItem = 0;
LRESULT count, length;
HWND h;
long i;
HDDEDATA trans_ret;
long long_result;
switch(message)
{
case WM_INITDIALOG:
DialogBox(ghInst, MAKEINTRESOURCE(ID_REGISTER), hwnd, lpfnRegisterProc);
EnableWindow(GetDlgItem(hwnd, IDC_APPLICATION), FALSE);
hModeless = hwnd;
lProc = GetWindowLong(GetDlgItem(hwnd, IDC_ARGS), GWL_WNDPROC);
SetWindowLong(GetDlgItem(hwnd, IDC_ARGS), GWL_WNDPROC, (LONG) lpfnMLEProc);
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_SETHORIZONTALEXTENT, 0x7FFF, 0);
SetWindowText(GetDlgItem(hwnd, IDC_APPLICATION), szService);
h = GetDlgItem(hwnd, IDC_COMMAND);
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_WinExec");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_DIAL");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_DIALQUIET");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_CANCELDIAL");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_INICHANGE");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_SHUTDOWN");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_SHUTDOWNQUIET");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_MODEMHANGUP");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_MODEMHANGUPQUIET");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_POST_DIALMODE");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_POST_DIALSTATE");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_TOGGLE_QUIETMODE");
SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_TOGGLE_DASHBOARD");
//SendMessage( h, CB_ADDSTRING, 0, (LPARAM) (char *) "DIALER_TOGGLE_PACKETMODE");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_OpenURL");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_OpenURLResult");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_Activate");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_ListWindows");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_GetWindowInfo");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_Exit");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_RegisterProtocol");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_UnRegisterProtocol");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_RegisterViewer");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_UnRegisterViewer");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_ParseAnchor");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_RegisterWindowClose");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_UnRegisterWindowClose");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_BeginProgress");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_SetProgressRange");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_MakingProgress");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_EndProgress");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_RegisterURLEcho");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_UnRegisterURLEcho");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_ShowFile");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_QueryVersion");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_CancelTransaction");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_RegisterDone");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_NavFwd");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_NavBack");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_NavHome");
// SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (char *) "WWW_NavReload");
// make sure there is an entry in the window
// SendMessage(h, CB_SETCURSEL, 0, (LPARAM) 0l );
// Add the command line to listbox
// sprintf(szTemp, "Command line: %s", pCommand);
// SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) szTemp);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_HELP:
GetWindowsDirectory(szArg, sizeof(szArg));
if (szArg[strlen(szArg) - 1] != '\\')
strcat(szArg, "\\");
strcat(szArg, "WINHELP DDETEST.HLP");
WinExec(szArg, SW_SHOW);
break;
case IDC_SEND:
GetWindowText(GetDlgItem(hwnd, IDC_COMMAND), szTopic, sizeof(szTopic));
if (strlen(szTopic) == 0)
break;
// Compose the argument string
count = SendMessage(GetDlgItem(hwnd, IDC_ARGS), EM_GETLINECOUNT, 0, 0);
memset(szArg, 0, sizeof(szArg));
for (i = 0; i < count; i++)
{
memset(szTemp, 0, sizeof(szTemp));
*((WORD *) szTemp) = sizeof(szTemp) - sizeof(WORD);
length = SendMessage(GetDlgItem(hwnd, IDC_ARGS), EM_GETLINE, (WPARAM) i, (LPARAM) szTemp);
if (length)
strcat(szArg, szTemp);
if (i != count - 1)
strcat(szArg, ",");
}
// tell the dialer to start dialing
// if( stricmp( szTopic, "Dial") == 0 )
// {
// HWND hWndDialer = NULL;
// hWndDialer = FindWindow( "AfxFrameOrView", NULL);
// if( hWndDialer )
// {
// SendMessage( hWndDialer, WM_COMMAND, (WPARAM)32789, 0l);
// }
// }
if (hszTopic)
DdeFreeStringHandle(dwInst, hszTopic);
hszTopic = DdeCreateStringHandle(dwInst, szTopic, CP_WINANSI);
if (hszItem)
DdeFreeStringHandle(dwInst, hszItem);
hszItem = DdeCreateStringHandle(dwInst, szArg, CP_WINANSI);
if (!hszItem)
{
// Item name cannot be 0, so make up some name
hszItem = DdeCreateStringHandle(dwInst, szService, CP_WINANSI);
}
hConv = DdeConnect(dwInst, hszMosaicService, hszTopic, NULL);
sprintf(szMessage, "Connect handle: %ld (0 means fail)", hConv);
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) szMessage);
if (strcmp(szTopic, "WWW_Exit") == 0 ||
strcmp(szTopic, "WWW_RegisterDone") == 0)
{
// Poke
trans_ret = DdeClientTransaction(NULL, 0, hConv, hszItem, CF_TEXT, XTYP_POKE,
60000, NULL);
}
else
{
// Request
trans_ret = DdeClientTransaction(NULL, 0, hConv, hszItem, CF_TEXT, XTYP_REQUEST,
60000, NULL);
}
if( strcmp( szTopic, "DIALER_MODEMHANGUP" ) == 0 ||
strcmp( szTopic, "DIALER_MODEMHANGUPQUIET" ) == 0 ||
strcmp( szTopic, "DIALER_SHUTDOWN" ) == 0 ||
strcmp( szTopic, "DIALER_INICHANGE" ) == 0 ||
strcmp( szTopic, "DIALER_CANCELDIAL" ) == 0 ||
strcmp( szTopic, "DIALER_DIAL" ) == 0 ||
strcmp( szTopic, "DIALER_DIALQUIET" ) == 0 )
{
if (trans_ret != DDE_FNOTPROCESSED)
{
long *pBuffer;
long itemcount;
// get the first long to see how many items exist
pBuffer = (long *) malloc(sizeof(long));
DdeGetData(trans_ret, (LPBYTE) pBuffer, sizeof(long), 0);
itemcount = *pBuffer;
free(pBuffer);
pBuffer = (long *) malloc((size_t) sizeof(long) * (size_t) itemcount);
DdeGetData(trans_ret, (LPBYTE) pBuffer, itemcount * sizeof(long), sizeof(long));
DdeFreeDataHandle(trans_ret);
strcpy(szArg, "Transaction result: ");
// caution: we are limited to 1000 characters total, but no checking will be
// done (because szArg is char[1000])
for (i = 0; i < itemcount; i++)
{
sprintf(szMessage, " %ld", pBuffer[i]);
strcat(szArg, szMessage);
}
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) szArg);
free(pBuffer);
}
else
{
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) (char *) "Transaction failed.");
}
}
// else if( strcmp( szTopic, "DIALER_WINEXEC" ) == 0 )
// {
//
//
// }
else if (strcmp(szTopic, "WWW_ListWindows") == 0)
{
// specialized return value
if (trans_ret != DDE_FNOTPROCESSED)
{
long *pBuffer;
long itemcount;
// get the first long to see how many items exist
pBuffer = (long *) malloc(sizeof(long));
DdeGetData(trans_ret, (LPBYTE) pBuffer, sizeof(long), 0);
itemcount = *pBuffer;
free(pBuffer);
pBuffer = (long *) malloc((size_t) sizeof(long) * (size_t) itemcount);
DdeGetData(trans_ret, (LPBYTE) pBuffer, itemcount * sizeof(long), sizeof(long));
DdeFreeDataHandle(trans_ret);
strcpy(szArg, "Transaction result: ");
// caution: we are limited to 1000 characters total, but no checking will be
// done (because szArg is char[1000])
for (i = 0; i < itemcount; i++)
{
sprintf(szMessage, " %ld", pBuffer[i]);
strcat(szArg, szMessage);
}
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) szArg);
free(pBuffer);
}
else
{
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) (char *) "Transaction failed.");
}
}
else if (strcmp(szTopic, "WWW_GetWindowInfo") == 0 ||
strcmp(szTopic, "WWW_ParseAnchor") == 0 ||
strcmp(szTopic, "WWW_QueryVersion") == 0)
{
// string return value
if (trans_ret != DDE_FNOTPROCESSED)
{
char *pBuffer, *pTemp;
long bufsize;
bufsize = DdeGetData(trans_ret, NULL, 0, 0); // get length
pBuffer = malloc((int) bufsize + sizeof(char)); // 1 extra for terminator
DdeGetData(trans_ret, (LPBYTE) pBuffer, bufsize, 0); // get data
pBuffer[bufsize] = '\0'; // null terminate
DdeFreeDataHandle(trans_ret); // free handle
pTemp = malloc((int) bufsize + 100);
sprintf(pTemp, "Transaction result: %s", pBuffer);
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) pTemp);
free(pTemp);
free(pBuffer);
}
else
{
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) (char *) "Transaction failed.");
}
}
else if (strcmp(szTopic, "WWW_UnRegisterViewer") == 0 ||
strcmp(szTopic, "WWW_Exit") == 0 ||
strcmp(szTopic, "WWW_UnRegisterProtocol") == 0 ||
strcmp(szTopic, "WWW_RegisterDone") == 0 ||
strcmp(szTopic, "WWW_OpenURLResult") == 0)
{
// no return value
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0,
(LPARAM) (char *) "Mosaic does not return any value for this verb.");
}
else if //(strcmp(szTopic, "WWW_RegisterProtocol") == 0 ||
( strcmp(szTopic, "WWW_RegisterViewer") == 0 ||
strcmp(szTopic, "WWW_Activate") == 0 ||
strcmp(szTopic, "WWW_OpenURL") == 0 ||
//strcmp(szTopic, "WWW_RegisterWindowClose") == 0 ||
//strcmp(szTopic, "WWW_UnRegisterWindowClose") == 0 ||
strcmp(szTopic, "WWW_BeginProgress") == 0 ||
strcmp(szTopic, "WWW_SetProgressRange") == 0 ||
strcmp(szTopic, "WWW_MakingProgress") == 0 ||
strcmp(szTopic, "WWW_EndProgress") == 0 ||
//strcmp(szTopic, "WWW_RegisterURLEcho") == 0 ||
//strcmp(szTopic, "WWW_UnRegisterURLEcho") == 0 ||
//strcmp(szTopic, "WWW_ShowFile") == 0 ||
strcmp( szTopic, "WWW_NavFwd" ) == 0 ||
strcmp( szTopic, "WWW_NavBack" ) == 0 ||
strcmp( szTopic, "WWW_NavHome" ) == 0 ||
strcmp( szTopic, "WWW_NavReload" ) == 0 ||
strcmp(szTopic, "WWW_CancelTransaction") == 0)
{
// long integer return value
if (trans_ret != DDE_FNOTPROCESSED)
{
DdeGetData(trans_ret, (LPBYTE) &long_result, sizeof(long_result), 0);
DdeFreeDataHandle(trans_ret);
sprintf(szMessage, "Transaction result: %ld", long_result);
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) szMessage);
}
else
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_ADDSTRING, 0, (LPARAM) (char *) "Transaction failed.");
}
i = (int) SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_GETCOUNT, 0, 0);
SendMessage(GetDlgItem(hwnd, IDC_LIST), LB_SETCURSEL, (WPARAM) i - 1, 0);
if (hConv)
DdeDisconnect(hConv);
break;
case IDC_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case IDC_CLEARLIST:
SendDlgItemMessage(hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0);
break;
case IDC_CLEARARGUMENTS:
SetDlgItemText(hwnd, IDC_ARGS, "");
SetFocus(GetDlgItem(hwnd, IDC_ARGS));
break;
}
return TRUE;
case WM_CLOSE:
SetWindowLong(GetDlgItem(hwnd, IDC_ARGS), GWL_WNDPROC, lProc);
DdeNameService(dwInst, hszService, 0, DNS_UNREGISTER);
if (hszService)
DdeFreeStringHandle(dwInst, hszService);
if (hszTopic)
DdeFreeStringHandle(dwInst, hszTopic);
if (hszItem)
DdeFreeStringHandle(dwInst, hszItem);
if (hszMosaicService)
DdeFreeStringHandle(dwInst, hszMosaicService);
DdeUninitialize(dwInst);
hModeless = NULL;
DestroyWindow(GetParent(hwnd));
return TRUE;
}
return FALSE;
}
LRESULT CALLBACK _export WndProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
switch(message)
{
case WM_CREATE:
hwndDialog = CreateDialog(ghInst, MAKEINTRESOURCE(ID_DIALOG), hwnd, DialogProc);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return (DefWindowProc(hwnd, message, wParam, lParam));
}
LRESULT CALLBACK _export MLEProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
switch (message)
{
case WM_KEYDOWN:
if (VK_RETURN == wParam)
{
PostMessage(hwnd, WM_CHAR, 0x0A, 0L);
return 0L;
}
break;
default:
break;
}
return (LRESULT) (CallWindowProc((FARPROC) lProc, hwnd, message, wParam, lParam));
}
BOOL CALLBACK _export ResponseProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
static char *pBuffer;
switch(message)
{
case WM_INITDIALOG:
pBuffer = (char *) lParam;
SetWindowText(GetDlgItem(hwnd, IDC_TOPIC), pTopic);
MessageBeep(0);
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
GetWindowText(GetDlgItem(hwnd, IDC_RESPONSE), pBuffer, 1000);
EndDialog(hwnd, TRUE);
}
else if (LOWORD(wParam) == IDCANCEL)
EndDialog(hwnd, FALSE);
break;
}
return FALSE;
}
BOOL CALLBACK _export RegisterProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
switch(message)
{
case WM_INITDIALOG:
SetWindowText(GetDlgItem(hwnd, IDC_DDENAME), "ddetest");
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
if (dwInst == 0)
DdeInitialize(&dwInst, (PFNCALLBACK) lpfnDDEProc, APPCLASS_STANDARD, 0);
hszMosaicService = DdeCreateStringHandle(dwInst, "SPRYDIALER", CP_WINANSI);
GetWindowText(GetDlgItem(hwnd, IDC_DDENAME), szService, sizeof(szService));
hszService = DdeCreateStringHandle(dwInst, szService, CP_WINANSI);
if (DdeNameService(dwInst, hszService, 0, DNS_REGISTER))
{
EndDialog(hwnd, TRUE);
return 0;
}
MessageBox(hwnd, "Registration failed. Try using another name.", "Error", MB_OK);
//DdeFreeStringHandle(dwInst, hszMosaicService);
//DdeFreeStringHandle(dwInst, hszService);
}
break;
}
return FALSE;
}