|
you are calling this from what function? I get no errors with your code and _WIN32_WINNT=0x500.
I'm on VS 2003, MFC 7.10
-- modified at 16:13 Monday 27th November, 2006
|
|
|
|
|
Nyarlatotep wrote: ...when CFileDialog destructor is invoked an exception occurs.
This is a known issue.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In what version(s). Do you have a link?
Thanks,
mark
|
|
|
|
|
Mark Salsbery wrote: In what version(s).
VS6. It has to do with the OPENFILENAME structure that MFC was compiled with. I'm not sure if it has been fixed in newer versions. Here is a semi-related article.
There's also the possibility that Adobe Reader is causing the problem.
A similar thread.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks. Noted for future reference
DavidCrow wrote: There's also the possibility that Adobe Reader is causing the problem.
*EDIT* It has been fixed in later versions.
|
|
|
|
|
I've avoided CFileDialog and used the GetOpenFileName API.
So no problem with destructors and CFileDialog but the original problem still occurs ...
|
|
|
|
|
Hi, I am not getting any error with your code.
Its working perfect.
Do you have Adobe Acrobat Reader 7.0 or later in your system.
If so, uninstall the Reader and try again.
Best Regards,
Suman
|
|
|
|
|
I've Acrobat Reader 5.1 (7.0 is too heavy ).
I have given the application to a friend of mine, running on W2000: same error.
I have used the API GetOpenFileName (in every 'taste') instead of MFC CFileDialog obtaining the same problem.
I've build a brand new MFC dialog application with no other code than a button which open a dialog and does a fake SQLite query and a button which runs GetOpenFileName, to be sure no other code could cause the problem in conjunction with GetOpenFileName: same error.
Summary: when a common dialog is shown (Open file dialog, File save dialog, Printer dialog), the next call to sqlite3_prepare() (which compile a SQLite query) fails with an exception.
Naturally I've used either common dialog+SQLite many times in the past with no such problems.
To get around this problem, I've have decided to put the Common Dialog call into a little application and call that from the main application which some kind of interprocess communication.
|
|
|
|
|
Think of the fact that GetOpenFileName changes current directory. So after using common dialogs it should be checked what file SQLite functions work with.
|
|
|
|
|
This could really be the answer ! But I should exhume the code wherever it is now, after three years.
However this seems an useful clue. Thanks.
|
|
|
|
|
Hello,
How can I read excel file through VC++ ? Which topics should I refer so that it enables me to read an excel file and put output on the excel sheet .
Is Visual Basic necessary for the same? since I don't know anything of Visual Basic.
Thanks
Prithaa
|
|
|
|
|
You could use Automation to read and write to excel sheets, even in VC++.
Search for "Excel Automation"
|
|
|
|
|
http://www.codeproject.com/database/cspreadsheet.asp
Thats just one I found in a quick search.
|
|
|
|
|
In addition to automation, you could also use ODBC.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have the following macro in a message map that compiles and works just fine under version 6.
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_CALENDAR, OnDateTimeChangeNotify)
But when I compile the source under vs 2005, I get the following error message,
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CurrencyPrices::* )(LPNMDATETIMECHANGE,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)' CurrencyPrices is the dialog class that implements this message map and one of the controls on the dialog is a DateTime control. From the error message, it's just not clear to me what I have to change. I'm pretty sure that the problem relates to casting from LPNDATETIMECHANGE to a NMHDR*, but I'm not sure. Thanks.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
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]
|
|
|
|
|
Didn't ON_NOTIFY callback prototype changed in VS2005 ?
check the prototype of OnDateTimeChangeNotify
|
|
|
|
|
Thanks Maximilien. I think you are correct. I dug into the docs and found this about ON_NOTIFY
afx_msg void memberFxn( NMHDR * pNotifyStruct, LRESULT * result ); It does look as though the first parameter is to be a NMHDR*. I'll make the change and know soon enough.
Thanks again.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
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]
|
|
|
|
|
What is the safest way to convert a BSTR to a std::string?
FF
|
|
|
|
|
You could add the result from this to your string buffer:
_com_util::ConvertBSTRToString( yourBstr )
|
|
|
|
|
I`m creating an MFC application. I use a modal dialogbox to configure some settings. To read a configuration file i`ve placed this code in the OnActivate event of dialogbox:
<code>
void CPortConfig::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
// TODO: Add your message handler code here
FILE *conffile;
errno_t err;
char tempbuffer[40];
char portname[10];
char baudrate[10];
char flowcontrol[10];
err = fopen_s(&conffile,"..//conffile.dat","r");
if(err !=0)
{
MessageBox(Configuration file not found!\nCreating new one..","Port configuration",MB_OK|MB_ICONERROR);
fopen_s(&conffile,"..//conffile.dat","a+");
fputs("COM1\t9600\tNone\n",conffile);
fclose(conffile);
err = 0;
}
fopen_s(&conffile,"..//conffile.dat","r");
fgets(tempbuffer,40,conffile);
sscanf(tempbuffer,"%s%*[\t\r]%s%*[\t\r]%s",portname,baudrate,flowcontrol);
fcloseall();
this->c_baudrate.SelectString(0,baudrate);
this->v_portname = portname;
this->v_flowcontrol = flowcontrol;
UpdateData(false);
}
</code>
In case when the file doe`s exist everything is OK, but when there is no file, I get the message box displayed on and on and on.I`ve figured out this far, that this part of code is being executed in a loop:
<code>
if(err !=0)
{
MessageBox("Port configuration",
"Configuration file not found!\nCreating new one..",
MB_OK|MB_ICONERROR);
fopen_s(&conffile,"..//conffile.dat","a+");
fputs("COM1\t9600\tNone\n",conffile);
fclose(conffile);
}
</code>
because every time i press OK on the messagebox the line "COM1\t9600\tNone\n" is added to the file.
There is no chance to close the application, only way to do it it using "End task"..
Please help me out with this ! What am I doing wrong?
-- modified at 11:20 Monday 27th November, 2006
|
|
|
|
|
Don't put your initialization code in OnActivate put it in OnInitDialog.
When your message box is dismissed a message is sent to the dialog telling it to activate however this causes the dialog to call OnActivate before your file creation code can execute to create a file.
|
|
|
|
|
Thanx! I was suspecting this to be the cause. Hope this will solve my problem!
|
|
|
|
|
Hi all,
how can I change the font in a RichEdit2 Control to Terminal?
I tried this, but the displayed font is not Terminal.
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_SIZE; // makes szFaceName and yHeight valid
cf.yHeight = 9 * 20; // in TWIPS, 20 twips per point
//cf.bPitchAndFamily = FIXED_PITCH;
cf.bCharSet = OEM_CHARSET;
::lstrcpy (cf.szFaceName, "Terminal");
m_pRichEdit->SetSelectionCharFormat(cf);
Thanks
|
|
|
|
|
Has no one any ideas or is it to easy ?
I'm trying to solve this problem since hours. It must be possible.
In Borland Delphi it's no problem, but I have to do this in VC++.
|
|
|
|
|
My understanding of how to use the rich edit is that you have to first select the text for which you wish to change the font.
I found the following code in a program that I wrote some time ago:
CHARRANGE CharRange ;
CHARFORMAT2 CharFormat ;
// To format the text just written, we must select it.
::SendMessage(
m_hwndThis,
EM_SETSEL,
0,
CharRange.cpMax) ; //'cpMax' set to LAST character position.
// Set up the character formatting structure.
CharFormat.cbSize = sizeof(CharFormat) ;
CharFormat.dwMask = CFM_BOLD | CFM_COLOR | CFM_ITALIC ;
CharFormat.dwEffects = (bBold) ? CFE_BOLD : 0 |
(bItalic) ? CFE_ITALIC : 0 ;
CharFormat.yHeight = 0 ;
CharFormat.yOffset = 0 ;
CharFormat.crTextColor = clrFG ; //Previously set
CharFormat.bCharSet = DEFAULT_CHARSET ;
CharFormat.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE ;
memset(CharFormat.szFaceName, 0, 1) ;
_tcscpy((_TCHAR*)&CharFormat.szFaceName, _T("Arial")) ;
// Format the text just written.
::SendMessage(
m_hwndThis,
EM_SETCHARFORMAT,
SCF_SELECTION,
(LPARAM)&CharFormat) ;
Don't know if this will help, but maybe it will give you some ideas where to continue.
Scott
|
|
|
|