Saveliy Tretiakov <saveliyt@mail.ru>

- Started serialui dll
- Implemented drvCommConfigDialogA and drvCommConfigDialogW

svn path=/trunk/; revision=14525
This commit is contained in:
Hervé Poussineau 2005-04-06 11:14:57 +00:00
parent b82483c76c
commit 2cec8d9d65
8 changed files with 642 additions and 1 deletions

View file

@ -61,7 +61,7 @@ DLLS_SHELLEXT = shellext
DLLS = acledit aclui advapi32 advpack cabinet cards comctl32 crtdll comdlg32 d3d8thk dbghelp expat fmifs freetype \
gdi32 gdiplus glu32 hid imagehlp imm32 iphlpapi kernel32 lzexpand mesa32 midimap mmdrv mpr msacm msafd \
msgina msi msimg32 msvcrt20 msvideo mswsock netapi32 ntdll ole32 oleaut32 oledlg olepro32 opengl32 \
packet psapi riched20 richedit rpcrt4 samlib secur32 setupapi shell32 shlwapi smlib smdll snmpapi \
packet psapi riched20 richedit rpcrt4 samlib secur32 serialui setupapi shell32 shlwapi smlib smdll snmpapi \
syssetup twain user32 userenv version wininet winmm winspool ws2help ws2_32 wsock32 wshirda dnsapi \
urlmon shdocvw dinput dinput8 dxdiagn devenum dsound lsasrv $(DLLS_KBD) $(DLLS_CPL) $(DLLS_SHELLEXT)

View file

@ -115,6 +115,7 @@ lib\richedit\riched32.dll 1
lib\rpcrt4\rpcrt4.dll 1
lib\samlib\samlib.dll 1
lib\secur32\secur32.dll 1
lib\serialui\serialui.dll 1
lib\setupapi\setupapi.dll 1
lib\shdocvw\shdocvw.dll 1
lib\shell32\shell32.dll 1

View file

@ -0,0 +1,36 @@
PATH_TO_TOP = ../..
TARGET_TYPE = dynlink
TARGET_NAME = serialui
TARGET_BASE = $(TARGET_BASE_LIB_SERIALUI)
TARGET_CFLAGS = \
-I./include \
-Wall \
-Werror \
-fno-builtin \
-DUNICODE \
-DLE \
-DDBG \
-D__USE_W32API
TARGET_LFLAGS = -nostartfiles -nostdlib
TARGET_SDKLIBS = kernel32.a user32.a shlwapi.a
TARGET_OBJECTS = serialui.o
DEP_OBJECTS := $(TARGET_OBJECTS)
TARGET_CLEAN = $(DEP_FILES)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

View file

@ -0,0 +1,32 @@
#define IDS_EVENPARITY 2001
#define IDS_MARKPARITY 2002
#define IDS_NOPARITY 2003
#define IDS_ODDPARITY 2004
#define IDS_SPACEPARITY 2005
#define IDS_ONESTOPBIT 2006
#define IDS_ONE5STOPBITS 2007
#define IDS_TWOSTOPBITS 2008
#define IDS_FC_NO 2009
#define IDS_FC_CTSRTS 2010
#define IDS_FC_XONXOFF 2011
#define IDS_TITLE 2012
#define IDD_COMMDLG 1000
#define IDC_GRP1 1001
#define IDC_OKBTN 1002
#define IDC_CANCELBTN 1003
#define IDC_BTN 1004
#define IDC_STC1 1005
#define IDC_STC2 1006
#define IDC_STC3 1007
#define IDC_STC4 1008
#define IDC_STC5 1009
#define IDC_BAUDRATE 1010
#define IDC_BYTESIZE 1011
#define IDC_PARITY 1012
#define IDC_STOPBITS 1013
#define IDC_FLOW 1014
#define IDC_RESTOREBTN 1015

View file

