|
hi,
i am trying to save a CString to a file. I'm doing this like this:
<br />
CStdioFile cfFile(strPath, CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone);<br />
CArchive ar(&cfFile, CArchive::store);<br />
<br />
cfFile.WriteString(strContents);<br />
<br />
ar.Close();<br />
<br />
cfFile.Close();<br />
This works, but it always places weird characters after the end of the contents of the string.
I'm deleting the file first before saving it, and I know the contents of the CString are correct. Any ideas?
thanks
|
|
|
|
|
Berkut wrote:
This works, but it always places weird characters after the end of the contents of the string.
How do you know the "writing" code is faulty? What are you using to verify the weird characters?
|
|
|
|
|
Berkut wrote:
always places weird characters after the end of the contents of the string.
Of course it will place wierd characters at the end of the string because you used CArchive. CArchive will insert its own codes. Remove the stuff for CArchive and you should be ok. Also check the documentation because I beleive the file may also be stored as binary and not text.
John
|
|
|
|
|
CArchive is an object-store -- not a text file.... it seems to be storing the CString "object", not the string....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Peter Weyzen
Santa Cruz Networks / VidiTel / Reality Fusion (pick a name -- may change at any moment)
|
|
|
|
|
Hi
I'm now creating some OfficeXP-like menus, but I don't know how to get such system colors. Any suggestions.
P. S. By the way, where can I look at Office 2003 interface.
|
|
|
|
|
Try taking a look at all the menu articles at code project one of them sould have implemented what you are looking for.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hi All
i have the following bit of code where im inserting a record into a table,
the record gets insterted ok, but i get a runtime error
saying "Operation is not allowed when the object is closed" on the line cpSet->Close();
please help
thanks, si
CString strSQL;
strSQL.Format("insert into new_call_message(school_id,unique_number,custom,type) values(4055,77866,1,'customeee')");
_variant_t vstrSQL;
vstrSQL.ChangeType(VT_BSTR);
vstrSQL = strSQL;
cpSet.CreateInstance(__uuidof(Recordset));
cpSet->Open(vstrSQL,cpDb.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
cpSet->Close();
|
|
|
|
|
You don't want to open a record set for this call. See the following code:
_ConnectionPtr pCon;<br />
<br />
_RecordsetPtr pRecordset;<br />
pCon = m_pConnection ;
<br />
<br />
basic_stringstream<wchar_t> strSQLStatement;<br />
variant_t vntRecordAffected;<br />
<br />
strSQLStatement <<L"INSERT INTO Access(Name, HTML) VALUES('myName', 'myHTML' ) ";<br />
bstr_t strSQLstmt = strSQLStatement.str().c_str();<br />
<br />
try<br />
{<br />
pCon->Execute(strSQLstmt, &vntRecordAffected, adCmdText );<br />
}<br />
catch( _com_error &e)<br />
{<br />
_bstr_t bstrSource(e.Source());<br />
_bstr_t bstrDescription(e.Description());<br />
TRACE("%s", e.ErrorMessage());<br />
}<br />
catch(...)<br />
{<br />
TRACE("*** UNHANDELED EXCEPTION ***");<br />
}
|
|
|
|
|
Hi John,
thanks for that,
im a bit confussed on how u have declare m_pConnection
in the header file
thanks in advance
si
|
|
|
|
|
si_69 wrote:
im a bit confussed on how u have declare m_pConnection
That was an example I took from another site. Just use cpDb instead.
John
|
|
|
|
|
John M. Drescher wrote:
That was an example I took from another site. Just use cpDb instead.
hi john
i have the following code now, but im getting an undeclared
identifier on m_pConnection. i know i have to declare
this but as what ? help as u have probably gathered my c++ is pants
thanks
simon
_ConnectionPtr cpDb; // is declared in my header file
cpDb = m_pConnection ;
basic_stringstream strSQLStatement;
variant_t vntRecordAffected;
strSQLStatement <<l"insert into="" new_call_message(school_id,unique_number,custom,type)="" values(4055,77866,1,'customeee')="" ";
bstr_t="" strsqlstmt="strSQLStatement.str().c_str();
try
{
cpDb-">Execute(strSQLstmt, &vntRecordAffected, adCmdText );
}
catch(_com_error &e)
{
GenerateError(e.Error(), e.Description());
}
|
|
|
|
|
Remove the following line:
cpDb = m_pConnection ;
m_pConnection was a _ConnectionPtr declared in their header file.
John
|
|
|
|
|
I've read some articles about how to write Explorer Bars. They are interesting, but if the bar cannot exchange with other parts of the Explorer, it is hardly of any use, I think.
For example, I want my bar to catch the events when user has selected files in explorer's right pane, then show some information and display common tasks which can be performed on such files. But how can I? None of the articles told me. I also want that the right pane can navigate to special folder I prefered.
I know that there is an IShellView::SelectItem method, but I don't know how can I hook into it. Or should I go another way?
|
|
|
|
|
Read Shell Programming by Mike Dunn, that's the beginning of your answer.
~RaGE();
|
|
|
|
|
I have read these ones, since they are knowleages that I should master. but I could not find exactly what I want
|
|
|
|
|
Hi,
My VC6 plugin needs to output some text to the build pane. Is this possible?(IApplication.PrintToOutputWindow only goes to a macro-specific page).
TIA
Peter
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
MDI with multiple views and one document
I have an MDI application with one document and one view.
I would like to create multiple instances from the same document class whereas any documents have the one view and any documents have the other view.
So i have made several View-classes and have created several document templates with the following code:
<br />
CMultiDocTemplate* pDocTemplate;<br />
pDocTemplate = new CMultiDocTemplate(<br />
IDR_MDITYPE,<br />
RUNTIME_CLASS(CMDIDoc),<br />
RUNTIME_CLASS(CChildFrame), <br />
RUNTIME_CLASS(MDIView ));<br />
AddDocTemplate(pDocTemplate);<br />
<br />
pDocTemplate = new CMultiDocTemplate(<br />
IDR_MDITYPE,<br />
RUNTIME_CLASS(CMDIDoc),<br />
RUNTIME_CLASS(CChildFrame) <br />
RUNTIME_CLASS(CMDIView2));<br />
AddDocTemplate(pDocTemplate);<br />
The difference between the doc templates are only the View-classes.
When i choose the open-file command from the file menu, the icon for the file-type is not the icon defined by IDR_MDITYPE but the icon with the next greater ID. (also at Explorer)
I have solved this problem by creating a icon which looks like the IDR_MDITYPE icon and which has the next greater ID. But this solution seems me to tricky. Does anybody know another one?
Thanks
Andy
|
|
|
|
|
I have a dialog box with a property sheet and 2 property pages. In my property page I have a button. When I push this button, I want to show a dialof. But the call to CreateDialogIndirect during the domodal doesn't return and my app is blocked. Any ideas ?
|
|
|
|
|
CHAIGNEAU wrote:
doesn't return
What do you mean ? Is the dialog box displayed ? How do you dismiss it ? Or does your program hang when doing the CreateDialogIndirect ? If yes, is it working if you use DoModal() isntead of starting it with CreateDialogIndirect() ?
~RaGE();
|
|
|
|
|
If your app hangs, maybe you have forgotten to use ShowWindow(SW_SHOW); to show your dialog, since this is not automatically done by the CreateDialogIndirect() function.
~RaGE();
|
|
|
|
|
I instantiate a dialog and then call domodal.
Domodal call CreateDialogIndirect() and my program hang.
I have found the reason : I must modify the ex style of my propertysheet to put WS_EX_CONTROLPARENT.
I have found in the MSDN an article wich describe this problem.
Thanx to all.
|
|
|
|
|
I have a problem using COXSizeControlBar from Dundas Ultimate Toolbox 7.5. I have a COX3DTabViewContainer object inside a class derived from COXSizeControlBar. The tab control has two tabs and in one tab there is a COXShorcutBar object, in the other tab there is a CTreeControl object. The problem is that when I use message handlers inside the class derived from COXSizeControlBar, the message handler gets called and processed but when the message returns to the control that originated the message (e.g. the tree control) the return value is always 0 (the value pointed by the LRESULT parameter of the message handler) even if I change the value in the message handler. It is not possible for me then to cancel the editing of a tree control item label (for instance). Have anybody found this problem yet? I have modified and example from Dundas which exactly does this and IT DOES NOT WORK? I guess it is a problem either with the message routing of the COXSizeControlBar or the COX3DTabViewContainer but I haven't been able to find it yet?
Thanks in advance,
Miguel
|
|
|
|
|
Miguel,
Can you send me the sample you created to reproduce this problem? I will try to fix it and send you the updated ToolBox files.
Ivor S. Sargoytchev
Dundas Software
|
|
|
|
|
Miguel,
The problem that you encountered is not in Ultimate ToolBox's COXSizeControlBar, but it is in the way MFC handles notify messages in grand parent windows. If you construct a small dialog based application that has a tab control and you add a tree as a child window of the tab control, you will find the same problem - handling TVN_BEGINLABELEDIT in the dialog and returning TRUE will not prevent a label from being edited.
The solution to this problem if to handle the TVN_BEGINLABELEDIT either in a derived class or a parent window class - but not in a grand parent.
Ivor S. Sargoytchev
Dundas Software
|
|
|
|
|
Igor,
I think I do not understand what you say in your mail. In the Dundas example I sent you, there are the following window classes:
CMainFrame ----> grandparent of CTreeCtrl data member
C3DTabViewBar----> parent of CTreeCtrl data member
CTreeCtrl ----> child
In your mail you say the TVN_BEGINLABELEDIT message should be handled either in a derived class (of CTreeCtrl I guess you mean) or in the parent window class (C3DTabViewBar which is derived from COXSizeControlBar). Well, in the example I sent you the TVN_BEGINLABELEDIT message handler is placed in the parent window (the C3DTabViewBar) and the message in not handled properly (as you can see in the example I sent you). As you say if you try to handle the message in the grand parent window (CMainFrame) it also doesn´t work (which I tried before).
From your mail, i guess you have another example that does not work but, do you please have an example that works with the COXSizeControlBar? I need to solve this problem and it will save a lot of time to me if you already have a solution for this.
¿Can you clarify to me what you say in your mail? If I understand right, the example I sent you should work and it doesn´t. I also tried to handle the message in CMainFrame and it also does not work.
Best Regards and thanks for the help,
Miguel
|
|
|
|