Auto scroll with CDHtmlDialog #2

[this is a re-post of the post I made August 10.  I tried setting up my
MSDN email alias again with a new alias to see if it makes a difference]

I am working on a little MFC 7.1 program for a friend and one thing I want
to do is load HTML into a fullscreen window.  I want the contents of this
window to smoothly scroll automatically (no user input) and when it reaches
the bottom to pause for a few seconds and then jump back to the top.

So I need to know:

1.  How to automatically vertically scroll the CDHtmlDialog window smoothly
without any user input (with a user adjustable rate).

2.  How to detect that I've reached the bottom of the HTML page.

3.  How to get the HTML page to jump back to the top after pausing at the
end.

I am using CDHtmlDialog and I have got it to load the web page show the
browser's scroll bar (thanks to Google Groups).  However, I don't know if I
need the scroll bar to do this or if it is accessible.

TIA
0
The
8/15/2005 4:43:41 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1331 Views

Similar Articles

[PageSpeed] 19

"The March Hare [MVP]" <" philatndsmdotmaps"@online.nospam> wrote in message 
news:1hmhr48n8pwez$.7z5hxo3yjuud.dlg@40tude.net...
> [this is a re-post of the post I made August 10.  I tried setting up my
> MSDN email alias again with a new alias to see if it makes a difference]
>
> I am working on a little MFC 7.1 program for a friend and one thing I want
> to do is load HTML into a fullscreen window.  I want the contents of this
> window to smoothly scroll automatically (no user input) and when it 
> reaches
> the bottom to pause for a few seconds and then jump back to the top.
>

Did you post this also in the webbrowser newsgroup?  You'll have much better 
response there.

-- David


0
dc2983 (3206)
8/15/2005 11:05:09 PM
Hi Phil,

Sorry for the delay response, it appears you still have some registration 
problems, we couldn't  find this post in our MSDN managed post queue, so I 
think you had better to contact our customer service for the MSDN managed 
customer registration issue.

>1.  How to automatically vertically scroll the CDHtmlDialog 
>window smoothly without any user input (with a user adjustable rate).

Do you mean the CHtmlView object in your CDHtmlDialog here?
If so, you cannot manupilate the stuff in the CHtmlView directly, it is 
because that the web page in your dialog is just loaded by the inside web 
browser control, which is hosted in the CHtmlView object, and the scroll 
bar you concern is not a common Win32 control neither, it is just painted 
by the web browser control.

So if you want to manupilate the web page, you need to access the 
IHtmlDocument2 interface to get its corresponding HTML document object, to 
scroll the page by code, you can use the 
IHtmlElement::put_scrollTop(scroll_pos) method, for example:

    static long scroll_pos = 0;
    HRESULT hr;
    IDispatch *pDisp = GetHtmlDocument();
    ASSERT( pDisp ); //if NULL, we failed

    IHTMLDocument2 *pDocument = NULL;
    hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
    ASSERT( SUCCEEDED( hr ) );
    ASSERT( pDocument );

    IHTMLElement *pBody = NULL;
    hr = pDocument->get_body( &pBody );
    ASSERT( SUCCEEDED( hr ) );
    ASSERT( pBody );
  
    IHTMLElement2 *pElement = NULL;
    hr = pBody->QueryInterface(IID_IHTMLElement2,(void**)&pElement);
    ASSERT(SUCCEEDED(hr));
    ASSERT( pElement );

    //scroll the web page to the scroll_pos-pixel position from the top:    
    pElement->put_scrollTop(++scroll_pos);

>2.  How to detect that I've reached the bottom of the HTML page.
>3.  How to get the HTML page to jump back to the top after pausing 
>at the end.

It appears no such event you can trap, I suggest you can estimate the 
scrool bar length of the current web page(it depends on the page's scroll 
range), then calculate the bottom position of the scroll_pos...


     //get the current scroll range:
     long scroll_height;
     pElement->get_scrollHeight( &scroll_height );

     //calculate the scrollbar_len:
     long scrollbar_len;
     scrollbar_len = func(scroll_height);
     ...

     if(scroll_pos>scroll_height - scrollbar_len)
    {
           //jump to the top pof the web page
           scroll_pos=0;    
           pElement->put_scrollTop(scroll_pos);
     }
     ...


Hope this helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ��C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn 

This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-garych (605)
8/17/2005 7:05:35 AM
On Wed, 17 Aug 2005 07:05:35 GMT, "Gary Chang[MSFT]" wrote:

> Sorry for the delay response, it appears you still have some registration 
> problems, we couldn't  find this post in our MSDN managed post queue, so I 
> think you had better to contact our customer service for the MSDN managed 
> customer registration issue.

I think I worked this out with MSDN support but I will post another
question in a new thread in this newsgroup so that you can verify that it
is working.

