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

Recommended Answers

All 5 Replies

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

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

www.cprogramming.com

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.

<CODE>
#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
</CODE

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.

HooperZipper

commented: bump of 4 year old thread -6

Congratulations -- you just answered a four-year-old long dead thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.