Solved

Need example of using GetWindowHwnd and SetWindowPos

Posted on 1998-03-20
3
1,573 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
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

744 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

20 Experts available now in Live!

Get 1:1 Help Now