Solved

Need example of using GetWindowHwnd and SetWindowPos

Posted on 1998-03-20
3
1,715 Views
Last Modified: 2008-02-01
I am trying to set the postion of a Dialog box in my application. I was looking into how to use the SetWindowPos function, but do not know how to implement this in the dialog's OnInitDialog call. Apparently i need to get the handle of the dialog first.
0
Comment
Question by:englm
[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
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1183671
You seem to be using MFC.  In that case, you already have the handle inside the CDialog class.
Since CDialog is a sub-class of CWnd, you can just call CWnd::SetWindowPos() from your OnInitDialog() function (you can omit the "CWnd::" qualifier).  You don't have to supply the handle, check the documentatation of CWnd::SetWindowPos().

BTW, MFC related questions have a better chance to be correctly answered in the "MFC" area.
0
 
LVL 4

Expert Comment

by:tflai
ID: 1183672
By the way, MoveWindow() gets the job done much easier, if all you want is move or resize the window.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1183673
Right.  If you don't need to set the Z-order of the window (position it "behind" or "in front of" other windows) than MoveWindow() is better.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

631 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