Solved

Need example of using GetWindowHwnd and SetWindowPos

Posted on 1998-03-20
3
1,609 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

770 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