954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to create click-on button in c

i have searched everywhere and i cannot find a simple c example for creating a simple click button, where if the user clicks on it, the program prints something to the screen, or something. any help would be very appreciated.

ben25x
Light Poster
41 posts since Dec 2010
Reputation Points: 10
Solved Threads: 1
 

You have to write a GUI program. For MS-Windows here is a tutorial

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

ok, the link brought me to some helpful code, but the compiler (Visual C++) is saying the 2nd argument in MessageBox isnt the correct type. once again, I run into LPCWSTR.

#include <windows.h>

int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR pszCmdLine, int iCmdShow)
{
	MessageBox(NULL, "Text", "Title", MB_OK | MB_ICONEXCLAMATION);
	return 0;
}
ben25x
Light Poster
41 posts since Dec 2010
Reputation Points: 10
Solved Threads: 1
 

Try this

MessageBox(NULL, L"Text", "Title", MB_OK | MB_ICONEXCLAMATION);
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
 

Or don't compile your code for UNICODE. Go to project --> Settings --> General and turn UNICODE off.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: