Solved

MFC Active Window

Posted on 2004-10-11
11
414 Views
Last Modified: 2013-11-25
there are problems... two things
1- window-A is active window and is checking the port if Window-B is shown, is the previous still monitoring and updating the things on port .....or not?
2- if Port is close by some WM_MESSAGE call then how can i get it so that i can reinitate it?

Scnario is that i have open a Serial port session in Window-A main window which is recieving a huge amount of data at that momment if i active the window-B.
Is Window-A still recieving if window-B is active?
0
Comment
Question by:neutrongenious
  • 6
  • 5
11 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 12285615
Send a message from window A once per loop to window B. When window A stops its message loop window B won't receive the messages anymore. In Window B's message loop you handle that message as to setting a counter to a high value. And use a timer to decrement this counter and reinstantiate window A if the counter reaches 0.
0
 
LVL 1

Author Comment

by:neutrongenious
ID: 12285788
can you please clear it a bit more?
0
 
LVL 13

Expert Comment

by:SteH
ID: 12285860
This requires that you explain a bit what window-A and window-B is. Are those independent applications? Or threads belonging to the same application. From the first part of your Q I understood that A is checking B to be still doing something, whereas the second part clearly explains the opposite. What way is correct?

On windows since Win95 you have multitasking. That is every application gets its share from the CPU slices. On NT like OSses you can influence how much by setting either applications or threads priority and in addition by specifying that CPU slices should be given in preferences to the active application or to background services. If window-A and B are independent applications window-A should be in the background and preference could be given to background services. But transfer speed of the serial port is negliable compared to LAN or USB ports. Using a serial port with a FIFO should remove any problems from not receiving all characters under normal circumstances. If you have several dedicated high speed ports this changes a bit. But normally those are only on special cards with a driver handling that issue already for you.

0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:neutrongenious
ID: 12292759
window-A is a dialoug based window which is recieving data from serial port.
window-B is another dialog based window in same application
Now on some event e.g. datacall() window-A calls window-B.
now my question is that is window-A still handeling the data comming on serial-port......
0
 
LVL 13

Expert Comment

by:SteH
ID: 12295411
While window-A is doing datacall () it is not doing something else. So you need to assure that datacall last short enough that no data from the serial port will be lost. If datacall is not too lengthy and the hardware is almost up to date I see no problems.
0
 
LVL 1

Author Comment

by:neutrongenious
ID: 12295490
right! but there is always some data on serial port.................
hardware is ok but in this case data is always there...........in this case will it work?
0
 
LVL 13

Accepted Solution

by:
SteH earned 40 total points
ID: 12295541
Serial ports since something like 5 years have FIFO buffers integrated. That means there can be 8 to 64 bytes stored before it needs to be read.

Whether it will work depends now on the speed of the serial link, the FIFO size and the maximum delay between to read cycles on the port. With a single port I doubt that you will run into problems since the system driver might even store data in an internal buffer (kBytes) and do reads whenever there is a need.

If you want to be sure about your setup, you need to do a test to verify. Can you add checksums to the data which gets to your port?
0
 
LVL 1

Author Comment

by:neutrongenious
ID: 12307142
hun........ can you guide me how can i do this i don't know how to add the checksum?
0
 
LVL 13

Expert Comment

by:SteH
ID: 12307184
Have a look at
http://www.createwindow.com/programming/crc32/
crc32 is the most commonly used check, so it should be worth a try. Other possibilities are MD5 hash:
http://www.faqs.org/rfcs/rfc1321.html

HTH
0
 
LVL 1

Author Comment

by:neutrongenious
ID: 12332964
SteH how can i call a Modeless window window......?
0
 
LVL 13

Expert Comment

by:SteH
ID: 12336830
Create the window (CDialog derived?) and call xxx.Show ().
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Auto Apply Receivables Credit Memos to Invoices in Microsoft Dynamics GP 1 116
VS2015 compilation and missing DLLs 9 147
haveThree challenge 22 118
WPF issue with Trigger 2 106
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question