|
Thanks for the reply.
I'm just a beginner. And as you can see on my example, from the given html file, I'd like to insert some strings within the html code and save it in a another html file. From the given data arrays, which specifies the location of a string in a html file to be inserted by a string "<SPAN class=source-mark>" and after the string is "</SPAN>". I tried everything but it can't insert a string into html. Someone suggests that put the html code in a string then find and replace. without knowing what the string to be inserted by a string"<SPAN....>", I can't use it. But I think, it may be use in inserting the string "<LINK ....>" and "<DIV ....>" in an html file but I don't know how to do that.
Please if you can guide me how I can proceed to this, I will appreciate it a lot.
Thanks...
With great power comes a great responsibility.
-- modified at 20:41 Tuesday 6th September, 2005
|
|
|
|
|
Here's some code, in which I treat words (separated by whitespaces and newlines) as units. I then test these words
to see if they are "special" (I don't know what your critera is for "special"). If the words are special, I wrap them
with [special][/special]. Please note that you will have to extend your word delimiters to include carriage returns (\r) as
well as tabs (\t), since they are legal and common whitespaces in HTML. The basic algorithm treats the input as a sequence of
units, rather than a 2-dimensional structure.
static CString strOriginal =
_T("This is the original text. Small words such as 'is' and 'the', are considered \"special\", and will be\n")
_T("wrapped with [special][/special]. Word delimiters are in this case spaces and newlines.\n")
_T("\n")
_T("The problem with automated accessibility testing tools\n")
_T("by Trenton Moss 5/5 (2 votes)\n")
_T("Are automated accessibility tools a little too good to be true? There are a number of underlying problems associated with ...\n");
static bool IsSpecialWord(const CString strWord)
{
return
strWord == _T("are") || strWord == _T("is") || strWord == _T("and") || strWord == _T("by");
}
void TheAlgorithm()
{
std::cout << strOriginal << std::endl;
int i = 0;
CString strLastWord;
CString strCopy;
strCopy.Preallocate(strOriginal.GetLength() * 2);
for(int i = 0; i < strOriginal.GetLength(); ) {
if(strOriginal[i] == _T(' ') || strOriginal[i] == _T('\n')) {
if(strLastWord.GetLength() > 0) {
if(IsSpecialWord(strLastWord))
strCopy += _T("[special]");
strCopy += strLastWord;
if(IsSpecialWord(strLastWord))
strCopy += _T("[/special]");
strLastWord = _T("");
}
strCopy += strOriginal[i++];
} else {
strLastWord += strOriginal[i++];
}
}
if(strLastWord.GetLength() > 0) {
if(IsSpecialWord(strLastWord))
strCopy += _T("[special]");
strCopy += strLastWord;
if(IsSpecialWord(strLastWord))
strCopy += _T("[/special]");
}
strCopy.FreeExtra();
std::cout << _T("------ the new copy -----") << std::endl;
std::cout << strCopy << std::endl;
} You can easily modify this code to suit your needs, provided that I have correctly understood the level of complexity required
to determining the "special" words, or positions where the HTML elements are to be inserted. If determining where to insert the HTML elements
are more complex, I still advise you to parse the string linearly, as it would be easier to keep the code optimized. Inserting strings into
strings is potentially very slow.
Good music: In my rosary[^]
|
|
|
|
|
Thanks for the response.
Anyway, using trial and error with my codes, I found a little solution with it, though I may say that it's not reliable for some instances, it gives the result I needed. By the way, the strings in html file to be inserted of an additional tag before and after are not known. or meaning to say, I didn't know what are the strings/words, that's why I found it difficult. The only given data are the position and length of it (RowLinePosition, ColumnLinePosition, and stringLength). I'm still looking for a better solution coz I think, a problem may occur in some instances.
With great power comes a great responsibility.
|
|
|
|
|
c:\program files\microsoft visual studio\vc98\include\ios.h(146) : error C2872: 'streambuf' : ambiguous symbol
c:\program files\microsoft visual studio\vc98\include\ios.h(159) : error C2872: 'ostream' : ambiguous symbol
c:\program files\microsoft visual studio\vc98\include\ios.h(159) : error ..
like this 102 Errors..
i guess its because of the clash between iostream.h and ios.h..
if we use #strings, #vectors ,why do <iostream.h> and IOS.H clash? both are same?
Thanks,
V
|
|
|
|
|
welcome to the world of mutli-inheritance and ambiguity...
you'll have to tell the compiler the namespace to walk through instead of letting it doing by itself...
consider this :
class A {
public:
virtual void debug() { };
};
class B {
public:
virtual void debug() { };
};
class AB : public A, public B {
public:
void f() {
this->debug();
this->A::debug();
this->B::debug();
}
};
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
oops sorry tox, i was away, n back to the seat now.. so what should i do now? the error traces back to the header file IOS.H
V
|
|
|
|
|
if the problem is with my program means i can use :: to access it.. but if it blames the header files?? .. hey tox dont strain yourself.. cuz i removed iostream.h from my .cpp file.. i no more use it..and its working fine. but i just wanted to know if i actually want both ios.h and iostream.h together, what'd i do??.. cool shark
V
|
|
|
|
|
Vivekuniq wrote:
102 Errors.. i guess its because of the clash between iostream.h and ios.h..
if we use #strings, #vectors ,why do and IOS.H clash? both are same?
Never include the iostream headers with the *.h ending, always the one without ending, e.g.
#include <iostream>
using namespace std;
int main() {
cout << "Hello, world!" << endl;
}
|
|
|
|
|
Hello,
I know that I should use the headers withouth the .h suffix, but I never read why. Is there a reason for this, or do all the developers this for consistency?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
The .h headers are obsolete, dating back to the days before the ANSI/ISO C++ standard. Standard C++ uses the new header files without .h suffix.
|
|
|
|
|
hi all,..
i'm creating a Doc/View program (single window). this program also has a menu (IDR_MAINFRAME), which looks like this:
[ my_program ]<br />
[ some option ] br />
[ 2nd option ] br />
[ submenu ] br />
|- [ option_to_check ]<br />
'- [ another_option_to_check ]<br />
[ exit_option ]
and, i created a handler which runs when i click on "another_option_to_check". when i do that, i would like to UNCHECK "option_to_check" and CHECK another_option_to_check or vice versa if 2nd option is checked.
i tried to do it like this:
<br />
void CVsebnostniTestView::OnMenuRisanjeTocke()<br />
{<br />
<br />
<br />
CMenu* mmenu;<br />
mmenu = GetMenu();<br />
<br />
if( mmenu->GetMenuState(ID_RISANJE_MNOGOKOTNIK, MF_CHECKED) )<br />
MessageBox( "Option checked!" );<br />
else<br />
MessageBox( "Option unchecked!" );<br />
<br />
}<br />
ID_RISANJE_MNOGOKOTNIK = id from option_to_check option in menu.
i also tried with CMenu* mmenu, and then submenu(3) etc. and even that didn't work. what am i doing wrong then?
i would really apretiate any help offered.
thanks and best regards
|
|
|
|
|
Sorry, I'm at work right now and don't have much time to respond.
You should consider using the OnUpdate... handlers to check and uncheck the items. These are called by MFC for each menu item just prior to displaying the menu. Here, you operate on a CCmdUI object for that menu item, telling it exactly how it should be displayed.
So if you keep a flag indicating the checked state of "option," you can easily check/uncheck "option" and "another_option" based on that state. Examples would be something like this, using both the On... and OnUpdate... handlers:
BOOL m_bOptionSelected = FALSE;
void OnOption()
{
m_bOptionChecked = FALSE;
}
void OnAnotherOption()
{
m_bOptionSelected = TRUE;
}
void OnUpdateOption(CCmdUI * pCmdUI)
{
pCmdUI->SetCheck( m_bOptionSelected ? BST_CHECKED :
BST_UNCHECKED);
pCmdUI->Enable(TRUE);
}
void OnUpdateAnotherOption(CCmdUI * pCmdUI)
{
pCmdUI->SetCheck( m_bOptionSelected ? BST_UNCHECKED :
BST_CHECKED);
pCmdUI->Enable(TRUE);
}
Hope it helps.
Bob Ciora
|
|
|
|
|
hi Bob,
sure it helped- alot.
thanks for informing me about ON_UPDATE message handlers. thanks again and best regards
|
|
|
|
|
lordgreg wrote: if( mmenu->GetMenuState(ID_RISANJE_MNOGOKOTNIK, MF_CHECKED) )
Shouldn't this be:
if (mmenu->GetMenuState(ID_RISANJE_MNOGOKOTNIK, MF_BYCOMMAND) == MF_CHECKED)
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Now Iam facing one problem in my code,
I need to select multiple items by holding ctrl key in Tree control.Please help me if anybody have readymade code. Its very Urgent.
|
|
|
|
|
|
Can someone tell what %ld stand for?
|
|
|
|
|
i guess you are talking about a string formatting parameter, like into printf()...
if so, %ld tells to the functions that a long decimal value is expected here...
you should have a look at Format Specification Fields[^] and printf Type Field Characters[^]
if not, please tell us a minimum because your are not clear at all...
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 5:58 Tuesday 6th September, 2005
|
|
|
|
|
I'm working on a project using the MS CHtmlEditView (VC++ 7.0). I need to send messages to MSHTML (i.e. WM_KEYDOWN ).
The usual procedure (pView->SendMessage(WM_KEYDOWN, 'A') ) has no effect.
Anyone have a clue on how to do that?
Thanks+regards
|
|
|
|
|
Hi,
I have an SDI Application with 3 views: CLeftView, CTopRightView, CBottomRightView. CTopRightView has a CListCtrl. In the code for CLeftView, if some condition is met, I want to add an item to the list control in CTopRightView.
To do this, in CLeftView I set a Doc var to the item i want to add. Next, I call UpdateAllViews() so it can call my Overridden OnUpdate functions in my views. My overriden OnUpdate function in CtopRightView adds the item set in Doc class to the list control.
The Problem: UpdateAllViews() seems to call OnCreate() before it calls my OnUpdate function, thus clearing all the contents I had in the list control, and then calls OnUpdate(). Is there any way to prevent it from calling the OnCreate()? I don't want to recreate the list control, just add an item to it.
TraileR ParK LifE 4Ever
|
|
|
|
|
UpdateAllViews() should not call OnCreate() method. Could you please make sure, you have created all views and initialized before calling UpdateAllViews() method.
Show us some code snipet..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi MailToGops,
Thanks for the reply. All views are created and initialized. Below is some code you requested of what I am trying to do:
in CLeftView:
GetDocument()->FileAction(&strFileName,1);
in Doc class:
void Ca1interfaceDoc::FileAction(CString* fl, int acn)<br />
{<br />
fileName = *fl;<br />
action = acn;<br />
<br />
SetModifiedFlag();<br />
UpdateAllViews(NULL);<br />
<br />
fileCount++;<br />
}
in CTopRightView:
int CTopRightView::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
if (CView::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
folderContents.Create(WS_VISIBLE|WS_CHILD|WS_BORDER|<br />
LVS_LIST|LVS_SINGLESEL,<br />
CRect(10,10,300,180), this, <br />
IDC_FOLDERCONTENTS);<br />
<br />
LV_ITEM lvItem;<br />
::memset(&lvItem, 0, sizeof(LV_ITEM));<br />
lvItem.mask = LVIF_TEXT|LVIF_STATE;<br />
lvItem.state = 0;<br />
lvItem.stateMask = 0;<br />
lvItem.pszText = "an item";<br />
lvItem.iItem = 0;<br />
<br />
folderContents.InsertItem(&lvItem);<br />
<br />
return 0;<br />
}<br />
<br />
void CTopRightView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)<br />
{<br />
<br />
if(GetDocument()->action == 1 ){<br />
LV_ITEM lvItem;<br />
::memset(&lvItem, 0, sizeof(LV_ITEM));<br />
lvItem.mask = LVIF_TEXT;<br />
lvItem.pszText = GetNTS(GetDocument()->fileName);<br />
lvItem.iItem = GetDocument()->fileCount;<br />
<br />
<br />
if(folderContents.InsertItem(&lvItem) == -1)<br />
folderContents.DeleteAllItems();<br />
<br />
GetDocument()->action = 0;<br />
}<br />
}
The reason I believe OnCreate gets called every time UpdateAllViews() runs is this:
*In CTopRightView::OnCreate() I create the list control along with a test item and add this test item.
*When I run the application I only see 2 items in the CTopRightViews's list control. The test item added in OnCreate() and the last item that was supposed to be added to the list control (many items are supposed to be added to the list control).
So it looks like every time UpdateAllViews is executed it recreates the list control with the test item and the most recent item to be added.
TraileR ParK LifE 4Ever
|
|
|
|
|
For an SDI application, this is normal behavior. When a view asks the document for the data to be rendered, it has the choice of adding only new items, or adding all the items (again). I prefer the latter as it is much easier to clear the list control and add all of the items, contrasted with figuring out which items in the document are already in the view's list and which are not.
The MSDN article Q103982 might be remotely related to what you are seeing.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi David,
Thanks for the reply.
So how would I specify that I want the View to add only new items?
The article refers to VC++ 6.1 and older. I am using VC++ .NET. I did not find OnInitialUpdate() function in the .NET Framework for CView, which they talk about in the article.
TraileR ParK LifE 4Ever
|
|
|
|
|
/*Trucker*\ wrote:
So how would I specify that I want the View to add only new items?
How many total items are we talking about here?
/*Trucker*\ wrote:
The article refers to VC++ 6.1 and older. I am using VC++ .NET. I did not find OnInitialUpdate() function in the .NET Framework for CView, which they talk about in the article.
That's why I indicated it might only be remotely related.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|