|
Use an STL set - it doesn't allow duplicates, and has log(n) time for searching.
Dave
|
|
|
|
|
|
Thanks!
I will give it a try
modified 12-Sep-18 21:01pm.
|
|
|
|
|
My function looks like this:
void ReplaceString(char *szSourceString, const char *szToReplace, const char *szReplaceWith)
{
char *szReplacePos = strstr(szSourceString, szToReplace);
char *szFirstPart = new char[strlen(szSourceString)];
while (szReplacePos != NULL)
{
memset(szFirstPart, 0, strlen(szSourceString));
strncpy(szFirstPart, szSourceString, szReplacePos-szSourceString);
strcat(szFirstPart, szReplaceWith);
strcat(szFirstPart, &szReplacePos[strlen(szToReplace)]);
strcpy(szSourceString, szFirstPart);
szReplacePos = strstr(szSourceString, szToReplace);
}
delete[] szFirstPart;
}
The szFirstPart pointer never changes but i still get a user breakpoint message. I have't free'd it before in the while loop so i don't understand it, any ideas?
THanks
|
|
|
|
|
|
Anonymous wrote:
char *szFirstPart = new char[strlen(szSourceString)];
char *szFirstPart = new char[strlen(szSourceString)+1]; // + 1 for the EOL char
Then take that char into account everywhere, for instance :
memset(szFirstPart, 0, strlen(szSourceString));
becomes
memset(szFirstPart, 0, strlen(szSourceString)+1);
How low can you go ? (MS rant)
|
|
|
|
|
I all,
I'm attempting to write an application using the doc/view arch. and I'm not sure how to do the following:
I want to have multiple views of a single document (read, different views using different dialogs and the like). A similar way to look at it would be the windows explorer. 2 very different views of the same data. That is in essence what I want to do, but each view has its own dialog box and set of functions associated with it. They are implemented as seperate dlls since they are used in many other applications.
Can I do this by setting up the splitters correctly?
What do I have to do to display these other dialog boxes within that particular view?
Any suggestions are greatly appreciated, even if it is another way of approaching the manner. I am using toolbars and rebars extensively and thought the doc/view approach would be the way to go.
Thank you in advance. This could be a complicated matter (it is to me!)
Dan
|
|
|
|
|
Yes, it is possible to implement multiple views of a single document and it can be done with a splitter frame.
The simplest solution for multiple concurrent dialog boxes is modeless style over modal style. Otherwise, consider a propertysheet.
Kuphryn
|
|
|
|
|
Hi,
I can override WM_ERASEBKGND and fill the control but it is valid only when the control has not the focus. If it gains focus, the text is drawn with a background system color (COLOR_WINDOW), WM_CTLCOLOR is not called.
Any idea ?
Nicolas
|
|
|
|
|
|
I dont know where to post this. My MFC app has a HElp Menu item> i want to launch the tripane help window from this button. My HTMLHELP workshop book tells me how to make a help project so I am assuming that I have the .chm file. Now I need to know how to launch this using the HTMLHelp API.....
|
|
|
|
|
You can use the ShellExecute function:
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
As operation you specify "open", as file your .chm file.
-Dominik
|
|
|
|
|
|
try using the remove(), replace(), insert() members of CString
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|
|
How do i use them on a char array?
|
|
|
|
|
You can't directly (not that I'm aware of anyways. However, one way would be to declare a CString and set it to your char array (CString str = charArray;) and them use the CString members mentioned earlier, are you could use the <string.h> functions such as strcat(), strcpy(), etc... Personally I prefer working with the CString as that wrapper class seems more flexible to me (or maybe its just cause I'm used to it). Either way would work fine and of course, you could also just use pointers and remove/replace in your char array as you like.
---------------------------------------------
Be good! But if you can't be good, at least be good at it and try not to get any on ya!
-mjf
|
|
|
|
|
hello!
i have a splash screen (greeting screen) in my mfc-programm. how can i change the time?(i would like to see the picture longer.)
thanks
MFC
|
|
|
|
|
search in your code for SetTimer
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
hello
i use static linking when i build my app but i had a tester tell me that on an old w95 machine the app couldnt load cos it was missing ws2_32.dll ... now i thought first off that static linking would put that in there but apparently not
can i distribute the ws2_32.dll as part of the installer without stuffing up old machines like that one?
thanks
"even if my world is weird it's my world" biz stuff about me
|
|
|
|
|
MS Redistribution package for W95[^]. (not needed on W98).
How low can you go ? (MS rant)
|
|
|
|
|
|
Hi,
My dialog based application don't run on another machine. In my dialog i have used the ActiveX component "Microsoft Forms 2.0 Textbox". I think that that is the problem. How can i code something to automaticly install this ActiveX comp. on a computer?
Please help me or give me a URL..
Thanks
|
|
|
|
|
This component is part of <winsysdir>\FM20.dll. Check out MSDN for further info about redistributing this stuff.
How low can you go ? (MS rant)
|
|
|
|
|
I have created a combo box control in a command bar control with the following code:
::CommandBar_InsertComboBox(hBar, hInst, 120 , CBS_DROPDOWNLIST , ID_ROOMS_COMBO, sizeof(g_arCmdbarRoomsButtons) / sizeof(TBBUTTON) );
To get a message when the user change the selected item of the combo box control I added the following message handler to my CMainFrame class:
...
ON_CBN_EDITCHANGE(ID_ROOMS_COMBO, OnEditChangeRoomsCombo)
...
void CMainFrame::OnEditChangeRoomsCombo()
{
...
}
...
So, the problem is that when the user change the selected item of the combo box control, this message handler will never called by the system!
(I work with eMbedded VC++ 3.0 and WinCE 3.0, but I think it is a simple MFC problem - a problem that I implemented something wrong).
Daniel
---------------------------
Never change a running system!
|
|
|
|