> Do you mean the CHtmlView object in your CDHtmlDialog here?

AFAICT, there is no CHtmlView object in the CDHtmlDialog.  However, I can
use the following code to get the HTML document directly and skip needing
to get the IDispatch interface:

		CComPtr<IHTMLDocument2> document;
		HRESULT hr = GetDHtmlDocument(&document);

> So if you want to manupilate the web page, you need to access the 
> IHtmlDocument2 interface to get its corresponding HTML document object, to 
> scroll the page by code, you can use the 
> IHtmlElement::put_scrollTop(scroll_pos) method, for example:
[...]

I used the rest of the code you provided (rewritten to use smart COM
pointers), thanks.

>>2.  How to detect that I've reached the bottom of the HTML page.
>>3.  How to get the HTML page to jump back to the top after pausing 
>>at the end.
> 
> It appears no such event you can trap, I suggest you can estimate the 
> scrool bar length of the current web page(it depends on the page's scroll 
> range), then calculate the bottom position of the scroll_pos...
[...]

I made this test more robust:

		long current_position(0);
		long height(0);
		hr = element->get_scrollTop(&current_position);
		element->get_scrollHeight(&height);
		// detect bottom of the page
		if (current_position != m_scroll_position || current_position > height) {

Thanks for your help.
0
phil3996 (17)
8/17/2005 2:20:31 PM
Hi Phil,

>             long current_position(0);
>	long height(0);
>	hr = element->get_scrollTop(&current_position);
>	element->get_scrollHeight(&height);
>	// detect bottom of the page
>	if (current_position != m_scroll_position || current_position > height) {

I have also considered this problem again, and found if the scroll bar 
reaches the bottom of the page, then the scroll position will stop as that 
point, so I test the following code for your reference:
                
                ...
                //auto-scroll the page first
                pElement->put_scrollTop(++m_scroll_position);
                
                // detect bottom of the page
	long current_position(0);
                hr = element->get_scrollTop(&current_position);
	if(m_scroll_position  > current_position)
	{
                    m_scroll_position = 0;
	    pElement->put_scrollTop(0);	
	}


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ��C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn 

This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-garych (605)
8/18/2005 3:11:23 AM
Reply:

Similar Artilces:

getdlgitemtext #2
Hi, I meke code from example behind, and not working corectly, buffor "String1" they are no my text in IDC_EDIT1 it is a somthing wrong this bufor, may please send me good idea. void CDialogPASS::OnBnClickedButtonDp2() { CString String1; GetDlgItemText(IDC_EDIT1, String1); } mike 1010 Is IDC_EDIT1 an actual control? I've seen this fail when the control ID changes due to editing of the dialog. joe On Fri, 30 Jun 2006 17:44:33 +0200, "1010" <mig1010@wp.pl> wrote: >Hi, > >I meke code from example behind, and not working >corectly,...

missing buttons #2
I just installed the new Office 2003 edtion. I went into e-mails and my send button and now my paper clip button are missing. I've checked in where you can add buttons but they're not in their either. What can I do to find them. Are you using Word as your e-mail editor? -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the message thread. *** In news:4E889BAD-E127-4AF8-BC98-7AB117D0B90B@microsoft.com, Sharon wrote: > I just installed the new Office 2003 edtion. I went into e-mail...

forwarding in Exchange 2003 #2
I configured the server (Exchange 2003) to forward a user��s emails to test@xyz.com. It is very strange that all messages sent from xyz.com are rejected (please see the sample NDR below), there is not problem to other domains. test@xyz.com did not receive the message while the envelope recipient (admin@abc.com) did. Does anyone know how to solve this? Any help would be appreciated. Thanks. SC -------------------------------------------------------------------------------------------------------------------------------------------- Your message To: admin@abc.com S...

2 Questions
Hi I run Win 2K with Excel 2K Question 1 I have some VB code in the "Sheet 1" module of my excel file. The code is as follows: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column <> 12 Then Exit Sub On Error GoTo ErrHandler Application.EnableEvents = False Target.Formula = UCase(Target.Formula) ErrHandler: Application.EnableEvents = True End Sub I would like this code to run automatically whenever the file is opened. (I am assuming that this would remove the enable/disable dialog box option when opening the file) Can someone tell ...

Disaster Recovery for CRM 1.2
Does anyone have any documentation on the steps to backing up CRM 1.2? We want to make sure we are backing CRM 1.2 up correctly if the server should go down. We were unable to find any documentation on Microsofts website for a step by step backup solution. Right now we are just backing the CRM databases using the scheduler in SQL; is this ALL that is required and if so do we backup ALL of the databases or just certain ones? The owners of the company want to make sure we can restore ALL of the data if needed. -- Thank You, Troy Hi Troy Microsoft have included details of backing...

Money 2003 restoring a backup asking for a password that does't ex #2
I have microsoft money 2003 at my work and would like to have the same data there in my home. So i made a backup, put on a pendrive and brought it to home. Installed microsoft money 2003 in my home and tried to restore this backup. Money 2003 insists asking a password that does not exist in the original backup file. I already tried to use the repair tool and didn't work. So, what i have to do to make the backup work and does not ask a password that does not exists? Thankyou sorry about the spam, i was using the google chrome and it bugged, sorry again about the tripple post :( "...

Multiple Outlook #2
I imported an Outlook 2000 pst file into Outlook 2003. Now when I open Outlook my Personal Folders appears 4 times in the left hand "All Mail Folders" When I close Outlook it gives me an error and msvbvm60.dll is mentioned. Any help on how to correct this issue would be greatly appreciated. Mick ...

queue stuck #2
HI... i ahve exchange 2003 and i am facing problem that i am getting lot junk email and all messagess are stuck in queue ..after that my server hang so i need to restart server and clear the queue before restart it does't allow me to clear the queue ... pls help me .. tejal ...

Trouble sending emails #2
I am recieving emails, but every time I try to send one I get an error message saying, "The server does not support the required HTTP methods. Ther server responded 'Not Implemented'." I have no idea wht that means or what I need to change. Help! On Thu, 30 Dec 2004 15:05:06 -0800, Tina wrote: > I am recieving emails, but every time I try to send one I get an error > message saying, "The server does not support the required HTTP methods. Ther > server responded 'Not Implemented'." I have no idea wht that means or what I > need to change. ...

hyperlinking to an item in Global Address List Options
I have had success linking via html from web page to opening a specific contact record from Microsoft Outlook. I have done it like this: outlook://Big%20Contacts/Contacts/~Peter%20Crawford However, my very large contact database also has people with basically the same name, like John Smith. In the current "Address Card" view inside Microsoft Outlook, one of the John Smith's is always sorted first. If I enter outlook://Big%20Contacts/Contacts/~John%20Smith the first John Smith in the sort order is always opened. However, I want to specify one of the other John Smith's....

Cannot open assigned task in Outlook 2003 #2
I am using Outlook 2003 on a XP Home PC. When a co-worker creates and assigns me a task, it comes into my Inbox and I can see it in my preview pane, but I cannot open it when I double-click it and I cannot accept or decline it thru the preview pane. My co-worker has Outlook 2003 on a XP Pro PC and has no problem opening and accepting tasks from me. By the way....when I attempt to open it, absolutely nothing happens that I can see....no error, no change of screens, nothing! I have ensured that when the co-worker sends the task, that they do NOT have "text only" set for me. THANKS...

display name #2
hi i have this problem: when i send a mail massage from an application by exchange 2003, in outlook i see the e-mail address (xx@mydomain .com) and not display name (Customer Care) how can i resolve it? Thanks An application should allow you to specify display name for sender. Does it send via SMTP or MAPI? Matrix_pd wrote: > hi > i have this problem: when i send a mail massage from an application by > exchange 2003, in outlook i see the e-mail address (xx@mydomain .com) and > not display name (Customer Care) > > how can i resolve it? > > Thanks -- Please re...

How do I make hyperlink target scroll to the top-left of spreadshe
I can't remember the setting to make Excel automatically scroll my hyperlinked cell to the top-left. For example, if my hyperlink is in cell A1 and the hyperlink destination is cell Z30, when you click the hyperlink in A1 the cell Z30 is now displayed in the top-left of the spreadsheet. It seems like there was a checkbox in the Options dialog box, but now I can't find it. I did this awhile ago, but forgot to write down the information. Hi Lori Tools>Options On the Transition tab Transition navigations keys -- Regards Ron de Bruin http://www.rondebruin.nl "Lori W....

double lookup #2
In Excel2000, I need help with the following formula: my data is arranged like this ( I can rearrange if needed).. joe pete sue rating 30 10 5 A 20 5 3 B 10 2 1 C I then have values for joe, pete, sue. I want to look up the name and then give me the rating. The numbers may not be exact. For example, I want the output to look like this ( with the formula looking up the rating) name amount rating (formula needed) joe 11 C pete 7 B sue 1 C Can someone please help me with the formula to fi...

Attachment Size #2
Hi ! Is it possible to block the adding of attachments in an=20 outlook client ? Or block the adding for attachments that=20 are bigger than 2 MB for example ? Can i get an error=20 Message or something ? (I think about an GPO or Registry=20 change or something else....) I have Users around here with Pop3 Outlook 2000 and=20 Outlook 2003 Clients. The Problem is that some of them are=20 trying to send Mails with Attachments with 300 (three=20 hundred!!) MB or something else like that.... Because they=20 don=B4t look an the size of their attachments. So the Mail is going through our WAN over ...

Auto Response with Exchange 5.5
I would like to create a auto response with Exchange 5.5. So when someone sends mail to careers@domain.com I can have an automated response go back. But I can't setup rules inside of outlook and keep it attached to the server I would like to make some sort of server side rule if possible?? Any suggestions? Thanks, BiG On Fri, 12 Aug 2005 15:09:59 -0400, bigdogg <bigdogg33_2000@yahoo.com> wrote: >I would like to create a auto response with Exchange 5.5. So when >someone sends mail to careers@domain.com I can have an automated >response go back. But I can't ...

auto forward problems
I setup a 'contact' for 5 existing users in Exchange 5.5 Administrator. I give the contacts the desired SMTP address where they want their mail forwarded to. I set the corresponding 'contact' as the 'alternate recipient' for each of the 5 as detailed in Q255697. 2 of 5 work, the other 3 do not. When sending to each of the 5, 3 return undeliverable stating "A configuration error in the e-mail system caused the message to bounce between two servers or to be forwarded between two recipients." Any ideas? -adam Adam SK wrote: > I setup a 'con...

Covert v. 2000 -> v. 2.0
Heelo All after serious cooruption we recover dmb file with Ontrac tools to v. 2000 but application are for v 2.0 are is possible conversion to v. 2.0 thanks Ervins ...

Changing password #2
Hi, If I change a domain user's password, will that user's Exchange Server 2003 mailbox's pssword be changed too? I mean, does Active Directory share the same password with Exchange Server 2003? Thanks! Exchange never had passwords separate from domain, not even in Exchange 4-5.5 era. So you would change just one password, which belongs to AD account. Michael wrote: > Hi, > > If I change a domain user's password, will that user's > Exchange Server 2003 mailbox's pssword be changed too? > I mean, does Active Directory share the same password > w...

2 fonts in Chart title in E2007
We are tranferring code from 2003 to 2007 and noticed a change in how VBA reads the following line: ActiveChart.ChartTitle.Characters(5,2).Font.Color = vbred IN 2003, it reads it correctly coloring letters 5 & 6 red. in 2007, it colors the whole Chart title red. It seems that regardless of the start and length I pass into the characters function, the formatting occurs to the entire chart title, not just the characters I wanted. Even recording the VBA in 2007 yields no help as it cannot record the partial font change, even though the GUI allows it. IN 2003 you can reco...

commissions #2
Can I make a mass change to the item properties to in the DB to allow commissions to be paid on all items.My items are currently set not to allow commissions. -- billr Billr3, Maybe, which method did you want? Did you realize that the default setting is to pay commission by sales rep? -- = Get Secure! - www.microsoft.com/security You must be using Outlook Express or some other type of newsgroup reader to see and download the file attachment. If you are not using a reader, follow the link below to setup Outlook Express. Click on "Open with newsreader" under the MS Ret...

User defined fields #2
Entered user defined fields the way I wanted, however, the software has now put it all in ascending order and there are no sort options available. Any way to correct without having to do it all over? Put in ascending order where?=20 --=20 Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for=20 Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx =20 "Darcy W." <Darcy W.@discussions.microsoft.com> wrote in me...

System hang after upgrade to GP 10 SP 2
Thanks to whoever that may help. My GP10 SP2 system hangs whenever we run the SOA or aging report. It seems that the reports created many connections (around 2-3k no. of connections) to the Database. To the point that it hangs up other users when they try to log-in. Is there any solutions to this? -- JackLaeng Actually it do not completly hang, it may be running too slow due to the huge number of connections requests on the server, this could affect server memory and cause this hang, you may need to find away to create a new report using SQL Analysis Service or find any other way to g...

Auto check email address
When typing in the TO: box, a drop-down list pops up with a list of names to choose from. Is there any way to edit the names in this list? Thanks for your help. I don't think there is. All that is is a list of recent addresses that you used. Same concept as "My Recent Documents" in Windows. I am wondering now if there is a way to reset it? "Pasbrig" <anonymous@discussions.microsoft.com> wrote in message news:1444101c4182b$00e2a410$a601280a@phx.gbl... > When typing in the TO: box, a drop-down list pops up with > a list of names to choose from. > &g...

I want to add scroll bar functionality in my screen capture utility
hi all, i have developed an application that shows a list of all running windows and allows user to capture their screens. I want to add scroll bar functionality in this app. I have add the scrollbar. scroll bars move but they dont scroll the image. please help me thanks & regards shoeb shoeb ali wrote: > hi all, > i have developed an application that shows a list of all running windows and > allows user to capture their screens. I want to add scroll bar functionality > in this app. I have add the scrollbar. scroll bars move but they dont scroll > the image. please ...