|
Have you tried rebuilding your release version with Debug information and stepping into the MFC code to see which API is failing?
Another option is to copy the CFile::GetStatus into your own code (temporarily), sprinkle that with diagnostic code, and then call it instead of GetFilePath.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Alvaro Mendez wrote:
Another option is to copy the CFile::GetStatus into your own code (temporarily), sprinkle that with diagnostic code, and then call it instead of GetFilePath.
That's probably the best way to handle it.
The way not to handle it is by forcefully clearing the error after the call. Which is what I've done.
J
"I am the Lorax. I speak for the trees."
|
|
|
|
|
Hi All.
I am after some code samples/info about controlling a device via the com port using C++/MFC (though I have never used it). Any info/articles/links appreciated.
Specifically, would like to set up the com port (9600 baud, 8, None, 1) and send and recieve text strings (Hyperterminal Style).
Cheers
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Hello
Here is the way how i did it.
Create a ActiveX Contrl-->Microsoft Communication Control32.
and add a member Variable for it.
Create a OnComm Event with the Wizard.
Open the Port with:
m_MSComm is the member variable for the Active X Control
m_MSComm.SetCommPort(1);<br />
m_MSComm.SetSettings(9600,N,8,1);
m_MSComm.SetInputLen(1);<br />
m_MSComm.SetRThreshold(1);<br />
m_MSComm.SetDTREnable(false);<br />
m_MSComm.SetRTSEnable(false);<br />
m_MSComm.SetPortOpen(true);
Close the Port:
m_MSComm.SetPortOpen(false);
Send a Byte
<br />
m_MSComm.SetRTSEnable(true);<br />
CString str; <br />
str=
vVar.vt = VT_BSTR;<br />
vVar.bstrVal=str.AllocSysString();<br />
m_MSComm.SetOutput(vVar);<br />
SysFreeString(vVar.bstrVal);<br />
m_MSComm.SetRTSEnable(false);<br />
Recieve something:
<br />
BEGIN_EVENTSINK_MAP(CMainDlg, CDialog)<br />
ON_EVENT(CMainDlg, IDC_MSCOMM, 1 , OnMscomm, VTS_NONE)<br />
END_EVENTSINK_MAP()<br />
<br />
<br />
void CMainDlg::OnMscomm() <br />
{<br />
switch(m_MSComm.GetCommEvent())<br />
{<br />
case 2:
CString Empf=m_MSComm.GetInput());<br />
break;<br />
} <br />
<br />
}<br />
That should it be.
Mfg DarkMarine.
DarkMarine@aon.at
|
|
|
|
|
Superb Stuff: Looks like I will be dragged (Kicking and Screming) into MFC.
Thankyou.
Were is .at at ? (Atlantis, Austria, Antartica) ?
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Glad that i could help you.
and .at is Austria.
Mfg DarkMarine
|
|
|
|
|
I have a method which calls the methods from lib.
In one of lib methods there is an exception.
How can I catch it.
:: MyFunc ()
{
try
{
}
catch (CException * ex)
{
ex-> Delete ()
}
}
Best regards,
Eugene Pustovoyt
|
|
|
|
|
To catch an exception, it first has to be thrown? Is the method in the lib (the dll actually) throwing an exception?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I call a lib method with incorrect parameter. Thus there is an exception which I cannot catch.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
So is the lib method actually throwing the exception?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Like David points out verify the lib method is explicitly throwing the exception. In other words, it needs to have a line similar to this:
throw new CSomeException(...);
Also,
- Verify that the exception being thrown is derived from CException.
- Verify that the exception is thrown by pointer, not by value.
If the exception is not explicitly being thrown, then most likely there's a bug in the code which is causing the program to throw an Access Violation exception. Those you can't catch like you're trying to do. The easiest way is by adding a catch-all clause:
catch (CException* e)
{
...
}
catch (...)
{
}
There are other ways to explicitly catch these type of exceptions (do a search for structured exception handling, if you're interested) but I recommend you take the simple route I explained above and clean up your code.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
If all else fails, use the following to catch all exceptions:
try
{
//somecode
{
catch (...)//note the dots, these are important
{
//cleanup
}
Joel Lucsy
|
|
|
|
|
Thank you DavidCrow , Alvaro Mendez and Joel Lucsy very much !!!
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I have an ATL COM+ server (on W2K or XP comuter) that passes data to/from wireless clients and an sql server. This works fine. Now we may need to unplug the sql server and replace it with a web server. Many of the web server's clients will be normal PCs using IE6. But my ALT server will also act like a client to the web server, but it will not have a visual interface. It still needs to get the data and format it for the wireless client, which also knows nothing about html.
Anyone have any ideas how to do this from the ATL program?
Thanks
|
|
|
|
|
Given that the client (COM server) is communicating with the web server via TCP/IP, one solution is winsock.
Kuphryn
|
|
|
|
|
The unix C++ prog i am porting to windows uses 'lrint' which is rounding to nearest integer. What do I use in VS instead?
Appreciate your help,
ns
|
|
|
|
|
double d = 123.45;<br />
int x = floor(d);<br />
int y = ceil(d);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi All
i have an application that written, which uses ado...when a user installs this application
he/she then has to configure a ODBC datasource manually
does ne1 know how i can do this automatically when the program installs? or can ne1 point me in the right direction
which type of setup project would be best for this ?? im using visual studio 2003
i assume that i need to edit the code in the setup program is that correct ????
thanks
si
|
|
|
|
|
You'll need to use SQLConfigDataSource() for that.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I am writing an HTML syntax highlighter for my MFC MDI app and I wrote a ParseAllLines function and it works perfectly for coloring the entire document. But I was wondering how to go about parsing/coloring as the user types into the rich edit control or pastes something into the document. Can anyone generally tell me what I need to do? Do I overwrite OnChange for the rich edit control? If so, what lines do I parse?
I appreciate any advice, thank you!
|
|
|
|
|
Handling EN_CHANGE message will tell you when text has changed, but I don't know how to get only the text that has changed. You might have to reparse the whole thing.
|
|
|
|
|
Hi, i want to paint inside a control;
Why? Because i want to change the color of the border of a group box
Does anyone know how to get the CRect with the dimensions of the border? Then i think i can attach a CBrush to that.
<br />
CWnd* pWnd = GetDlgItem(IDNAME);<br />
CDC* pControlDC = pWnd->GetDC();<br />
<br />
pWnd->Invalidate();<br />
pWnd->UpdateWindow();<br />
<br />
pWnd->ReleaseDC(pControlDC);<br />
HOpe someone knows :>
Greetings
Jens
|
|
|
|
|
Hi!
I have a list control and I want to read data from it line by line. I can easily read multiple lines of data if they are selected, like this:
POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos != NULL)
while (pos)
nItem = pList->GetNextSelectedItem(pos);
How do I iterate through all the items whether or not any are selected and whether or not they are visible?
If I could find a function which returned the top-most item, I think I could then use the GetNext() function. There is a GetTopIndex() function but I think that only returns the top-most item that is visible.
Can anyone point out where I am going wrong?
Thank you.
|
|
|
|
|
|
int nCount = GetItemCount();
for (int x = 0; x < nCount; x++)
{
CString strText = GetItemText(x, 0);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|