Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need example of using GetWindowHwnd and SetWindowPos

Posted on 1998-03-20
3
Medium Priority
?
1,794 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 150 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

Industry Leaders: 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

963 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