|
I have to replicate a window whose handle is known. A window can't be replicated using setwindowlong and getwindowlong. if replication is possible,both windows should be functional and at the same time scrolling in one window should not reflect in other window.
Is it possible to replicate a window with its data buffer?
|
|
|
|
|
|
Hi,
I have a strange problem, I have no device connected to Com1 yet whatever I send via SetOutput() is waiting for me when I issue GetInput()
I am using the MSComm ocx within my VC++ 6.0 as such:
m_mscomm1.SetCommPort( 1 );
m_mscomm1.SetSettings( "9600,N,8,1" );
m_mscomm1.SetPortOpen( TRUE );
// now I write some date
CString StringToWrite;
StringToWrite = "Test";
COleVariant var;
var.vt = VT_BSTR;
var.bstrVal = StringToWrite.AllocSysString();
m_mscomm1.SetOutput( var );
// now I read the input buffer
COleVariant oVA;
CString ctmp;
oVA.Attach( m_mscomm1.GetInput() );
ctmp.Format( "%s", oVA.bstrVal );
===========================
ctmp now = "Test";
|
|
|
|
|
There are two methods for reading...
----------------------
POLLING =======
----------------------
Assuming the Mscomm control is on the form and has the name MyCom and that there is a form property named mybuffer, the following code illustrates how to poll for waiting characters ( this is in VB but same procedure you can use in VC) :
Procedure myform.myproc
IF Thisform.MyCom.InBufferCount > 0
Thisform.mybuffer = Thisform.mybuffer + Thisform.MyCom.Input
ENDIF
ENDPROC
----------------------
EVENT DRIVEN ( YOU SHOULD USE THIS BECAUSE THIS IS BETTER ) =====
----------------------
For example, you can place the following code in the OnComm event to append received data to a property of a form called mybuffer:
Procedure MyCom.OnComm
IF This.CommEvent = 2
ThisForm.mybuffer = ThisForm.mybuffer + This.Input
ENDIF
ENDPROC
----------------------
Do this way and tell me if problem persist.
Or You can read articles in msdn...(By searching in MSDN)
one of good articles is :
******
INFO: Troubleshooting Tips for the MSComm Control
******
--------------------------------------------------
Say Whatever You Know.
Helping other people is good for health.
=========
Manish
=========
---------------------------------------------------
|
|
|
|
|
Hi,
I'm wondering why my tab-key is not working when I try to jump to the next control in my dialog. Also I would like the enter-key to have the same effect as the tab-key.
Anyone any idea how to do this? (Sorry I'm very new to VC++ )
Thanks
|
|
|
|
|
Press CTRL+D in the dialog editor to set correct TAB-order, then you should be able to use TAB key to jump to the next control. If you would like Enter key to have the same effect as the TAB key, you can overload the dialog's OnKeyDown() function.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Thanks, but I guess there's another problem:
When I start my dialog project, tab key is working fine until I press a button which calls a routine from where there is no return. All the dialog functionality is ok except for the tab-key.
How can I overcome this problem
|
|
|
|
|
What do you mean "no return"?
Could you show me the codes?
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Here you are:
void CSimulatorDlg::OnOK()
{
static launched=false;
if (!launched)
{
launched=true;
goOpenGL(); // Careful!! There is no return from this function!!
}
}
And at the end of goOpenGL() there is the following instruction from where there's no return :
glutMainLoop(); // Go into main loop and stay there
The function above comes from the GLUT-library (openGL)
|
|
|
|
|
Well, I think you'd better not call goOpenGL() in OnOK() function.
Because if OnOK() doesn't return, the dialog can't get messages so there will be some unexpected behaviors. You should start a thread to process goOpenGL() like this:
UINT ProcessingThread(LPVOID lpData)
{
goOpenGL();
return 0;
}
void CSimulatorDlg::OnOK()
{
static launched=false;
if(!launched)
{
launched=true;
AfxBeginThread(ProcessingThread,NULL);
}
}
and there should be no trouble.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Working prefectly now
Thanks a lot
|
|
|
|
|
I am working on a logger for my friend and I need to know how I could go about capturing the keyboard commands and saving them to a file.
Help is much appreciated.
"To wonder is to begin to understand"
|
|
|
|
|
Look under "Hooks" on the MSDN Index, you will have different types of Hooks, Keyboard Hooks are for you.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Ahhhh, that hurts. How can I get it to log for the entire system and not just one program (I have never used hooks)
"To wonder is to begin to understand"
|
|
|
|
|
Actually System Hooks are for the entire system, not just one program.
I don't remember the details about the use (I have used them a little bit a long time ago), but you can capture pretty much anything (you won't be able to get the keyboard entry for de logon process, and that kind of stuff).
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I'm reading a up to hundred CStrings from a file that I would like to load in memory and for each CString, have an associated integer with it so that everytime I access the CString I add 1 to the integer. Just like a list control would work with the associated DWORD for the item data. I have looked in to CList and CArray but not sure if those would be best for what I need to do. What would be the best way of doing this?
|
|
|
|
|
MFC container classes were written as a sropgap while STL was finalised. You should use STL over MFC container classes.
What you need here is map. A map is an associative container, so for example
map<cstring, int=""> m_map;
means that you use CStrings to index a list of integers. You can add CStrings to the list like this:
m_map["My String, could equally be a CString variable"] = 1;
Then you can add to the value like this:
m_map["My String, could equally be a CString variable"]++;
Finally, you can iterate through the list like this:
map<cstring, int="">::iterator it = m_map.begin();
for (;it != m_map.end; ++it)
{
AfxMessageBox(it.first()); // Just shows all the strings in message boxes
}
This is off the top of my head, I may have made a typo here or there, but it's fundamentally correct AFAIK.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you Christian! Thats exactly what I need. For some reason I still shy away from ATL.
One more thing. Would it be possible for me to do the same in lets say Linux/Unix?
|
|
|
|
|
Did you mean ATL ? I've actually put a lot of time into ATL recently and found once it starts to gel it is very cool stuff, but that is an aside. STL is nothing to do with ATL, and it is part of the C++ standard, one of the many reasons I prefer it to MFC containers. Yes, anywhere you have C++ by definition you will have STL containers and algorithms.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Yes your correct, STL is what I meant. STL looks to be pretty cool for collection classes. I'm looking into ATL for something new to rack my mind with and got the two mixed up.
Jay
|
|
|
|
|
Well, you're looking in the right place. I read books on ATL for almost a year before I came up with a project as an excuse to start coding. ATL Internals says that most people spend about six months in the dark with ATL until one day the light comes on and they start to see exactly how it fits nad why it is so cool. That was certainly the case with me.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Is there a way to get the value of each string also? I have been looking through MSDN and havn't found anything about that.
|
|
|
|
|
MSDN does not provide much good STL info. You can step through a map using iterators, like this:
map<CString, int>::iterator it = m_MyMap.begin();
for (;it != m_MyMp.end(), ++it)
{
CString s = it->first();
}
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you Christian! Just ran into it searching through yahoo also.
|
|
|
|
|
Don't know why I thought about STL before. I'm loading the whole file into memory and searching for each occurance of a few key words on each access. One thing I found is that you can use a map of vectors, list, etc. which seems alot better, faster and easier.
ATL I'm still lost.
|
|
|
|