|
If you created the resource string using MSXML then the string will be a BSTR which is UTF-16 by definition. Microsoft warns that the string will not contain the byte order mark that you normally can check for at the beginning of a disk file.
The thing to remember when parsing a BSTR string created with MSXML is that the line indicating the encoding will not reflect the actual encoding of the string.
In other words,
<?xml version="1.0" encoding="UTF-8"?>
in a BSTR representation should be ignored as the encoding will always be UTF-16.
|
|
|
|
|
|
|
Hi all,
i am required to write a simple BHO which changes the "User-Agent" Header for every HTTP-Request (has to be a BHO). I already had success with IWebBrowser2::Navigate for a single specific website. Is it possible to do this inline (Without (re-)navigate) and for any request done with the IE?
<br />
void CComServer::IEBeforeNavigate2(DISPPARAMS* pDispParams)<br />
{<br />
pDispParams = pDispParams;<br />
<br />
CComBSTR url = ((*pDispParams).rgvarg)[5].pvarVal->bstrVal;<br />
if (url == "http://www.url.com" )<br />
{<br />
CComPtr<IWebBrowser2> spBrowser;<br />
CComPtr<IDispatch> spDisp = ((*pDispParams).rgvarg)[6].pdispVal;<br />
spDisp->QueryInterface(IID_IWebBrowser2, (void**)&spBrowser);<br />
spBrowser->Stop();<br />
<br />
CComBSTR newURL = "http://www.google.com/";<br />
spBrowser->Navigate(newURL, NULL, NULL, NULL, NULL);<br />
((*pDispParams).rgvarg)[0].boolVal = TRUE;<br />
<br />
return;<br />
}<br />
Thanks in advance
|
|
|
|
|
hi..
i have an array of data i want to sort the data linearly..is there any way to do it..?
|
|
|
|
|
Use std::sort from the STL. For example to sort an array of int s:
int NumArray[] = {3, 1, 4, 1, 5, 9, 2, 6, 5};
int *pNumOnePartEnd = NumArray + sizeof(NumArray)/sizeof(NumArray[0]);
std::sort(NumArray, pNumOnePartEnd);
Remember to #include <algorithm> .
Steve
|
|
|
|
|
Stephen Hewitt wrote:
int NumArray[] = {3, 1, 4, 1, 5, 9, 2, 6, 5};
int *pNumOnePartEnd = NumArray + sizeof(NumArray)/sizeof(NumArray[0]);
std::sort(NumArray, pNumOnePartEnd);
should probably be pNumOnePastEnd
|
|
|
|
|
Yes, I did mean to write "one past the end". Note however that I made the mistake consistently so the example would still work.
Steve
|
|
|
|
|
Hi again guys
i have a strange problem.
i'm reading from a file character by character and i'm pushing the characters into a queue like this
<br />
do{<br />
c = getc (pFile);<br />
plainText.push(c);<br />
} while (c != EOF);<br />
so far so good then i copy the content of the queue into a string but i try to remove all unessesary spaces
<br />
string text;<br />
while (!PlainText.empty()) <br />
{<br />
if (PlainText.front()!=' ')<br />
{<br />
Plain_Text+=PlainText.front();<br />
PlainText.pop();<br />
}<br />
else if(PlainText.front()==' ')<br />
{<br />
while(PlainText.front()==' ' && !PlainText.empty() )<br />
{<br />
PlainText.pop();<br />
}<br />
Plain_Text+=" ";<br />
}<br />
<br />
}<br />
I'm not sure if i made my self clear so i'll give you an example.
lets say i have this writen in a file
<br />
This is writen in<br />
a text file but with more than one <br />
spaces in between the words
i want to copy the contents of this file into the string
but in this form
This is writen in a text file but with more than one spaces in between the words
My code doesn't make any changes it lives all the spaces as they where
any ideas pls help
Thanks a lot
-- modified at 6:13 Sunday 11th June, 2006
|
|
|
|
|
you didn't mention what type is your queue ? write here the definition of the queue
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
thanks for the reply my queue is of type char
queue<char>PlainText;
|
|
|
|
|
Do you want to convert a multiline string into a single line one. Although you talk about removing extra spaces but from the example it seems you want to remove newline ('\n') character.
-Saurabh
|
|
|
|
|
Hey thanks for the reply
yes i also whant to remove newline but spaces in between as well the example is not clear because when i post the message my spaces where removed.
|
|
|
|
|
antonaras wrote: ...when i post the message my spaces where removed.
Use ampersand nbsp; in your post.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I have created a small project in vc++6 with a editable list control. I took the help of some of the articles found here.
I wanted the listview's edit box to have some background colour when that box is being edited. I intergrated another class I found in CodeProject. But the box doese'nt behave properly. I do not know how to correct it, or what I should change.
Can somebody help me out. I can e-mail the project to you so that you can see it and tell me what I must add or change.
Thanks.
Tara
Fortitudine Vinsinues!
|
|
|
|
|
use WM_CTLCOLOREDIT message in your class(derived CListCtrl) and use
<br />
HDC hdc=(HDC)wParam)<br />
::SetBkColor(hdc,RGB(53,197,200));<br />
whitesky
|
|
|
|
|
I have added that to the class. But this is what is happening:
When I click on a cell in the listview the background changes color. After that, when I start typing the color changes back to white and the corners remain yellow...
Please help!
Thanks.
Tara
Fortitudine Vinsinues!
|
|
|
|
|
Hope I understood your question
WM_CTLCOLOREDIT is a message notify
you can see in MSDN(this explain)
"This message notifies the parent window of an edit control when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the edit control."
see this code maybe it is some helpful to you :
<br />
BEGIN_MESSAGE_MAP(CAnswerView,CListView)<br />
ON_MESSAGE(WM_CTLCOLOREDIT, OnColorEdit)<br />
END_MESSAGE_MAP()<br />
...<br />
...<br />
LRESULT CAnswerView::OnColorEdit(WPARAM wParam,LPARAM lParam)<br />
{<br />
HDC hdc=(HDC)wParam;<br />
SetBkColor(hdc,RGB(53,97,200));<br />
SetTextColor(hdc,RGB(255,255,255));<br />
return (LRESULT)m_Brush->m_hObject;<br />
}<br />
whitesky
|
|
|
|
|
pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
as we know, this is a simple way to create and load the frame with its resouces,
and we notice that the pContext is NULL. And we get a bug:
if pContext is NULL, it will fire CView::OnInitalUpdate Twice!
Here is My explain:
BOOL CFrameWnd::LoadFrame(...)
{
...
if ( !Create(...) ) /// it will fire CView::OnInitialUpdate()
{
return FALSE;
}
...
if ( pContext == NULL )
{
/// it will fire CView::OnInitialUpdate() again
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
}
return TRUE;
}
So, why these four lines:
if ( pContext == NULL )
{
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
}
Can anyone help me or fix it?
Thanks!
-- modified at 4:14 Sunday 11th June, 2006
|
|
|
|
|
I am facing problem in finding how can we list all the deleted files in a directory??? I mean is there no way of doing it by some function rather than making a function urself????Can FindFirstFile,FindNextFile can be useful???
|
|
|
|
|
You can enumerate the contents of the Recycle Bin and look at the original location of the files. The only other alternative would be to parse the file system structures (similar to what ScanDisk and NDD do) and look for directory entries marked as deleted. (But even then, the file's data may have been overwritten.)
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
See Here[^]maybe it is some helpful to you
whitesky
|
|
|
|
|
Hi All.
I need to know how can i write some function that getting Folder path and return me list of all file in this folder.
The function will be something like this
void func(CString sFolderPath , CString sFileList)
{
...
...
...
While(bFileExist){
sFileList += File.Name;
sFileList += '\n';
bFileExist = FindNextFile(....);
}
}
Thanks for any help.
|
|
|
|
|
use the shell api SHBrowseForFolder once you select a folder use FindFirstFile and then FindNextFile to retrieve all the files under that folder.
hope this helps
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
See
<br />
(1)<br />
TCHAR lpt[260];<br />
lpt[0]='\0';<br />
strcat(lpt,"c:\\");<br />
GetCurrentDirectory(sizeof(lpt),lpt);<br />
DlgDirList(lpt,IDC_LIST2,NULL,DDL_DIRECTORY|DDL_ARCHIVE);
-----------------------------<br />
(2)<br />
WIN32_FIND_DATA find;<br />
HANDLE handle=FindFirstFile("*.*",&find);<br />
while(FindNextFile(handle,&find)!=0)<br />
m_List2.AddString(find.cFileName);
FindClose(handle);
whitesky
|
|
|
|