-
Notifications
You must be signed in to change notification settings - Fork 1
Getting starting
Semyon Gritsenko edited this page Jun 17, 2021
·
2 revisions
#include <iostream>
#include "GUIFramework.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);
unique_ptr<SeparateWindow> mainWindow(make_unique<SeparateWindow>(className, title, settings, functionName));
mainWindow->setExitMode(BaseComponent::exitMode::quit);
new Button(L"SimpleButton", L"Some text on button", 0, 0, mainWindow.get(), [](WPARAM, LPARAM) -> LRESULT { cout << "Click" << endl; return 0; });
MSG msg = {};
while (GetMessageW(&msg, nullptr, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
CREATE_DEFAULT_WINDOW_FUNCTION(main)
int main(int argc, char** argv)
{
gui_framework::GUIFramework& ref = gui_framework::GUIFramework::get();
ref.addTask([]() { test(L"Main window", L"Title", "main", 300, 200); });
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
ref.addTask([]() { test(L"Main window", L"Title", "main", 300, 200); });. This method pass task to thread pool. - You need to write next code for each separate window:
MSG msg = {};
while (GetMessageW(&msg, nullptr, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
This cycle handles all messages for your window.
- This code
mainWindow->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::ComponentSettingsis WinAPI styles.