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.

1
2
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?
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)
http://www.amazon.co.uk/Programming-Windows%C2%AE-Microsoft-Charles-Petzold-ebook/dp/B004OR1XLK/ref=sr_1_4?ie=UTF8&qid=1392367298&sr=8-4&keywords=petzold

Richter : Windows Via C/C++ 5th Edition
http://www.amazon.co.uk/Windows-Via-Edition-Jeffrey-Richter/dp/0735663777/ref=sr_1_1?ie=UTF8&qid=1392366739&sr=8-1&keywords=Windows+via+C%2B%2B
Last edited on by Canis lupus
Topic archived. No new replies allowed.