Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-27
2
Medium Priority
?
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
Norbert earned 750 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

715 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