@ -0,0 +1,440 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS SerialUI DLL
* FILE: serialui.c
* PUROPSE: A dialog box to cunfigure COM port.
* Functions to set(and get too) default configuration.
* PROGRAMMERS: Saveliy Tretiakov (saveliyt@mail.ru)
* REVISIONS:
* ST (05/04/2005) Created. Implemented drvCommConfigDialog.
*/
#include <serialui.h>
static HINSTANCE hDllInstance;
/************************************
*
* DATA
*
************************************/
struct
{
DWORD Baud;
CHAR *Str;
} Bauds[] =
{
{ CBR_110, "110" },
{ CBR_300, "300" },
{ CBR_600, "600" },
{ CBR_1200, "1200" },
{ CBR_2400, "2400" },
{ CBR_4800, "4800" },
{ CBR_9600, "9600" },
{ CBR_14400, "14400" },
{ CBR_19200, "19200" },
{ CBR_38400, "38400" },
{ CBR_56000, "56000" },
{ CBR_57600, "57600" },
{ CBR_115200, "115200" },
{ CBR_128000, "128000" },
{ CBR_256000, "256000" },
{ 0, 0 }
};
struct
{
BYTE ByteSize;
CHAR *Str;
} ByteSizes[] =
{
{ 5, "5" },
{ 6, "6" },
{ 7, "7" },
{ 8, "8" },
{ 0, 0 }
};
struct
{
BYTE Parity;
UINT StrId;
} Paritys[] =
{
{ EVENPARITY, IDS_EVENPARITY },
{ MARKPARITY, IDS_MARKPARITY },
{ NOPARITY, IDS_NOPARITY },
{ ODDPARITY, IDS_ODDPARITY },
{ SPACEPARITY, IDS_SPACEPARITY },
{ 0, 0 }
};
struct
{
BYTE StopBit;
UINT StrId;
} StopBits[] =
{
{ ONESTOPBIT, IDS_ONESTOPBIT },
{ ONE5STOPBITS, IDS_ONE5STOPBITS },
{ TWOSTOPBITS, IDS_TWOSTOPBITS },
{ 0, 0 }
};
/************************************
*
* DLLMAIN
*
************************************/
BOOL
STDCALL
DllMain(HINSTANCE hInstance,
DWORD dwReason,
LPVOID reserved)
{
if(dwReason==DLL_PROCESS_ATTACH)
{
hDllInstance = hInstance;
}
else if(dwReason==DLL_THREAD_ATTACH)
{
DisableThreadLibraryCalls(hInstance);
}
return TRUE;
}
/************************************
*
* EXPORTS
*
************************************/
/*
* @implemented
*/
BOOL WINAPI drvCommConfigDialogW(LPCWSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig)
{
DIALOG_INFO DialogInfo;
if(!lpszDevice || !lpCommConfig)
{
return FALSE;
}
DialogInfo.lpszDevice = lpszDevice;
DialogInfo.lpCC = lpCommConfig;
return DialogBoxParamW(hDllInstance, MAKEINTRESOURCEW(IDD_COMMDLG),
hWnd, (DLGPROC)CommDlgProc, (LPARAM)&DialogInfo);
}
/*
* @implemented
*/
BOOL WINAPI drvCommConfigDialogA(LPCSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig)
{
BOOL result;
UINT len;
WCHAR *wstr;
len = MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, NULL, 0);
if((wstr = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
{
MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, wstr, len);
result = drvCommConfigDialogW(wstr, hWnd, lpCommConfig);
HeapFree(GetProcessHeap(), 0, wstr);
return result;
}
else
return FALSE;
}
/*
* @unimplemented
*/
BOOL WINAPI drvSetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize)
{
UNIMPLEMENTED
}
/*
* @unimplemented
*/
BOOL WINAPI drvSetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize)
{
UNIMPLEMENTED
}
/*
* @unimplemented
*/
BOOL WINAPI drvGetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize)
{
UNIMPLEMENTED
}
/*
* @unimplemented
*/
BOOL WINAPI drvGetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize)
{
UNIMPLEMENTED
}
/************************************
*
* INTERNALS
*
************************************/
LRESULT CommDlgProc(HWND hDlg,
UINT Msg,
WPARAM wParam,
LPARAM lParam)
{
LPDIALOG_INFO lpDlgInfo = NULL;
HWND hBox;
switch (Msg)
{
case WM_INITDIALOG:
{
WCHAR wstr[255], *format;
CHAR str[255];
RECT rc, rcDlg, rcOwner;
HWND hOwner;
INT i, len;
lpDlgInfo = (LPDIALOG_INFO)lParam;
SetWindowLong(hDlg, DWL_USER, (LONG)lpDlgInfo);
/* Set title */
LoadStringA(hDllInstance, IDS_TITLE, str, 254);
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
if((format = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
{
MultiByteToWideChar(CP_ACP, 0, str, -1, format, len);
wnsprintfW(wstr, 254, format, lpDlgInfo->lpszDevice);
HeapFree(GetProcessHeap(), 0, format);
SetWindowTextW(hDlg, wstr);
}
if(!(hOwner = GetParent(hDlg)))
hOwner = GetDesktopWindow();
/* Position dialog in the center of owner window */
GetWindowRect(hOwner, &rcOwner);
GetWindowRect(hDlg, &rcDlg);
CopyRect(&rc, &rcOwner);
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
OffsetRect(&rc, -rc.left, -rc.top);
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
SetWindowPos(hDlg, HWND_TOP,
rcOwner.left + (rc.right / 2),
rcOwner.top + (rc.bottom / 2),
0, 0, SWP_NOSIZE);
/* Initialize baud rate combo */
if(!(hBox = GetDlgItem(hDlg, IDC_BAUDRATE)))
EndDialog(hDlg, 0);
for(i = 0; Bauds[i].Str; i++)
{
SendMessageA(hBox, CB_INSERTSTRING, (WPARAM)i, (LPARAM)Bauds[i].Str);
if(Bauds[i].Baud == lpDlgInfo->lpCC->dcb.BaudRate)
SendMessageA(hBox, CB_SETCURSEL, (WPARAM)i, 0);
}
if(SendMessage(hBox, CB_GETCURSEL, 0, 0)==CB_ERR)
SendMessageA(hBox, CB_SETCURSEL, DEFAULT_BAUD_INDEX, 0);
/* Initialize byte size combo */
if(!(hBox = GetDlgItem(hDlg, IDC_BYTESIZE)))
EndDialog(hDlg, 0);
for(i = 0; ByteSizes[i].Str; i++)
{
SendMessageA(hBox, CB_INSERTSTRING, (WPARAM)i, (LPARAM)ByteSizes[i].Str);
if(ByteSizes[i].ByteSize == lpDlgInfo->lpCC->dcb.ByteSize)
SendMessageA(hBox, CB_SETCURSEL, (WPARAM)i, 0);
}
if(SendMessage(hBox, CB_GETCURSEL, 0, 0)==CB_ERR)
SendMessageA(hBox, CB_SETCURSEL, DEFAULT_BYTESIZE_INDEX, 0);
/* Initialize parity combo */
if(!(hBox = GetDlgItem(hDlg, IDC_PARITY)))
EndDialog(hDlg, 0);
for(i = 0; Paritys[i].StrId; i++)
{
if(LoadStringA(hDllInstance, Paritys[i].StrId, str, 254))
{
SendMessageA(hBox, CB_INSERTSTRING, (WPARAM)i, (LPARAM)str);
if(Paritys[i].Parity == lpDlgInfo->lpCC->dcb.Parity)
SendMessageA(hBox, CB_SETCURSEL, (WPARAM)i, 0);
}
}
if(SendMessage(hBox, CB_GETCURSEL, 0, 0)==CB_ERR)
SendMessageA(hBox, CB_SETCURSEL, DEFAULT_PARITY_INDEX, 0);
/* Initialize stop bits combo */
if(!(hBox = GetDlgItem(hDlg, IDC_STOPBITS)))
EndDialog(hDlg, 0);
for(i = 0; StopBits[i].StrId; i++)
{
if(LoadStringA(hDllInstance,StopBits[i].StrId, str, 254))
{
SendMessageA(hBox, CB_INSERTSTRING, (WPARAM)i, (LPARAM)str);
if(StopBits[i].StopBit == lpDlgInfo->lpCC->dcb.StopBits)
SendMessageA(hBox, CB_SETCURSEL, (WPARAM)i, 0);
}
}
if(SendMessage(hBox, CB_GETCURSEL, 0, 0)==CB_ERR)
SendMessageA(hBox, CB_SETCURSEL, DEFAULT_STOPBITS_INDEX, 0);
/* Initialize flow control combo */
if(!(hBox = GetDlgItem(hDlg, IDC_FLOW)))
EndDialog(hDlg, 0);
if(LoadStringA(hDllInstance,IDS_FC_NO, str, 254))
{
SendMessageA(hBox, CB_INSERTSTRING, 0, (LPARAM)str);
SendMessageA(hBox, CB_SETCURSEL, 0, 0);
lpDlgInfo->InitialFlowIndex = 0;
}
if(LoadStringA(hDllInstance,IDS_FC_CTSRTS, str, 254))
{
SendMessageA(hBox, CB_INSERTSTRING, 1, (LPARAM)str);
if(lpDlgInfo->lpCC->dcb.fRtsControl == RTS_CONTROL_HANDSHAKE
|| lpDlgInfo->lpCC->dcb.fOutxCtsFlow == TRUE)
{
SendMessageA(hBox, CB_SETCURSEL, 1, 0);
lpDlgInfo->InitialFlowIndex = 1;
}
}
if(LoadStringA(hDllInstance,IDS_FC_XONXOFF, str, 254))
{
SendMessageA(hBox, CB_INSERTSTRING, 2, (LPARAM)str);
if(lpDlgInfo->lpCC->dcb.fOutX || lpDlgInfo->lpCC->dcb.fInX)
{
SendMessageA(hBox, CB_SETCURSEL, 2, 0);
lpDlgInfo->InitialFlowIndex = 2;
}
}
/* Set focus */
SetFocus(GetDlgItem(hDlg, IDC_OKBTN));
return FALSE;
} /* WM_INITDIALOG */
case WM_COMMAND:
{
switch(wParam)
{
case IDC_CANCELBTN:
EndDialog(hDlg, FALSE);
break;
case IDC_OKBTN:
OkButton(hDlg);
EndDialog(hDlg, TRUE);
break;
}
return TRUE;
} /* WM_COMMAND */
case WM_CLOSE:
{
EndDialog(hDlg, FALSE);
return TRUE;
} /* WM_CLOSE */
default:
return FALSE;
}
}
VOID OkButton(HWND hDlg)
{
LPDIALOG_INFO lpDlgInfo;
UINT Index;
lpDlgInfo = (LPDIALOG_INFO) GetWindowLong(hDlg, DWL_USER);
/* Baud rate */
Index = SendMessage(GetDlgItem(hDlg, IDC_BAUDRATE), CB_GETCURSEL, 0, 0);
lpDlgInfo->lpCC->dcb.BaudRate = Bauds[Index].Baud;
/* Byte size */
Index = SendMessage(GetDlgItem(hDlg, IDC_BYTESIZE), CB_GETCURSEL, 0, 0);
lpDlgInfo->lpCC->dcb.ByteSize = ByteSizes[Index].ByteSize;
/* Parity */
Index = SendMessage(GetDlgItem(hDlg, IDC_PARITY), CB_GETCURSEL, 0, 0);
lpDlgInfo->lpCC->dcb.Parity = Paritys[Index].Parity;
/* Stop bits */
Index = SendMessage(GetDlgItem(hDlg, IDC_STOPBITS), CB_GETCURSEL, 0, 0);
lpDlgInfo->lpCC->dcb.StopBits = StopBits[Index].StopBit;
/* Flow Control */
Index = SendMessage(GetDlgItem(hDlg, IDC_FLOW), CB_GETCURSEL, 0, 0);
if(lpDlgInfo->InitialFlowIndex != Index)
{
switch(Index)
{
case 0: /* NO */
lpDlgInfo->lpCC->dcb.fDtrControl = DTR_CONTROL_DISABLE;
lpDlgInfo->lpCC->dcb.fRtsControl = RTS_CONTROL_DISABLE;
lpDlgInfo->lpCC->dcb.fOutxCtsFlow = FALSE;
lpDlgInfo->lpCC->dcb.fOutxDsrFlow = FALSE;
lpDlgInfo->lpCC->dcb.fOutX = FALSE;
lpDlgInfo->lpCC->dcb.fInX = FALSE;
break;
case 1: /* CTS/RTS */
lpDlgInfo->lpCC->dcb.fDtrControl = DTR_CONTROL_DISABLE;
lpDlgInfo->lpCC->dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
lpDlgInfo->lpCC->dcb.fOutxCtsFlow = TRUE;
lpDlgInfo->lpCC->dcb.fOutxDsrFlow = FALSE;
lpDlgInfo->lpCC->dcb.fOutX = FALSE;
lpDlgInfo->lpCC->dcb.fInX = FALSE;
break;
case 2: /* XON/XOFF */
lpDlgInfo->lpCC->dcb.fDtrControl = DTR_CONTROL_DISABLE;
lpDlgInfo->lpCC->dcb.fRtsControl = RTS_CONTROL_DISABLE;
lpDlgInfo->lpCC->dcb.fOutxCtsFlow = FALSE;
lpDlgInfo->lpCC->dcb.fOutxDsrFlow = FALSE;
lpDlgInfo->lpCC->dcb.fOutX = TRUE;
lpDlgInfo->lpCC->dcb.fInX = TRUE;
break;
}
}
}

View file

@ -0,0 +1,10 @@
LIBRARY serialui.dll
EXPORTS
drvCommConfigDialogW@12
drvCommConfigDialogA@12
drvSetDefaultCommConfigW@12
drvSetDefaultCommConfigA@12
drvGetDefaultCommConfigW@12
drvGetDefaultCommConfigA@12

View file

@ -0,0 +1,74 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS SerialUI DLL
* FILE: serialui.h
* PURPOSE: header file
* PROGRAMMERS: Saveliy Tretiakov (saveliyt@mail.ru)
*/
#include <windows.h>
#include <shlwapi.h>
#include "resource.h"
#define UNIMPLEMENTED \
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); \
return FALSE;
#define DEFAULT_BAUD_INDEX 6
#define DEFAULT_BYTESIZE_INDEX 3
#define DEFAULT_PARITY_INDEX 2
#define DEFAULT_STOPBITS_INDEX 0
typedef struct _DIALOG_INFO
{
LPCWSTR lpszDevice;
UINT InitialFlowIndex;
LPCOMMCONFIG lpCC;
} DIALOG_INFO, *LPDIALOG_INFO;
/************************************
*
* EXPORTS
*
************************************/
BOOL WINAPI drvCommConfigDialogW(LPCWSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig);
BOOL WINAPI drvCommConfigDialogA(LPCSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig);
BOOL WINAPI drvSetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize);
BOOL WINAPI drvSetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize);
BOOL WINAPI drvGetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize);
BOOL WINAPI drvGetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize);
/************************************
*
* INTERNALS
*
************************************/
LRESULT CommDlgProc(HWND hDlg,
UINT Msg,
WPARAM wParam,
LPARAM lParam);
VOID OkButton(HWND hDlg);

