html input type="file" 禁止手工输入问题

又看到过百度上面active 控件的设置

现在使用<s:file name="appPubRsaFile" onkeydown="event.returnValue=false;" ></s:file>

这个来显示 别的以后研究下


add:<input type="file" name="upload" UNSELECTABLE="on"/>
#include <windows.h> #include <shlobj.h> #include <stdio.h> #include <time.h> #include "aip_common.h" // GUI control IDs #define BTN_BROWSE_FOLDER (101) #define BTN_SAVE_SYMBOLS (102) #define BTN_GENERATE_DATA (103) #define BTN_PROCESS_DATA (104) #define EDIT_FOLDER_PATH (105) #define EDIT_USER_SYMBOLS (106) // Constants #define ZERO (0) #define ONE (1) #define TWO (2) #define MAX_FOLDER_LENGTH (260) #define MAX_SYMBOL_INPUT (10000) #define MAX_LINE_CONTENT (10000) #define MAX_SYMBOL_PAIRS (10) #define MAX_LINE_COUNT (100) #define MAX_LINE_LENGTH (50) // Character type ranges #define DIGIT_START L'0' #define DIGIT_END L'9' #define UPPERCASE_START L'A' #define UPPERCASE_END L'Z' #define LOWERCASE_START L'a' #define LOWERCASE_END L'z' // Stack constants #define STACK_INIT -ONE #define STACK_EMPTY -ONE #define LINE_CONTENT_ELEMENTS (MAX_LINE_CONTENT) // Structure to store symbol pairs typedef struct { U2 u2_t_SYMBOL_open; // Opening symbol character U2 u2_t_SYMBOL_close; // Closing symbol character } ST_SYMBOL_PAIR; // Global variables ST_SYMBOL_PAIR st_g_SYMBOL_pairs_p[MAX_SYMBOL_PAIRS]; // Array of symbol pairs U4 u4_g_SYMBOL_num_pairs = ZERO; // Number of loaded symbol pairs U2 u2_g_FILE_folder_path_p[MAX_FOLDER_LENGTH]; // Selected folder path U2 u2_g_SYMBOL_user_symbols_p[MAX_SYMBOL_INPUT]; // User input symbols /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_saveFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Saves user-defined symbol pairs to Symbol.txt file after validation */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* const U2 *u2p_a_SYMBOL_user_input : User input symbols */ /* Return: void */ /*===================================================================================================================================*/ void v_g_SYMBOL_saveFile(const U2 *u2p_g_FILE_folder_path_p, const U2 *u2p_a_SYMBOL_user_input) { // Construct full file path U2 u2_t_FILE_file_path_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_file_path_p, (U4)MAX_FOLDER_LENGTH, L"%ls\\Symbol.txt", u2p_g_FILE_folder_path_p); // Validate input characters - disallow digits and letters for (U4 u4_t_SYMBOL_char_index = ZERO; u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] != L'\0'; u4_t_SYMBOL_char_index++) { // Check if character is digit or letter if (((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] >= DIGIT_START) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] <= DIGIT_END)) || ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] >= UPPERCASE_START) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] <= UPPERCASE_END)) || ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] >= LOWERCASE_START) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] <= LOWERCASE_END))) { // Show error message for invalid character U2 u2_t_ERROR_message_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_ERROR_message_p, (U4)MAX_FOLDER_LENGTH, L"错误:在输入中检测到非法字符:'%lc'。请重新输入合法的符号。", u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index]); MessageBoxW(NULL, u2_t_ERROR_message_p, L"Error", MB_OK | MB_ICONERROR); return; // Exit function on error } else { /* Character is valid - do nothing */ } } // Open file for writing with UTF-8 encoding FILE *vdp_t_FILE_file = _wfopen(u2_t_FILE_file_path_p, L"w, ccs=UTF-8"); if (!vdp_t_FILE_file) { // File creation failed MessageBoxW(NULL, L"错误:无法创建 Symbol.txt 文件。", L"错误", MB_OK | MB_ICONERROR); } else { U4 u4_t_SYMBOL_pair_count = (U4)ZERO; // Counter for valid pairs // Process input string to extract symbol pairs for (U4 u4_t_SYMBOL_char_index = (U4)ZERO; u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] != L'\0'; u4_t_SYMBOL_char_index++) { // Skip whitespace characters if ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] == L' ') || (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] == L'\t') || (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] == L'\n')) { continue; // Skip to next character } // Check if we have a complete pair (current char + next char) else if ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L'\0') && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L'\n') && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L' ') && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L'\t')) { // Write symbol pair to file fwprintf(vdp_t_FILE_file, L"%lc%lc\n", u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index], u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + ONE]); u4_t_SYMBOL_char_index++; // Skip the closing symbol we just wrote u4_t_SYMBOL_pair_count++; // Increment valid pair count } else { /* Incomplete pair - skip to next character */ } } // Close file handle fclose(vdp_t_FILE_file); // Show success or error message based on pair count if (u4_t_SYMBOL_pair_count > ZERO) { MessageBoxW(NULL, L"符号对已成功保存到 Symbol.txt 文件!", L"成功", MB_OK | MB_ICONINFORMATION); } else { MessageBoxW(NULL, L"输入中未检测到有效的符号对。", L"错误", MB_OK | MB_ICONERROR); } } } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_loadFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Loads symbol pairs from Symbol.txt file into memory */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: U4 : 1 if loaded successfully, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_loadFile(const U2 *u2p_g_FILE_folder_path_p) { // Construct full file path U2 u2_t_FILE_file_path_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_file_path_p, (U4)MAX_FOLDER_LENGTH, L"%ls\\Symbol.txt", u2p_g_FILE_folder_path_p); // Open file for reading with UTF-8 encoding FILE *vdp_t_FILE_input_file = _wfopen(u2_t_FILE_file_path_p, L"r, ccs=UTF-8"); if (!vdp_t_FILE_input_file) { // File open failed MessageBoxW(NULL, L"错误:无法打开 Symbol.txt 文件。", L"错误", MB_OK | MB_ICONERROR); return 0; } else { // Reset symbol pair count u4_g_SYMBOL_num_pairs = (U4)ZERO; U2 u2_t_FILE_line_p[(U4)MAX_LINE_CONTENT]; // Read file line by line while (fgetws(u2_t_FILE_line_p, (U4)LINE_CONTENT_ELEMENTS, vdp_t_FILE_input_file) && u4_g_SYMBOL_num_pairs < MAX_SYMBOL_PAIRS) { // Get line length and remove trailing newline if present U4 u4_t_SYMBOL_line_length = wcslen(u2_t_FILE_line_p); if (u4_t_SYMBOL_line_length > (U4)ZERO && u2_t_FILE_line_p[u4_t_SYMBOL_line_length - (U4)ONE] == L'\n') { u2_t_FILE_line_p[u4_t_SYMBOL_line_length - (U4)ONE] = L'\0'; u4_t_SYMBOL_line_length--; } else { /* No newline at end - do nothing */ } // Skip empty lines if (u4_t_SYMBOL_line_length == (U4)ZERO) { continue; } else { U2 u2_t_SYMBOL_open, u2_t_SYMBOL_close; // Parse two characters from the line if (swscanf(u2_t_FILE_line_p, L"%lc%lc", &u2_t_SYMBOL_open, &u2_t_SYMBOL_close) == (U4)TWO) { // Validate symbols - must not be digits or letters if ((u2_t_SYMBOL_open >= DIGIT_START && u2_t_SYMBOL_open <= DIGIT_END) || (u2_t_SYMBOL_open >= UPPERCASE_START && u2_t_SYMBOL_open <= UPPERCASE_END) || (u2_t_SYMBOL_open >= LOWERCASE_START && u2_t_SYMBOL_open <= LOWERCASE_END) || (u2_t_SYMBOL_close >= DIGIT_START && u2_t_SYMBOL_close <= DIGIT_END) || (u2_t_SYMBOL_close >= UPPERCASE_START && u2_t_SYMBOL_close <= UPPERCASE_END) || (u2_t_SYMBOL_close >= LOWERCASE_START && u2_t_SYMBOL_close <= LOWERCASE_END)) { // Skip invalid symbol pair continue; } else { // Store valid symbol pair st_g_SYMBOL_pairs_p[u4_g_SYMBOL_num_pairs].u2_t_SYMBOL_open = u2_t_SYMBOL_open; st_g_SYMBOL_pairs_p[u4_g_SYMBOL_num_pairs].u2_t_SYMBOL_close = u2_t_SYMBOL_close; u4_g_SYMBOL_num_pairs++; // Increment pair count } } else { /* Line doesn't contain two symbols - skip */ } } } // Close file handle fclose(vdp_t_FILE_input_file); // Show success message with loaded pair count U2 u2_t_ERROR_message_p[256]; swprintf(u2_t_ERROR_message_p, sizeof(u2_t_ERROR_message_p) / sizeof(U2), L"从 Symbol.txt 文件中加载了 %d 个有效的符号对。", u4_g_SYMBOL_num_pairs); MessageBoxW(NULL, u2_t_ERROR_message_p, L"成功", MB_OK | MB_ICONINFORMATION); return u4_g_SYMBOL_num_pairs > ZERO; } } /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_generateRandomData */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Generates random data using loaded symbol pairs and saves to Data.txt */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: void */ /*===================================================================================================================================*/ void v_g_SYMBOL_generateRandomData(const U2 *u2p_g_FILE_folder_path_p) { // Check if any symbol pairs are loaded if (u4_g_SYMBOL_num_pairs == (U4)ZERO) { MessageBoxW(NULL, L"错误:未加载任何符号对,请先加载 Symbol.txt 文件!", L"错误", MB_OK | MB_ICONERROR); } else { // Construct Data.txt file path U2 u2_t_FILE_data_path_p[MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_data_path_p, MAX_FOLDER_LENGTH, L"%ls\\Data.txt", u2p_g_FILE_folder_path_p); // Create Data.txt file FILE *vdp_t_FILE_input_file = _wfopen(u2_t_FILE_data_path_p, L"w, ccs=UTF-8"); if (!vdp_t_FILE_input_file) { MessageBoxW(NULL, L"错误:无法创建 Data.txt 文件。", L"错误", MB_OK | MB_ICONERROR); } else { // Initialize random number generator srand((U4)time(NULL)); // Generate random number of lines (1-100) U4 u4_t_DATA_num_lines = rand() % MAX_LINE_COUNT + ONE; // Generate each line for (U4 u4_t_DATA_line_index = (U4)ZERO; u4_t_DATA_line_index < u4_t_DATA_num_lines; u4_t_DATA_line_index++) { // Generate random line length (1-50 characters) U4 u4_t_FILE_length = rand() % MAX_LINE_LENGTH + (U4)ONE; // Generate each character in the line for (U4 u4_t_SYMBOL_char_index = (U4)ZERO; u4_t_SYMBOL_char_index < u4_t_FILE_length; u4_t_SYMBOL_char_index++) { // Randomly select a symbol pair U4 u4_t_SYMBOL_pair_index = rand() % u4_g_SYMBOL_num_pairs; // Randomly choose to write opening or closing symbol if (rand() % TWO == (U4)ZERO) { fputwc(st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_open, vdp_t_FILE_input_file); } else { fputwc(st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_close, vdp_t_FILE_input_file); } } // Write newline at end of each line fputwc(L'\n', vdp_t_FILE_input_file); } // Close file handle fclose(vdp_t_FILE_input_file); // Show success message MessageBoxW(NULL, L"Data.txt 文件已成功生成!", L"成功", MB_OK | MB_ICONINFORMATION); } } } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_matches */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Checks if given open/close symbols form a valid pair */ /* Arguments: U2 u2_t_SYMBOL_open : Opening symbol */ /* U2 u2_t_SYMBOL_close : Closing symbol */ /* Return: U4 : 1 if valid pair, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_matches(U2 u2_t_SYMBOL_open, U2 u2_t_SYMBOL_close) { U4 u4_t_SYMBOL_match_flag = (U4)FALSE; // Match flag // Iterate through all loaded symbol pairs for (U4 u4_t_SYMBOL_pair_index = (U4)ZERO; u4_t_SYMBOL_pair_index < u4_g_SYMBOL_num_pairs; u4_t_SYMBOL_pair_index++) { // Check if this pair matches the given symbols if (st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_open == u2_t_SYMBOL_open && st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_close == u2_t_SYMBOL_close) { u4_t_SYMBOL_match_flag = (U4)TRUE; // Set match flag break; // Exit loop early since we found a match } else { /* Not a match - continue searching */ } } return u4_t_SYMBOL_match_flag; } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_isOpening */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Checks if character is a valid opening symbol */ /* Arguments: U2 u2_t_SYMBOL_ch : Character to check */ /* Return: U4 : 1 if valid opening symbol, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_isOpening(U2 u2_t_SYMBOL_ch) { U4 u4_t_SYMBOL_is_open_flag = (U4)FALSE; // Flag for opening symbol // Iterate through all loaded symbol pairs for (U4 u4_t_SYMBOL_pair_index = (U4)ZERO; u4_t_SYMBOL_pair_index < u4_g_SYMBOL_num_pairs; u4_t_SYMBOL_pair_index++) { // Check if character matches any opening symbol if (st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_open == u2_t_SYMBOL_ch) { u4_t_SYMBOL_is_open_flag = (U4)TRUE; // Set flag break; // Exit loop early } else { /* Not an opening symbol - continue searching */ } } return u4_t_SYMBOL_is_open_flag; } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_isClosing */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Checks if character is a valid closing symbol */ /* Arguments: U2 u2_t_SYMBOL_ch : Character to check */ /* Return: U4 : 1 if valid closing symbol, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_isClosing(U2 u2_t_SYMBOL_ch) { U4 u4_t_SYMBOL_is_close_flag = (U4)FALSE; // Flag for closing symbol // Iterate through all loaded symbol pairs for (U4 u4_t_SYMBOL_pair_index = (U4)ZERO; u4_t_SYMBOL_pair_index < u4_g_SYMBOL_num_pairs; u4_t_SYMBOL_pair_index++) { // Check if character matches any closing symbol if (st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_close == u2_t_SYMBOL_ch) { u4_t_SYMBOL_is_close_flag = (U4)TRUE; // Set flag break; // Exit loop early } else { /* Not a closing symbol - continue searching */ } } return u4_t_SYMBOL_is_close_flag; } /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_validateDataFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Validates symbol pairs in Data.txt and saves results to Result.txt */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: void */ /*===================================================================================================================================*/ void v_g_SYMBOL_validateDataFile(const U2 *u2p_g_FILE_folder_path_p) { // Construct file paths U2 u2_t_FILE_data_path_p[(U4)MAX_FOLDER_LENGTH]; U2 u2_t_FILE_result_path_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_data_path_p, MAX_FOLDER_LENGTH, L"%ls\\Data.txt", u2p_g_FILE_folder_path_p); swprintf(u2_t_FILE_result_path_p, MAX_FOLDER_LENGTH, L"%ls\\Result.txt", u2p_g_FILE_folder_path_p); // Open Data.txt for reading FILE *vdp_t_FILE_data_file = _wfopen(u2_t_FILE_data_path_p, L"r, ccs=UTF-8"); if (!vdp_t_FILE_data_file) { MessageBoxW(NULL, L"错误:无法打开 Data.txt 文件。", L"错误", MB_OK | MB_ICONERROR); } else { // Create Result.txt for writing FILE *vdp_t_FILE_result_file = _wfopen(u2_t_FILE_result_path_p, L"w, ccs=UTF-8"); if (!vdp_t_FILE_result_file) { MessageBoxW(NULL, L"错误:无法创建 Result.txt 文件。", L"错误", MB_OK | MB_ICONERROR); fclose(vdp_t_FILE_data_file); // Close data file before returning } else { U2 u2_t_FILE_line_p[(U4)MAX_LINE_CONTENT]; // Line buffer // Process each line in Data.txt while (fgetws(u2_t_FILE_line_p, (U4)MAX_LINE_CONTENT, vdp_t_FILE_data_file)) { // Get line length and remove newline if present U4 u4_t_SYMBOL_line_length = wcslen(u2_t_FILE_line_p); if (u4_t_SYMBOL_line_length > ZERO && u2_t_FILE_line_p[u4_t_SYMBOL_line_length - ONE] == L'\n') { u2_t_FILE_line_p[u4_t_SYMBOL_line_length - ONE] = L'\0'; u4_t_SYMBOL_line_length -= ONE; } else { /* No newline - do nothing */ } // Skip empty lines if (u4_t_SYMBOL_line_length == ZERO) { continue; } else { // Stack for symbol validation U2 u2_t_SYMBOL_validation_stack_p[(U4)MAX_LINE_CONTENT]; U4 u4_t_SYMBOL_stack_top_index = (U4)STACK_INIT; // Stack pointer U4 u4_t_SYMBOL_matched_flag = (U4)TRUE; // Validation flag // Process each character in the line for (U4 u4_t_SYMBOL_char_index = (U4)ZERO; u4_t_SYMBOL_char_index < u4_t_SYMBOL_line_length; u4_t_SYMBOL_char_index++) { U2 u2_t_SYMBOL_current_char = u2_t_FILE_line_p[u4_t_SYMBOL_char_index]; // Check for opening symbol if (u4_g_SYMBOL_isOpening(u2_t_SYMBOL_current_char)) { // Push opening symbol to stack u2_t_SYMBOL_validation_stack_p[++u4_t_SYMBOL_stack_top_index] = u2_t_SYMBOL_current_char; } // Check for closing symbol else if (u4_g_SYMBOL_isClosing(u2_t_SYMBOL_current_char)) { // Check if stack is empty or top doesn't match if (u4_t_SYMBOL_stack_top_index == (U4)STACK_EMPTY || !u4_g_SYMBOL_matches(u2_t_SYMBOL_validation_stack_p[u4_t_SYMBOL_stack_top_index], u2_t_SYMBOL_current_char)) { u4_t_SYMBOL_matched_flag = (U4)FALSE; // Set invalid flag break; // Exit character loop early } else { // Valid match - pop from stack u4_t_SYMBOL_stack_top_index--; } } else { /* Not a symbol - skip character */ } } // Check if stack is not empty after processing all characters if (u4_t_SYMBOL_stack_top_index != (U4)STACK_EMPTY) { u4_t_SYMBOL_matched_flag = (U4)FALSE; } else { /* Stack is empty - do nothing */ } // Write validation result to Result.txt fwprintf(vdp_t_FILE_result_file, L"%s\n", u4_t_SYMBOL_matched_flag ? L"YES" : L"NO"); } } // Close both files fclose(vdp_t_FILE_data_file); fclose(vdp_t_FILE_result_file); // Show success message MessageBoxW(NULL, L"Result.txt文件已成功生成!", L"成功", MB_OK | MB_ICONINFORMATION); } } } /*===================================================================================================================================*/ /* Function Name: v_g_FILE_browseFolder */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Opens folder selection dialog and stores selected path */ /* Arguments: HWND hwnd : Parent window handle */ /* Return: void */ /*===================================================================================================================================*/ void v_g_FILE_browseFolder(HWND hwnd) { // Initialize folder browser structure BROWSEINFOW st_t_UI_folder_dialog_p = {(U4)ZERO}; st_t_UI_folder_dialog_p.lpszTitle = L"选择文件夹"; st_t_UI_folder_dialog_p.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; // Show folder selection dialog LPITEMIDLIST stp_t_UI_folder_item_p = SHBrowseForFolderW(&st_t_UI_folder_dialog_p); if (stp_t_UI_folder_item_p != NULL) { // Get selected folder path SHGetPathFromIDListW(stp_t_UI_folder_item_p, u2_g_FILE_folder_path_p); // Update folder path in edit control SetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p); } else { /* User canceled - do nothing */ } } /*===================================================================================================================================*/ /* Function Name: g_UI_WindowProc */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Main window message handler */ /* Arguments: HWND hwnd : Window handle */ /* UINT msg : Message ID */ /* WPARAM wParam : Message parameter */ /* LPARAM lParam : Message parameter */ /* Return: LRESULT : Result of message processing */ /*===================================================================================================================================*/ LRESULT CALLBACK g_UI_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: { // Create GUI controls RECT st_t_UI_window_rect; GetClientRect(hwnd, &st_t_UI_window_rect); // Create Browse Folder button CreateWindowW(L"BUTTON", L"浏览文件夹", WS_VISIBLE | WS_CHILD, 20, 50, 120, 30, hwnd, (HMENU)BTN_BROWSE_FOLDER, NULL, NULL); // Create Folder Path edit box CreateWindowW(L"EDIT", L"", WS_VISIBLE | WS_CHILD | WS_BORDER, 150, 50, 430, 30, hwnd, (HMENU)EDIT_FOLDER_PATH, NULL, NULL); // Create Symbols input edit box CreateWindowW(L"EDIT", L"", WS_VISIBLE | WS_CHILD | WS_BORDER, 20, 90, 400, 30, hwnd, (HMENU)EDIT_USER_SYMBOLS, NULL, NULL); // Create Save Symbols button CreateWindowW(L"BUTTON", L"保存符号对", WS_VISIBLE | WS_CHILD, 430, 90, 150, 30, hwnd, (HMENU)BTN_SAVE_SYMBOLS, NULL, NULL); // Create Generate Data button CreateWindowW(L"BUTTON", L"生成Data.txt文件", WS_VISIBLE | WS_CHILD, 20, 130, 130, 30, hwnd, (HMENU)BTN_GENERATE_DATA, NULL, NULL); // Create Process Data button CreateWindowW(L"BUTTON", L"处理数据", WS_VISIBLE | WS_CHILD, 230, 170, 120, 40, hwnd, (HMENU)BTN_PROCESS_DATA, NULL, NULL); break; } case WM_COMMAND: // Handle button clicks switch (LOWORD(wParam)) { case BTN_BROWSE_FOLDER: // Browse for folder v_g_FILE_browseFolder(hwnd); break; case BTN_SAVE_SYMBOLS: // Save symbols to file GetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p, MAX_FOLDER_LENGTH); GetDlgItemTextW(hwnd, EDIT_USER_SYMBOLS, u2_g_SYMBOL_user_symbols_p, MAX_SYMBOL_INPUT); v_g_SYMBOL_saveFile(u2_g_FILE_folder_path_p, u2_g_SYMBOL_user_symbols_p); break; case BTN_GENERATE_DATA: // Generate random data GetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p, MAX_FOLDER_LENGTH); if (u4_g_SYMBOL_loadFile(u2_g_FILE_folder_path_p)) { v_g_SYMBOL_generateRandomData(u2_g_FILE_folder_path_p); } else { /* Symbol loading failed - do nothing */ } break; case BTN_PROCESS_DATA: // Process data and validate symbols GetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p, MAX_FOLDER_LENGTH); v_g_SYMBOL_validateDataFile(u2_g_FILE_folder_path_p); break; } break; case WM_DESTROY: // Exit application PostQuitMessage(ZERO); break; default: // Default message processing return DefWindowProcW(hwnd, msg, wParam, lParam); } return ZERO; } /*===================================================================================================================================*/ /* Function Name: wWinMain */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Application entry point, creates main window and message loop */ /* Arguments: HINSTANCE hInstance : Application instance */ /* HINSTANCE hPrevInstance : Unused */ /* LPWSTR lpCmdLine : Command line arguments */ /* int nCmdShow : Window show command */ /* Return: int : Application exit code */ /*===================================================================================================================================*/ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { // Window class name const U2 u2_g_UI_class_name_p[] = L"SymbolMatcher"; // Register window class WNDCLASSW st_t_UI_window_class = {(U4)ZERO}; st_t_UI_window_class.lpfnWndProc = g_UI_WindowProc; st_t_UI_window_class.hInstance = hInstance; st_t_UI_window_class.lpszClassName = u2_g_UI_class_name_p; RegisterClassW(&st_t_UI_window_class); // Create main window HWND vdp_t_UI_main_window = CreateWindowW(u2_g_UI_class_name_p, L"符号匹配系统", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 610, 280, NULL, NULL, hInstance, NULL); // Message loop MSG st_t_UI_message; while (GetMessageW(&st_t_UI_message, NULL, ZERO, ZERO)) { TranslateMessage(&st_t_UI_message); DispatchMessageW(&st_t_UI_message); } return ZERO; } 现在符号匹配机制有点问题,分析一下为什么 数据 ((()){}){}[] (()())[{}][] {[[]{{}}[]]})() [](){} )( (([)]) 结果应该是 YES YES NO YES NO NO 要改变语言,注释用英文,打印用中文
最新发布
08-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值