|
I have a string that is :
string myString ="Appliance.Oven.Heater";<br />
string commandString="Run:appladdr:TurnOn:150seconds"; In commandString I want to replace "appladdr" with myString .
for the final string to be
Run:Appliance.Oven.Heater:TurnOn:150seconds
I was getting a memory error using CString .
when I did
CString finalString = commandString.c_str();<br />
finalString.replace("appladdr",myString.c_str());
What am i doing wrong ?
I would like to do this using STL itself.
|
|
|
|
|
act_x wrote:
What am i doing wrong ?
I would like to do this using STL itself.
My good deed of the day:
#include <iostream.h>
#include <string>
using namespace std;
void main()
{
string myString ="Appliance.Oven.Heater";
string commandString="Run:appladdr:TurnOn:150seconds";
commandString.insert(4, myString.c_str());
commandString.replace(24, 8, "");
cout << commandString.c_str() << endl;
}
-Nick Parker
The true measure of a man is how he treats someone who can do him absolutely no good. - Samuel Johnson
|
|
|
|
|
Using STL:
int nPos = commandString.find( "appladdr" );
if ( nPos != string::npos ) {
commandString.replace( nPos, strlen("appladdr"), myString );
}
The MFC code looks right though - what exactly is the memory error that you are getting, and on which line?
Dave
|
|
|
|
|
I am doing all of the MFC in thread functions . I do not know if that is a problem . I am getting memory read errors .
|
|
|
|
|
Are you sharing the string objects between threads? MFC objects should never be used in more than one thread, and the default STL string implementation provided with VC6 is not threadsafe for reading.
Dave
|
|
|
|
|
Hello CPIAN_GURUS!
I've placed a WebBrowser2 control (the active x that comes with VC++6 (Project >> Add To Project >> Components & Controls >>...)) In a dialog and in an array of property pages...
The one that is in the dialog works perfectly, but the one that is in the array of property pages don't appear... the strange thing is that I hear the sound of the page loaded (the 'click' that sounds when a page has been loaded completely) but I cannot see the control...
Any idea?
Do you think I'm missing something?
TYIA!!!
|
|
|
|
|
Perhaps the one on the property page is incorrectly positioned/sized?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have varying widthg content that will populate the CCombobox. I checked autoHSCrollin rthe design view but it doesnt develop the horiz scrollbars when necessary> How can I get the horiz scroll functionality?
Appreciate your help,
ns
|
|
|
|
|
I don't know, but this[^] article shows to craft a combobox whose droplist is always wide enough to display the widest string in the combobox.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
sounds promising...
Appreciate your help,
ns
|
|
|
|
|
CComboBox::SetHorizontalExtent()
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi everybody!
Can anyone tell me how to use CDaoRecordset::Delete();
to delete records in a *mdb database.
Thanks!..
|
|
|
|
|
How do you put controls into a non-doc/view MDI child window?
-- Steve
|
|
|
|
|
Either create a dialog, and put the controls via the resource editor, and create the dialog as a modeless dialog in the child window , or create each individual controls manually in the child window.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
I'm not expirianced in using MFC, so I need help in working with CStringList class
I'm not eble to set or get elements of this collection.
I need an example.
Thank you
|
|
|
|
|
Here's an example. Btw, see if CStringArray (a directly accessible dynamic array of CStrings ) is more suited to your needs. I tend to use that because it's more efficient. Of course if you need a list, then CStringList is the non-STL way to go.
CStringList myStringList;
CString strFirst = "First";
CString strSecond = "Second";
CString strThird = "Third";
POSITION pos = myStringList.GetHeadPosition();
pos = myStringList.InsertAfter (pos, &strFirst);
pos = myStringList.InsertAfter (pos, &strSecond);
pos = myStringList.InsertAfter (pos, &strThird);
pos = myStringList.GetHeadPosition();
while (pos != NULL) {
CString* pString = (CString *) myStringList.GetNext (pos);
TRACE ("Element = %s\n", *pString);
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
do the job that UrlDecod() in asp by vc6.
vc newbie , thx for your help !
|
|
|
|
|
(using VC++6, MFC,... )
Howdy'
I'm now displaying a webcontrol (CWebBrowser2, from the components) in my UI; it's in a CWnd, inside a floating window; I have two floating window, each display some UI, one of them receive the webcontrol; the other floating window contain tree controls, buttons, ...
If I really create the the webcontrol, the rest of the UI doesn't gets initialized properly, they don't get resized, they don't receive an appropriate WM_SIZE.
If I don't create the webcontrol, the UI is perfect, I receive 2 size messages, one, I think is ok, of cx=0 and cy=0, and the other size with the good value (cx, and cy are normal values, the real size.
Also, if the floating windows are docked, everything gets displayed as expected ?
I don't know if it's because the control takes a long time to create ? or if it's eating messages intended to the parent window ?
Anyone have some clues ?
Thanks.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Hi!
I've the following code:
In my CDocument based class:
//Scripting support
class CScript
{
public:
CString sString0, sString1, sString2, sString3, sString4;
int i0, i1, i2, iID;
};
//Script IDs
#define MOVE_PLAYER 0
#define TEXTBOX 1
#define CHOICE_TEXTBOX 2
#define GIVE_ITEM 3
#define MOVE_OBJECT 4
#define HAS_ITEM 5
#define IF_ELSE 6
//End scripting
class CMyMap
{
public:
CMyMap()
{x=0; y=0; id=0; iMax[0]=0; iMax[1]=0; iMax[2]=0; iHitpoints=0; bWalk=true;};
CMyMap(int nx, int ny, int nid)
{x=nx; y=ny; id=nid; iMax[0]=0; iMax[1]=0; iMax[2]=0; iHitpoints=0; bWalk=true;};
int x, y, id, iMax[3], iHitpoints;
bool bMoveable, bDestroyable, bTileSave, bWalk;
CScript cs_arrayScript[3][100];
};
class CTheEditDoc : public CDocument
{
[...]
public:
CArray<CMyMap, CMyMap&> dv_arrayMaps;
// Overrides
void Serialize(CArchive &ar);
[...]
}
void CTheEditDoc ::Serialize(CArchive &ar)
{
CDocument::Serialize(ar);
if (ar.IsStoring())
{
dv_arrayMaps.Serialize(ar);
}
else
{
dv_arrayMaps.Serialize(ar);
}
UpdateAllViews(NULL);
}
My problem 0:
When saving my document everything works fine, but when it comes to reloading it cs_arrayScript[3][100] is filled with waste (all other variables are loaded corectly). Is the Serialize function of CArray unable to serialize my 2D-array properly?
My problem 1:
While the User works with my app the CArray dv_arrayMaps is filled. After some CMyMaps (I think about 10-15) are pushed into it the app slows down a whole step. Is there a way around it? Am I handling to much data?
[I tried dv_arrayMaps.FreeExtra()]
Build a system that even a fool can use, and only a fool will use it.
|
|
|
|
|
can someone please tell me how to check to make sure that a string getting passed into my function is of length 9 exactly?
BSTR __stdcall FindBankName(char* strFilename, char* strRoutingNumber, BSTR strErrString)
thanks in advance, i am pretty unfamiliar with char arrays..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
|
thanks, i appreciate it!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Hello,
In MDI project i want to remove View's border, i already try pView->ModifyStyleEx(WS_EX_CLIENTEDGE, 0, 0); , but i have always the border.
if someone know how to remove the border ?
thx in advance
|
|
|
|
|
In OnInitialUpdate , before calling the parent's implementation, insert:
ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thx it's perfect !
|
|
|
|