Microsoft KB Archive/278512

= BUG: Visual FoxPro May Ignore DDE Messages =

Article ID: 278512

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q278512



SYMPTOMS
You are using DDEAdvise to receive messages. Under a variety of system loads, Visual FoxPro (VFP) may ignore these DDEAdvise messages. The behavior does not produce an error that warns the user that the message was dropped.



CAUSE
Dynamic data exchange (DDE) is an older method for inter-application communication, which has been supplanted by newer technologies.



RESOLUTION
If possible, use a different technology than DDE, such as COM.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a directory to hold the files that you will create in the steps that follow.  Paste the following code in a file named DDEForm.prg: PUBLIC loForm

loForm = CREATEOBJECT(&quot;DDEForm&quot;) loForm.Visible = .T.

DEFINE CLASS DDEForm AS form

Caption = &quot;DDE Server&quot; Name = &quot;DDEForm&quot; lDone = .F.  nChannel = 0 cItem = &quot;&quot;

ADD OBJECT cmdStartConn AS commandbutton WITH ; AutoSize = .T., ; Top = 24, ; Left = 24, ; Height = 27, ; Width = 109, ; Caption = &quot;Start Connection&quot;, ; Name = &quot;cmdStartConn&quot;

ADD OBJECT cmdEndConn AS commandbutton WITH ; AutoSize = .T., ; Top = 108, ; Left = 24, ; Height = 27, ; Width = 106, ; Caption = &quot;End Connection&quot;, ; Name = &quot;cmdEndConn&quot;

ADD OBJECT cmdStartData AS commandbutton WITH ; Top = 24, ; Left = 156, ; Height = 27, ; Width = 84, ; Caption = &quot;Start Data&quot;, ; Name = &quot;cmdStartData&quot;

ADD OBJECT cmdEndData AS commandbutton WITH ; Top = 108, ; Left = 156, ; Height = 27, ; Width = 84, ; Caption = &quot;End Data&quot;, ; Name = &quot;cmdEndData&quot;

PROCEDURE QueryUnload This.ReleaseConn ENDPROC

PROCEDURE ReleaseConn =DDESetService(&quot;VFPServer&quot;, &quot;release&quot;) ENDPROC PROCEDURE FastDoEvents *!* From Q268771 BUG: DOEVENTS Command Runs Slowly LOCAL lnRow, lnCol, lcWindow

lcWindow = WONTOP

lnRow = MROW(lcWindow) lnCol = MCOL(lcWindow)

IF ( lnRow > 0 ) AND ( lnCol > 0 ) IF NOT EMPTY(lcWindow) MOUSE AT lnRow, lnCol WINDOW (lcWindow) ELSE MOUSE AT lnRow, lnCol ENDif ELSE KEYBOARD &quot; &quot; =INKEY ENDif

DOEVENTS ENDPROC PROCEDURE cmdStartConn.Click =DDESetService(&quot;VFPServer&quot;, &quot;define&quot;) =DDESetService(&quot;VFPServer&quot;, &quot;advise&quot;, .T.)

=DDESetTopic(&quot;VFPServer&quot;, &quot;TestSequence&quot;, &quot;cbSequence&quot;) ENDPROC

PROCEDURE cmdEndConn.Click ThisForm.ReleaseConn ENDPROC

PROCEDURE cmdStartData.Click LOCAL i

i = 0

DO WHILE NOT ThisForm.lDone lnChannel = ThisForm.nChannel lcItem = ThisForm.cItem lcData = &quot;Item &quot; + LTRIM(STR(i, 10, 0)) =DDEPoke(lnChannel, lcItem, lcData) i = i + 1

ThisForm.FastDoEvents && To allow cmdEndData to be clicked ENDdo ENDPROC

PROCEDURE cmdEndData.Click ThisForm.lDone = .T.  ENDPROC

ENDDEFINE   Paste the following code in a file named cbSequence.prg: LPARAMETERS tnChannel, tcAction, tcItem, tcData, tcFormat, tnStatus

WAIT WINDOW &quot;Advising&quot; NOWAIT _SCREEN.ActiveForm.nChannel = tnChannel _SCREEN.ActiveForm.cItem = tcItem   Create a table to log the results using the following code: CREATE TABLE SaveVal (cData C(10))   Paste the following code in a file named cbSaveIt.prg: LPARAMETERS tnChannel, tcAction, tcItem, tcData, tcFormat, tnStatus

IF NOT USED(&quot;SaveVal&quot;) USE SaveVal IN 0 SHARED ENDif

INSERT INTO saveVal VALUES (tcData) </li> Run DDEForm.prg, and click Start Connection.</li> Start another instance of VFP, and SET DEFAULT TO the directory where the files are stored.</li>  Type the following lines in the Command window: lnChannel = DDEInitiate(&quot;VFPServer&quot;, &quot;TestSequence&quot;) ? DDEAdvise(lnChannel, &quot;TestSequence&quot;, &quot;cbSaveIt&quot;, 2) </li> Switch to the first instance, and click the Start Data button.</li>  Switch to the second instance, and type the following code in the Command window: SET REFRESH TO 5,5 BROWSE </li></ol>

After a while, you should observe that during times of system load, numbers in the sequence may be dropped without notice. If the load is heavier, more messages will be dropped.

Keywords: kbbug kbnofix KB278512

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.