How to set buttons in the center of the window?

So, I started working with windows.h again, because Qt seems like I am not really learning anything, and in Qt you could set things in the center and then resize the window and the button will stay in the center, like everything else that we use on the computer.

How can I do that in real code, in windows.h, if I have to be specific.

Oh, and how do I set the text in a textbox as a string? Like, I can make a text box but it doesnt do anything but allow you to type in it.
i don't use windows.h but i'm assuming it would be something like this for the button.

button.setPostion(window.getSize().x / 2 - button.getSize().x, 
window.getSize().y / 2 - button.getSize().y;)
Last edited on
No, it's nothing like that. Windows.h is a C header, and C has no concept of OOP programming.

Any WinAPI tutorial on Google should really answer this question. Did you try it yet?
MSDN Library is your friend, start here
as i said i don't use it
Yeah, I don't like the MSDN Library so much. I mean, I still use it... but it is NOT very specific to me at all. That, and it is IMPOSSIBLE to navigate for all the syntaxes and APIs. To me, at lease. I will try that, but do you know any other tutorials on this kinda thing???
You will need to process WM_SIZE message and rearrange button position yourself.

This is not an easy task.
AceDawg45 wrote:
I will try that, but do you know any other tutorials on this kinda thing???
No, I learned the basics of WinAPI from Petzold and Richter, the rest I get (mainly) from MSDN.

Petzold : Programming Windows (5th edition)

Richter : Windows Via C/C++ 5th Edition
Last edited on by Canis lupus
Topic archived. No new replies allowed.