Solved

Using HtmlHelp() function launches a window on the wrong monitor.

Posted on 2008-10-27
2
372 Views
Last Modified: 2013-12-14
When I use the HtmlHelp() function in the Windows API to display my .chm file, the help window appears on a different monitor.  I have my application running on the right-hand monitor, and the help window appears on the left monitor.

How can I control where the window appears?

I am using HH_DISPLAY_TOPIC.

Thanks.
HWND hwnd = ::HtmlHelp( wnd, url, HH_DISPLAY_TOPIC, NULL ) ;

Open in new window

0
Comment
Question by:Blivrail
2 Comments
 
LVL 3

Accepted Solution

by:
Norbert earned 250 total points
ID: 22819805
The HtmlHelp function delivers the window Handle of the Help Window.
Yo can use the MoveWindow Function to move the window where ever you want.

RECT r;

GetWindowRect(wnd,&r);
 

HWND hwnd = ::HtmlHelp( wnd, url, HH_DISPLAY_TOPIC, NULL ) ;

if(hwnd!=NULL)

{

    //overlaps the window wnd with the help window

    MoveWindow(hwnd,r.left,r.top,r.right-r.left,r.bottom-r.top,TRUE);

}

Open in new window

0
 

Author Comment

by:Blivrail
ID: 22823922
I tried your method and it worked beautifully, although I wouldn't think that resizing the help window to be the same as the calling window would be nice.

I changed it so that it would center over the existing window instead.
RECT r;

GetWindowRect(wnd,&r);

 

HWND hwnd = ::HtmlHelp( wnd, url, HH_DISPLAY_TOPIC, NULL ) ;
 

if ( hwnd )

{

    RECT r2 ;

    GetWindowRect( hwnd, &r2 ) ;
 

    // Center the help window (r2) based on the parent window (r).

    LONG rHCenter = ( r.right + r.left ) / 2 ;

    LONG rVCenter = ( r.top + r.bottom ) / 2 ;

    LONG r2HalfWidth = ( r2.right - r2.left ) / 2 ;

    LONG r2HalfHeight = ( r2.bottom - r2.top ) / 2 ;

    MoveWindow( hwnd,

                rHCenter - r2HalfWidth,

                rVCenter - r2HalfHeight,

                r2.right - r2.left,

                r2.bottom - r2.top,

                TRUE

              ) ;

}

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now