View file

@ -0,0 +1,48 @@
#include "resource.h"
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS SerialUI DLL\0"
#define REACTOS_STR_INTERNAL_NAME "serialui\0"
#define REACTOS_STR_ORIGINAL_FILENAME "serialui.dll\0"
#include <reactos/version.rc>
STRINGTABLE LOADONCALL DISCARDABLE
BEGIN
IDS_EVENPARITY, "Even"
IDS_MARKPARITY, "Mark"
IDS_NOPARITY, "No parity"
IDS_ODDPARITY, "Odd"
IDS_SPACEPARITY, "Space"
IDS_ONESTOPBIT, "1 stop bit"
IDS_ONE5STOPBITS, "1.5 stop bits"
IDS_TWOSTOPBITS, "2 stop bits"
IDS_FC_NO, "No"
IDS_FC_CTSRTS, "CTS/RTS"
IDS_FC_XONXOFF, "XON/XOFF"
IDS_TITLE, "Properties for %s"
END
IDD_COMMDLG DIALOGEX 6,5,222,175
FONT 8,"MS Sans Serif"
STYLE 0x10C80080
EXSTYLE 0x00000001
BEGIN
CONTROL "",IDC_GRP1,"Button",0x50000007,6,5,210,146,0x00000000
CONTROL "OK",IDC_OKBTN,"Button",0x50010000,98,156,56,13,0x00000000
CONTROL "Cancel",IDC_CANCELBTN,"Button",0x50010000,158,156,56,13,0x00000000
CONTROL "Baud rate:",IDC_STC1,"Static",0x50000000,24,31,42,9,0x00000000
CONTROL "Byte size:",IDC_STC2,"Static",0x50000000,24,53,42,9,0x00000000
CONTROL "Parity:",IDC_STC3,"Static",0x50000000,24,73,42,9,0x00000000
CONTROL "Stop bits:",IDC_STC4,"Static",0x50000000,24,96,42,9,0x00000000
CONTROL "Flow control:",IDC_STC5,"Static",0x50000000,24,120,42,9,0x00000000
CONTROL "",IDC_BAUDRATE,"ComboBox",0x50210003,98,29,100,50,0x00000000
CONTROL "",IDC_BYTESIZE,"ComboBox",0x50210003,98,49,100,50,0x00000000
CONTROL "",IDC_PARITY,"ComboBox",0x50210003,98,72,100,50,0x00000000
CONTROL "",IDC_STOPBITS,"ComboBox",0x50210003,98,94,100,50,0x00000000
CONTROL "",IDC_FLOW,"ComboBox",0x50210003,98,116,100,50,0x00000000
END