|
|
I have a console app that reads and writes from a virtual comport pair.
It works great when only one instance of the program is running. But when I execute another app that opens a different virtual comport pair, I get some strange errors. I have tried different (brand) virtual comport devices, resulting in the same effect.
Once I enter data on the comport for the second application to read, the first app will respond erroneously. The second app fails to perform as it should as well.
So my real question: Do console apps share memory space somehow? These are not threads but separate processes.
Any help is appreciated.
Thanks.
|
|
|
|
|
switang wrote: So my real question: Do console apps share memory space somehow? These are not threads but separate processes.
No, but the virtual com port might be doing so.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I never have any problems when using terminals to connect between the comports. I'd rule out the virtual ports as the culprit. I've used two different virtual devices (com0com and VSPD).
I have noticed that entering data in the input com of one app causes the other app to respond as if it received data.
I'll have to try this setup on another system to rule mine out.
|
|
|
|
|
switang wrote: I never have any problems when using terminals to connect between the comports.
What I meant was that it might create the same buffer for multiple connections. Thus, if you have 2 programs opening a virtual port to talk to each other, and then you open another instance of each program, depending on how the virtual com ports are implemented (e.g. if they are a COM service), they may be considered the same session, or may try to use the same buffers.
switang wrote: I have noticed that entering data in the input com of one app causes the other app to respond as if it received data.
So if you enter data in 1 of the apps, both the app you expect to received the data and the app you don't expect to receive it are getting it? If that is the case, it would seem to indicate what I said above (and that the virtual port isn't thread-safe).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
It's beginning to look like a problem with my system. If I figure something out I'll try to post.
Thanks for the input.
|
|
|
|
|
I am modifying a MFC based C++ application which I have migrated from VS6 to VS8. Several months ago I was surfing the Internet and came across a forum post somewhere (I can't remember where) that described oring together two button styles I recall (BS_PUSHBUTTON, etc.) which generated a button that looks like a tab with rounded corners on the top and flaired corners at the bottom. This apparently was an undocumented feature of VS. I, in fact, modified the dwStyle parameter of a button creation and was able to observe it generate this tab-like shape. I mentally filed away this interesting feature as possibly useful in the future -- big mistake as I forgot the details. I now have a project that needs exactly such a button shape and cannot recall the details or how to generate it. Is there a programmer out there that can tell me what dwStyle parameters can be used to generate this tab shaped button.
|
|
|
|
|
Hello all Are you concerntating?
Yes, good. I am wondering it anyone knows the answer to
this topic or can point me in the right direction.
I'll elaborate upon my query. Thus any replies I get
(hopefully), will be answeredin the correct context.
Below are is a sample three controls.
- A standalone control (Demo control 1)
- Another standalone control (Demo control 2)
- A meta control which has its own features as well as
containing controls (1 & 2 above)
When I build the first two, they both build and register successfully. I can
use either (or both) on other projects as child windows. i.e. VC dialogues, VB
forms, Delphi Forms. Web pages ect. with no problems.
There seems to be a problem when ActiveX control is a parent.
The nature of my
query is this: how can achieve no3 (meta control) Without
it causing crashes when I insert it into other projects (or the test
container) Step by
step to what I did to create number 3:
- I've designed a control for called CMetaCtrrl via
AppWizard
- Inserted both Demo1 and Demo2 ActiveX controls into the project with their
wrapper classes generated
- Added a member 'variables' to both
- Inserted the handler WM_CREATE (that's what you have to do if you're using
child windows)
- Inside the function OnCreate. I've added code to allow creation of the children windows
CRect rcInit(CPoint(0), CPoint(0));
m_demo1.CreateControl(m_demo1.GetClsid(), "", WS_CHILD | WS_VISIBLE,
rcInit, this, 1001);
m_demo2.CreateControl(m_demo2.GetClsid(), "", WS_CHILD | WS_VISIBLE,
rcInit, this, 1002);
- Added code to position and make Demo controls 1 &
2 visible
- Built the project (Which it does successfully) also
favourably accomplished is the registration of the control.
That done I test newly created control. It's when I insert that's when the
troubles start. When using the test container it raises an execption, or on
placement of the control on a form (or dialogue) the same things happens.
In addition to that it brings down whatever development tool I'm using. The
problem is occurring when an attempt is made to create the first chold
window.
On debugging I've stepped into m_demo1.CreateControl().
Which leads me to step into
AFX_MODULE_STATE* AFXAPI <br />
AfxGetModuleState() the module state is not a NULL pointer.
I then went to probe into
CMetaCtrl::InitControlContainer() (BOOL CWnd::InitControlContainer()) . The issue
behind it is coming from the fourth line of the snippet
(m_pCtrlCont = <br />
afxOccManager->CreateContainer(this); )
<CODE>
TRY
{
if (m_pCtrlCont == NULL)
m_pCtrlCont = afxOccManager->CreateContainer(this);
}
END_TRY
</CODE> I fail to understand why this is happening. I know how to place
common controls a child on an ActiveX control. I would like to know how to
create and place an ActiveX child and have another as it's parent. Surely, there must be a way
of doing this. I'm sorry this is so verbose, I had to explain it such
a way that I will get my question in it's correct context.
Many Thanks Alton
|
|
|
|
|
Hi Alton
Sounds like you've forgotten to add the following to the beginning of your control:
void AfxEnableControlContainer( );
You can't contain a control without it
Tom
|
|
|
|
|
|
Hi Alton
Glad I could help
Personally, I put it into my InitInstance method or as near to the POE as possible. Doesn't really matter though, as long as it's called before you attempt to embed your object.
Tom
PS, thanks for the feedback
|
|
|
|
|
Im new to C++ and so im not to sure how comboboxes work and how to populate tham, but this was my best guess:
LPCTSTR intList[] = {"one","two","three",}; <br />
HWND hList;<br />
hList = GetDlgItem(IDC_COMBO1);<br />
for (int i = 0; i < 3; i++) <br />
{ <br />
SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)"hello"); <br />
}
but doesnt seem to be correct.
What am i doing wrong?
|
|
|
|
|
ceejeeb wrote: but doesnt seem to be correct.
Why?
If you are working with a combobox, you need to send a CB_ADDSTRING message instead.
Have you tried:
SendMessage(hList, CB_ADDSTRING, 0, (LPARAM) intList[i]);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
you should have added a member variable for you combobox and then you can simply used
<br />
m_VariableOfYourComboBox.AddString( "hello" );
|
|
|
|
|
You are assuming MFC. The OP provided nothing which indicated that was being used.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I agree with Maximilien its easy declare a variable for combobox and use of m_Combo.InsertString or m_Combo.AddString
|
|
|
|
|
Hi to you all,
In a Dialog, I use an Edit element to enter a key value for new objects. I use the same dialog somewhere else to select one of the objects and I then replace this CEdit element with a CComboBox from which the value can be selected. I would likt to use the same CString variable. In the current version, this CString is connected to the CEdit object in the DoDataExchange by a DDX_Text(pDX,.....). I would likt (in the OnInitDialog routine) to disconnect this CString from the CEdit element, and reconnect it (with a new DDX_Text probably) to the CComboBox element. Is there a way in which one can disconnect the data exchange? Or should I take the DDX_Text for this element out of DoDataExchange and put it in OnInitDialog altogether?
Anyone have any suggestions?
Thanks in advance
William
|
|
|
|
|
Wim Engberts wrote: ...this CString is connected to the CEdit object...
Use a CEdit member variable instead. For the combobox control, use a CComboBox member variable.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
David,
This is indeed what I do, however, I would like both controls to do their data exchange with the same CString variable, since I always show only one of the two (either the CEdit or the CComboBox), depending on the mode that I have selected for the dialog.
I am now experimenting with a double DDX_Text in the DoDataExchange routine (referring both controls to the same CString). This compiles fine and it also seems to work properly. However, when starting the classwizard, I get an error. So far I have been able to go around this by putting the second DDX_Text outside of Microsoft's automatic data map (so putting it behind the "//}}AFX_DATA_MAP" line). So far, this seems to work properly.
Regards,
William
|
|
|
|
|
While ClassWizard is nice, do not let it ultimately govern how you lay out your code. It's meant to solve a problem a particular way, but that does not mean that other ways can't also be employed.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hello,
what is wrong with my application? i got an error message when i try to execute it.
The procedure entry point GetThreadId could not be located in the dynamic link library KERNEL32.dll
#include "stdafx.h"
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
GetThreadId((HWND)111);
return 0;
}
thank you
|
|
|
|
|
What version of Windows are you running it on? According to this[^], it's not available on all versions.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
hmm.. i am using windows xp
but how then i can send message to the thread process...?
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
HANDLE pKhwnd;
pKhwnd = CreateThread(0, 0, pKhookThread, &hInstance, 0, 0);
WaitForSingleObject(pKhwnd, 10000);
PostThreadMessage(GetThreadId(pKhwnd), WM_DESTROY, 0, 0);
FileWrite("Application Terminated");
return 0;
}
what function i have to use to get thread id?
|
|
|
|
|
Not knowing what your thread function does, just because you create a thread, what makes you think it will accept or handle your message? Possibly some of the articles here[^] might help you out.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
that thread listens for messages so WM_DESTROY should terminate thread process...
|
|
|
|