INT_PTR CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); static _Bool install_thread_running = 0; switch (message) { case WM_INITDIALOG: return (INT_PTR)TRUE; case WM_CLOSE: PostQuitMessage(0); break; case WM_COMMAND: { if (HIWORD(wParam) == BN_CLICKED) { int id = LOWORD(wParam); //HWND control_hwnd = (HWND)lParam; switch (id) { case ID_CANCEL_BUTTON: if (MessageBox(main_window, "Are you sure you want to exit?", "uTox Updater", MB_YESNO | MB_SETFOREGROUND) == IDYES) { if (is_tox_installed) { open_utox_and_exit(); } else { exit(0); } } break; case ID_INSTALL_BUTTON: if (!install_thread_running) { if (_beginthread(start_installation, 0, 0) != -1) install_thread_running = 1; } break; case ID_BROWSE_BUTTON: buttons_enable(0); browse_for_install_folder(); buttons_enable(1); break; } } break; } case WM_APP: { if (wParam == UTOX_INSTALL_ENDED) install_thread_running = 0; } } return (INT_PTR)FALSE; }
static void start_installation() { HWND desktop_shortcut_checkbox = GetDlgItem(main_window, ID_DESKTOP_SHORTCUT_CHECKBOX); HWND startmenu_shortcut_checkbox = GetDlgItem(main_window, ID_STARTMENU_SHORTCUT_CHECKBOX); HWND start_on_boot_checkbox = GetDlgItem(main_window, ID_START_ON_BOOT_CHECKBOX); HWND tox_url_checkbox = GetDlgItem(main_window, ID_TOX_URL_CHECKBOX); HWND browse_textbox = GetDlgItem(main_window, ID_BROWSE_TEXTBOX); _Bool create_desktop_shortcut, create_startmenu_shortcut, use_with_tox_url; wchar_t install_path[MAX_PATH]; int install_path_len = GetWindowTextW(browse_textbox, install_path, MAX_PATH); if (install_path_len == 0) { MessageBox(main_window, "Please select a folder to install uTox in", "Error", MB_OK | MB_SETFOREGROUND); PostMessage(main_window, WM_APP, UTOX_INSTALL_ENDED, 0); return; } create_desktop_shortcut = Button_GetCheck(desktop_shortcut_checkbox); create_startmenu_shortcut = Button_GetCheck(startmenu_shortcut_checkbox); use_with_tox_url = Button_GetCheck(tox_url_checkbox); is_tox_set_start_on_boot = Button_GetCheck(start_on_boot_checkbox); LOG_TO_FILE("will install with options: %u %u %u %ls\n", create_desktop_shortcut, create_startmenu_shortcut, use_with_tox_url, install_path); if (MessageBox(main_window, "Are you sure you want to continue?", "uTox Updater", MB_YESNO | MB_SETFOREGROUND) != IDYES) { PostMessage(main_window, WM_APP, UTOX_INSTALL_ENDED, 0); return; } buttons_enable(0); int ret = install_tox(create_desktop_shortcut, create_startmenu_shortcut, use_with_tox_url, install_path, install_path_len); if (ret == 0) { set_current_status("installation complete"); MessageBox(main_window, "Installation successful.", "uTox Updater", MB_OK | MB_SETFOREGROUND); open_utox_and_exit(); } else if (ret == -1) { set_current_status("could not write to install directory."); } else if (ret == -2) { set_current_status("download error, please check your internet connection and try again."); } else { set_current_status("error during installation"); MessageBox(main_window, "Installation failed. If it's not an internet issue please send the log file (tox_log.txt) to the developers.", "uTox Updater", MB_OK | MB_SETFOREGROUND); exit(0); } PostMessage(main_window, WM_APP, UTOX_INSTALL_ENDED, 0); buttons_enable(1); }
void board_role_select(void) { buttons_enable(); while (m_board_role == NOT_SELECTED) { if (!NRF_LOG_PROCESS()) { wait_for_event(); } } buttons_disable(); }