MCPcopy Create free account
hub / github.com/Zhou-zhi-peng/SerialPortForWindowsTerminal / SettingFunc

Function SettingFunc

SerialForWindowsTerminal.cpp:538–677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536}
537
538INT_PTR CALLBACK SettingFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
539{
540 UNREFERENCED_PARAMETER(lParam);
541 switch (message)
542 {
543 case WM_INITDIALOG:
544 {
545 CenterParentWindow(hDlg);
546 auto cfg = ReadSerialConfig();
547 auto hWndPort = GetDlgItem(hDlg, IDC_COMBO_PORT);
548 UpdatePortControl(hDlg);
549 auto portCount = ComboBox_GetCount(hWndPort);
550 if (cfg.Serial != 0)
551 {
552 for (int i = 0; i < portCount; ++i)
553 {
554 auto com = (int)ComboBox_GetItemData(hWndPort, i);
555 if (com == cfg.Serial)
556 {
557 ComboBox_SetCurSel(hWndPort, i);
558 break;
559 }
560 }
561 }
562 else
563 {
564 ComboBox_SetCurSel(hWndPort, 0);
565 }
566
567 auto hWndBaudRate = GetDlgItem(hDlg, IDC_COMBO_SPEED);
568 ComboBox_AddString(hWndBaudRate, L"50");
569 ComboBox_AddString(hWndBaudRate, L"75");
570 ComboBox_AddString(hWndBaudRate, L"100");
571 ComboBox_AddString(hWndBaudRate, L"105");
572 ComboBox_AddString(hWndBaudRate, L"300");
573 ComboBox_AddString(hWndBaudRate, L"600");
574 ComboBox_AddString(hWndBaudRate, L"1200");
575 ComboBox_AddString(hWndBaudRate, L"2400");
576 ComboBox_AddString(hWndBaudRate, L"4800");
577 ComboBox_AddString(hWndBaudRate, L"9600");
578 ComboBox_AddString(hWndBaudRate, L"19200");
579 ComboBox_AddString(hWndBaudRate, L"38400");
580 ComboBox_AddString(hWndBaudRate, L"57600");
581 ComboBox_AddString(hWndBaudRate, L"115200");
582 ComboBox_AddString(hWndBaudRate, L"128000");
583 ComboBox_AddString(hWndBaudRate, L"256000");
584 ComboBox_SetText(hWndBaudRate, std::to_wstring(cfg.BaudRate).c_str());
585
586 auto hWndWordLength = GetDlgItem(hDlg, IDC_COMBO_WORD);
587 ComboBox_AddString(hWndWordLength, L"4");
588 ComboBox_AddString(hWndWordLength, L"5");
589 ComboBox_AddString(hWndWordLength, L"6");
590 ComboBox_AddString(hWndWordLength, L"7");
591 ComboBox_AddString(hWndWordLength, L"8");
592 ComboBox_AddString(hWndWordLength, L"9");
593 ComboBox_AddString(hWndWordLength, L"10");
594 ComboBox_SetCurSel(hWndWordLength, (int)(cfg.WordLength - 4));
595

Callers

nothing calls this directly

Calls 4

CenterParentWindowFunction · 0.85
ReadSerialConfigFunction · 0.85
UpdatePortControlFunction · 0.85
WriteSerialConfigFunction · 0.85

Tested by

no test coverage detected