How to set buttons in the center of the window?

Feb 13, 2014 at 9:39pm
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.
Feb 13, 2014 at 10:54pm
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 Feb 13, 2014 at 10:55pm
Feb 13, 2014 at 11:43pm
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?
Feb 13, 2014 at 11:57pm
closed account (z05DSL3A)
MSDN Library is your friend, start here http://msdn.microsoft.com/library/windows/desktop/ff381399(v=vs.85).aspx
Feb 14, 2014 at 12:46am
as i said i don't use it
Feb 14, 2014 at 1:10am
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???
Feb 14, 2014 at 7:31am
You will need to process WM_SIZE message and rearrange button position yourself.

This is not an easy task.
Feb 14, 2014 at 8:40am
closed account (z05DSL3A)
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 Feb 14, 2014 at 8:42am by Canis lupus
Topic archived. No new replies allowed.