Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7636465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:41:16+00:00 2026-05-31T07:41:16+00:00

I have a modeless dialog, which is owned by the main window and snapped

  • 0

I have a modeless dialog, which is owned by the main window and snapped to the certain reference point in the main window. I do this by computing the top-left corner of the reference point in the screen co-ordinates, and assigning it to the Top and Left properties of the owned window.

When I open that owned modeless dialog, everything is OK. Then, when I move the main window by the mouse, I’d like the owned dialog to move at the same time. To achieve this, I re-compute the screen position of the reference point and pass it to the Top and Left properties of the owned window in the MouseMove event handler. Apparently, such thing should work (cf. the thread:
Lock a window position to another window?
). In my case, however, the owned window doesn’t move with the owner, rather, only when I drop the main window and hover on its client area the owned window jumps to its intended position.

In MFC, I could work around by sending the WM_WINDOWPOSCHANGED event to the owned window. But what can I do in WPF?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:41:17+00:00Added an answer on May 31, 2026 at 7:41 am

    Code below is working very well for me. There is also a bit more complex binding solution.

    In your main window get the event for LocationChanged:

    <Window ... LocationChanged="Window_LocationChanged">
    

    In the code-behind, keep the dialog as a field of the MainWindow. Then have the following code:

    public partial class MainWindow : Window
    {
        // keep a reference to the dialog
        Dialog m_dlg;
    
        public MainWindow( ) {
            InitializeComponent( );
        }
    
        ...
    
        private void createDialog( ) {
            m_dlg = new Dialog( );
            realign( );
            m_dlg.Show( );
        }
    
        // change the dialog left and right when the main window moves:
        private void Window_LocationChanged( object sender, EventArgs e ) {
            realign( );
        }
    
        private void realign( ) {
            if( m_dlg != null ) {
                m_dlg.Left = this.Left + 30;
                m_dlg.Top = this.Top + 30;
            }
        }
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a modeless dialog box being generated which prompts users to open a
I have a modeless dialog which i need to show multiple instances of it
I like to write a modeless dialog based app, but I have a problem.
I have a very weird behaviour in a screen with a modeless dialog and
In the main view of my application, I create a modeless dialog i.e.: CMyDialog
I always have trouble remembering whether the modal or modeless dialog is the one
I have a modeless dialog that overrides closeEvent() in order to save its state.
I have an application with tray icon. There is a hidden main window (CMainFrm),
I have an installer which installs about 40 files and two directories. This installer
From what I understand to make dialog Modeless you have to allocate it on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.