Author: cwittich
Date: Wed Feb 27 13:54:25 2008
New Revision: 32501
URL:
http://svn.reactos.org/svn/reactos?rev=32501&view=rev
Log:
remove duplicated code
Modified:
trunk/reactos/boot/freeldr/fdebug/fdebug.c
Modified: trunk/reactos/boot/freeldr/fdebug/fdebug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/fdebug/fdebug…
==============================================================================
--- trunk/reactos/boot/freeldr/fdebug/fdebug.c (original)
+++ trunk/reactos/boot/freeldr/fdebug/fdebug.c Wed Feb 27 13:54:25 2008
@@ -35,10 +35,7 @@
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ConnectionDialogProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK CaptureDialogProc(HWND, UINT, WPARAM, LPARAM);
-VOID EnableConnectMenuItem(BOOL Enable);
-VOID EnableDisconnectMenuItem(BOOL Enable);
-VOID EnableStartCaptureMenuItem(BOOL Enable);
-VOID EnableStopCaptureMenuItem(BOOL Enable);
+VOID EnableFileMenuItemByID(UINT Id, BOOL Enable);
VOID CheckLocalEchoMenuItem(BOOL Checked);
VOID Rs232Thread(VOID* Parameter);
@@ -231,8 +228,8 @@
if (DialogBox(hInst, (LPCTSTR)IDD_CONNECTION, hWnd, (DLGPROC)ConnectionDialogProc) ==
IDOK)
{
bConnected = TRUE;
- EnableDisconnectMenuItem(TRUE);
- EnableConnectMenuItem(FALSE);
+ EnableFileMenuItemByID(IDM_FILE_DISCONNECT, TRUE);
+ EnableFileMenuItemByID(IDM_FILE_CONNECT, FALSE);
_beginthread(Rs232Thread, 0, NULL);
}
}
@@ -241,8 +238,8 @@
if (bConnected)
{
bConnected = FALSE;
- EnableDisconnectMenuItem(FALSE);
- EnableConnectMenuItem(TRUE);
+ EnableFileMenuItemByID(IDM_FILE_DISCONNECT, FALSE);
+ EnableFileMenuItemByID(IDM_FILE_CONNECT, TRUE);
}
else
{
@@ -253,8 +250,8 @@
if (DialogBox(hInst, (LPCTSTR)IDD_CAPTURE, hWnd, (DLGPROC)CaptureDialogProc) == IDOK)
{
bCapturing = TRUE;
- EnableStopCaptureMenuItem(TRUE);
- EnableStartCaptureMenuItem(FALSE);
+ EnableFileMenuItemByID(IDM_FILE_STOPCAPTURE, TRUE);
+ EnableFileMenuItemByID(IDM_FILE_STARTCAPTURE, FALSE);
hCaptureFile = CreateFile(strCaptureFileName, FILE_APPEND_DATA,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
}
break;
@@ -262,8 +259,8 @@
if (bCapturing)
{
bCapturing = FALSE;
- EnableStopCaptureMenuItem(FALSE);
- EnableStartCaptureMenuItem(TRUE);
+ EnableFileMenuItemByID(IDM_FILE_STOPCAPTURE, FALSE);
+ EnableFileMenuItemByID(IDM_FILE_STARTCAPTURE, TRUE);
CloseHandle(hCaptureFile);
hCaptureFile = NULL;
}
@@ -419,94 +416,24 @@
return FALSE;
}
-VOID EnableConnectMenuItem(BOOL Enable)
+VOID EnableFileMenuItemByID(UINT Id, BOOL Enable)
{
HMENU hMenuBar;
HMENU hFileMenu;
hMenuBar = GetMenu(hMainWnd);
hFileMenu = GetSubMenu(hMenuBar, 0);
-
- if (Enable)
- {
- EnableMenuItem(hFileMenu, IDM_FILE_CONNECT, MF_BYCOMMAND|MF_ENABLED);
- }
- else
- {
- EnableMenuItem(hFileMenu, IDM_FILE_CONNECT, MF_BYCOMMAND|MF_GRAYED);
- }
-}
-
-VOID EnableDisconnectMenuItem(BOOL Enable)
+ EnableMenuItem(hFileMenu, Id, MF_BYCOMMAND|(Enable ? MF_ENABLED : MF_GRAYED));
+}
+
+VOID CheckLocalEchoMenuItem(BOOL Checked)
{
HMENU hMenuBar;
HMENU hFileMenu;
hMenuBar = GetMenu(hMainWnd);
hFileMenu = GetSubMenu(hMenuBar, 0);
-
- if (Enable)
- {
- EnableMenuItem(hFileMenu, IDM_FILE_DISCONNECT, MF_BYCOMMAND|MF_ENABLED);
- }
- else
- {
- EnableMenuItem(hFileMenu, IDM_FILE_DISCONNECT, MF_BYCOMMAND|MF_GRAYED);
- }
-}
-
-VOID EnableStartCaptureMenuItem(BOOL Enable)
-{
- HMENU hMenuBar;
- HMENU hFileMenu;
-
- hMenuBar = GetMenu(hMainWnd);
- hFileMenu = GetSubMenu(hMenuBar, 0);
-
- if (Enable)
- {
- EnableMenuItem(hFileMenu, IDM_FILE_STARTCAPTURE, MF_BYCOMMAND|MF_ENABLED);
- }
- else
- {
- EnableMenuItem(hFileMenu, IDM_FILE_STARTCAPTURE, MF_BYCOMMAND|MF_GRAYED);
- }
-}
-
-VOID EnableStopCaptureMenuItem(BOOL Enable)
-{
- HMENU hMenuBar;
- HMENU hFileMenu;
-
- hMenuBar = GetMenu(hMainWnd);
- hFileMenu = GetSubMenu(hMenuBar, 0);
-
- if (Enable)
- {
- EnableMenuItem(hFileMenu, IDM_FILE_STOPCAPTURE, MF_BYCOMMAND|MF_ENABLED);
- }
- else
- {
- EnableMenuItem(hFileMenu, IDM_FILE_STOPCAPTURE, MF_BYCOMMAND|MF_GRAYED);
- }
-}
-
-VOID CheckLocalEchoMenuItem(BOOL Checked)
-{
- HMENU hMenuBar;
- HMENU hFileMenu;
-
- hMenuBar = GetMenu(hMainWnd);
- hFileMenu = GetSubMenu(hMenuBar, 0);
-
- if (Checked)
- {
- CheckMenuItem(hFileMenu, IDM_FILE_LOCALECHO, MF_BYCOMMAND|MF_CHECKED);
- }
- else
- {
- CheckMenuItem(hFileMenu, IDM_FILE_LOCALECHO, MF_BYCOMMAND|MF_UNCHECKED);
- }
+ CheckMenuItem(hFileMenu, IDM_FILE_LOCALECHO, MF_BYCOMMAND|(Checked ? MF_CHECKED :
MF_UNCHECKED));
}
VOID Rs232Thread(VOID* Parameter)