SavvyUI C++ Windows Component Library

Getting Started

Create Application

NOTE: The following instructions are specific for Visual Studio 2019, but these steps may only differently for other versions of Visual Studio.

  1. Start Visual Studio
  2. Click the "Create a new project" button
  3. Select the "Windows Desktop Application" C++ template and click Next
  4. Enter the name of your new application in the "Project Name" field
  5. Enter or choose the location/folder you want this new project to be saved under
  6. Leave the "Place solution and project in the same directory" option checked, and then click the Create button to create the project

The generated project will contain a .cpp file, which contains the main function for this project, replace the content of this file with the following:

			#include <include/Frame.h>
			#include <include/EventListeners.h>

			#include "framework.h"
			#include "MyApplication.h"

			class MainFrame : public Frame
			{
				CardPanel _cardPanel;
				
			public:

				MainFrame(const wstring& wndClassName, const wstring& title): Frame(wndClassName, title)
				{
					Theme::GetInstance()->setDarkTheme(); // setSilverTheme()
					
					setLicense(L"Set Your License String Here!!!");
				}


				void onConstructWindow()
				{
					setWindowCentered();

					// Add the child components
					RECT clientRect;
					GetClientRect(getNativeWindowHandle(), &clientRect);

					GridPanel* contentPane = getContentPane();
					contentPane->setLayout({ 5, -1, 5 }, { 5, -1, 5 });
					contentPane->addComponent(CreateCardPanel(contentPane->getNativeWindowHandle(), clientRect), 1, 1);
				}
				
				Component *CreateCardPanel(HWND hwndParent, RECT rect)
				{
					_cardPanel.createComponent(hwndParent, rect);

					return &_cardPanel;
				}
			};

			//============================================= Main Entry Function =========================================

			#define MAX_LOADSTRING 100

			int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
								 _In_opt_ HINSTANCE hPrevInstance,
								 _In_ LPWSTR    lpCmdLine,
								 _In_ int       nCmdShow)
			{
				UNREFERENCED_PARAMETER(hPrevInstance);
				UNREFERENCED_PARAMETER(lpCmdLine);

				WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
				WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name

				LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
				LoadStringW(hInstance, IDC_MYAPPLICATION, szWindowClass, MAX_LOADSTRING);

				RECT rect;
				rect.left = 0;
				rect.top = 0;
				rect.right = 1400;
				rect.bottom = 900;

				MainFrame frame(szWindowClass, szTitle);
				return frame.createComponent(nullptr, rect);
			}
								

Update the Project Settings

NOTE: The following instructions are specific to Visual Studio 2019, but they should be similar for other versions of Visual Studio.

  1. Right-click the project node under the Solution Explorer panel, and select Properties from the context menu, we will assume that you want to create 64-bit applications only, so we will configure the x64 Debug and Release configurations only.
  2. Under the Project Property Pages dialog, select "Debug" from the Configuration dropdown, and select "x64" from the Platform dropdown
  3. Expand the "Configuration Properties" node
  4. Click the "VC++ Directories" node, and then click the "Include Directories" value inside the right-side panel, this will shown the dropdown arrow, click it, and then click the "<Edit...>" selection under that dropdown.
  5. Add the path of the SavvyUI library folder inside the box at the top of the shown dialog; i.e. c:/SavvyUI, and then click OK.
  6. Click the "Library Directories" value inside the right-side panel, this will shown the dropdown arrow, click it, and then click the "<Edit...>" selection under that dropdown.
  7. Add the path of the SavvyUI library folder inside the box at the top of the shown dialog; i.e. c:/SavvyUI, and then click OK.
  8. Next, expand the "Linker" node under Configuration Properties inside the left-side panel.
  9. Click the "Input" node under the Linker node.
  10. Click the "Additional Dependencies" value inside the right-side panel, this will shown the dropdown arrow, click it, and then click the "<Edit...>" selection under that dropdown.
  11. Add the entry "SavvyUI_X64_Debug.lib" without the double-quotes to the box at the top of the shown dialog; i.e. SavvyUI_X64_Debug.lib, and then click OK.
  12. Repeat these steps for the Release x64 Configuration, but this time, specify the library name as SavvyUI_X64.lib instead of SavvyUI_Debug.lib. Click OK when done to save the changes you made to these configurations in the Project Property Pages dialog.