|
Suggestion. Write a function that searches for the start of the tag and returns the index of the opening <. Write another function that searches for the end of the tag and returns the index of the closing >. Then write a function that 'moves' everything from after the end index to the opening index.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Sorry, don't quite follow.
|
|
|
|
|
How about an ASCII picture.
Start End
Index Index
| |
LPTSTR str = "<xyz>texttext2<h>header</h><xyz>";
| |____|
| Stuff to move-+
| |
+--<--< goes here -<--<-+
The first function will return the start index.
The second function will return the end index.
The third function will move all characters after the end index to the end of the string and place them in start index resulting in
LPTSTR str = "<xyz>texttext2<xyz>";
Hope that is clearer.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Beautiful picture.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Use strchr(). Look for left angle bracket. Read the next char. If it isnt an 'x' then delete everything up to and including the next right angle bracket with a matching tag.
==============================
Nothing to say.
|
|
|
|
|
Iterate over the string, copying characters from source to destination. If you see a tag not named xyz, stop copying until the matching tag is encountered.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
This is what I was looking for, I just couldn't get it to work.
Could you show a pseudo snippet of code in C?
Thanks
|
|
|
|
|
const char *pszSource = "<xyz>texttext2<h>header</h></xyz>";
char szDest[128] = { '\0' };
int x = 0;
while (pszSource && *pszSource != '\0')
{
szDest[x] = *pszSource;
x++;
pszSource++;
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 27-Jan-12 16:38pm.
|
|
|
|
|
I tried few source codes to test read/write disk sectors. I noticed that a small part of the sectors remains hidden, despite the fact media examiners (like ftk image AccessData) reveal their presence. Is this solvable in VC++?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
I've a problem I've never seen before. One application launches one or more child processes. Rarely, one of those child processes doesn't completely exit. It doesn't show up in task manager, but does show up in Resource Monitor, Process Explorer and by calling a CreateToolhelp32Snapshot/Process32First. When I try to open the process, it fails (and Process Explorer shows question marks for all handles, which would seem to me that they have been closed.)
Anyone have a clue?
PS. This is on Windows 7 64 and both the main application and child applications are 64-bit. Both are in C++ and use Qt. I just inherited this project so am not yet familiar with all the wiring, but I've never seen this behavior before.
|
|
|
|
|
Hey Joe,
Unfortunately... it means there is a bug in your code somewhere. I call them 'Zombie processes' and they are generally caused by a handle leak. You can create a process zombie by launching a child process duplicating and never closing its handle. The process does not show up in the task manager because the process has exited. The zombies are consuming system resources and next will be your brain.
Best Wishes,
-David Delaune
|
|
|
|
|
I am trying to set the font for radio button using below code in my project but font does not set. Font and color does not set for text on radio button.
I have a dialog base application (MFC), at dialog there are some radio buttons
In dialog class, Oninitdialog() i use
CFont* pFont = GetDlgItem( IDC_RADIO1 )->GetFont();
LOGFONT LogFont = { 0 };
pFont->GetLogFont( &LogFont );
LogFont.lfItalic = TRUE;
LogFont.lfWidth = 9;
LogFont.lfHeight = 12;
LogFont.lfWeight = FW_BOLD;
memcpy(LogFont.lfFaceName,"Verdana",7);
m_StaticFont.CreateFontIndirect( &LogFont );
GetDlgItem( IDC_RADIO1 )->SetFont( &m_StaticFont );
in header file
CFont m_StaticFont;
To set the color for text on radio button, i use OnCtlColor (WM_CTLCOLOR)
HBRUSH CtestxmlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
///
if(pWnd->GetDlgCtrlID() == IDC_RADIO1)
pDC->SetTextColor(RGB(255,0,0));
////
}
But when i use above code in a test program it works. Please suggest what's wrong.
I have debug my project and found OnCtlColor calls and it set the text color also.
Please help.
|
|
|
|
|
How is this test program different from the dialog based program that you mentioned first?
|
|
|
|
|
Both are dialog based applications. Test program contains only one radio button.
In main program there are lot of controls and work against them
|
|
|
|
|
As you can see yourself, the code works.
So that means what you've done is correct.
That must mean, there is something else going wrong in the first program.
Maybe a wrong ID has been used.
You could debug the code to get the answer.
|
|
|
|
|
The font is set but text color is not set in first program.
This is the problem with radio buttons. If i add a new radio button then also text color is not set.
But for static control the text color is set.
It means something needs to be supported for radio button
|
|
|
|
|
I found the reason why.I am using XP theme. Below url also says that
http://www.go4expert.com/forums/showthread.php?t=16457&page=2
If i remove xp theme then color is set for radio text.
Is there any solution for that problem.It's require for me to use XP theme.
XP theme
="1.0"="UTF-8"="yes"
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="appname.exe"/>
<description>appname</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>
|
|
|
|
|
Hi all,
I just want to know one thing that when we insert items in List Control its memory increases by 4k. I wanted to know that this memory increase also depends on number of columns we insert in each row.
Thanks in advance
|
|
|
|
|
Did you give it a try? I mean just include another column and see for yourself
I know I am coward since the day I know that fortune favors the brave
|
|
|
|
|
Hi all
I have the following code
CString s;
s = "CSECT";
do {
memset(&buffer[0],0x20,121);
pFile->ReadString(&buffer[0],123);
} while(s.Find((LPCTSTR) &buffer[0]) == -1);
When buffer has the following the return code remains -1
000000 00000 000BC 10 TESTA CSECT
|
|
|
|
|
As I read the docco[^], you've got your find inside-out. Your code is looking for the contents of the buffer inside "CSECT". No great surprise that it's not found.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
|
Several things could be going wrong here.
First - As Peter said, you've got it inside out.
Second - Even though you're assigning a non-unicode string to a CString object, it would be converted to a unicode string if you're doing a unicode build.
Third - Looks like the buffer contains binary data. If so, it would not work with a string object since it would look at a 0 as the null terminating character to end the string.
So, I recommend you use the memcmp function to find the string - memcmp(buffer, (LPVOID)(LPCTSTR)s, 121);
|
|
|
|
|
Hello,
is there a convenient way to pass a pointer to a data member so that it is recognized as a template argument?
The following does not compile under VC++ 2008:
template<class Parent, typename Type, Type Parent::*Member>
void AddMember(Type Parent::*Member)
{
return true;
}
...
AddMember(&TestObject::i);
Alex
|
|
|
|
|
Not completely sure... but did you try just this:
void AddMember(Type *Member)
If you're calling a method for it, no need to specify Parent::*Member, where the pointer comes from is up to the caller.
|
|
|
|