NEURON
ms1.cpp
Go to the documentation of this file.
1 #include "../winio/debug.h"
2 
3 #include <stdio.h>
4 #include <string.h>
5 #include <windows.h>
6 #pragma hdrstop
7 #include <ddeml.h>
8 #include <dde.h>
9 #include <windowsx.h>
10 extern "C" {
11 extern void HandleOutput(const char*);
12 extern DWORD idInst; /* Instance of app for DDEML */
13  HCONV hConvExtra;
14 }
15 static HSZ hszService;
16 static HSZ hszTopic;
17 static HSZ hszItem;
18 static HDDEDATA hData;
19 static DWORD dwResult;
20 static WORD wFmt = CF_TEXT; /* Clipboard format */
21 static char szDDEData[256]; /* Local receive data buffer */
22 
23 int start() {
24 HandleOutput("hel2mos start-\n");
25  if (!idInst) {
26  MessageBox(NULL, "idInst is 0", "ochelp start", MB_OK);
27  return 0;
28  }
29  hszService = DdeCreateStringHandle ( idInst, "NETSCAPE", CP_WINANSI );
30  hszTopic = DdeCreateStringHandle ( idInst, "WWW_OpenURL", CP_WINANSI );
31  hszItem = DdeCreateStringHandle ( idInst, "NetscapeData", CP_WINANSI );
32  hConvExtra = DdeConnect ( idInst, hszService, hszTopic,
33  (PCONVCONTEXT) NULL );
34  if (!hConvExtra) {
35  MessageBox(NULL, "Conversation not established with NETSCAPE",
36  "ochelp start", MB_OK);
37  return 0;
38  }
39 HandleOutput("Conversation established with NETSCAPE\n");
40  return 1;
41 }
42 
43 void stop() {
44 HandleOutput("hel2mos stop-\n");
45  if (hConvExtra) {
46  DdeDisconnect ( hConvExtra );
47  }
48  if (idInst) {
49  DdeFreeStringHandle ( idInst, hszService );
50  DdeFreeStringHandle ( idInst, hszTopic );
51  DdeFreeStringHandle ( idInst, hszItem );
52  }
53 }
54 
55 
56 static void take(HCONV hc, const char* name) {
57  if ( hc != (HCONV)NULL ){
58  DdeFreeStringHandle(idInst, hszItem);
59  sprintf(szDDEData, "%s,,0xFFFFFFFF,0x0,,", name);
60  hszItem = DdeCreateStringHandle ( idInst, (LPTSTR)szDDEData, CP_WINANSI );
61 
62  hData = DdeClientTransaction ( NULL, 0, hc,
63  hszItem, wFmt, XTYP_REQUEST, 1000, &dwResult );
64  if (!hData) {
65  MessageBox(NULL, szDDEData, "WWW_OpenURL failed", MB_OK);
66  }
67  }else{
68  HandleOutput( "A connection to Netscape via DDE is not established." );
69  }
70 }
71 
72 void send(const char* url) {
73 // HandleOutput("hel2mos %s\n", url);
74  take(hConvExtra, url);
75 }
76 
static HSZ hszService
Definition: ms1.cpp:15
static HSZ hszTopic
Definition: ms1.cpp:16
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
static void take(HCONV hc, const char *name)
Definition: ms1.cpp:56
HCONV hConvExtra
Definition: ms1.cpp:13
int start()
Definition: ms1.cpp:23
static HSZ hszItem
Definition: ms1.cpp:17
DWORD idInst
Definition: ddeclnt.cpp:21
static DWORD dwResult
Definition: ms1.cpp:19
void stop()
Definition: ms1.cpp:43
char * name
Definition: init.cpp:16
static WORD wFmt
Definition: ms1.cpp:20
static HDDEDATA hData
Definition: ms1.cpp:18
void HandleOutput(const char *)
Definition: hel2mos.cpp:18
return NULL
Definition: cabcode.cpp:461
static char szDDEData[256]
Definition: ms1.cpp:21
void send(const char *url)
Definition: ms1.cpp:72