|
Dear All
I am using a webBrowser control as part of my project which i am developing. After loading a web page within a dialog box, I am interested in segmenting the current web page into coherent blocks (for example: images, tables, lists). I have tried detecting collections of html elements (images, paragraphs, divs...) by retrieving them from an instance of the html document.
Now, i am not sure if its the right method to segment a web page. Because i will end up specifying (hard coding) which elements to detect (anchors (a), divs, tablerows (tr), tabledata(td), unordered lists (ul)... and so forth)
detecting such elements and storing them in blocks will create redundancy. for example may contain anchors . detecting each seperately will result in blocks within blocks !!!
Does any body have a good idea for implementing the segmentation. I hope i have put it forward and not confused you guys.
Your views will be very much appreciated
llp00na
-- modified at 13:26 Tuesday 22nd November, 2005
|
|
|
|
|
I've got a serious problem with SHFileOperation which, in short, disallow me to use it for copying files (I haven't tried it on deleting\moving\something else). The code below is showing the way I am using it.
<br />
CString szTo(theApp.m_szMwDir), szFrom(theApp.m_szOoTDir);<br />
szTo += "\\Data Files\\\0\0";<br />
szFrom += "\\*.*\0";<br />
SHFILEOPSTRUCT fos;<br />
fos.hwnd = m_hWnd;<br />
fos.pFrom = szFrom;<br />
fos.pTo = szTo;<br />
fos.wFunc = FO_COPY;<br />
fos.fFlags = FOF_NOCONFIRMMKDIR;<br />
fos.hNameMappings = NULL;<br />
fos.lpszProgressTitle = NULL;<br />
SHFileOperation(&fos);
The problem is that when I run the application it comes out with "Error, file not found" error generated by SHFileOperation. theApp.m_szOoTDir is initialized correctly so it can't be a problem. Now let's get to the strange part. Let's assume that theApp.m_szOoTDir = "C:\TR_OoT_Test\Data Files" (it has this value in my test app so I'll use it for convenience). I want to copy all files in it and its subdirs to the destination directory (around 1000 in total) hence the wildcards. So, as I've already told, the application comes out with an error that the file cannot be found. But if I will create a char array and hardcode the path into application...it works. The path is the same:
CString szTo(theApp.m_szMwDir);<br />
szTo += "\\Data Files\\\0\0";<br />
char szFrom[] = "C:\\TR_OoT_Test\\Data Files\\*.*\0\0";<br />
SHFILEOPSTRUCT fos;<br />
fos.hwnd = m_hWnd;<br />
fos.pFrom = szFrom;<br />
fos.pTo = szTo;<br />
fos.wFunc = FO_COPY;<br />
fos.fFlags = FOF_NOCONFIRMMKDIR;<br />
fos.hNameMappings = NULL;<br />
fos.lpszProgressTitle = NULL;<br />
SHFileOperation(&fos);
If I will dynamically create char array by copying, concatenating, converting from CString or any other ways it stops working. So in short it works only with path written down when I am initializing an array or pointer to char string and ONLY to char string. I am absolutly clueless why it is so and how to overcome it. I was trying different workarounds for a few days and came up with nothing. In short - I am desperate. Any input is really appreciated.
Thank you for you time.
|
|
|
|
|
Alex Orovetskiy wrote: If I will dynamically create char array by copying, concatenating, converting from CString or any other ways it stops working
CString probably doesn't store multiple "\0"s at the end of the string. the first one terminates the string while you're concatenating, so it doesn't bother storing anything past that.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris' observation is correct. To remedy this, I suggest using this class from Michael Dunn. It takes care of those \0 oddities!
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Actually CString does handle multiple \0. Otherwise it won't work for pTo field of the structure. And even if it doesn't it still doesn't explain the fact why if I convert CString to char[] (using the way described in MSDN aka using strcpy) and add a \0 to the end it still doesn't work. Oh and I would really like to avoid using any wrapper classes. The project is already bloated (at least for the purpose it serves) and I don't want to bloat it any more.
|
|
|
|
|
Alex Orovetskiy wrote: Actually CString does handle multiple \0.
actually, it doesn't. when doing an assignment to a CString, it checks the length of the new (right hand side) string by scanning for the first \0. then it reallocs and memcpy's strlen bytes from the new string to the destination string. it will never scan past the first \0, never count anything past the \0 towards the new string length, never alloc space for anything past the \0, and never copy anything past the \0.
step into the CString assignment operator and watch.
CString test;
test = "A\0\0";
ASSERT(test.GetLength()==1);
CString isn't going to get you where you want to go.
Cleek | Image Toolkits | Thumbnail maker
-- modified at 15:07 Tuesday 22nd November, 2005
|
|
|
|
|
Chris Losinger wrote: CString isn't going to get you where you want to go.
OK...but why does it work for pTo field which also should be double-zero terminated ? Actually it working for pTo and not working for pFrom got me to beleive that it is not double-zero problem...
|
|
|
|
|
Alex Orovetskiy wrote: Oh and I would really like to avoid using any wrapper classes.
Why?
Alex Orovetskiy wrote: The project is already bloated (at least for the purpose it serves) and I don't want to bloat it any more.
Bloated? With data, possibly. With code, hardly ever. You are making the common mistake of assuming more code = more bloat. This is hardly ever the case, especially without any supporting metrics. Whether you put together the 30 lines of code to deal with SHFileOperation() and its nuances, or you use a class that wraps those same 30 lines of code, the net result is the same.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Bloated? With data, possibly. With code, hardly ever. You are making the common mistake of assuming more code = more bloat.
Well yeah, I am making this assuption. I am basing it on one thing: when I'm not doing any coding on the project and than return only to spend around 10 mins figuring out what does what. But that's pretty much irrelevant to the subject.
Just tried the following (note that szFrom contains \*.*):
<br />
char buf[MAX_PATH];<br />
strcpy(buf,szFrom);<br />
strcat(buf,"\0");
It didn't work. I will try using the demo of that wrapper class to see if it comes out with the same results or no.
|
|
|
|
|
Alex Orovetskiy wrote: strcat(buf,"\0");
any of the string functions are going to recognize '\0' as an empty string and basically do nothing at all: "append nothing to a string? consider it done!".
try :
buf[szFrom.GetLength() + 1] = 0;
Cleek | Image Toolkits | Thumbnail maker
-- modified at 15:35 Tuesday 22nd November, 2005
|
|
|
|
|
If I knew how to build statues I would have built one for you. It works. It perfectly works. No words can express my gratitude. Thank you !
P.S. And like always the solution was really simple. I remember putting a wrong comma once...
|
|
|
|
|
|
Alex Orovetskiy wrote: It didn't work.
What do you mean by "It didn't work?" After strcpy() returns, buf and szFrom should contain identical strings. Are you saying this is not the case?
Alex Orovetskiy wrote: strcat(buf,"\0");
Given that strcat() operates on nul-terminated strings, this effectively does nothing. What were you expecting?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Given that strcat() operates on nul-terminated strings, this effectively does nothing. What were you expecting?
Expecting the wrong thing it seems Actually I didn't think it would turn this way. Oh well...it is working now. Thank you guys for spending your time on me.
|
|
|
|
|
Does anyone know please if it is possible to change the default settings of the internet and private network combo box settings on the Network Management screen programmatically using evc4. Currently Internet defaults to 'My ISP' private network defaults to 'My Work Network'. I need to default both to GPRS.
Any sample code gratefully received.
-- modified at 17:39 Tuesday 22nd November, 2005
|
|
|
|
|
Hi,
I have a dialog based app that basically has 3 dialogs. There is a main dialog that has a menu that allows the user to "bring up" the other two dialogs by selecting them from the menu. I was wondering how I could get the handle to the menu in my main dialog so that I could place a check mark next to the dialogs that are currently displayed.
I have code that does this, but it is from an MDI app and doesn't work for this dialog based app.
Here is a little bit of the code that I thought would work, but doesn't
<br />
CMenu* pMainMenu = GetParent()->GetMenu();<br />
CMenu* pSub = pMainMenu->GetSubMenu(1);
Thanks in advance for your help.
|
|
|
|
|
Are you sure that GetParent() needs to be called?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
NYTSX wrote: // This code returns a 0 for GetParent()
Which means that the window does not have a parent window.
The dialog is a top level window, so it contains the menu itself. So simply calling GetMenu() should do the trick.
CMenu *pMainMenu = GetMenu();
if (pMainMenu)
{
CMenu *pSubMenu = pMainMenu->GetSubMenu(1);
if (pSubMenu)
{
...
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I don't believe that the dialog is the owner of the menu. The menu actually resides in the main dialog class, and the dialog I am working with is the child.
By calling GetMenu(), I still get a return value of 0.
Does anyone else have any suggestions? I was told this is one of the requirements I needed for the app.
Thanks in advance.
|
|
|
|
|
Hi!
I want to split the main window of an MDI-application.
On the left pane there should be an form (not the problem),
and on the right pane the child-windows should be.
The MSDN did not really help.
Similar to splitting child-windows (in CChildFrame),
I tried to split CMainFrame. But what do I have to insert
into the right pane - so that there are the child-windows.
CMainFrame can not work...
Alex
|
|
|
|
|
Do you have a CSplitterWnd object (in the parent frame)? Have you overridden the frame's OnCreateClient() method? From that, have you called CSplitterWnd::CreateStatic() and CSplitterWnd::CreateView() ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello!
I'm sorry to answer so late...
Yes, I have overridden the OnCreateClient() similar
to CChildFrame. But what have I to put into the
right pane?
It seems that in every pane has to be a View (or
a Frame with another CSplitterWnd object and
a view in each pane).
But on the left side, there should be the Child
Windows.
What I want is to have an form on one side of the
program where I can place several controls.
Alex
|
|
|
|
|
LionAM wrote: What I want is to have an form on one side of the
program where I can place several controls.
So can't you use CFormView for this?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I have the following pb:
I have an simple MFC app where I launch a function(INIT) that starts a thread(THREAD 1=wait for connection) that connects to a socket(CSocket).After the connection,I Detach and get the handle...now...my pb is this:
if I re-Attach the handle of the socket after the connection in the INIT function then when my server "dies"...I get the OnClose event on the CSocket object...but if I try to re-Attach the handle of the socket inside that Thread 1 or even in another Thread 2...I never receive that notification of the OnClose event
Anyone knows why, and the most important...does he have a solution for this pb ?
(I admit that I'm a begginer with MFC)
Of all the things I've lost, my mind I miss the most
|
|
|
|
|
Sorry, you lost me after the start-a-thread-that-waits-for-a-connection-that-connects-to-a-socket thing...
Have a look at the MSDN samples chatter/chatsrv that shows socket basics and see if that helps. You'll find it here[^]
If things doesn't light up for you, post again and describe what you are trying to do and why you think you need multiple threads.
Perhaps you should derive your socket class from CAsyncSocket instead...;)
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|