Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    207
    Points
    395
         User Info     Contact     Gamer ID
    Join Date
    Mar 2010
    Posts
    207
    Points
    395

    Default CBPGUI C++ Library (Beta)

    Lately I've been working on a C++ library that was built around the Win32 API. This library is an OO library made for quick and easy GUI creation for applications on the Windows operating system. You can download it here. Please take some time to look through all the files and let me know if you've found any errors, or places where more functions could be added, or places where things can be done better.

    I'll now provide a few examples, but before you run any of these you need to set up the library. It is rather easy to do, just download the folder, and extract it to your include folder for your IDE.

    Examples:

    Basic & Blank Window:
    Code:
    //Include the headers.
    #include <CBPGUI/CBPGUI.h>
    //Allow access to the CBPGUI namespace.
    using namespace nsCBPGUI; 
    //Application entry point will be called when the program is ran, this is just a defined as WinMain.
    ApplicationEntryPoint ()
    {
    	//Create the window.
    	WindowCreation Window ("CBPGUI Library Testing Application");
    	//Set the size.
    	Window.SetLocation (315, 115, 700, 480);
    	//Create the window, and exit the application is the window couldn't be created.
    	if (Window.Create () < 0) return 0;
    	//Handle the messages.
    	return MessageLoop ();
    }
    Adding a window procedure, just like in Win32, message handling will be in the WindowProcedure functions.

    Code:
    #include <CBPGUI/CBPGUI.h>
    using namespace nsCBPGUI; 
    //Window procedure function.
    LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
    {
    	//Handle the messages.
    	switch (uiMsg)
    	{
    		case WM_DESTROY: //When we destroy the window.
    			PostQuitMessage (0); //Exit the message loop.
    			break;
    		default: //handle all other messages.
    			return DefWindowProc (hWnd, uiMsg, wParam, lParam);
    	}
    	return 0;
    } 
    ApplicationEntryPoint ()
    {
    	WindowCreation Window ("CBPGUI Library Testing Application");
    	Window.SetLocation (315, 115, 700, 480);
    	//Add the callback.
    	Window.SetCallback (WndProc);
    	if (Window.Create () < 0) return 0;
    	return MessageLoop ();
    }
    Now lets get onto making some controls, like buttons, edit boxes, ect.

    Code:
    #include <CBPGUI/CBPGUI.h>
    using namespace nsCBPGUI;
    LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
    {
        //Allocate the edit box only one time.
        static EditCreation EditBox (hWnd); //Set parent window in the constructor.
    	switch (uiMsg)
    	{
    		case WM_DESTROY:
    			PostQuitMessage (0);
    			break;
    		case WM_CREATE: //When the window is created, I use this time to create controls.
    			{
    				//Create a button.
    				ButtonCreation Button (hWnd); //Set parent window in the constructor.
    				Button.SetLocation (5, 5, 130, 30); //Set the location.
    				Button.SetText ("Click Me!"); //Set the text.
    				Button.SetMenuID (1000); //Set the ID, so we know when its clicked.
    				Button.Create (); //Create the button.
    				//Create an edit box.
    				EditBox.SetLocation (150, 5, 130, 30); //Set the location.
    				EditBox.Create (); //Create the edit box.
    			}
    			break;
    		case WM_COMMAND: //When something happens.
    			switch (LOWORD (wParam))
    			{
    				case 1000: //1000 = the button Menu ID.
    					//Display the text in the edit box.
    					MessageBox (hWnd, EditBox.GetText ().c_str (), "Message:", MB_OK);
    					break;
    			}
    		default:
    			return DefWindowProc (hWnd, uiMsg, wParam, lParam);
    	}
    	return 0;
    }
    ApplicationEntryPoint ()
    {
    	WindowCreation Window ("CBPGUI Library Testing Application");
    	Window.SetLocation (315, 115, 700, 480);
    	Window.SetCallback (WndProc);
    	if (Window.Create () < 0) return 0;
    	return MessageLoop ();
    }
    We can also print text easily:
    If you want you can change the font, see Font.h

    Code:
    #include <CBPGUI/CBPGUI.h>
    using namespace nsCBPGUI;
    LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uiMsg)
    	{
    		case WM_DESTROY:
    			PostQuitMessage (0);
    			break;
    		case WM_PAINT: //When we paint the window, used for displaying graphics.
    			{
    				//Create an object to the DeviceContext.
    				DeviceContext DC (hWnd); //Set the window to print to in the constructor.
    				DC.PrintText (5, 5, "Hello World!!!!"); //Print the text at (5, 5)
    			}
    			break;
    		default:
    			return DefWindowProc (hWnd, uiMsg, wParam, lParam);
    	}
    	return 0;
    } 
    ApplicationEntryPoint ()
    {
    	WindowCreation Window ("CBPGUI Library Testing Application");
    	Window.SetLocation (315, 115, 700, 480);
    	Window.SetCallback (WndProc);
    	if (Window.Create () < 0) return 0;
    	return MessageLoop ();
    }
    There are many other things that you can do with this library, and many more things will be added soon.

    Again, please let me know if you have any more ideas for this library, it is far from complete and your help in completing it would be great.

    When the library is complete, tutorials on using each feature will be added to the CBP youtube channel:

    http://youtube.com/user/CurlyBraceProduction


    -LeetGamer

    0 Not allowed! Not allowed!
    AIM & Skype: iLeetGamerX

    Youtube: http://www.youtube.com/user/CurlyBraceProduction

  2. #2
    Extreme Noob
    I can count to potato.
    KyzZLe's Avatar
    Join Date
    Jun 2010
    Location
    California
    Posts
    98
    Points
    265
         User Info     Contact     Gamer ID
    Join Date
    Jun 2010
    Location
    California
    Posts
    98
    Points
    265
    Gamer IDs

    Gamertag: Mongrisimo PSN ID: Loptosaurus

    Contact info:

    Youtube Channel: http://www.youtube.com/NextGenClan

    Default

    Quote Originally Posted by -LeetGamer- View Post
    There are many other things that you can do with this library, and many more things will be added soon.

    Again, please let me know if you have any more ideas for this library, it is far from complete and you're help in completing it would be great.

    When the library is complete, tutorials on using each feature will be added to the CBP youtube channel:

    http://youtube.com/user/CurlyBraceProduction


    -LeetGamer
    your*

    0 Not allowed! Not allowed!

  3. #3
    Member
    Join Date
    Mar 2010
    Posts
    207
    Points
    395
         User Info     Contact     Gamer ID
    Join Date
    Mar 2010
    Posts
    207
    Points
    395

    Default

    oopss

    0 Not allowed! Not allowed!
    AIM & Skype: iLeetGamerX

    Youtube: http://www.youtube.com/user/CurlyBraceProduction

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 11:28 AM.
Powered by vBulletin®
Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.