|
Hi all
My MFC application is using an ActiveX control in one of its windows.
Is there any way to use this control out of my process? I meen to run it (or to host it) in another process wich will be executed from my app, but still be able to see it on my app's window, like now.
What is the best way to this?
Thanks.
|
|
|
|
|
I have limited VC++ experience. I have used C and other languages a lot. I need to communicate with a serial device from a VC++ Dialog application, which I am developing.
How do I do this?
Thank you,
Joe Massarelli
|
|
|
|
|
I posted this reply (incorrectly - the guy was asking about a parrallel port...) this morning.
Mostly like reading and writing a file: (EXAMPLE - your mileage may vary...)
void CSerialPort::initPort(int comNumber, int baudRate)
{
closePort();
m_ComNumber = comNumber;
m_BaudRate = baudRate;
CString comStr;
comStr.Format(_T("%s%d"), _T("COM"), comNumber);
m_ComHandle = CreateFile(comStr,
GENERIC_READ | GENERIC_WRITE,
0, 0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
DCB dcb;
GetCommState(m_ComHandle, &dcb);
dcb.BaudRate = m_BaudRate;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(m_ComHandle, &dcb);
COMMTIMEOUTS timeouts;
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(m_ComHandle, &timeouts);
EscapeCommFunction(m_ComHandle, SETRTS);
EscapeCommFunction(m_ComHandle, SETDTR);
}
bool CSerialPort::readByteFromChannel(char* inByte)
{
DWORD numRead;
BOOL ret = true;
ret = ReadFile(m_ComHandle, inByte, 1, &numRead, 0);
return ( (ret) && (numRead == 1) );
}
void CSerialPort::sendPacket(char* pktBuffer, int len)
{
DWORD numWritten;
WriteFile(m_ComHandle, pktBuffer, len, &numWritten, 0);
if (numWritten != (DWORD)len)
// do comm error handling here
}
|
|
|
|
|
and how 'bout usb port?
rIsHaBh
|
|
|
|
|
Don't know - haven't had to do them yet but I think they are treated the same as basic serial ports.
|
|
|
|
|
I've created the .H files and I've put the include. Now my problem is with keeping the linker from complaining about multiply-defined symbols... I'm getting some linker errors and I've read in the page that you told me but I'm lost. I don't know which symbols should I define so I don't get this linker errors.
I'm getting this errors:
<br />
imevo.obj : error LNK2001: unresolved external symbol _IID_ITTSBufNotifySink<br />
imevo.obj : error LNK2001: unresolved external symbol _CLSID_TTSEnumerator<br />
imevo.obj : error LNK2001: unresolved external symbol _IID_ITTSFindA<br />
imevo.obj : error LNK2001: unresolved external symbol _CLSID_MMAudioDest<br />
imevo.obj : error LNK2001: unresolved external symbol _IID_IAudioMultiMediaDevice<br />
In imevo.cpp these symbols are used in some functions like these:
hRes = CoCreateInstance(CLSID_MMAudioDest,NULL,CLSCTX_ALL,IID_IAudioMultiMediaDevice,
(void**)&pIAMM);
hRes=CoCreateInstance(CLSID_TTSEnumerator,NULL,CLSCTX_ALL,IID_ITTSFind,(void**)&pITTSFind);
hRes=pITTSFind->Select(TTSModeInfo.gModeID, &pITTSCentral, (LPUNKNOWN) pIAMM);
hRes=pITTSCentral->TextData(CHARSET_TEXT,0,datos,NULL,IID_ITTSBufNotifySinkW);
I think I've defined all variables that I should (in imevo.cpp)
<br />
ITTSCentral *pITTSCentral;<br />
IAudioMultiMediaDevice *pIAMM;<br />
PITTSFIND pITTSFind;<br />
But I get these errors. Any idea? How should I use yor advice (I don't know if I need it or not)
<br />
#if !defined(some_unique_symbol_here)<br />
#define some_unique_symbol_here<br />
#pragma once<br />
?
Thank you very much
|
|
|
|
|
The following may help.
Create a separate .cpp file, change it to not using precompiled headers, and add the following.
#include <objbase.h><br />
#include <initguid.h><br />
#include <speech.h>
Also make sure the paths are set correctly to the SAPI .dll and .lib files in your VS settings.
|
|
|
|
|
I want to supply "Select count (*) from Employee" as the sql to a CRecordSet call, but CRecordSet dosent support Count(*) and advices m_ptr->MoveNext() all the way to the end where GetRecordCount will have the answer!
Any tips on implementing an equivalent of Count(*)??
Ger
|
|
|
|
|
Put "SELECT COUNT(*) FROM Employee" in the CRecordset::GetDefaultSQL() method. The record set will need one member variable to hold the returned value. m_nFields should be set to 1 in the constructor. You'll need an entry in the DoDataExchange() method.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
David,
I think you have too much time on your hands.... you've answered every message and left no scraps for the rest of us...;P
onwards and upwards...
|
|
|
|
|
Which doesn't necessarily mean that I provided the best, or even correct, answer. By all means, add to, or take away from, my response if necessary.
- DC
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I am building an MFC application in which I inserted an ActiveX control. I want to subclass (or hook) the control so that I can process some mouse message. Could you please help me with that?
Thank you very much.
|
|
|
|
|
My question is how would I detect when windows are open and closed/etc in another program and then send info accordingly to that program. I know this is a newbie question but I'm lost at this point.
|
|
|
|
|
My question is how would I detect when windows are open and closed/etc in another program and then send info accordingly to that program. I know this is a newbie question but I'm lost at this point
|
|
|
|
|
You're wanting to know when windows are opened and closed, yes? I'm inclined to suggest FindWindow() , but it has limitations. While I've not tried, you might could create a message-watching hook with SetWindowsHookEx() , watching for the WM_CREATE and WM_DESTROY messages. Without knowing more about what you are after, it's hard to pinpoint a reliable solution.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
This program is basically going to be a macro for a game. I need to know when things such as the option window comes up for attack, cast, etc. when the battle is over so the character can exit the place of battle. So if I knew when windows opened I could reference them and send mouse and keyboard commands and gain information from them.
|
|
|
|
|
I would say it is impossible.
If the game is developed to use DirectX or a similar hardware programming API, you can't hook it's messages very easily. The only viable solution would be (In DX case) to monitor for the DirectX COM main interface object when a new instance is requested on the interface, then hook this request and filter it through a custom message handler. In short: impossible.
The usage of DirectX grants a direct access to the hardware when the game is running, thus effectively passing the Windows messaging structure. So, what you're asking would require some sort of a plug-in or extension into the actual game engine. You might want to discuss the game developers if they left any viable add-on slots open into the actual engine.
But without help from the game developers, you're out of luck.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
my suggestion would be to watch packets comeing in from the game's port. if you can get a scheme of packets (i did this for ultima online back in the day) you can hook with the packets and read from there.
|
|
|
|
|
hello!
can anyone tell me why NetUserSetInfo gives an error while using the structure USER_INFO_1005 in windows XP and NT. the error value is 87 and the value of the last parameter of the function is 5.
can anyone please help me
thank you
|
|
|
|
|
Has it worked in the past? Can you show us a code snippet of how you are using the function?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
DWORD adminStatus;
DWORD check;
USER_INFO_1005 user;
user.usri1005_priv= USER_PRIV_ADMIN;
adminStatus=NetUserSetInfo(NULL,username,1005,(LPBYTE)&user,&check);
This is way i am trying to use this function.The same is given in MSDN.
Thank you.Waiting for your reply.
|
|
|
|
|
Is username the right type and have the right value?
Can you use NetUserSetInfo() with 1003? I'm just trying to ascertain if it's related to 1005 or NetUserSetInfo() in general.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I included <TLHELP32.H> in my project then got the compiler error says ULONG_PTR is undeclared identity. What am I missing?
|
|
|
|
|
=[ Abin ]= wrote:
What am I missing?
Not sure, since there is no ULONG_PTR in TLHELP32.H. If you remove the inclusion, does the compiler still complain?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|