Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _WIN32_IE 0x0600
- #include <windows.h>
- #include <commctrl.h>
- #pragma comment(lib, "comctl32.lib")
- #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #define WM_MODAL_CLOSED (WM_USER + 1)
- // Control identifiers
- #define IDC_BUTTON_ADD_NEW_PRODUCT 101
- #define IDC_BUTTON_ADD_NEW_ENTRIES 102
- #define IDC_BUTTON_MODIFY 103
- #define IDC_BUTTON_SELL 104
- #define IDC_BUTTON_CALCULATE 105
- #define IDC_BUTTON_DELETE 106
- #define IDC_LISTVIEW 107
- #define IDC_TABCONTROL 108
- #define IDC_EDIT_SEARCH 109
- #define IDC_STATIC_SEARCH 110
- // Control identifiers "Add new product"
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_CODE 111
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_DESCRIPTION 112
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_INITIAL_STOCK 113
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_PRICE 114
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_RETAIL_PRICE 115
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR_LABEL 116
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE_LABEL 117
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL_LABEL 118
- #define IDC_EDIT_MODAL_ADDNEWPRODUCT_CODE 119
- #define IDC_EDIT_MODAL_ADDNEWPRODUCT_DESCRIPTION 120
- #define IDC_EDIT_MODAL_ADDNEWPRODUCT_INITIAL_STOCK 121
- #define IDC_EDIT_MODAL_ADDNEWPRODUCT_PRICE 122
- #define IDC_EDIT_MODAL_ADDNEWPRODUCT_RETAIL_PRICE 123
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR 124
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE 125
- #define IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL 126
- #define IDC__MODAL_ADDNEWPRODUCT_BUTTON_ACCEPT 127
- #define IDC__MODAL_ADDNEWPRODUCT_BUTTON_CANCEL 128
- // Control identifiers "Add new entries"
- #define IDC_STATIC_MODAL_ADDNEWENTRIES_CODE 129
- #define IDC_STATIC_MODAL_ADDNEWENTRIES_DESCRIPTION 130
- #define IDC_STATIC_MODAL_ADDNEWENTRIES_CURRENT_STOCK 132
- #define IDC_STATIC_MODAL_ADDNEWENTRIES_NEW_ENTRIES 133
- #define IDC_STATIC_MODAL_ADDNEWENTRIES2_CODE 134
- #define IDC_STATIC_MODAL_ADDNEWENTRIES2_DESCRIPTION 135
- #define IDC_STATIC_MODAL_ADDNEWENTRIES2_CURRENT_STOCK 137
- #define IDC_EDIT_MODAL_ADDNEWENTRIES_NEW_ENTRIES 138
- #define IDC__MODAL_ADDNEWENTRIES_BUTTON_ACCEPT 139
- #define IDC__MODAL_ADDNEWENTRIES_BUTTON_CANCEL 140
- // Control identifiers "Modify Product"
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_CODE 141
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_DESCRIPTION 142
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_INITIAL_STOCK 143
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_CURRENT_STOCK 144
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_NEW_ENTRIES 145
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_SALES 146
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_PRICE 147
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_RETAIL_PRICE 148
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR_LABEL 149
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE_LABEL 150
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL_LABEL 151
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_CODE 152
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_DESCRIPTION 153
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_INITIAL_STOCK 154
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_CURRENT_STOCK 155
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_NEW_ENTRIES 156
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_SALES 157
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_PRICE 158
- #define IDC_EDIT_MODAL_MODIFYPRODUCT_RETAIL_PRICE 159
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR 160
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE 161
- #define IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL 162
- #define IDC__MODAL_MODIFYPRODUCT_BUTTON_ACCEPT 163
- #define IDC__MODAL_MODIFYPRODUCT_BUTTON_CANCEL 164
- // Control identifiers "Sell Product"
- #define IDC_STATIC_MODAL_SELLPRODUCT_CODE 165
- #define IDC_STATIC_MODAL_SELLPRODUCT_DESCRIPTION 166
- #define IDC_STATIC_MODAL_SELLPRODUCT_CURRENT_STOCK 167
- #define IDC_STATIC_MODAL_SELLPRODUCT_SALES 168
- #define IDC_STATIC_MODAL_SELLPRODUCT_NEW_SALES 169
- #define IDC_STATIC_MODAL_SELLPRODUCT_PRICE 170
- #define IDC_STATIC_MODAL_SELLPRODUCT_RETAIL_PRICE 171
- #define IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR_LABEL 172
- #define IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE_LABEL 173
- #define IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL_LABEL 174
- #define IDC_EDIT_MODAL_SELLPRODUCT_CODE 175
- #define IDC_STATIC_MODAL_SELLPRODUCT2_DESCRIPTION 176
- #define IDC_STATIC_MODAL_SELLPRODUCT2_CURRENT_STOCK 177
- #define IDC_STATIC_MODAL_SELLPRODUCT2_SALES 178
- #define IDC_EDIT_MODAL_SELLPRODUCT_NEW_SALES 179
- #define IDC_EDIT_MODAL_SELLPRODUCT_PRICE 180
- #define IDC_EDIT_MODAL_SELLPRODUCT_RETAIL_PRICE 181
- #define IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR 182
- #define IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE 183
- #define IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL 184
- #define IDC__MODAL_SELLPRODUCT_BUTTON_ACCEPT 185
- #define IDC__MODAL_SELLPRODUCT_BUTTON_CANCEL 186
- // Control identifiers "Calculate Product"
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_CODE 187
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_DESCRIPTION 188
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_PRICE 189
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_RETAIL_PRICE 190
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR_LABEL 191
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE_LABEL 192
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL_LABEL 193
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT2_CODE 194
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT2_DESCRIPTION 195
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT2_PRICE 196
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT2_RETAIL_PRICE 197
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR 198
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE 199
- #define IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL 200
- #define IDC__MODAL_CALCULATEPRODUCT_BUTTON_ACCEPT 201
- #define IDC__MODAL_CALCULATEPRODUCT_BUTTON_CANCEL 202
- // Define the maximum size of the buffer for the window text
- #define MAX_WINDOW_TEXT_LENGTH 256
- // Message handling procedure prototype
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT CALLBACK AddProductModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT CALLBACK AddNewEntriesModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT CALLBACK ModifyProductModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT CALLBACK SellProductModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- LRESULT CALLBACK CalculateModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- void ResizeControls(HWND hwnd, int width, int height);
- void SetControlFont(HWND hwndControl, int fontSize);
- void SetTabControlFont(HWND hwndTabControl, int fontSize);
- void SetListViewFont(HWND hwndListView, int fontSize);
- void ShowModalWindow(HWND hwndParent, int modalId);
- void CenterWindow(HWND hwnd);
- void ResizeAddProductModalControls(HWND hwnd);
- void ResizeAddNewEntriesModalControls(HWND hwnd);
- void ResizeModifyProductModalControls(HWND hwnd);
- void ResizeSellProductModalControls(HWND hwnd);
- void ResizeCalculateModalControls(HWND hwnd);
- void UpdateListViewColumns(HWND hwndListView, int selectedTab);
- // Function to check if a character is a digit
- bool IsDigit(char c) {
- return c >= '0' && c <= '9';
- }
- // Function to check if a string represents a positive integer
- bool IsPositiveInteger(const char* str) {
- if (str == NULL || *str == '\0') {
- return false;
- }
- for (const char* p = str; *p != '\0'; ++p) {
- if (!IsDigit(*p)) {
- return false;
- }
- }
- return true;
- }
- // Function to check if a string is empty
- bool IsEmpty(const char* str) {
- return str == NULL || *str == '\0';
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
- INITCOMMONCONTROLSEX icc;
- icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
- icc.dwICC = ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES;
- InitCommonControlsEx(&icc);
- const char CLASS_NAME[] = "Sample Window Class";
- WNDCLASS wc = {0};
- wc.lpfnWndProc = WindowProc;
- wc.hInstance = hInstance;
- wc.lpszClassName = CLASS_NAME;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // Window background
- RegisterClass(&wc);
- HWND hwnd = CreateWindowEx(
- 0,
- CLASS_NAME,
- "Inventory",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
- NULL,
- NULL,
- hInstance,
- NULL
- );
- if (hwnd == NULL) {
- return 0;
- }
- CenterWindow(hwnd); // Center the main window
- ShowWindow(hwnd, nCmdShow);
- MSG msg = {0};
- while (GetMessage(&msg, NULL, 0, 0)) {
- if (!IsDialogMessage(hwnd, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- return 0;
- }
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- static HWND hTabControl;
- static HWND hListView;
- static HWND hEditSearch;
- static HWND hStaticSearch;
- static HWND hButtonAddNewProduct;
- static HWND hButtonAddNewEntries;
- static HWND hButtonModify;
- static HWND hButtonSell;
- static HWND hButtonCalculate;
- static HWND hButtonDelete;
- switch (uMsg) {
- case WM_CREATE: {
- // Create tab control
- hTabControl = CreateWindowEx(
- 0, WC_TABCONTROL, NULL,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_TABSTOP,
- 10, 10, 560, 40, // Increase the height of the TabControl
- hwnd, (HMENU)IDC_TABCONTROL, GetModuleHandle(NULL), NULL
- );
- TCITEM tie;
- tie.mask = TCIF_TEXT;
- tie.pszText = "Inventory";
- TabCtrl_InsertItem(hTabControl, 0, &tie);
- tie.pszText = "Sales";
- TabCtrl_InsertItem(hTabControl, 1, &tie);
- tie.pszText = "Events";
- TabCtrl_InsertItem(hTabControl, 2, &tie);
- // Create search label
- hStaticSearch = CreateWindowEx(
- 0, "STATIC", "Search:",
- WS_CHILD | WS_VISIBLE,
- 570, 20, 50, 25, // Adjust the position and height of the label
- hwnd, (HMENU)IDC_STATIC_SEARCH, GetModuleHandle(NULL), NULL
- );
- // Create search text box
- hEditSearch = CreateWindowEx(
- 0, "EDIT", NULL,
- WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP,
- 620, 20, 160, 25, // Adjust the position and height of the text box
- hwnd, (HMENU)IDC_EDIT_SEARCH, GetModuleHandle(NULL), NULL
- );
- // Create buttons
- hButtonAddNewProduct = CreateWindow(
- "BUTTON", "Add \nnew product",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_MULTILINE | WS_TABSTOP,
- 10, 450, 140, 50,
- hwnd, (HMENU)IDC_BUTTON_ADD_NEW_PRODUCT, GetModuleHandle(NULL), NULL
- );
- hButtonAddNewEntries = CreateWindow(
- "BUTTON", "Add \nnew entries",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_MULTILINE | WS_TABSTOP,
- 160, 450, 140, 50,
- hwnd, (HMENU)IDC_BUTTON_ADD_NEW_ENTRIES, GetModuleHandle(NULL), NULL
- );
- hButtonModify = CreateWindow(
- "BUTTON", "Modify",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 310, 450, 80, 50,
- hwnd, (HMENU)IDC_BUTTON_MODIFY, GetModuleHandle(NULL), NULL
- );
- hButtonSell = CreateWindow(
- "BUTTON", "Sell",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 400, 450, 80, 50,
- hwnd, (HMENU)IDC_BUTTON_SELL, GetModuleHandle(NULL), NULL
- );
- hButtonCalculate = CreateWindow(
- "BUTTON", "Calculate",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 490, 450, 80, 50,
- hwnd, (HMENU)IDC_BUTTON_CALCULATE, GetModuleHandle(NULL), NULL
- );
- hButtonDelete = CreateWindow(
- "BUTTON", "Delete",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 580, 450, 80, 50,
- hwnd, (HMENU)IDC_BUTTON_DELETE, GetModuleHandle(NULL), NULL
- );
- // Create ListView
- hListView = CreateWindowEx(
- 0, WC_LISTVIEW, NULL,
- WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_EDITLABELS | WS_TABSTOP,
- 10, 60, 760, 380, // Adjust the position and height of the ListView
- hwnd, (HMENU)IDC_LISTVIEW, GetModuleHandle(NULL), NULL
- );
- // Add columns to the ListView for the Inventory tab
- LVCOLUMN lvc;
- lvc.mask = LVCF_TEXT | LVCF_WIDTH;
- lvc.pszText = "Product Code";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 0, &lvc);
- lvc.pszText = "Product";
- lvc.cx = 200;
- ListView_InsertColumn(hListView, 1, &lvc);
- lvc.pszText = "Initial Stock";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 2, &lvc);
- lvc.pszText = "Current Stock";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 3, &lvc);
- lvc.pszText = "New Entries";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 4, &lvc);
- lvc.pszText = "Sales";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 5, &lvc);
- lvc.pszText = "Price";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 6, &lvc);
- lvc.pszText = "Retail Price";
- lvc.cx = 100;
- ListView_InsertColumn(hListView, 7, &lvc);
- break;
- }
- case WM_NOTIFY: {
- LPNMHDR pnmh = (LPNMHDR)lParam;
- if (pnmh->hwndFrom == hTabControl && pnmh->code == TCN_SELCHANGE) {
- int selectedTab = TabCtrl_GetCurSel(hTabControl);
- UpdateListViewColumns(hListView, selectedTab);
- }
- break;
- }
- case WM_COMMAND: {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC_BUTTON_ADD_NEW_PRODUCT:
- ShowModalWindow(hwnd, IDC_BUTTON_ADD_NEW_PRODUCT);
- break;
- case IDC_BUTTON_ADD_NEW_ENTRIES:
- ShowModalWindow(hwnd, IDC_BUTTON_ADD_NEW_ENTRIES);
- break;
- case IDC_BUTTON_MODIFY:
- ShowModalWindow(hwnd, IDC_BUTTON_MODIFY);
- break;
- case IDC_BUTTON_SELL:
- ShowModalWindow(hwnd, IDC_BUTTON_SELL);
- break;
- case IDC_BUTTON_CALCULATE:
- ShowModalWindow(hwnd, IDC_BUTTON_CALCULATE);
- break;
- case IDC_BUTTON_DELETE: {
- int response = MessageBox(hwnd, "Are you sure you want to delete the selected product(s)?", "Confirm Deletion", MB_YESNO | MB_ICONQUESTION);
- if (response == IDYES) {
- // Here you can add the logic to delete the selected product(s)
- MessageBox(hwnd, "Product(s) deleted successfully.", "Success", MB_OK | MB_ICONINFORMATION);
- }
- break;
- }
- }
- }
- break;
- }
- case WM_SIZE: {
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- int width = clientRect.right - clientRect.left;
- int height = clientRect.bottom - clientRect.top;
- ResizeControls(hwnd, width, height);
- break;
- }
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- void ResizeControls(HWND hwnd, int width, int height) {
- static HWND hTabControl = GetDlgItem(hwnd, IDC_TABCONTROL);
- static HWND hListView = GetDlgItem(hwnd, IDC_LISTVIEW);
- static HWND hEditSearch = GetDlgItem(hwnd, IDC_EDIT_SEARCH);
- static HWND hStaticSearch = GetDlgItem(hwnd, IDC_STATIC_SEARCH);
- static HWND hButtonAddNewProduct = GetDlgItem(hwnd, IDC_BUTTON_ADD_NEW_PRODUCT);
- static HWND hButtonAddNewEntries = GetDlgItem(hwnd, IDC_BUTTON_ADD_NEW_ENTRIES);
- static HWND hButtonModify = GetDlgItem(hwnd, IDC_BUTTON_MODIFY);
- static HWND hButtonSell = GetDlgItem(hwnd, IDC_BUTTON_SELL);
- static HWND hButtonCalculate = GetDlgItem(hwnd, IDC_BUTTON_CALCULATE);
- static HWND hButtonDelete = GetDlgItem(hwnd, IDC_BUTTON_DELETE);
- // Calculate the font size based on the window size
- int fontSize = MulDiv(15, height, 600); // Adjust the font size proportionally
- // Adjust the font of the controls
- SetControlFont(hButtonAddNewProduct, fontSize);
- SetControlFont(hButtonAddNewEntries, fontSize);
- SetControlFont(hButtonModify, fontSize);
- SetControlFont(hButtonSell, fontSize);
- SetControlFont(hButtonCalculate, fontSize);
- SetControlFont(hButtonDelete, fontSize);
- SetControlFont(hEditSearch, fontSize);
- SetControlFont(hStaticSearch, fontSize);
- SetTabControlFont(hTabControl, fontSize);
- SetListViewFont(hListView, fontSize);
- // Resize and reposition controls
- MoveWindow(hTabControl, 10, 10, width - 20, 40, TRUE); // Adjust the height of the TabControl
- MoveWindow(hStaticSearch, width - 210, 20, 50, 25, TRUE); // Adjust the position and height of the label
- MoveWindow(hEditSearch, width - 160, 20, 140, 25, TRUE); // Adjust the position and height of the text box
- MoveWindow(hListView, 10, 60, width - 20, height - 120, TRUE); // Adjust the position and height of the ListView
- MoveWindow(hButtonAddNewProduct, 10, height - 60, 140, 60, TRUE);
- MoveWindow(hButtonAddNewEntries, 160, height - 60, 140, 60, TRUE);
- MoveWindow(hButtonModify, 310, height - 60, 80, 60, TRUE);
- MoveWindow(hButtonSell, 400, height - 60, 80, 60, TRUE);
- MoveWindow(hButtonCalculate, 490, height - 60, 80, 60, TRUE);
- MoveWindow(hButtonDelete, 580, height - 60, 80, 60, TRUE);
- // Invalidate and update the window to ensure proper redrawing
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- void SetControlFont(HWND hwndControl, int fontSize) {
- HFONT hFont = CreateFont(
- fontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
- DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, VARIABLE_PITCH, TEXT("Segoe UI")
- );
- SendMessage(hwndControl, WM_SETFONT, (WPARAM)hFont, TRUE);
- }
- void SetTabControlFont(HWND hwndTabControl, int fontSize) {
- HFONT hFont = CreateFont(
- fontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
- DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, VARIABLE_PITCH, TEXT("Segoe UI")
- );
- SendMessage(hwndTabControl, WM_SETFONT, (WPARAM)hFont, TRUE);
- }
- void SetListViewFont(HWND hwndListView, int fontSize) {
- HFONT hFont = CreateFont(
- fontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
- DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, VARIABLE_PITCH, TEXT("Segoe UI")
- );
- SendMessage(hwndListView, WM_SETFONT, (WPARAM)hFont, TRUE);
- // Adjust the font of the ListView columns
- LVCOLUMN lvc;
- lvc.mask = LVCF_SUBITEM;
- for (int i = 0; i < 8; i++) {
- lvc.iSubItem = i;
- ListView_SetColumn(hwndListView, i, &lvc);
- }
- }
- void ShowModalWindow(HWND hwndParent, int modalId) {
- const char MODAL_CLASS_NAME[] = "Modal Window Class";
- WNDCLASS wc = {0};
- wc.hInstance = GetModuleHandle(NULL);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- switch (modalId) {
- case IDC_BUTTON_ADD_NEW_PRODUCT:
- wc.lpfnWndProc = AddProductModalWindowProc;
- break;
- case IDC_BUTTON_ADD_NEW_ENTRIES:
- wc.lpfnWndProc = AddNewEntriesModalWindowProc;
- break;
- case IDC_BUTTON_MODIFY:
- wc.lpfnWndProc = ModifyProductModalWindowProc;
- break;
- case IDC_BUTTON_SELL:
- wc.lpfnWndProc = SellProductModalWindowProc;
- break;
- case IDC_BUTTON_CALCULATE:
- wc.lpfnWndProc = CalculateModalWindowProc;
- break;
- default:
- MessageBox(hwndParent, "Invalid modal window ID", "Error", MB_OK | MB_ICONERROR);
- return;
- }
- wc.lpszClassName = MODAL_CLASS_NAME;
- RegisterClass(&wc);
- HWND hwndModal = CreateWindowEx(
- 0,
- MODAL_CLASS_NAME,
- NULL, // No title used
- WS_OVERLAPPEDWINDOW | WS_VISIBLE,
- CW_USEDEFAULT, CW_USEDEFAULT, 300, 320,
- hwndParent,
- NULL,
- GetModuleHandle(NULL),
- NULL
- );
- if (hwndModal == NULL) {
- MessageBox(hwndParent, "Could not create modal window", "Error", MB_OK | MB_ICONERROR);
- return;
- }
- CenterWindow(hwndModal); // Center the modal window
- EnableWindow(hwndParent, FALSE); // Disable the main window
- // Ensure that the controls are resized correctly
- switch (modalId) {
- case IDC_BUTTON_ADD_NEW_PRODUCT:
- ResizeAddProductModalControls(hwndModal);
- break;
- case IDC_BUTTON_ADD_NEW_ENTRIES:
- ResizeAddNewEntriesModalControls(hwndModal);
- break;
- case IDC_BUTTON_MODIFY:
- ResizeModifyProductModalControls(hwndModal);
- break;
- case IDC_BUTTON_SELL:
- ResizeSellProductModalControls(hwndModal);
- break;
- case IDC_BUTTON_CALCULATE:
- ResizeCalculateModalControls(hwndModal);
- break;
- }
- MSG msg = {0};
- while (GetMessage(&msg, NULL, 0, 0)) {
- if (!IsDialogMessage(hwndModal, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- EnableWindow(hwndParent, TRUE); // Enable the main window
- SetForegroundWindow(hwndParent); // Bring the main window to the front
- DestroyWindow(hwndModal);
- UnregisterClass(MODAL_CLASS_NAME, GetModuleHandle(NULL));
- }
- LRESULT CALLBACK AddProductModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- static HWND hEditCode;
- static HWND hEditDescription;
- static HWND hEditInitialStock;
- static HWND hEditPrice;
- static HWND hEditRetailPrice;
- static HWND hStaticProfitDollar;
- static HWND hStaticProfitPercentage;
- static HWND hStaticVatRetail;
- static HWND hButtonAccept;
- static HWND hButtonCancel;
- switch (uMsg) {
- case WM_CREATE: {
- // Create labels and edit controls
- CreateWindowEx(0, "STATIC", "Product Code:", WS_CHILD | WS_VISIBLE, 10, 10, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- hEditCode = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 10, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_ADDNEWPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Description:", WS_CHILD | WS_VISIBLE, 10, 40, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_DESCRIPTION, GetModuleHandle(NULL), NULL);
- hEditDescription = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 40, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_ADDNEWPRODUCT_DESCRIPTION, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Initial Stock:", WS_CHILD | WS_VISIBLE, 10, 70, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_INITIAL_STOCK, GetModuleHandle(NULL), NULL);
- hEditInitialStock = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 70, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_ADDNEWPRODUCT_INITIAL_STOCK, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Price:", WS_CHILD | WS_VISIBLE, 10, 100, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- hEditPrice = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 100, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_ADDNEWPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail Price:", WS_CHILD | WS_VISIBLE, 10, 130, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- hEditRetailPrice = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 130, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_ADDNEWPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in $:", WS_CHILD | WS_VISIBLE, 10, 160, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitDollar = CreateWindowEx(0, "STATIC", "$0", WS_CHILD | WS_VISIBLE, 140, 160, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in %:", WS_CHILD | WS_VISIBLE, 10, 190, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitPercentage = CreateWindowEx(0, "STATIC", "0%", WS_CHILD | WS_VISIBLE, 140, 190, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail VAT $:", WS_CHILD | WS_VISIBLE, 10, 220, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL_LABEL, GetModuleHandle(NULL), NULL);
- hStaticVatRetail = CreateWindowEx(0, "STATIC", "$0($0)", WS_CHILD | WS_VISIBLE, 140, 220, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL, GetModuleHandle(NULL), NULL);
- // Create Accept and Cancel buttons
- hButtonAccept = CreateWindow(
- "BUTTON", "Accept",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 10, 250, 80, 30,
- hwnd, (HMENU)IDC__MODAL_ADDNEWPRODUCT_BUTTON_ACCEPT, GetModuleHandle(NULL), NULL
- );
- hButtonCancel = CreateWindow(
- "BUTTON", "Cancel",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 100, 250, 80, 30,
- hwnd, (HMENU)IDC__MODAL_ADDNEWPRODUCT_BUTTON_CANCEL, GetModuleHandle(NULL), NULL
- );
- // Resize and center the controls
- ResizeAddProductModalControls(hwnd);
- break;
- }
- case WM_COMMAND: {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC__MODAL_ADDNEWPRODUCT_BUTTON_ACCEPT: {
- // Validate input fields
- char code[256];
- char description[256];
- char initialStock[256];
- char price[256];
- char retailPrice[256];
- GetWindowTextA(hEditCode, code, sizeof(code));
- GetWindowTextA(hEditDescription, description, sizeof(description));
- GetWindowTextA(hEditInitialStock, initialStock, sizeof(initialStock));
- GetWindowTextA(hEditPrice, price, sizeof(price));
- GetWindowTextA(hEditRetailPrice, retailPrice, sizeof(retailPrice));
- if (IsEmpty(code) || IsEmpty(description) || IsEmpty(initialStock) ||
- IsEmpty(price) || IsEmpty(retailPrice)) {
- MessageBox(hwnd, "The registration could not be completed because there are empty fields.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- if (!IsPositiveInteger(code) || !IsPositiveInteger(initialStock) ||
- !IsPositiveInteger(price) || !IsPositiveInteger(retailPrice)) {
- MessageBox(hwnd, "Invalid values have been entered for the required field.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- // Here you can add the logic to handle the Accept button
- DestroyWindow(hwnd);
- break;
- }
- case IDC__MODAL_ADDNEWPRODUCT_BUTTON_CANCEL:
- DestroyWindow(hwnd);
- break;
- }
- }
- break;
- }
- case WM_SIZE: {
- // Resize and center the controls
- ResizeAddProductModalControls(hwnd);
- break;
- }
- case WM_CLOSE:
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- LRESULT CALLBACK AddNewEntriesModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- static HWND hEditCode;
- static HWND hEditDescription;
- static HWND hEditCurrentStock;
- static HWND hEditNewEntries;
- static HWND hButtonAccept;
- static HWND hButtonCancel;
- switch (uMsg) {
- case WM_CREATE: {
- // Create labels and edit controls
- CreateWindowEx(0, "STATIC", "Product Code:", WS_CHILD | WS_VISIBLE, 10, 10, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES_CODE, GetModuleHandle(NULL), NULL);
- hEditCode = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 140, 10, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES2_CODE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Description:", WS_CHILD | WS_VISIBLE, 10, 40, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES_DESCRIPTION, GetModuleHandle(NULL), NULL);
- hEditDescription = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 140, 40, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES2_DESCRIPTION, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Current Stock:", WS_CHILD | WS_VISIBLE, 10, 100, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES_CURRENT_STOCK, GetModuleHandle(NULL), NULL);
- hEditCurrentStock = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 140, 100, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES2_CURRENT_STOCK, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "New Entries:", WS_CHILD | WS_VISIBLE, 10, 130, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_ADDNEWENTRIES_NEW_ENTRIES, GetModuleHandle(NULL), NULL);
- hEditNewEntries = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 130, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_ADDNEWENTRIES_NEW_ENTRIES, GetModuleHandle(NULL), NULL);
- // Create Accept and Cancel buttons
- hButtonAccept = CreateWindow(
- "BUTTON", "Accept",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 10, 160, 80, 30,
- hwnd, (HMENU)IDC__MODAL_ADDNEWENTRIES_BUTTON_ACCEPT, GetModuleHandle(NULL), NULL
- );
- hButtonCancel = CreateWindow(
- "BUTTON", "Cancel",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 100, 160, 80, 30,
- hwnd, (HMENU)IDC__MODAL_ADDNEWENTRIES_BUTTON_CANCEL, GetModuleHandle(NULL), NULL
- );
- // Resize and center the controls
- ResizeAddNewEntriesModalControls(hwnd);
- break;
- }
- case WM_COMMAND: {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC__MODAL_ADDNEWENTRIES_BUTTON_ACCEPT: {
- // Validate input fields
- char code[256];
- char description[256];
- char currentStock[256];
- char newEntries[256];
- GetWindowTextA(hEditCode, code, sizeof(code));
- GetWindowTextA(hEditDescription, description, sizeof(description));
- GetWindowTextA(hEditCurrentStock, currentStock, sizeof(currentStock));
- GetWindowTextA(hEditNewEntries, newEntries, sizeof(newEntries));
- if (IsEmpty(code) || IsEmpty(description) ||
- IsEmpty(currentStock) || IsEmpty(newEntries)) {
- MessageBox(hwnd, "The registration could not be completed because there are empty fields.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- if (!IsPositiveInteger(code) ||
- !IsPositiveInteger(currentStock) || !IsPositiveInteger(newEntries)) {
- MessageBox(hwnd, "Invalid values have been entered for the required field.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- // Here you can add the logic to handle the Accept button
- DestroyWindow(hwnd);
- break;
- }
- case IDC__MODAL_ADDNEWENTRIES_BUTTON_CANCEL:
- DestroyWindow(hwnd);
- break;
- }
- }
- break;
- }
- case WM_SIZE: {
- // Resize and center the controls
- ResizeAddNewEntriesModalControls(hwnd);
- break;
- }
- case WM_CLOSE:
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- LRESULT CALLBACK ModifyProductModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- static HWND hEditCode;
- static HWND hEditDescription;
- static HWND hEditInitialStock;
- static HWND hEditCurrentStock;
- static HWND hEditNewEntries;
- static HWND hEditSales;
- static HWND hEditPrice;
- static HWND hEditRetailPrice;
- static HWND hStaticProfitDollar;
- static HWND hStaticProfitPercentage;
- static HWND hStaticVatRetail;
- static HWND hButtonAccept;
- static HWND hButtonCancel;
- switch (uMsg) {
- case WM_CREATE: {
- // Create labels and edit controls
- CreateWindowEx(0, "STATIC", "Product Code:", WS_CHILD | WS_VISIBLE, 10, 10, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- hEditCode = CreateWindowEx(0, "COMBOBOX", NULL, WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_TABSTOP, 140, 10, 200, 200, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Description:", WS_CHILD | WS_VISIBLE, 10, 40, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_DESCRIPTION, GetModuleHandle(NULL), NULL);
- hEditDescription = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 40, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_DESCRIPTION, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Initial Stock:", WS_CHILD | WS_VISIBLE, 10, 70, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_INITIAL_STOCK, GetModuleHandle(NULL), NULL);
- hEditInitialStock = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 70, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_INITIAL_STOCK, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Current Stock:", WS_CHILD | WS_VISIBLE, 10, 100, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_CURRENT_STOCK, GetModuleHandle(NULL), NULL);
- hEditCurrentStock = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 100, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_CURRENT_STOCK, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "New Entries:", WS_CHILD | WS_VISIBLE, 10, 130, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_NEW_ENTRIES, GetModuleHandle(NULL), NULL);
- hEditNewEntries = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 130, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_NEW_ENTRIES, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Sales:", WS_CHILD | WS_VISIBLE, 10, 160, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_SALES, GetModuleHandle(NULL), NULL);
- hEditSales = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 160, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_SALES, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Price:", WS_CHILD | WS_VISIBLE, 10, 190, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- hEditPrice = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 190, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail Price:", WS_CHILD | WS_VISIBLE, 10, 220, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- hEditRetailPrice = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 220, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_MODIFYPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in $:", WS_CHILD | WS_VISIBLE, 10, 250, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitDollar = CreateWindowEx(0, "STATIC", "$0", WS_CHILD | WS_VISIBLE, 140, 250, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in %:", WS_CHILD | WS_VISIBLE, 10, 280, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitPercentage = CreateWindowEx(0, "STATIC", "0%", WS_CHILD | WS_VISIBLE, 140, 280, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail VAT $:", WS_CHILD | WS_VISIBLE, 10, 310, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL_LABEL, GetModuleHandle(NULL), NULL);
- hStaticVatRetail = CreateWindowEx(0, "STATIC", "$0($0)", WS_CHILD | WS_VISIBLE, 140, 310, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL, GetModuleHandle(NULL), NULL);
- // Create Accept and Cancel buttons
- hButtonAccept = CreateWindow(
- "BUTTON", "Accept",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 10, 340, 80, 30,
- hwnd, (HMENU)IDC__MODAL_MODIFYPRODUCT_BUTTON_ACCEPT, GetModuleHandle(NULL), NULL
- );
- hButtonCancel = CreateWindow(
- "BUTTON", "Cancel",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 100, 340, 80, 30,
- hwnd, (HMENU)IDC__MODAL_MODIFYPRODUCT_BUTTON_CANCEL, GetModuleHandle(NULL), NULL
- );
- // Resize and center the controls
- ResizeModifyProductModalControls(hwnd);
- break;
- }
- case WM_COMMAND: {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC__MODAL_MODIFYPRODUCT_BUTTON_ACCEPT: {
- // Validate input fields
- char code[256];
- char description[256];
- char initialStock[256];
- char currentStock[256];
- char newEntries[256];
- char sales[256];
- char price[256];
- char retailPrice[256];
- GetWindowTextA(hEditCode, code, sizeof(code));
- GetWindowTextA(hEditDescription, description, sizeof(description));
- GetWindowTextA(hEditInitialStock, initialStock, sizeof(initialStock));
- GetWindowTextA(hEditCurrentStock, currentStock, sizeof(currentStock));
- GetWindowTextA(hEditNewEntries, newEntries, sizeof(newEntries));
- GetWindowTextA(hEditSales, sales, sizeof(sales));
- GetWindowTextA(hEditPrice, price, sizeof(price));
- GetWindowTextA(hEditRetailPrice, retailPrice, sizeof(retailPrice));
- if (IsEmpty(code) || IsEmpty(description) || IsEmpty(initialStock) ||
- IsEmpty(currentStock) || IsEmpty(newEntries) || IsEmpty(sales) ||
- IsEmpty(price) || IsEmpty(retailPrice)) {
- MessageBox(hwnd, "The registration could not be completed because there are empty fields.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- if (!IsPositiveInteger(code) || !IsPositiveInteger(initialStock) ||
- !IsPositiveInteger(currentStock) || !IsPositiveInteger(newEntries) ||
- !IsPositiveInteger(sales) || !IsPositiveInteger(price) || !IsPositiveInteger(retailPrice)) {
- MessageBox(hwnd, "Invalid values have been entered for the required field.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- // Here you can add the logic to handle the Accept button
- DestroyWindow(hwnd);
- break;
- }
- case IDC__MODAL_MODIFYPRODUCT_BUTTON_CANCEL:
- DestroyWindow(hwnd);
- break;
- }
- }
- break;
- }
- case WM_SIZE: {
- // Resize and center the controls
- ResizeModifyProductModalControls(hwnd);
- break;
- }
- case WM_CLOSE:
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- LRESULT CALLBACK SellProductModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- static HWND hEditCode;
- static HWND hEditDescription;
- static HWND hEditCurrentStock;
- static HWND hEditSales;
- static HWND hEditNewSales;
- static HWND hEditPrice;
- static HWND hEditRetailPrice;
- static HWND hStaticProfitDollar;
- static HWND hStaticProfitPercentage;
- static HWND hStaticVatRetail;
- static HWND hButtonAccept;
- static HWND hButtonCancel;
- switch (uMsg) {
- case WM_CREATE: {
- // Create labels and edit controls
- CreateWindowEx(0, "STATIC", "Product Code:", WS_CHILD | WS_VISIBLE, 10, 10, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- hEditCode = CreateWindowEx(0, "COMBOBOX", NULL, WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_TABSTOP, 140, 10, 200, 200, hwnd, (HMENU)IDC_EDIT_MODAL_SELLPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Description:", WS_CHILD | WS_VISIBLE, 10, 40, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_DESCRIPTION, GetModuleHandle(NULL), NULL);
- hEditDescription = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 40, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT2_DESCRIPTION, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Current Stock:", WS_CHILD | WS_VISIBLE, 10, 70, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_CURRENT_STOCK, GetModuleHandle(NULL), NULL);
- hEditCurrentStock = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 70, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT2_CURRENT_STOCK, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Registered Sales:", WS_CHILD | WS_VISIBLE, 10, 100, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_SALES, GetModuleHandle(NULL), NULL);
- hEditSales = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 100, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT2_SALES, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "New Sales:", WS_CHILD | WS_VISIBLE, 10, 130, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_NEW_SALES, GetModuleHandle(NULL), NULL);
- hEditNewSales = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 130, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_SELLPRODUCT_NEW_SALES, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Price:", WS_CHILD | WS_VISIBLE, 10, 160, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- hEditPrice = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 160, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_SELLPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail Price:", WS_CHILD | WS_VISIBLE, 10, 190, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- hEditRetailPrice = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | WS_TABSTOP, 140, 190, 200, 20, hwnd, (HMENU)IDC_EDIT_MODAL_SELLPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in $:", WS_CHILD | WS_VISIBLE, 10, 220, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitDollar = CreateWindowEx(0, "STATIC", "$0", WS_CHILD | WS_VISIBLE, 140, 220, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in %:", WS_CHILD | WS_VISIBLE, 10, 250, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitPercentage = CreateWindowEx(0, "STATIC", "0%", WS_CHILD | WS_VISIBLE, 140, 250, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail VAT $:", WS_CHILD | WS_VISIBLE, 10, 280, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL_LABEL, GetModuleHandle(NULL), NULL);
- hStaticVatRetail = CreateWindowEx(0, "STATIC", "$0($0)", WS_CHILD | WS_VISIBLE, 140, 280, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL, GetModuleHandle(NULL), NULL);
- // Create Accept and Cancel buttons
- hButtonAccept = CreateWindow(
- "BUTTON", "Accept",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 10, 310, 80, 30,
- hwnd, (HMENU)IDC__MODAL_SELLPRODUCT_BUTTON_ACCEPT, GetModuleHandle(NULL), NULL
- );
- hButtonCancel = CreateWindow(
- "BUTTON", "Cancel",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 100, 310, 80, 30,
- hwnd, (HMENU)IDC__MODAL_SELLPRODUCT_BUTTON_CANCEL, GetModuleHandle(NULL), NULL
- );
- // Resize and center the controls
- ResizeSellProductModalControls(hwnd);
- break;
- }
- case WM_COMMAND: {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC__MODAL_SELLPRODUCT_BUTTON_ACCEPT: {
- // Validate input fields
- char code[256];
- char description[256];
- char currentStock[256];
- char sales[256];
- char newSales[256];
- char price[256];
- char retailPrice[256];
- GetWindowTextA(hEditCode, code, sizeof(code));
- GetWindowTextA(hEditDescription, description, sizeof(description));
- GetWindowTextA(hEditCurrentStock, currentStock, sizeof(currentStock));
- GetWindowTextA(hEditSales, sales, sizeof(sales));
- GetWindowTextA(hEditNewSales, newSales, sizeof(newSales));
- GetWindowTextA(hEditPrice, price, sizeof(price));
- GetWindowTextA(hEditRetailPrice, retailPrice, sizeof(retailPrice));
- if (IsEmpty(code) || IsEmpty(description) || IsEmpty(currentStock) ||
- IsEmpty(sales) || IsEmpty(newSales) || IsEmpty(price) || IsEmpty(retailPrice)) {
- MessageBox(hwnd, "The registration could not be completed because there are empty fields.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- if (!IsPositiveInteger(code) || !IsPositiveInteger(currentStock) ||
- !IsPositiveInteger(sales) || !IsPositiveInteger(newSales) ||
- !IsPositiveInteger(price) || !IsPositiveInteger(retailPrice)) {
- MessageBox(hwnd, "Invalid values have been entered for the required field.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- // Here you can add the logic to handle the Accept button
- DestroyWindow(hwnd);
- break;
- }
- case IDC__MODAL_SELLPRODUCT_BUTTON_CANCEL:
- DestroyWindow(hwnd);
- break;
- }
- }
- break;
- }
- case WM_SIZE: {
- // Resize and center the controls
- ResizeSellProductModalControls(hwnd);
- break;
- }
- case WM_CLOSE:
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- LRESULT CALLBACK CalculateModalWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- static HWND hEditCode;
- static HWND hEditDescription;
- static HWND hEditPrice;
- static HWND hEditRetailPrice;
- static HWND hStaticProfitDollar;
- static HWND hStaticProfitPercentage;
- static HWND hStaticVatRetail;
- static HWND hButtonAccept;
- static HWND hButtonCancel;
- switch (uMsg) {
- case WM_CREATE: {
- // Create labels and edit controls
- CreateWindowEx(0, "STATIC", "Product Code:", WS_CHILD | WS_VISIBLE, 10, 10, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_CODE, GetModuleHandle(NULL), NULL);
- hEditCode = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE, 140, 10, 200, 200, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT2_CODE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Description:", WS_CHILD | WS_VISIBLE, 10, 40, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_DESCRIPTION, GetModuleHandle(NULL), NULL);
- hEditDescription = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE, 140, 40, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT2_DESCRIPTION, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Price:", WS_CHILD | WS_VISIBLE, 10, 70, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_PRICE, GetModuleHandle(NULL), NULL);
- hEditPrice = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE, 140, 70, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT2_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail Price:", WS_CHILD | WS_VISIBLE, 10, 100, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- hEditRetailPrice = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE, 140, 100, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT2_RETAIL_PRICE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in $:", WS_CHILD | WS_VISIBLE, 10, 130, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitDollar = CreateWindowEx(0, "STATIC", "$0", WS_CHILD | WS_VISIBLE, 140, 130, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Gain in %:", WS_CHILD | WS_VISIBLE, 10, 160, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE_LABEL, GetModuleHandle(NULL), NULL);
- hStaticProfitPercentage = CreateWindowEx(0, "STATIC", "0%", WS_CHILD | WS_VISIBLE, 140, 160, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE, GetModuleHandle(NULL), NULL);
- CreateWindowEx(0, "STATIC", "Retail VAT $:", WS_CHILD | WS_VISIBLE, 10, 190, 120, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL_LABEL, GetModuleHandle(NULL), NULL);
- hStaticVatRetail = CreateWindowEx(0, "STATIC", "$0($0)", WS_CHILD | WS_VISIBLE, 140, 190, 200, 20, hwnd, (HMENU)IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL, GetModuleHandle(NULL), NULL);
- // Create Accept and Cancel buttons
- hButtonAccept = CreateWindow(
- "BUTTON", "Accept",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 10, 220, 80, 30,
- hwnd, (HMENU)IDC__MODAL_CALCULATEPRODUCT_BUTTON_ACCEPT, GetModuleHandle(NULL), NULL
- );
- hButtonCancel = CreateWindow(
- "BUTTON", "Cancel",
- WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP,
- 100, 220, 80, 30,
- hwnd, (HMENU)IDC__MODAL_CALCULATEPRODUCT_BUTTON_CANCEL, GetModuleHandle(NULL), NULL
- );
- // Resize and center the controls
- ResizeCalculateModalControls(hwnd);
- break;
- }
- case WM_COMMAND: {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC__MODAL_CALCULATEPRODUCT_BUTTON_ACCEPT: {
- // Validate input fields
- char code[256];
- char description[256];
- char price[256];
- char retailPrice[256];
- GetWindowTextA(hEditCode, code, sizeof(code));
- GetWindowTextA(hEditDescription, description, sizeof(description));
- GetWindowTextA(hEditPrice, price, sizeof(price));
- GetWindowTextA(hEditRetailPrice, retailPrice, sizeof(retailPrice));
- if (IsEmpty(code) || IsEmpty(description) || IsEmpty(price) || IsEmpty(retailPrice)) {
- MessageBox(hwnd, "The registration could not be completed because there are empty fields.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- if (!IsPositiveInteger(code) || !IsPositiveInteger(price) || !IsPositiveInteger(retailPrice)) {
- MessageBox(hwnd, "Invalid values have been entered for the required field.", "Error", MB_OK | MB_ICONERROR);
- break;
- }
- // Here you can add the logic to handle the Accept button
- DestroyWindow(hwnd);
- break;
- }
- case IDC__MODAL_CALCULATEPRODUCT_BUTTON_CANCEL:
- DestroyWindow(hwnd);
- break;
- }
- }
- break;
- }
- case WM_SIZE: {
- // Resize and center the controls
- ResizeCalculateModalControls(hwnd);
- break;
- }
- case WM_CLOSE:
- DestroyWindow(hwnd);
- return 0;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
- void ResizeAddProductModalControls(HWND hwnd) {
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- int width = clientRect.right - clientRect.left;
- int height = clientRect.bottom - clientRect.top;
- // Calculate the font size based on the window size
- int fontSize = MulDiv(15, height, 300); // Adjust the font size proportionally
- // Adjust the font of the controls
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_INITIAL_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_INITIAL_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_ADDNEWPRODUCT_BUTTON_ACCEPT), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_ADDNEWPRODUCT_BUTTON_CANCEL), fontSize);
- // Resize and reposition controls
- int labelWidth = 120;
- int editWidth = (width * 40) / 100;
- int editHeight = MulDiv(20, height, 300); // Adjust the height of the edits proportionally
- int buttonWidth = (width - 30) / 2; // Leave a margin of 10 pixels between the buttons
- int buttonHeight = MulDiv(30, height, 300); // Adjust the height of the button proportionally
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_CODE), 14, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_CODE), editWidth + (width * 8) / 100, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_DESCRIPTION), 14, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_DESCRIPTION), editWidth + (width * 8) / 100, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_INITIAL_STOCK), 14, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_INITIAL_STOCK), editWidth + (width * 8) / 100, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PRICE), 14, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_PRICE), editWidth + (width * 8) / 100, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_RETAIL_PRICE), 14, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWPRODUCT_RETAIL_PRICE), editWidth + (width * 8) / 100, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR_LABEL), 14, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_DOLLAR), editWidth + (width * 8) / 100, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE_LABEL), 14, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_PROFIT_PERCENTAGE), editWidth + (width * 8) / 100, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL_LABEL), 14, (height * 58) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWPRODUCT_VAT_RETAIL), editWidth + (width * 8) / 100, (height * 58) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_ADDNEWPRODUCT_BUTTON_ACCEPT), 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_ADDNEWPRODUCT_BUTTON_CANCEL), width - buttonWidth - 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- // Invalidate and update the window to ensure proper redrawing
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- void ResizeAddNewEntriesModalControls(HWND hwnd) {
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- int width = clientRect.right - clientRect.left;
- int height = clientRect.bottom - clientRect.top;
- // Calculate the font size based on the window size
- int fontSize = MulDiv(15, height, 300); // Adjust the font size proportionally
- // Adjust the font of the controls
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES2_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES2_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES2_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_NEW_ENTRIES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWENTRIES_NEW_ENTRIES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_ADDNEWENTRIES_BUTTON_ACCEPT), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_ADDNEWENTRIES_BUTTON_CANCEL), fontSize);
- // Resize and reposition controls
- int labelWidth = 120;
- int editWidth = (width * 40) / 100;
- int editHeight = MulDiv(20, height, 300); // Adjust the height of the edits proportionally
- int buttonWidth = (width - 30) / 2; // Leave a margin of 10 pixels between the buttons
- int buttonHeight = MulDiv(30, height, 300); // Adjust the height of the button proportionally
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_CODE), 14, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES2_CODE), editWidth + (width * 8) / 100, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_DESCRIPTION), 14, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES2_DESCRIPTION), editWidth + (width * 8) / 100, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_CURRENT_STOCK), 14, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES2_CURRENT_STOCK), editWidth + (width * 8) / 100, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_ADDNEWENTRIES_NEW_ENTRIES), 14, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_ADDNEWENTRIES_NEW_ENTRIES), editWidth + (width * 8) / 100, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_ADDNEWENTRIES_BUTTON_ACCEPT), 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_ADDNEWENTRIES_BUTTON_CANCEL), width - buttonWidth - 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- // Invalidate and update the window to ensure proper redrawing
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- void ResizeModifyProductModalControls(HWND hwnd) {
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- int width = clientRect.right - clientRect.left;
- int height = clientRect.bottom - clientRect.top;
- // Calculate the font size based on the window size
- int fontSize = MulDiv(15, height, 300); // Adjust the font size proportionally
- // Adjust the font of the controls
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_INITIAL_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_INITIAL_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_NEW_ENTRIES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_NEW_ENTRIES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_SALES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_SALES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_MODIFYPRODUCT_BUTTON_ACCEPT), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_MODIFYPRODUCT_BUTTON_CANCEL), fontSize);
- // Resize and reposition controls
- int labelWidth = 120;
- int editWidth = (width * 40) / 100;
- int editHeight = MulDiv(20, height, 300); // Adjust the height of the edits proportionally
- int buttonWidth = (width - 30) / 2; // Leave a margin of 10 pixels between the buttons
- int buttonHeight = MulDiv(30, height, 300); // Adjust the height of the button proportionally
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_CODE), 14, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_CODE), editWidth + (width * 8) / 100, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_DESCRIPTION), 14, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_DESCRIPTION), editWidth + (width * 8) / 100, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_INITIAL_STOCK), 14, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_INITIAL_STOCK), editWidth + (width * 8) / 100, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_CURRENT_STOCK), 14, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_CURRENT_STOCK), editWidth + (width * 8) / 100, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_NEW_ENTRIES), 14, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_NEW_ENTRIES), editWidth + (width * 8) / 100, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_SALES), 14, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_SALES), editWidth + (width * 8) / 100, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PRICE), 14, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_PRICE), editWidth + (width * 8) / 100, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_RETAIL_PRICE), 14, (height * 58) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_MODIFYPRODUCT_RETAIL_PRICE), editWidth + (width * 8) / 100, (height * 58) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR_LABEL), 14, (height * 66) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_DOLLAR), editWidth + (width * 8) / 100, (height * 66) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE_LABEL), 14, (height * 74) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_PROFIT_PERCENTAGE), editWidth + (width * 8) / 100, (height * 74) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL_LABEL), 14, (height * 82) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_MODIFYPRODUCT_VAT_RETAIL), editWidth + (width * 8) / 100, (height * 82) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_MODIFYPRODUCT_BUTTON_ACCEPT), 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_MODIFYPRODUCT_BUTTON_CANCEL), width - buttonWidth - 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- // Invalidate and update the window to ensure proper redrawing
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- void ResizeSellProductModalControls(HWND hwnd) {
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- int width = clientRect.right - clientRect.left;
- int height = clientRect.bottom - clientRect.top;
- // Calculate the font size based on the window size
- int fontSize = MulDiv(15, height, 300); // Adjust the font size proportionally
- // Adjust the font of the controls
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT2_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT2_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT2_CURRENT_STOCK), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_NEW_SALES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_NEW_SALES), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_SELLPRODUCT_BUTTON_ACCEPT), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_SELLPRODUCT_BUTTON_CANCEL), fontSize);
- // Resize and reposition controls
- int labelWidth = 120;
- int editWidth = (width * 40) / 100;
- int editHeight = MulDiv(20, height, 300); // Adjust the height of the edits proportionally
- int buttonWidth = (width - 30) / 2; // Leave a margin of 10 pixels between the buttons
- int buttonHeight = MulDiv(30, height, 300); // Adjust the height of the button proportionally
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_CODE), 14, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_CODE), editWidth + (width * 8) / 100, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT2_DESCRIPTION), 14, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT2_DESCRIPTION), editWidth + (width * 8) / 100, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_CURRENT_STOCK), 14, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT2_CURRENT_STOCK), editWidth + (width * 8) / 100, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_NEW_SALES), 14, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_NEW_SALES), editWidth + (width * 8) / 100, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PRICE), 14, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_PRICE), editWidth + (width * 8) / 100, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_RETAIL_PRICE), 14, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_EDIT_MODAL_SELLPRODUCT_RETAIL_PRICE), editWidth + (width * 8) / 100, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR_LABEL), 14, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_DOLLAR), editWidth + (width * 8) / 100, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE_LABEL), 14, (height * 58) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_PROFIT_PERCENTAGE), editWidth + (width * 8) / 100, (height * 58) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL_LABEL), 14, (height * 66) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_SELLPRODUCT_VAT_RETAIL), editWidth + (width * 8) / 100, (height * 66) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_SELLPRODUCT_BUTTON_ACCEPT), 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_SELLPRODUCT_BUTTON_CANCEL), width - buttonWidth - 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- // Invalidate and update the window to ensure proper redrawing
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- void ResizeCalculateModalControls(HWND hwnd) {
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- int width = clientRect.right - clientRect.left;
- int height = clientRect.bottom - clientRect.top;
- // Calculate the font size based on the window size
- int fontSize = MulDiv(15, height, 300); // Adjust the font size proportionally
- // Adjust the font of the controls
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_CODE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_DESCRIPTION), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_RETAIL_PRICE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL_LABEL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_CALCULATEPRODUCT_BUTTON_ACCEPT), fontSize);
- SetControlFont(GetDlgItem(hwnd, IDC__MODAL_CALCULATEPRODUCT_BUTTON_CANCEL), fontSize);
- // Resize and reposition controls
- int labelWidth = 120;
- int editWidth = (width * 40) / 100;
- int editHeight = MulDiv(20, height, 300); // Adjust the height of the edits proportionally
- int buttonWidth = (width - 30) / 2; // Leave a margin of 10 pixels between the buttons
- int buttonHeight = MulDiv(30, height, 300); // Adjust the height of the button proportionally
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_CODE), 14, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_CODE), editWidth + (width * 8) / 100, (height * 2) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_DESCRIPTION), 14, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_DESCRIPTION), editWidth + (width * 8) / 100, (height * 10) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PRICE), 14, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_PRICE), editWidth + (width * 8) / 100, (height * 18) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_RETAIL_PRICE), 14, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT2_RETAIL_PRICE), editWidth + (width * 8) / 100, (height * 26) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR_LABEL), 14, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_DOLLAR), editWidth + (width * 8) / 100, (height * 34) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE_LABEL), 14, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_PROFIT_PERCENTAGE), editWidth + (width * 8) / 100, (height * 42) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL_LABEL), 14, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC_STATIC_MODAL_CALCULATEPRODUCT_VAT_RETAIL), editWidth + (width * 8) / 100, (height * 50) / 100, editWidth, editHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_CALCULATEPRODUCT_BUTTON_ACCEPT), 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- MoveWindow(GetDlgItem(hwnd, IDC__MODAL_CALCULATEPRODUCT_BUTTON_CANCEL), width - buttonWidth - 10, height - buttonHeight - 10, buttonWidth, buttonHeight, TRUE);
- // Invalidate and update the window to ensure proper redrawing
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- void CenterWindow(HWND hwnd) {
- RECT rc;
- GetWindowRect(hwnd, &rc);
- int width = rc.right - rc.left;
- int height = rc.bottom - rc.top;
- int screenWidth = GetSystemMetrics(SM_CXSCREEN);
- int screenHeight = GetSystemMetrics(SM_CYSCREEN);
- int x = (screenWidth - width) / 2;
- int y = (screenHeight - height) / 2;
- SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
- }
- void UpdateListViewColumns(HWND hwndListView, int selectedTab) {
- // Here you can add the logic to update the columns of the ListView based on the selected tab
- }
Advertisement
Add Comment
Please, Sign In to add comment