11# HComponentLibrary
2- Lightweight Java like Windows GUI library for C++
2+ HComponenLibrary is a lightweight UI component library for C++ which is highly inspired by Java Swing. <br >
3+ Project aims to make it easy to convert __ minimal__ Java Swing projects to native Windows application.
4+ ## Sample Applications
5+ A java swing developer can easily understand how to use HComponentLibrary with these examples.
6+ ### "Hello World" Application
7+ Here is an example of how to use library, its syntax hugely inspired by Swing.
8+ ```
9+ #include "windows.h"
10+ #include "HCl.h";
311
4- H Componen Library(HCl) is a free to use lightweight Java like Windows GUI library for C++.
5- HCl classes:
12+ // Starting point of application
13+ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) {
14+ ReportHINSTANCE(hInstance);//send hInstance to HCl to create frame with it
15+
16+ // A frame created with title 'Hello World'
17+ HFrame frame = HFrame("Hello World");
18+ frame.setLocation(10, 10);
19+ frame.setSize(500, 500);
20+ frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
21+
22+ // A button created with label 'Click Me' and set an action listener
23+ HButton but = HButton("Click Me");
24+ but.setSize(100, 30);
25+ but.setLocation(30, 30);
26+ but.addActionListener([](ActionEvent)->int {//action listener as a lambda function
27+ PostQuitMessage(0);
28+ return 0;
29+ });
30+
31+ // Add UI components to frame and set frame visible
32+ frame.add(&but);
33+ frame.setVisible(true);
34+
35+ // Wait all frames to close
36+ return WaitAll();
37+ }
38+ ```
39+ ### An Example With Combo Box
40+ Slightly more complex application with combo box and text field.
41+ ```
42+ #include "HCl.h";
43+ #include "windows.h"
44+
45+ HComboBox combo;
46+ HTextField htf;
47+ // Starting point of application
48+ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) {
49+ ReportHINSTANCE(hInstance);//send hInstance to HCl to create frame with it
50+
51+ HFrame frame = HFrame("Example with HComboBox");
52+ frame.setLocation(50, 50);
53+ frame.setSize(400, 250);
54+ frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
55+
56+ htf = HTextField("");
57+ htf.setSize(170, 25);
58+ htf.setLocation(10, 10);
59+
60+ HButton btnadd = HButton("Add");
61+ btnadd.setSize(100, 25);
62+ btnadd.setLocation(190,10);
63+ btnadd.addActionListener([](ActionEvent)->int{
64+ combo.addItem(htf.getText());
65+ return 0;
66+ });
67+ HButton btndel = HButton("Delete");
68+ btndel.setSize(100, 25);
69+ btndel.setLocation(190, 40);
70+ btndel.addActionListener([](ActionEvent)->int {
71+ combo.removeItemAt(combo.getSelectedIndex());
72+ return 0;
73+ });
74+ frame.add(&btndel);
75+ frame.add(&btnadd);
76+ frame.add(&htf);
77+
78+ String str[] = {"Computer 1","Tablet 1","Tablet 2","Phone 1","Phone 2"};
79+ combo = HComboBox(str,5);
80+ String str2[] = {"a","b","c"};
81+ combo.setList(str2,3);
82+ combo.setSize(300, 400);
83+ combo.setLocation(50, 110);
84+ frame.add(&combo);
85+
86+ HButton but = HButton("Selected Item");
87+ but.setSize(100, 25);
88+ but.setLocation(190, 70);
89+ but.addActionListener([](ActionEvent)->int {
90+ MessageBoxA(0,combo.getSelectedItem(),"You Selected",MB_OK);
91+ return 0;
92+ });
93+
94+ frame.add(&but);
95+ frame.setVisible(true);
96+
97+ combo.addItem("Added after creation");
98+
99+ //Finish your app always with this function, it waits all frames to close
100+ return WaitAll();
101+ }
102+ ```
103+ ## Classes
104+ HComponentLibrary consist of classes below:
105+ ```
6106- ActionEvent
7107- ButtonGroup
8108- Component
@@ -20,7 +120,8 @@ HCl classes:
20120- KeyEvent
21121- Point
22122- String
23-
123+ ```
124+ ## How to Install
24125To use HCl library do this steps after copying HCl Component Library folder to C:\
25126
26127 1. Open a Windows Desktop Application in Visual Studio
@@ -34,6 +135,6 @@ To use HCl library do this steps after copying HCl Component Library folder to C
34135 Please be sure that you have configured project settings for x86(32 bit) not only x64.
35136
36137That's all, you can use H Component Library in your C++ project by using; #include "HCl.h";
37-
38- * Source code of my library is preparing.
39- Detailed explanations about usage will also be uploaded *
138+ ## Build From Source
139+ Just open HCl.sln file with Visual Studio, change source code and compile.< br >
140+ * I finished this project years ago in high school so souce code might be spaghetti. *
0 commit comments