-
Notifications
You must be signed in to change notification settings - Fork 1
Getting starting
Semyon Gritsenko edited this page Jun 22, 2021
·
2 revisions
#include <iostream>
#include "GUIFramework.h"
#include "WindowHolder.h"
#include "Composites/SeparateWindow.h"
#include "Components/Button.h"
#pragma comment (lib, "GUIFramework.lib")
using namespace std;
void test(const wstring& className, const wstring& title, const string& functionName, int x, int y)
{
using namespace gui_framework;
utility::ComponentSettings settings(WS_BORDER, x, y, 800, 600);
WindowHolder holder(make_unique<SeparateWindow>(className, title, settings, functionName));
holder.get()->setExitMode(BaseComponent::exitMode::quit);
new Button(L"SimpleButton", L"Some text on button", 0, 0, holder.get(), [](WPARAM, LPARAM) -> LRESULT { cout << "Click" << endl; return 0; });
holder.get()->setLargeIcon("assets/icon.ico");
holder.runMainLoop();
}
CREATE_DEFAULT_WINDOW_FUNCTION(main)
int main(int argc, char** argv)
{
gui_framework::GUIFramework& ref = gui_framework::GUIFramework::get();
thread(test, L"Main window", L"Title", "main", 300, 200).detach();
string s;
while (cin >> s)
{
}
return 0;
}
- CREATE_DEFAULT_WINDOW_FUNCTION(main) macro for creation default separate window procedure. You need to do this for each separate and child window, and after pass this name to constructor.
- In this example window creates and works in another thread by calling
thread(test, L"Main window", L"Title", "main", 300, 200).detach();
. - You need to write next code for each WindowHolder:
holder.runMainLoop();
This method handles all messages for your window. - This code
holder.get()->setExitMode(BaseComponent::exitMode::quit);
control close behavior. quit fully close all windows and stop receiving messages, destroyWindow(default) only close current window. - This
#pragma comment (lib, "GUIFramework.lib")
link program with GUIFramework library. - All styles in
utility::ComponentSettings
is WinAPI styles.