|
Isn't it in the ActiveX list already installed (Menu "Project > Add to Project > Components and Control > Registered ActiveX Components")?
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hi,
yes, is true!
thanx
mirso
|
|
|
|
|
Hi,
I want to read data from serial port asynchronously. I developed a program and I am sending the reading part of that program. When I build this code, I have not met any error. But, when I run the program and read data from serial port, my program gives unhandled exception error and I can not see any data on my edit box. Anybody else that helps me about this problem?
Thank you,
Semih
The reading part of my program:
#define MAX_BUFF 128
#define TEN_K 10240
#define STRMAX 1024
HANDLE Open_Com;
HANDLE SPEvent;
DCB dcb;
COMMTIMEOUTS CommTimeouts;
OVERLAPPED overlapped;
CWinThread* pComPort;
CSP_AsyncRead_2Dlg *pWnd = ((CSP_AsyncRead_2Dlg*) pComPort);
UINT ReadPort(LPVOID pComPort)
{
BYTE counter=0;
char sMsg[512];
BOOL fSuccess = 0;
DWORD dwEvtMask = 0;
BYTE tmp[16];
int ReadConstant = 1;
Open_Com = CreateFile("COM3",
GENERIC_READ | GENERIC_WRITE, //access (read and write)
0, // 0: cannot share the com port
NULL, // security (None)
OPEN_EXISTING, // creation : open existing
FILE_ATTRIBUTE_NORMAL, // overlapped I/O
NULL); // no templates file for COM port
if (Open_Com == INVALID_HANDLE_VALUE) //check whether the COM port is opened or not
{
AfxMessageBox("Port Acildi");
} // end if (m_hCom == INVALID_HANDLE_VALUE)
if (Open_Com)
{
memset(&dcb,0,sizeof(dcb));
dcb.DCBlength = sizeof ( DCB ) ;
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(Open_Com, &dcb); // guncel dcb sutructure degerlerini yerlestir
SetupComm(Open_Com, MAX_BUFF, MAX_BUFF); // set input and output buffer sizes
fSuccess = SetCommMask (Open_Com, EV_RXCHAR | EV_RXFLAG); // Set the mask for the events you want to listen for
} // end if (Open_Com)
if(fSuccess)
{
while(Open_Com != INVALID_HANDLE_VALUE)
{
int iBytesRead = 0;
DWORD iBytesReadThisTime = 0;
char szData[MAX_BUFF];
BOOL bRead;
WaitCommEvent(Open_Com, &dwEvtMask, 0);
SetCommMask (Open_Com, EV_RXCHAR);
if (dwEvtMask & EV_RXCHAR){
bRead = ReadFile(Open_Com, &tmp, ReadConstant, &iBytesReadThisTime, 0);
iBytesRead += iBytesReadThisTime;
}
tmp[iBytesRead] = '\0';
if(tmp[0] != '\0'){
try
{
pWnd->m_Vreaddata.SetAt(counter++,*tmp);;//
}
catch(CException* e)
{
AfxMessageBox("Error Occurs!");
e->Delete();
}
} // if(szData[0] != '\0')
}
} //if(fSuccess)
return 0;
}
|
|
|
|
|
Where is your program crashing ? I suggest you to use the debugger and step into the code to see where it crashes. It is also very usefull to see the variables value.
|
|
|
|
|
I always use the debugger to check any errors. In the following, I marked the line where my program is crashing. Please make suggestions that overcome my problem.
#define MAX_BUFF 128
#define TEN_K 10240
#define STRMAX 1024
HANDLE Open_Com;
HANDLE SPEvent;
DCB dcb;
COMMTIMEOUTS CommTimeouts;
OVERLAPPED overlapped;
CWinThread* pComPort;
CSP_AsyncRead_2Dlg *pWnd = ((CSP_AsyncRead_2Dlg*) pComPort);
UINT ReadPort(LPVOID pComPort)
{
BYTE counter=0;
char sMsg[512];
BOOL fSuccess = 0;
DWORD dwEvtMask = 0;
BYTE tmp[16];
int ReadConstant = 1;
Open_Com = CreateFile("COM3",
GENERIC_READ | GENERIC_WRITE, //access (read and write)
0, // 0: cannot share the com port
NULL, // security (None)
OPEN_EXISTING, // creation : open existing
FILE_ATTRIBUTE_NORMAL, // overlapped I/O
NULL); // no templates file for COM port
if (Open_Com == INVALID_HANDLE_VALUE) //check whether the COM port is opened or not
{
AfxMessageBox("Port Acildi");
} // end if (m_hCom == INVALID_HANDLE_VALUE)
if (Open_Com)
{
memset(&dcb,0,sizeof(dcb));
dcb.DCBlength = sizeof ( DCB ) ;
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(Open_Com, &dcb); // guncel dcb sutructure degerlerini yerlestir
SetupComm(Open_Com, MAX_BUFF, MAX_BUFF); // set input and output buffer sizes
fSuccess = SetCommMask (Open_Com, EV_RXCHAR | EV_RXFLAG); // Set the mask for the events you want to listen for
} // end if (Open_Com)
if(fSuccess)
{
while(Open_Com != INVALID_HANDLE_VALUE)
{
int iBytesRead = 0;
DWORD iBytesReadThisTime = 0;
char szData[MAX_BUFF];
BOOL bRead;
WaitCommEvent(Open_Com, &dwEvtMask, 0);
SetCommMask (Open_Com, EV_RXCHAR);
if (dwEvtMask & EV_RXCHAR){
bRead = ReadFile(Open_Com, &tmp, ReadConstant, &iBytesReadThisTime, 0);
iBytesRead += iBytesReadThisTime;
}
tmp[iBytesRead] = '\0';
if(tmp[0] != '\0'){
try
{
pWnd->m_Vreaddata.SetAt(counter++,*tmp);
}
catch(CException* e)
{
AfxMessageBox("Error Occurs!");
e->Delete();
}
} // if(szData[0] != '\0')
}
} //if(fSuccess)
return 0;
}
|
|
|
|
|
|
The variable name of my edit box. Its category is value and its variable type is CString.
|
|
|
|
|
Uuuuhhhh
What's this ???
CWinThread* pComPort;<br />
CSP_AsyncRead_2Dlg *pWnd = ((CSP_AsyncRead_2Dlg*) pComPort);<br />
<br />
...<br />
...<br />
<br />
pWnd->m_Vreaddata.SetAt(counter++,*tmp); <br />
What are you trying to do there ??? You have an unitialized CWinThread pointer that is converted to a CSP_AsyncRead_2Dlg pointer and after that you call a function from this 'pointer'
First, you cannot convert a CWinThread pointer into a CSP_AsyncRead_2Dlg (they are completely different things) and second your pointer points to unitilazed memory (it hasn't been initialized) and so you cannot use it before make it points to a valid object.
|
|
|
|
|
So, how should I change my program? Could you write the correct parts that must be changed in my program?
Gratefully thank you for your help.
|
|
|
|
|
If your CSP_AsyncRead_2Dlg* class is the main window of your program and if you use the MFC, you can use AfxGetMainWindow to retrieve a pointer to the main window (then you'll have to cast it to CSP_AsyncRead_2Dlg*).
I also strongly suggest you to get rid of global variables and global functions, preferably make them members of some class.
|
|
|
|
|
What is the message generated when some one a website is about to be loaded or is loading ?
|
|
|
|
|
Opening page...3 items remaining... downloading...
Js for fun
V
|
|
|
|
|
Anonymous wrote:
website is about to be loaded
If you are using CHTMLView then look for thsi message CHtmlView::OnProgressChange
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Use BeforeNavigate2 for a WebBrowser Control.
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
marcdev wrote:
Use BeforeNavigate2 for a WebBrowser Control.
Sorry for correcting you, May be i am wrong too. BeforeNavigate2 fire When WebBrowser start loading the Webpage !
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Ups You're right. I missunderstood the question. Thanks !!
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
marcdev wrote:
I missunderstood the question. Thanks !!
It's Ok
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Does anyone know how to switch the input focus from a console window back to the application window??
I've tried SwitchToThisWindow but it doesn't work.
Is it because i'm calling this in a worker thread function.
UINT MyThreadProc( LPVOID pParam )
{
HWND hwndMain = (AfxGetMainWnd())->GetSafeHwnd();
SwitchToThisWindow(hwndMain, TRUE);
}
|
|
|
|
|
klboy wrote:
how to switch the input focus from a console window back to the application window
What do you mean ? I don't understand your question here. Do you have two separate apps (one a console application and the other a windows application) and inside the console application, you want to set the focus to the other application (that is the window app) ?
If yes, you will need to get the handle with FindWindow function.
|
|
|
|
|
cedric moonen wrote:
What do you mean ? I don't understand your question here. Do you have two separate apps (one a console application and the other a windows application) and inside the console application, you want to set the focus to the other application (that is the window app) ?
If yes, you will need to get the handle with FindWindow function.
No i only have one MFC application.
In the my application i have a DLL statically loaded from which i call a function to invoke a debugging console window.
My application communicates to this console window via tcp.
The console acts is the server and my application acts a client.
Now i want to be able to switch to my main application window where i can pressed a key and send a corresponding debug command to the console window.
But atm as soon as i invoke the console window and establish a server-client connection i can't switch back to the my app window.
The console seems to be waiting to receive some data from my application.
I need to switch to the application so that i can press a key for the client to send a debug command to the console.
|
|
|
|
|
Hi!
I use VC++.NET 2003.
I want to compress following text string.
I store following text in std::string.
std::string
a="2B3A2BF0BCD8773D23BEE5550A56E86AF6CF64911214862625027CE7032451282E33F0BFB09D69091D39B1A1788E1A707E50A1948038500CF2044163F379912AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7AD8B59848C7670C94B29B54D2379E2E7A";
I need to compress above string before transferring it from my server.
How do I compress above string into a compressed string (for example,
std::string b;).
Any help will be appreciated
|
|
|
|
|
|
Hi
I want to automate powerpoint presentation into my MFC Dilogue based application. Let me clear it that I don't want whole Power Point but I want to show presentation files directly into my dialogue. Before this also I have requested help here but didn't get satisfactory answer....
Yes I got one or two code which shows how to load power point from my dialogue based application, but it loads power point as seperate application which normally starts when we start it from Start-> Programm -> Microsoft Power Point. Instead i want to show whole power point into my own dialogue of MFC application.
Any example, likn, idea ....
Thanking you guys...
Amarelia Maehsh
Gujarat
India
-- modified at 6:45 Friday 2nd September, 2005
|
|
|
|
|
that day itself i answered with OLE.
anyway see if this is useful for u..
Click Here^
Regards,
V
|
|
|
|
|
Hi there, I am using Visual C++ ( 2003 IDE ) and I need to have 2 classes which points to each other. ( The need to be able to call Functions on each other !!!!!
It works fine from mb->ma but when I call mb from ma I get an error : "Use of undefined Typ" or similiar
Can someone help me. Just need to have 2 Classes being able to call funtions on each other...
<br />
class mb;<br />
<br />
class ma<br />
{<br />
friend class mb;<br />
public:<br />
ma();<br />
int ausgabe;<br />
int mein(void);<br />
int Callb(void);<br />
void SetParent(mb *aptrb);<br />
protected:<br />
mb *_ptrb;<br />
};<br />
int ma::Callb()<br />
{<br />
int lreturn = 0;<br />
mb *lptr = _ptrb;<br />
return lreturn;<br />
}<br />
void ma::SetParent(mb *aptrb)<br />
{<br />
_ptrb = aptrb;<br />
}<br />
ma::ma()<br />
{<br />
int a = 2;<br />
}<br />
int ma::mein()<br />
{<br />
return ausgabe;<br />
}<br />
class mb<br />
{<br />
public:<br />
mb();<br />
~mb();<br />
void tuewas(void);<br />
int richtig(void);<br />
void SetParent(ma *aptra);<br />
protected:<br />
ma *ptra;<br />
};<br />
int mb::richtig()<br />
{<br />
return 500;<br />
}<br />
void mb::SetParent(ma *aptra)<br />
{<br />
ptra = aptra;<br />
}<br />
mb::mb()<br />
{<br />
int a = 2;<br />
}<br />
mb::~mb()<br />
{<br />
int b = 2;<br />
}<br />
void mb::tuewas()<br />
{<br />
int a = 2;<br />
ma *p = ptra;<br />
if ( p != 0 )<br />
{<br />
a = p->mein();<br />
a = a + 3;<br />
p->Callb();<br />
<br />
}<br />
}<br />
|
|
|
|