|
If only that were true!
My code has an HTML control embedded in a dialog, and that is the property of a TreeView of files. When I select a file from the treeview, and choose "HTML" on my menu, it executes the following code:
case ID_LAUNCH_HTML:
________if(hHTMLDlg)________// this is the HTML display window
________________DestroyWindow(hHTMLDlg);
________hHTMLDlg = CreateDialog(hInst,(LPCTSTR)IDD_HTMLVIEW, hwnd, (DLGPROC)HTMLDlgProc);
________SendMessage(hHTMLCtrl, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)_T(""));
________SendMessage(hHTMLCtrl, DTM_ENABLESHRINK, 0, g_bMakeFit);
________if (!SHCreateMenuBar(&mbiHTML))
________________MessageBox(hwnd, L"SHCreateMenuBar Failed", L"Error", MB_OK);
________hwndCB = mbiHTML.hwndMB;
________if(!bHTMLLoaded){
________________hFile = CreateFile(tPath, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
________________________FILE_ATTRIBUTE_NORMAL,NULL);
________________if(hFile==(void*)-1)
________________________ShowLastError();
________________dwHTMLFileSize = 2 + GetFileSize((HANDLE)hFile,NULL); // 2 bytes must be 0 to get 1 wide-char terminus
________________if(pHTMLSource)
________________________delete pHTMLSource;
________________pHTMLSource = new char[dwHTMLFileSize];
________________memset(pHTMLSource,0,dwHTMLFileSize);
________________ReadFile(hFile,pHTMLSource,dwHTMLFileSize,&BytesRead,NULL);
________________// this is the sourcefile needed to fill the HTML dialog
________________CloseHandle(hFile); // pHTMLSource + (dwHTMLFileSize - 40)
________________}
________lRes = SendMessage(hHTMLCtrl,WM_SETTEXT,0,(LPARAM)(LPCTSTR)TEXT(""));
________SendMessage(hHTMLCtrl,DTM_CLEAR,0,0);
________SendMessage(hHTMLCtrl,DTM_ADDTEXT,false,(LPARAM)/*(LPCTSTR)*/pHTMLSource);
________SendMessage(hHTMLCtrl,DTM_ENDOFSOURCE,(WPARAM)0,(LPARAM)0);
________SendMessage(hHTMLCtrl,DTM_FITTOWINDOW, 0, (LPARAM)VARIANT_TRUE);
________bHTMLLoaded = true;
________ShowWindow(hHTMLDlg,SW_SHOWNORMAL);
________MoveWindow(hHTMLCtrl,0,0,240,268, true);
________ShowWindow(hHTMLCtrl,SW_SHOWNORMAL);
________MoveWindow(hHTMLDlg, 0, 0, 240, 294, true);
________ShowWindow(g_hwndTreeView,SW_HIDE);________________
________ShowWindow(g_hwndEdit,SW_HIDE);________________
________BringWindowToTop(hHTMLCtrl);
________hFocus = GetFocus();
________SetFocus(hHTMLCtrl);
________hFocus = GetFocus();
________break;</small>
As you can see, the handle for the htmlctrl is "hHTMLCtrl". I assure you that this code successfully puts the selected file into HTML display on this control.
But when I send it to a section of code that contains your suggestion
HWND hwnd = ::GetWindow(hHTMLCtrl, GW_CHILD);
::SendMessage(hwnd, WM_COMMAND, 0x139E, 0); //for pc2002
::SendMessage(hwnd, WM_COMMAND, 0x156BA, 0);//for pc2000
I find that (1), this handle has no child windows, and
(2) if I use the handle instead of the child you suggest, the clipboard is empty. I am using Pocket PC2002, but I have tried both the two different WParam values and neither does anything.
But you have done this much: you have provided a good basis for discussion.
(I have read this same solution in the past and tried and failed the same way, so this is well publicized code.
There must be something one can do, but it is also true that the version of IE (Pocket IE) also lacks the functions to copy selected text or any equivalent of the CTRL-F find of the desktop version.
Yet the text is there — somewhere. There's got to be a way to get my hands on it!
|
|
|
|
|
I wonder if this was carried over into CE?
BUG: CHtmlView Leaks Memory by Not Releasing BSTRs in Several Methods
The information in this article applies to:
The Microsoft Foundation Classes (MFC), when used with:
Microsoft Visual C++, 32-bit Enterprise Edition 6.0
Microsoft Visual C++, 32-bit Professional Edition 6.0
Microsoft Visual C++, 32-bit Learning Edition 6.0
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q241750&
The following methods in CHtmlView cause a memory leak if called:
Navigate
GetFullName
GetType
GetLocationName
GetLocationURL
LoadFromResource(LPCTSTR lpszResource)
LoadFromResource(UINT nRes)
|
|
|
|
|
I noticed the example code never calls CSTHtmlDialog::DeleteHtmlImages() nor does it ever call destroy window (since it called ::CreateWindow in CSTHtmlDialog::CreateHtmlWindow) - i forget does this window get automatically destroyed when it's parent is destroyed?
Anyone?
|
|
|
|
|
Hi.
Your sample interest me but use HtmlView.dll. Do you know if this dll is still support under Windows CE .net 4.0?
I use embedded Visual C++ 4.0 under WinCE .net 4.0. Every sample I found didn't work. There is compilation problem.
I'm trying to see if I can integrate htmlview.dll in my SDK but if you have an idea to help me, please let me know.
Thanks a lot.
Christian Dubois
|
|
|
|
|
Should be supported in WinCE .net 4.2.
Don't know yet but that's what Microsoft web sites claim.
|
|
|
|
|
I can use html text in my html control for PocketPC 2003, but images fail to display. I hate to think I'll have to try to host the CF's html control to fix this incompatibility...
|
|
|
|
|
hi everyone
I follow the step of "Using STHtmlDialog library",but have one error that is "~\STHtmlDialog\STHtmlDialog.cpp(4) : fatal error C1083: Cannot open include file: 'resource.h': No such file or directory"
Please tell me how to debug!
GOLDEN
|
|
|
|
|
hi everyone
Please tell me how to find the document that about the HtmlView or WebBrowser Control in EVC3.0 . Because i want to develop a web browser application . But i can't find the HtmlView Control in the EVC tool . I ever developed the basic function of web browser on PC . But i can't find the HtmlView Control so i can't develop the browser function that be like "goback" or "gohome"
CHICKEN
|
|
|
|
|
If i want to use Existing ListView Class and i want to call that class on link of next page.how could i do it?i am not fully aware of html control class of pocket pc?
|
|
|
|
|
I keep getting an Access Violation on exit when running as a WCE ARM Debug build on my iPAQ Pocket PC. I get this same Access Violation on exit when I just use the HTML Viewer directly (without your wrapper). Does this not work on Pocket PC? Or am I doing something else wrong?
Any help appreciated.
Thanks,
/Heather
|
|
|
|
|
Hmmm... I'm getting a similer odd error in my program; think I've tracked it down to flipping between multiple CHTMLViews in some of my property pages. "tracked it down" is a slippery statement, of course.
I copied the supplied CSTHtmlDialog class and made a CSTHtmlView class so I could tack it into a tabbed propertypage (several tabs in fatc )
I am looking into the lack of destroywindow calls in this class. Heather, did you ever find your bug?
Thanks, I will update this comment if I find the culprit!
|
|
|
|
|
well, after few hours of tracing down this bug, it turns out that the htmlview control cannot handle long file names!!
of course on the MSDN example its something like:
SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT(""));
now.. try replacing "pic.gif" with "whycantstupidmshandlelongfilenames.gif" and you will get the access violation error.
|
|
|
|
|
How can I handle the events occur when button click or when the selected elenment on combobox? Is there no way?
|
|
|
|
|
-Press Ctrl+W
-Handle any events that you want
or
-Double click on your button in resource view
I'm a Vietnamese student
|
|
|
|
|
How can I use the 'goback','goforward'and 'goHome'?
|
|
|
|
|
How can I load a html file in this programme ?
Thanks !
|
|
|
|
|
|
I want to load a html file in this app directly,
For example,
SetHtml(_T("\\1.htm")) ;
But this method is no use.
How could I ?
Thanks for your help !
Dalek
|
|
|
|
|
First of all you should read your text file into a string.
Then you should convert ANSI to Unicode (only if your text file is ANSI). Read more about convertng at:
http://www.pocketpcdn.com/articles/strings.html
"Strings on Pocket PC, Unicode and ANSI".
Then you should use SetHtml method of CSTHtmlDialog.
CSTHtmlDialog does not support reading from file in this version but I will add it in the next version.
Best regards,
Vassili Philippov
MS-MVP Mobile Devices
|
|
|
|
|
cool, when will the next version be available?
i have one problem with reading from file. I use CreateFile and ReadFile and it seems that I have to use a char[] buffer with a constant size. Of course, I don't know yet how big the html-files will be.
What can I do?
Make the buffer so big, that it can handle all sizes of files?
Use a different String Type in ReadFile?
Read files in another way?
thx, Daniel
|
|
|
|
|
Is there A way to make the same thing with Visual 6.0 for Windows 2000
thanks
|
|
|
|
|
Sure.
Read an article of my friend about developing
Web-Style user interface for desktop applications:
http://www.spbteam.com/rk/notes/webstyle-ui.html
He participated in 2 comertial projects that used
HTML based user interface and were developed with VC++ 6.0.
Best regards,
Vassil Philippov
|
|
|
|
|
Visual Studio .Net supports HTML dialogs from the box, but that wasn't the question.
You could look up Ralph Waldens HTML control at http://www.keyworks.net/code.htm. Ralph was the lead architect for WinHelp and HTML Help. His control enables to view an HTML file from a compiled HTML Help file (.chm), but I seem to remember the control could load from resources as well.
Quite nice! It, of course, uses Internet Explorer.
A light alternative is QTM from gipsysoft: http://www.gipsysoft.com/qhtm/index.shtml. It doesn't support all HTML tags, but good enough for the not-so complex HTML. Doesn't rely on IE...
VictorV
|
|
|
|
|
You did a good job of encapsulating some of the more annoying characteristics of the HTML control! However, I do have one question: Why is the use of HTML advantageous in a dialog?
Usually, dialogs are designed for user interaction, which means controls other than static text and static images are needed. To handle this in HTML, you would either need a CGI that can accept a form submission, or handle JavaScript/VBScript events. Neither option is viable on a PocketPC, as you pointed out in your article.
One of the powers of HTML is that you text layout is flexible. Different browsers can use different fonts, font sizes, and window sizes, and still be able to view the page in a comfortable manner. In contrast, PocketPCs all have the same size screen, the same fonts and the same font sizes available.
Please, do not take my comments the wrong way. I think your encapsulation effort is great! I just do not agree with your rational for using HTML in dialog boxes.
--
Paul
"I drank... WHAT?"
|
|
|
|
|
I wrote this article because many developers in newsgroups asked questions about using HTML in dialogs. So it's needed.
I also think that sometimes it's a good idea to use HTML based dialogs in offline applications. Read article about Web-style user interface:
http://www.spbteam.com/rk/notes/webstyle-ui.html
More over for HTMLDialog you could use all power of CGI, and even better. You could handle links by your program so you could use database, network and other features that are provided by eVC.
Vassili Philippov
|
|
|
|
|