Solved

Changing an initial position of a dialog

Posted on 1999-01-13
10
283 Views
Last Modified: 2013-11-20
I want to create a dialog that will start at a known position (not in the middle of the screen as the default).
I tried:
BOOL CMyDlg::PreCreateWindow(CREATESTRUCT& cs)
{      
    cs.cy = Const;
    cs.cx = Const;
    cs.y = Const;    
    cs.x = Const;      

    return CDialog::PreCreateWindow(cs);
}
But it doesn't work.
Any ideas?
Thanks.
0
Comment
Question by:gilbert_chang
  • 6
  • 4
10 Comments
 
LVL 4

Accepted Solution

by:
nil_dib earned 40 total points
ID: 1327597
Try
SetWindowPos( &wndTopMost, 5, 5, 80, 80, SWP_SHOWWINDOW);
in OnInitDialog().
0
 

Author Comment

by:gilbert_chang
ID: 1327598
I have. Doesn't work.
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1327599
Oppps ....
this work fine in my app ....
BOOL CMyDlg::OnInitDialog()
{
      CDialog::OnInitDialog();

      SetWindowPos( &wndTopMost, 5, 5, 80, 80, SWP_SHOWWINDOW);
      
      return TRUE;  // return TRUE  unless you set the focus to a control
}

did you delete the PreCreateWindow method?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:gilbert_chang
ID: 1327600
I did delete the PreCreateWindow method.
All this line does is change the dimensions of the window, but not it's position.
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1327601
mail me your code
jds1@ipa.fhg.de
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1327602
mmhhh....
the code works fine
I set the lParam to a value, and the dialog is displayed in the
top left corner.

LONG lParam = 100;

CMyDlg dia;
xPos = LOWORD(lParam);  // horizontal position of cursor
yPos = HIWORD(lParam);  // vertical position of cursor
...

Could it be that the lParam is exact the value of the mid screen coorinates?
Try to set xPos and yPos to a value.
CMyDlg dia;
xPos = 100;  // horizontal position of cursor
yPos = 100;  // vertical position of cursor
and look for the result ....

0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1327603
Another idea: look for the return value of SetWindowPos.
Should be 1.
0
 

Author Comment

by:gilbert_chang
ID: 1327604
It shouldn't matter much, since when I tried your:
SetWindowPos( &wndTopMost, 5, 5, 80, 80, SWP_SHOWWINDOW);
It didn't work either, with nothing to do with xPos,yPos.
I debugged, and got xPos=550, yPos=y , so it should have changed something anyway.
Is it possible that I am creating some kind of a dialog that resets its position after OnInitDialog?
Thanks.
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1327605
No, I've tested your code and it works (with lParam = 100).
>>and got xPos=550, yPos=y
What is y (What is the value of lParam)?
Which compiler?
Do you have other windows displayed at the same time?
 

0
 

Author Comment

by:gilbert_chang
ID: 1327606
y=0, VC++5,I have another window (The main window) displayed at the same time.
The window we are talking about should be one that pops when the mouse moves over something.
thanks
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 73
while loop over for loop 7 115
has22 challenge 11 105
Fibonacci challenge 11 133
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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