ok if i wanted to create something how would i say

if (button"f") {


do yatta yatta

if i wanted to do that how would i... probaly a really STUPID;) quesion but here it is

12 Years
Discussion Span
Last Post by Ancient Dragon

I double my recommendation that you learn the core language before jumping into APIs.

do you have a site that i could do that on..

i use


anything else?:-|


Creating controls (buttons) in C++ is fairly simple. You should already know how to create a window. A button is basically a window (it is creating in the same way with CreateWind), the main differences are that a button/control has its parent handle set to the HWND of the main window (usually). Second, the window style is WS_CHILD. Here's the code. This must be done prior to the message pump. If the button is clicked, the menu is sent along to the WndProc as the WPARAM LOWORD. The button 'class' has been registered with windows as 'BUTTON', so that is what you must use.

#define BUTTON 400 // Passed to the WNDPROC for identification

HWND myButton = CreateWindowExW(NULL, L"BUTTON", L"TextOnButton",
WS_CHILD, 30, 30, 200, 40, parentHandle, BUTTON, GetModuleHandle(NULL), NULL);
ShowWindow(myButton, showWindow); // show button on window
UpdateWindow(myButton); // re-call WndProc

It is fairly simple to create buttons is C++. Unfortunately, the Win32 button is 'ugly' and I recommend creating a new one. Use the Internet Explorer button as a base or even the ones on this website.

I hope this small tutorial helped.


Votes + Comments
bump of 4 year old thread
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.