Annotation of mstools/samples/sdktools/winat/winat.c, revision 1.1.1.2

1.1       root        1: //===========================================================================
                      2: //
                      3: // Module: WINAT.C
                      4: //
                      5: // Purpose: Main program for WINAT.exe.  This program is a GUI Windows
                      6: //          NT AT Command Scheduler.  The base code was taken from the
                      7: //          Windows NT AT command files.  I have preserved (mostly) the
                      8: //          same algorithms and data structures.
                      9: //
                     10: // Author: Kory Gill
                     11: //
                     12: // Date  : March 1993
                     13: //
                     14: // Copyright: Copyright Microsoft Corporation 1993
                     15: //
                     16: // Original banner from Windows NT at.c
                     17: //
                     18: //      /*++
                     19: //
                     20: //      Copyright (c) 1987-1992  Microsoft Corporation
                     21: //
                     22: //      Module Name:
                     23: //
                     24: //          atcmd.c
                     25: //
                     26: //      Abstract:
                     27: //
                     28: //          Code for AT command, to be used with SCHEDULE service on
                     29: //          Windows NT.
                     30: //
                     31: //          The module was taken from LanManager\at.c and then modified
                     32: //          considerably to work with NT Schedule service.
                     33: //
                     34: //      Author:
                     35: //
                     36: //          Vladimir Z. Vulovic     (vladimv)       06 - November - 1992
                     37: //
                     38: //      Environment:
                     39: //
                     40: //          User Mode - Win32
                     41: //
                     42: //      Revision History:
                     43: //
                     44: //          06-Nov-1992     vladimv
                     45: //              Created
                     46: //
                     47: //          20-Feb-1993     yihsins
                     48: //              Get rid of hard coded strings and parse/print time according
                     49: //              to user profile
                     50: //
                     51: //      --*/
                     52: //
                     53: //===========================================================================
                     54: 
                     55: 
                     56: //===========================================================================
                     57: // includes
                     58: //===========================================================================
                     59: 
                     60: #include <windows.h>    // required for all Windows applications
                     61: #include "lmcons.h"     // LAN Manager defines
                     62: #include "MYnetmsg.h"   // APE2 defines
                     63: #include "lmerr.h"      // LAN Manager error messages
                     64: #include "lmat.h"       // AT Command prototypes
                     65: #include "lmapibuf.h"   // NetApiBufferFree
                     66: #include "WINAT.h"      // specific to this program
                     67: #include "listhapi.h"   // hotizontal listbox routines
                     68: #include <assert.h>     // assert
                     69: #include <stdio.h>      // assert
                     70: 
                     71: 
                     72: //===========================================================================
                     73: // global variables
                     74: //===========================================================================
                     75: 
                     76: ATTIME  AtTime[NUM_TIMES] =                 // time strings and ms since 12am
                     77:     {
1.1.1.2 ! root       78:        "00:00",  0, "00:30",  0, "01:00",  0, "01:30",  0,
        !            79:        "02:00",  0, "02:30",  0, "03:00",  0, "03:30",  0,
        !            80:        "04:00",  0, "04:30",  0, "05:00",  0, "05:30",  0,
        !            81:        "06:00",  0, "06:30",  0, "07:00",  0, "07:30",  0,
        !            82:        "08:00",  0, "08:30",  0, "09:00",  0, "09:30",  0,
        !            83:        "10:00",  0, "10:30",  0, "11:00",  0, "11:30",  0,
        !            84:        "12:00",  0, "12:30",  0, "13:00",  0, "13:30",  0,
        !            85:        "14:00",  0, "14:30",  0, "15:00",  0, "15:30",  0,
        !            86:        "16:00",  0, "16:30",  0, "17:00",  0, "17:30",  0,
        !            87:        "18:00",  0, "18:30",  0, "19:00",  0, "19:30",  0,
        !            88:        "20:00",  0, "20:30",  0, "21:00",  0, "21:30",  0,
        !            89:        "22:00",  0, "22:30",  0, "23:00",  0, "23:30",  0
1.1       root       90:     };
                     91: AT_INFO GlobalAtInfo;                       // at information structure
                     92: BOOL    fTimer;                             // flag for timer events
                     93: DWORD   GlobalJobId;                        // job id as dword
                     94: DWORD   dwDisposition;                      // used for registry calls
                     95: DWORD   dwH = DWH;                          // height of main window
                     96: DWORD   dwTime;                             // time in milliseconds
                     97: DWORD   dwW = DWW;                          // width of main window
                     98: DWORD   dwX = DWX;                          // x location of main window
                     99: DWORD   dwY = DWY;                          // y location of main window
1.1.1.2 ! root      100: FARPROC lpAmPmProc;                                                     // subclass for add/change AmPm edit control
        !           101: FARPROC lpAmPmDefProc;                                          // default handler for add/change AmPm edit control
        !           102: FARPROC lpDownButtonProc;                                       // subclass for spin button
        !           103: FARPROC lpDownButtonDefProc;                            // default handler for spin buttons
        !           104: FARPROC lpHourProc;                                                     // subclass for add/change hour edit control
        !           105: FARPROC lpHourDefProc;                                          // default handler for add/change hour edit control
        !           106: FARPROC lpMinProc;                                                      // subclass for add/change min edit control
        !           107: FARPROC lpMinDefProc;                                           // default handler for add/change min edit control
        !           108: FARPROC lpUpButtonProc;                                         // subclass for spin button
        !           109: FARPROC lpUpButtonDefProc;                                      // default handler for spin buttons
1.1       root      110: HANDLE  hInst;                              // instance
                    111: HCURSOR hCursorOld;                         // old cursor
                    112: HCURSOR hCursorWait;                        // hourglass cursor
                    113: HFONT   hFont;                              // handle to font
                    114: HANDLE  GlobalMessageHandle;                // handle to netmsg.dll
                    115: HKEY    hkHandle;                           // hangle to registry
1.1.1.2 ! root      116: HWND    hCurrentFocus = NULL;                           // handle to window with focus (used for hour/min/ampm spin buttons)
1.1       root      117: HWND    hGlobalhWnd;                        // handle to main window
                    118: HWND    hGlobalAddChg = NULL;               // handle to Add/Change dialog when active
1.1.1.2 ! root      119: HWND    hHour = NULL;                       // handle to hour
        !           120: HWND    hMin = NULL;                        // handle to minutes
        !           121: HWND    hAmPm = NULL;                       // handle to ampm
1.1       root      122: LOGFONT lf;                                 // font
                    123: PWSTR   GlobalComputerName;                 // currently selected comp. name
                    124: UCHAR   szRegistryPath[] = SZREGPATH;       // path to registry for stored info
                    125: UCHAR   szAppName[] = SZAPPTITLE;           // name of this application
                    126: UCHAR   szAtCommand[MAX_ATCMD_LEN+1];       // entire line in atcommand listbox
                    127: UCHAR   szCommandM[MAXCOMMANDLEN+1];        // multibyte command
                    128: UCHAR   szComputerM[MAXCOMPUTERNAMELEN+1];  // multibyte comp. name
                    129: UCHAR   szDateAbbr[4];                      // store day of month as string
                    130: UCHAR   szDayAbbr[7][4]   =                 // abbreviations
                    131:     {
1.1.1.2 ! root      132:        "M ", "T ", "W ", "Th ", "F ", "Sa ", "Su "
1.1       root      133:     };
                    134: UCHAR   szDefault[] = " ";                  // default char for wide conversion
                    135: UCHAR   szError[] = SZGENERROR;             // error message
                    136: UCHAR   szNoEntries[] = SZNOENTRIES;        // error message
                    137: UCHAR   szTime[8];                          // store time as string
                    138: UCHAR   szTitle[]   = SZAPPTITLE;           // title bar text
                    139: UCHAR   szWhenDay[MAXWHENDAYLEN + 1];       // used to build when/day string
1.1.1.2 ! root      140: UINT    uAmPmChars;                                                     // count of characters in add/change AmPm edit control
        !           141: UINT    uHourChars;                                                     // count of characters in add/change hour edit control
        !           142: UINT    uMinChars;                                                      // count of characters in add/change min edit control
        !           143: UINT    uTimer;                             // handle of timer
1.1       root      144: WCHAR   szCommandW[MAXCOMMANDLEN+1];        // widechar command
                    145: WCHAR   szComputerW[MAXCOMPUTERNAMELEN+1];  // widechar comp. name
                    146: 
1.1.1.2 ! root      147: // jean-marc - start
        !           148: UCHAR   gszCommandLine[MAXCOMPUTERNAMELEN+1]; // stores the passed in commandline
        !           149: // jean-marc - end
1.1       root      150: 
                    151: 
                    152: //===========================================================================
                    153: // FUNCTION: AddChangeDlgProc()
                    154: //===========================================================================
                    155: 
                    156: BOOL APIENTRY
                    157: AddChangeDlgProc(
                    158:     HWND hWnd,         // window handle
                    159:     UINT message,      // type of message
                    160:     UINT uParam,       // additional information
                    161:     LONG lParam        // additional information
                    162:     )
                    163: {
                    164: 
                    165:     NET_API_STATUS  status;
                    166:     PAT_INFO        pAtInfo = NULL;
                    167:     SYSTEMTIME      SystemTime;
                    168:     UCHAR           szAtCommand[MAX_ATCMD_LEN];
                    169:     UCHAR           szTemp[30];
                    170:     char *          ptr;
                    171:     int             JobId;
                    172:     int             i;
                    173:     int             wmEvent;
                    174:     int             wmId;
                    175:     static BOOL     fChange;
1.1.1.2 ! root      176:     BOOL                        Translated;
        !           177:     UINT                        Value;
        !           178:     int                         Delta;
        !           179: 
1.1       root      180:     // owner draw stuff
                    181:     static LPDRAWITEMSTRUCT  lpdis;          // Long Pointer to owner-draw struct
                    182:     LPMEASUREITEMSTRUCT      lpmis;          // Long Pointer to o-d measure struct
                    183:     static HBITMAP           hButtonUpDef,   // for button's regular state bm
1.1.1.2 ! root      184:                             hButtonUpDep,   // for button's pushed  state bm
        !           185:                             hButtonDownDef, // for button's regular state bm
        !           186:                             hButtonDownDep; // for button's pushed  state bm
        !           187: 
1.1       root      188:     switch (message) {
1.1.1.2 ! root      189: 
1.1       root      190:                case WM_SPINBUTTON:
1.1.1.2 ! root      191: 
        !           192:            if ( (hCurrentFocus != hHour) && (hCurrentFocus != hMin) && (hCurrentFocus != hAmPm) ) {
        !           193: 
        !           194:                break;
        !           195: 
        !           196:            }
        !           197: 
        !           198:                if ( lParam == UP ) {
        !           199: 
        !           200:                        Delta = UP;
        !           201: 
        !           202:                } else {
        !           203: 
        !           204:                                Delta = DOWN;
        !           205: 
        !           206:                }
        !           207: 
        !           208:                if ( uParam == (UINT)GetDlgItem( hWnd, IDC_HOUR ) ) {
        !           209: 
1.1       root      210:                                Value = GetDlgItemInt( hWnd, IDC_HOUR, &Translated, FALSE );
1.1.1.2 ! root      211: 
1.1       root      212:                                if ( Translated == 0 ) {
1.1.1.2 ! root      213: 
1.1       root      214:                                        SetDlgItemInt( hWnd, IDC_HOUR, DEFAULT_HOUR, FALSE );
1.1.1.2 ! root      215: 
1.1       root      216:                                } else {
1.1.1.2 ! root      217: 
1.1       root      218:                                        if ( ( Value >= 12 || Value < 1 ) && Delta == UP ) {
1.1.1.2 ! root      219: 
1.1       root      220:                                                Value = 1;
1.1.1.2 ! root      221: 
1.1       root      222:                                        } else if ( ( Value > 12 || Value <= 1 ) && Delta == DOWN ) {
1.1.1.2 ! root      223: 
1.1       root      224:                                                Value = 12;
1.1.1.2 ! root      225: 
1.1       root      226:                                        } else {
1.1.1.2 ! root      227: 
1.1       root      228:                                                if ( (Value == 11 && Delta == UP) || (Value == 12 && Delta == DOWN) ) {
1.1.1.2 ! root      229: 
        !           230:                                                        GetDlgItemText( hWnd, IDC_AMPM, (LPTSTR)&szTemp, sizeof(szTemp) );
        !           231: 
        !           232:                                                if ( szTemp[0] == 'A' || szTemp[0] == 'a' ) {
        !           233: 
        !           234:                                                        SetDlgItemText( hWnd, IDC_AMPM,  (LPCTSTR)"PM" );
        !           235: 
        !           236:                                                } else {
        !           237: 
1.1       root      238:                                                                SetDlgItemText( hWnd, IDC_AMPM,  (LPCTSTR)"AM" );
1.1.1.2 ! root      239: 
1.1       root      240:                                                        }
                    241:                                                }
1.1.1.2 ! root      242: 
1.1       root      243:                                                Value += Delta;
1.1.1.2 ! root      244: 
1.1       root      245:                                        }
1.1.1.2 ! root      246: 
1.1       root      247:                                        SetDlgItemInt( hWnd, IDC_HOUR, Value, FALSE );
1.1.1.2 ! root      248: 
1.1       root      249:                                }
1.1.1.2 ! root      250: 
        !           251:                                SendDlgItemMessage( hWnd, IDC_HOUR, EM_SETSEL, 0, -1 );
1.1       root      252:                                //SetFocus( (HWND)uParam );
1.1.1.2 ! root      253: 
1.1       root      254:                        } else if ( uParam == (UINT)GetDlgItem( hWnd, IDC_MIN ) ) {
1.1.1.2 ! root      255: 
        !           256:                Value = GetDlgItemInt( hWnd, IDC_MIN, &Translated, FALSE );
        !           257: 
1.1       root      258:                                if ( Translated == 0 ) {
1.1.1.2 ! root      259: 
1.1       root      260:                                        SetDlgItemInt( hWnd, IDC_MIN, DEFAULT_MIN, FALSE );
1.1.1.2 ! root      261: 
1.1       root      262:                                } else {
1.1.1.2 ! root      263: 
1.1       root      264:                                        if ( ( Value >= 59 || Value < 0 ) && Delta == UP ) {
1.1.1.2 ! root      265: 
1.1       root      266:                                                Value = 0;
1.1.1.2 ! root      267: 
1.1       root      268:                                        } else if ( ( Value > 59 || Value <= 0 ) && Delta == DOWN ) {
1.1.1.2 ! root      269: 
1.1       root      270:                                                Value = 59;
1.1.1.2 ! root      271: 
1.1       root      272:                                        } else {
1.1.1.2 ! root      273: 
1.1       root      274:                                                Value += Delta;
1.1.1.2 ! root      275: 
1.1       root      276:                                        }
1.1.1.2 ! root      277: 
1.1       root      278:                                }
1.1.1.2 ! root      279: 
1.1       root      280:                                if ( Value > 9 ) {
1.1.1.2 ! root      281: 
1.1       root      282:                                        SetDlgItemInt( hWnd, IDC_MIN, Value, FALSE );
1.1.1.2 ! root      283: 
1.1       root      284:                                } else {
1.1.1.2 ! root      285: 
1.1       root      286:                                        szTemp[0] = '0';
                    287:                                        szTemp[1] = '0' + Value;
                    288:                                        szTemp[2] = '\0';
1.1.1.2 ! root      289: 
        !           290:                                SetDlgItemText( hWnd, IDC_MIN, szTemp );
        !           291:                            }
        !           292: 
        !           293:                                SendDlgItemMessage( hWnd, IDC_MIN, EM_SETSEL, 0, -1 );
1.1       root      294:                                //SetFocus( (HWND)uParam );
1.1.1.2 ! root      295: 
        !           296:                } else if ( uParam == (UINT)GetDlgItem( hWnd, IDC_AMPM ) ) {
        !           297: 
        !           298:                        GetDlgItemText( hWnd, IDC_AMPM, (LPTSTR)&szTemp, sizeof(szTemp) );
        !           299: 
        !           300:                        if ( szTemp[0] == 'A' || szTemp[0] == 'a' ) {
        !           301: 
        !           302:                                SetDlgItemText( hWnd, IDC_AMPM,  (LPCTSTR)"PM" );
        !           303: 
        !           304:                        } else {
        !           305: 
1.1       root      306:                                        SetDlgItemText( hWnd, IDC_AMPM,  (LPCTSTR)"AM" );
1.1.1.2 ! root      307: 
1.1       root      308:                                }
1.1.1.2 ! root      309: 
        !           310:                SendDlgItemMessage( hWnd, IDC_AMPM, EM_SETSEL, 0, -1 );
        !           311:                        //SetFocus( (HWND)uParam );
        !           312: 
        !           313:                        }
        !           314: 
        !           315:                break;
        !           316: 
        !           317:        case WM_MEASUREITEM:
        !           318: 
        !           319:            lpmis = (LPMEASUREITEMSTRUCT)lParam; // for convenience
        !           320:            lpmis->itemWidth  = 7;
        !           321:            lpmis->itemHeight = 7;
        !           322: 
        !           323:            break;
        !           324: 
        !           325:        case WM_DRAWITEM:
        !           326: 
        !           327:            lpdis = (LPDRAWITEMSTRUCT)lParam;    // for convenience
        !           328: 
        !           329:            switch (lpdis->itemAction) {
        !           330: 
        !           331:                case ODA_DRAWENTIRE:
        !           332:                    if ( lpdis->CtlID == IDD_DOWNBUT ) {
        !           333:                        DrawBitmap(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hButtonDownDef, SRCCOPY);
        !           334:                    } else {
        !           335:                        DrawBitmap(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hButtonUpDef, SRCCOPY);
        !           336:                    }
        !           337: 
        !           338:                    break;
        !           339: 
        !           340:                case ODA_SELECT:
        !           341:                    // handle select state -- text is right & down 2 pixels
        !           342:                    // also handle focus state since it's associated
        !           343:                    if (lpdis->itemState & ODS_SELECTED) {
        !           344:                        if ( lpdis->CtlID == IDD_DOWNBUT ) {
        !           345:                                DrawBitmap(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hButtonDownDep, SRCCOPY);
        !           346:                            } else {
        !           347:                                DrawBitmap(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hButtonUpDep, SRCCOPY);
        !           348:                            }
        !           349:                    }
        !           350:                    else {
        !           351:                        if ( lpdis->CtlID == IDD_DOWNBUT ) {
        !           352:                                DrawBitmap(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hButtonDownDef, SRCCOPY);
        !           353:                            } else {
        !           354:                                DrawBitmap(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hButtonUpDef, SRCCOPY);
        !           355:                            }
        !           356: 
        !           357:                                if ( hCurrentFocus != NULL ) {
        !           358: 
        !           359:                                        SetFocus( hCurrentFocus );
        !           360: 
        !           361:                                }
        !           362: 
        !           363:                    }
        !           364:                    break;
        !           365: 
        !           366:                case ODA_FOCUS:
        !           367:                    if (lpdis->itemState & ODS_FOCUS) {
        !           368: 
        !           369:                            break;
        !           370:                        }
        !           371: 
        !           372:                        break;
        !           373: 
        !           374:                default:
        !           375: 
        !           376:                    break;
        !           377: 
        !           378:            }  //itemAction
        !           379: 
        !           380:            break;
        !           381: 
        !           382:        case WM_INITDIALOG:
        !           383: 
        !           384:                        /* load bitmaps and get area of text rectangle for owner-draw button */
        !           385: 
        !           386:            hButtonUpDef = LoadBitmap(hInst,"BUTTONUPDEF"); // regular state
        !           387:            hButtonUpDep   = LoadBitmap(hInst,"BUTTONUPDEP");   // pushed  state
        !           388: 
        !           389: 
        !           390:            hButtonDownDef = LoadBitmap(hInst,"BUTTONDOWNDEF"); // regular state
        !           391:            hButtonDownDep = LoadBitmap(hInst,"BUTTONDOWNDEP");   // pushed  state
        !           392: 
        !           393:            hCurrentFocus = NULL;
        !           394:            hHour = GetDlgItem( hWnd, IDC_HOUR );
        !           395:            hMin  = GetDlgItem( hWnd, IDC_MIN );
        !           396:            hAmPm = GetDlgItem( hWnd, IDC_AMPM );
        !           397: 
        !           398:                        SendDlgItemMessage( hWnd, IDC_NEWCOMMAND, WM_SETFONT, (WPARAM)hFont, 1L );
1.1       root      399:                        SendDlgItemMessage( hWnd, IDC_DAYS, WM_SETFONT, (WPARAM)hFont, 1L );
                    400:                        SendDlgItemMessage( hWnd, IDC_HOUR, WM_SETFONT, (WPARAM)hFont, 1L );
                    401:                        SendDlgItemMessage( hWnd, IDC_MIN, WM_SETFONT,  (WPARAM)hFont, 1L );
                    402:                        SendDlgItemMessage( hWnd, IDC_AMPM, WM_SETFONT, (WPARAM)hFont, 1L );
1.1.1.2 ! root      403: 
        !           404:            // fill in Days
        !           405:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Monday");
        !           406:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Tuesday");
        !           407:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Wednesday");
        !           408:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Thursday");
        !           409:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Friday");
        !           410:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Saturday");
        !           411:            SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)"Sunday");
        !           412: 
        !           413:            for ( i=1; i<=9; ++i ) {
        !           414: 
        !           415:                UCHAR szDateAbbr[2];
        !           416: 
        !           417:                szDateAbbr[0] = i + '0';
        !           418:                szDateAbbr[1] = '\0';
        !           419: 
        !           420:                SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)szDateAbbr );
        !           421: 
        !           422:            }
        !           423: 
        !           424:                for ( i=10; i<=31; ++i ) {
        !           425: 
        !           426:                UCHAR szDateAbbr[3];
        !           427: 
        !           428:                szDateAbbr[0] = i/10 + '0';
        !           429:                szDateAbbr[1] = i%10 + '0';
        !           430:                szDateAbbr[2] = '\0';
        !           431: 
        !           432:                SendDlgItemMessage(hWnd, IDC_DAYS, LB_ADDSTRING, 0, (LPARAM)szDateAbbr );
        !           433: 
        !           434:            }
        !           435: 
        !           436:                if ( lParam == IDC_ADD ) {
        !           437: 
        !           438:                    SendDlgItemMessage(hWnd, IDC_DAYS, LB_SETCURSEL, 0, 0);
        !           439: 
        !           440:                    // fill in Time
        !           441: 
        !           442:                        SetDlgItemInt( hWnd, IDC_HOUR, DEFAULT_HOUR, FALSE );
        !           443: 
        !           444:                        if ( DEFAULT_MIN > 9 ) {
        !           445: 
1.1       root      446:                                        SetDlgItemInt( hWnd, IDC_MIN, DEFAULT_MIN, FALSE );
1.1.1.2 ! root      447: 
1.1       root      448:                                } else {
1.1.1.2 ! root      449: 
1.1       root      450:                                        szTemp[0] = '0';
                    451:                                        szTemp[1] = '0' + DEFAULT_MIN;
                    452:                                        szTemp[2] = '\0';
1.1.1.2 ! root      453: 
        !           454:                                SetDlgItemText( hWnd, IDC_MIN, szTemp );
        !           455:                            }
        !           456: 
        !           457:                        SetDlgItemText( hWnd, IDC_AMPM, (LPCTSTR)DEFAULT_AMPM );
        !           458: 
        !           459:                    // set the Every radio button
        !           460: 
        !           461:                    SendDlgItemMessage(hWnd, IDC_EVERY, BM_SETCHECK, TRUE, 0);
        !           462: 
        !           463:                    fChange = FALSE;
        !           464: 
        !           465:                        lstrcpy( szTemp, "Add Command" );
        !           466: 
        !           467:                SetWindowText( hWnd, szTemp );
        !           468: 
        !           469:                } else {
        !           470: 
        !           471:                    fChange = TRUE;
        !           472: 
1.1       root      473:                                lstrcpy( szTemp, "Change Command" );
1.1.1.2 ! root      474: 
1.1       root      475:                                SetWindowText( hWnd, szTemp );
1.1.1.2 ! root      476: 
1.1       root      477:                                // fill in current command info
                    478: 
1.1.1.2 ! root      479:                                SendDlgItemMessage(
        !           480:                        hGlobalhWnd,
        !           481:                        IDC_ATCOMMANDS,
        !           482:                        LB_GETTEXT,
        !           483:                        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_GETCURSEL, 0, 0 ),
        !           484:                        (LPARAM)szAtCommand
        !           485:                        );
        !           486: 
        !           487:                        // get job id
        !           488: 
        !           489:                    JobId = 0;
        !           490: 
        !           491:                    ptr   = szAtCommand;
        !           492: 
        !           493:                    while( *ptr >= '0' && *ptr <= '9' ) {
        !           494: 
        !           495:                        JobId *= 10;
        !           496:                        JobId += (UINT)*ptr - '0';
        !           497: 
        !           498:                        ptr++;
        !           499: 
        !           500:                    }
        !           501: 
        !           502:                    // get info on this job
        !           503: 
        !           504:                    status = NetScheduleJobGetInfo(
        !           505:                    GlobalComputerName,
        !           506:                        JobId,
        !           507:                        (LPBYTE *)&pAtInfo
        !           508:                        );
        !           509: 
        !           510:                    if ( status != NERR_Success ) {
        !           511: 
        !           512:                        //MessageBox( hWnd, "Problem getting Job Info.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !           513: 
        !           514:                        MessagePrint( status );
        !           515: 
        !           516:                        EndDialog( hWnd, 0 );
        !           517: 
        !           518:                    }
        !           519: 
        !           520:                    // fill in command
        !           521: 
        !           522:                    WideCharToMultiByte(
        !           523:                        (UINT)CP_ACP,
        !           524:                        (DWORD)0,
        !           525:                        (LPWSTR)pAtInfo->Command,
        !           526:                        MAX_ATCMD_LEN,
        !           527:                    (LPSTR)szCommandM,
        !           528:                    MAX_ATCMD_LEN,
        !           529:                    (LPSTR)NULL, (LPBOOL)NULL
        !           530:                    );
        !           531: 
        !           532:                SetDlgItemText( hWnd, IDC_NEWCOMMAND, szCommandM );
        !           533: 
        !           534:                // set days this command runs
        !           535: 
        !           536:                if ( pAtInfo->DaysOfWeek != 0) {
        !           537: 
        !           538:                        for ( i=0; i<7; ++i ) {
        !           539: 
        !           540:                                if ( ( pAtInfo->DaysOfWeek & (1 << i) ) != 0 ) {
        !           541: 
        !           542:                                        SendDlgItemMessage( hWnd, IDC_DAYS, LB_SETSEL, TRUE, i );
        !           543: 
        !           544:                                }
        !           545: 
        !           546:                        }
        !           547: 
        !           548:                }
        !           549: 
        !           550:                if ( pAtInfo->DaysOfMonth != 0) {
        !           551: 
        !           552:                        for ( i=0; i<31; ++i ) {
        !           553: 
        !           554:                                if ( ( pAtInfo->DaysOfMonth & (1L << i) ) != 0 ) {
        !           555: 
        !           556:                                        SendDlgItemMessage( hWnd, IDC_DAYS, LB_SETSEL, TRUE, i+7 );
        !           557: 
        !           558:                                }
        !           559: 
        !           560:                        }
        !           561: 
        !           562:                }
        !           563: 
        !           564:                // fill in every/today/tomorrow/next flag
        !           565: 
        !           566:                if ( pAtInfo->Flags & JOB_RUN_PERIODICALLY ) {
        !           567: 
        !           568:                        SendDlgItemMessage( hWnd, IDC_EVERY, BM_SETCHECK, TRUE, 0 );
        !           569: 
        !           570:                        SendMessage( hWnd, WM_COMMAND, IDC_EVERY, 0 );
        !           571: 
        !           572:                } else if ( (pAtInfo->DaysOfWeek != 0) || (pAtInfo->DaysOfMonth != 0) ) {
        !           573: 
        !           574:                        SendDlgItemMessage( hWnd, IDC_NEXT, BM_SETCHECK, TRUE, 0 );
        !           575: 
        !           576:                        SendMessage( hWnd, WM_COMMAND, IDC_NEXT, 0 );
        !           577: 
1.1       root      578:                                } else if ( pAtInfo->Flags & JOB_RUNS_TODAY ) {
1.1.1.2 ! root      579: 
        !           580:                        SendDlgItemMessage( hWnd, IDC_TODAY, BM_SETCHECK, TRUE, 0 );
        !           581: 
        !           582:                        SendMessage( hWnd, WM_COMMAND, IDC_TODAY, 0 );
        !           583: 
1.1       root      584:                                } else {
1.1.1.2 ! root      585: 
        !           586:                        SendDlgItemMessage( hWnd, IDC_TOMORROW, BM_SETCHECK, TRUE, 0 );
        !           587: 
        !           588:                        SendMessage( hWnd, WM_COMMAND, IDC_TOMORROW, 0 );
        !           589: 
        !           590:                                }
        !           591: 
        !           592:                    // set time for this command
        !           593: 
        !           594:                {
        !           595: 
        !           596:                    UINT  uJobTime = (UINT)(pAtInfo->JobTime / 1000 / 60 / 60);
        !           597:                        UINT  uAM = TRUE;
        !           598: 
        !           599:                        if ( uJobTime == 0 ) {
        !           600: 
        !           601:                                uJobTime = 12;
        !           602: 
        !           603:                        } else if ( uJobTime == 12 ) {
        !           604: 
        !           605:                            uAM = FALSE;
        !           606: 
        !           607:                        } else if ( uJobTime > 12 ) {
        !           608: 
        !           609:                            uJobTime -= 12;
        !           610: 
        !           611:                            uAM = FALSE;
        !           612: 
1.1       root      613:                                }
1.1.1.2 ! root      614: 
        !           615:                        SetDlgItemInt( hWnd, IDC_HOUR, uJobTime, FALSE );
        !           616: 
        !           617:                        uAM ? SetDlgItemText( hWnd, IDC_AMPM, "AM" ) : SetDlgItemText( hWnd, IDC_AMPM, "PM" );
        !           618: 
1.1       root      619:                                        if ( (UINT)(pAtInfo->JobTime / 1000 / 60 % 60) > 9 ) {
1.1.1.2 ! root      620: 
1.1       root      621:                                                SetDlgItemInt( hWnd, IDC_MIN, (UINT)(pAtInfo->JobTime / 1000 / 60 % 60), FALSE );
1.1.1.2 ! root      622: 
1.1       root      623:                                        } else {
1.1.1.2 ! root      624: 
1.1       root      625:                                                szTemp[0] = '0';
                    626:                                                szTemp[1] = '0' + (UINT)(pAtInfo->JobTime / 1000 / 60 % 60);
                    627:                                                szTemp[2] = '\0';
1.1.1.2 ! root      628: 
        !           629:                                        SetDlgItemText( hWnd, IDC_MIN, szTemp );
        !           630:                                    }
        !           631: 
1.1       root      632:                            }
1.1.1.2 ! root      633: 
        !           634:                // free buffer
        !           635: 
1.1       root      636:                                NetApiBufferFree( (LPVOID)pAtInfo );
1.1.1.2 ! root      637: 
        !           638:                }
        !           639: 
        !           640:            // set up subclass functions
        !           641: 
1.1       root      642:                        lpAmPmProc = MakeProcInstance( (FARPROC)AmPmProc, hInst );
                    643:                        lpAmPmDefProc = (FARPROC) SetWindowLong( GetDlgItem( hWnd, IDC_AMPM ), GWL_WNDPROC, (LONG)lpAmPmProc );
                    644:                        lpDownButtonProc = MakeProcInstance( (FARPROC)DownButtonProc, hInst );
                    645:                        lpDownButtonDefProc = (FARPROC) SetWindowLong( GetDlgItem( hWnd, IDD_DOWNBUT ), GWL_WNDPROC, (LONG)lpDownButtonProc );
                    646:                        lpUpButtonProc = MakeProcInstance( (FARPROC)UpButtonProc, hInst );
                    647:                        lpUpButtonDefProc = (FARPROC) SetWindowLong( GetDlgItem( hWnd, IDD_UPBUT ), GWL_WNDPROC, (LONG)lpUpButtonProc );
                    648:                        lpHourProc = MakeProcInstance( (FARPROC)HourProc, hInst );
                    649:                        lpHourDefProc = (FARPROC) SetWindowLong( GetDlgItem( hWnd, IDC_HOUR ), GWL_WNDPROC, (LONG)lpHourProc );
                    650:                        lpMinProc = MakeProcInstance( (FARPROC)MinProc, hInst );
                    651:                        lpMinDefProc = (FARPROC) SetWindowLong( GetDlgItem( hWnd, IDC_MIN ), GWL_WNDPROC, (LONG)lpMinProc );
1.1.1.2 ! root      652: 
1.1       root      653:                        // will default to two chars
1.1.1.2 ! root      654: 
1.1       root      655:                        uHourChars = 2;
1.1.1.2 ! root      656:                        uMinChars = 2;
        !           657: 
        !           658: 
1.1       root      659:                        hGlobalAddChg = hWnd;
1.1.1.2 ! root      660: 
        !           661:                break;
        !           662: 
        !           663:        case WM_COMMAND:    // message: command from application menu
1.1       root      664: 
                    665:                        wmId    = LOWORD(uParam);
                    666:                        wmEvent = HIWORD(uParam);
                    667: 
                    668:                        switch (wmId) {
                    669: 
1.1.1.2 ! root      670:                case IDC_TODAY:
        !           671:                case IDC_TOMORROW:
        !           672: 
        !           673:                    GetLocalTime( &SystemTime );
        !           674: 
        !           675:                    if ( SystemTime.wDayOfWeek == 0 ) {
        !           676: 
        !           677:                        SystemTime.wDayOfWeek = 7;
        !           678: 
        !           679:                    }
        !           680: 
        !           681:                        for( i=0; i<NUMDAYITEMS; ++i ) {
        !           682: 
        !           683:                                SendDlgItemMessage( hWnd, IDC_DAYS, LB_SETSEL, FALSE, i );
        !           684: 
        !           685:                        }
1.1       root      686: 
1.1.1.2 ! root      687:                        SendDlgItemMessage(
        !           688:                                hWnd,
        !           689:                                IDC_DAYS,
        !           690:                                LB_SETSEL,
        !           691:                                TRUE,
        !           692:                                wmId == IDC_TOMORROW ? SystemTime.wDayOfWeek : SystemTime.wDayOfWeek - 1 );
1.1       root      693: 
1.1.1.2 ! root      694:                    EnableWindow(GetDlgItem(hWnd, IDC_DAYS), FALSE);
1.1       root      695: 
1.1.1.2 ! root      696:                    break;
        !           697: 
        !           698:                case IDC_EVERY:
        !           699: 
        !           700:                    EnableWindow(GetDlgItem(hWnd, IDC_DAYS), TRUE);
        !           701: 
        !           702:                    break;
        !           703: 
        !           704:                case IDC_NEXT:
        !           705: 
        !           706:                    EnableWindow(GetDlgItem(hWnd, IDC_DAYS), TRUE);
        !           707: 
        !           708:                    break;
1.1       root      709: 
                    710:                                case IDCANCEL:
1.1.1.2 ! root      711: 
        !           712:                                    hCurrentFocus = NULL;
1.1       root      713:                                    DeleteObject( hButtonUpDef );
                    714:                                    DeleteObject( hButtonUpDep );
                    715:                                    DeleteObject( hButtonDownDep );
                    716:                                    DeleteObject( hButtonDownDef );
                    717: 
                    718:                                        EndDialog( hWnd, IDCANCEL );
1.1.1.2 ! root      719: 
1.1       root      720:                                        break;
1.1.1.2 ! root      721: 
        !           722:                case IDOK:
        !           723: 
        !           724:                    if ( ValidateAddChangeArguments( hWnd ) == TRUE ) {
        !           725: 
        !           726:                        if( fChange == TRUE) {
        !           727: 
        !           728:                                status = JobDel( DEL_ID_CHANGE, hGlobalhWnd);
        !           729: 
        !           730:                        }
        !           731: 
        !           732:                        status = JobAdd();
        !           733: 
        !           734:                            if ( status == NERR_Success ) {
        !           735: 
        !           736:                                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_BOTTOM );
        !           737: 
1.1       root      738:                                                        hCurrentFocus = NULL;
                    739:                                                        DeleteObject( hButtonUpDef );
                    740:                                                    DeleteObject( hButtonUpDep );
                    741:                                                    DeleteObject( hButtonDownDep );
1.1.1.2 ! root      742:                                                    DeleteObject( hButtonDownDef );
        !           743: 
        !           744:                                                    EndDialog( hWnd, IDOK );
        !           745: 
        !           746:                            } else {
        !           747: 
        !           748:                                //MessageBox( hWnd, "Problem adding command.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !           749: 
        !           750:                                MessagePrint( status );
1.1       root      751: 
1.1.1.2 ! root      752:                            }
        !           753: 
        !           754:                    }
        !           755: 
        !           756:                    break;
        !           757: 
        !           758:                case IDC_ADDCHANGEHELP:
        !           759: 
        !           760:                    if (!WinHelp (hWnd, "WINAT.HLP", HELP_KEY,(DWORD)(LPSTR)"CONTENTS")) {
1.1       root      761:                                                MessageBox (GetFocus(),
                    762:                                                        "Unable to activate help",
                    763:                                                        SZWINDOWTITLE, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);
1.1.1.2 ! root      764:                    }
1.1       root      765: 
1.1.1.2 ! root      766:                    break;
1.1       root      767: 
1.1.1.2 ! root      768:            }
1.1       root      769: 
1.1.1.2 ! root      770:            break;
1.1       root      771: 
                    772:     }
                    773: 
                    774:     return (0);
                    775: 
                    776: }
                    777: 
                    778: 
                    779: 
                    780: //===========================================================================
                    781: // FUNCTION: AmPmProc()
                    782: //===========================================================================
                    783: LRESULT APIENTRY AmPmProc( HWND hWnd, UINT message, UINT uParam, LONG lParam )
                    784: {
1.1.1.2 ! root      785: // jean-marc - start
        !           786:     // NOTE: the dialog resource for this field includes the ES_READONLY flag
        !           787:     // to prevent the delete key from working, otherwise the delete key was
        !           788:     // going through by somehow by-passing the WM_CHAR case.
        !           789: 
        !           790:     switch (message)
        !           791:     {
        !           792:       case WM_SETFOCUS:
        !           793:        hCurrentFocus = hWnd;
        !           794:        break;
        !           795: 
        !           796:       case WM_CHAR:
        !           797:       {
        !           798:        switch(uParam)
        !           799:        {
        !           800:          case 'A':
        !           801:          case 'a':
        !           802:            SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)"AM");
        !           803:            return 0;
        !           804: 
        !           805:          case 'P':
        !           806:          case 'p':
        !           807:            SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)"PM");
        !           808:            return 0;
        !           809: 
        !           810:          default:
        !           811:            MessageBeep(MB_OK);
        !           812:            return 0;
        !           813:        }
        !           814:       }
        !           815:       return 0;
        !           816:     }
1.1       root      817: 
1.1.1.2 ! root      818:     return CallWindowProc( (WNDPROC)lpAmPmDefProc, hWnd, message, uParam, lParam ) ;
        !           819: // jean-marc - end
1.1       root      820: }
                    821: 
                    822: 
                    823: 
                    824: //===========================================================================
                    825: // FUNCTION: AreYouSure()
                    826: //
                    827: // Arguments:
                    828: //
                    829: //   Uses globals.
                    830: //
                    831: // Return Value:
                    832: //
                    833: //   ID_YES if the yes button pressed
                    834: //   ID_NO  if the  no button pressed
                    835: //
                    836: //===========================================================================
                    837: UINT
                    838: AreYouSure(
                    839:     HWND hWnd
                    840:     )
                    841: {
                    842: 
                    843:     return ( MessageBox(
1.1.1.2 ! root      844:                 hWnd,
        !           845:                 "Remove the selected command?",
        !           846:                 "Confirm Remove",
        !           847:                 MB_YESNO | MB_ICONEXCLAMATION
        !           848:                 )
        !           849:           );
1.1       root      850: 
                    851: }
                    852: 
1.1.1.2 ! root      853: 
        !           854: //===========================================================================
        !           855: // FUNCTION: UpButtonProc()
        !           856: //===========================================================================
        !           857: LRESULT APIENTRY UpButtonProc( HWND hWnd, UINT message, UINT uParam, LONG lParam )
        !           858: {
        !           859: // jean-marc - start
        !           860: #define TIME_DELAY 150
        !           861: #define TIME_DELAY 150
        !           862: 
        !           863:   DWORD dwEventTime;
        !           864: 
        !           865:   switch (message)
        !           866:   {
        !           867:     case WM_LBUTTONDOWN:
        !           868:       if (hCurrentFocus == hHour || hCurrentFocus == hMin || hCurrentFocus == hAmPm)
        !           869:       {
        !           870:        dwEventTime = GetTickCount() - TIME_DELAY;
        !           871:        do
        !           872:        {
        !           873:          if (dwEventTime + TIME_DELAY > GetTickCount())
        !           874:            continue;
        !           875:          SendMessage(hGlobalAddChg, WM_SPINBUTTON, (UINT)hCurrentFocus, (LONG)UP);
        !           876:          InvalidateRect(hCurrentFocus, NULL, TRUE);
        !           877:          UpdateWindow(hCurrentFocus);
        !           878:          dwEventTime = GetTickCount();
        !           879:        }
        !           880:        while (GetAsyncKeyState(VK_LBUTTON) & 0x8000);
        !           881:       }
        !           882:       break;
        !           883:   }
        !           884: 
        !           885:   return CallWindowProc((WNDPROC)lpUpButtonDefProc, hWnd, message, uParam, lParam);
        !           886: // jean-marc - end
        !           887: }
1.1       root      888: 
                    889: 
                    890: //===========================================================================
                    891: // FUNCTION: DownButtonProc()
                    892: //===========================================================================
                    893: LRESULT APIENTRY DownButtonProc( HWND hWnd, UINT message, UINT uParam, LONG lParam )
                    894: {
1.1.1.2 ! root      895: // jean-marc - start
        !           896: #define TIME_DELAY 150
1.1       root      897: 
1.1.1.2 ! root      898:   DWORD dwEventTime;
        !           899: 
        !           900:   switch (message)
        !           901:   {
        !           902:     case WM_LBUTTONDOWN:
        !           903:       if (hCurrentFocus == hHour || hCurrentFocus == hMin || hCurrentFocus == hAmPm)
        !           904:       {
        !           905:        dwEventTime = GetTickCount() - TIME_DELAY;
        !           906:        do
        !           907:        {
        !           908:          if (dwEventTime + TIME_DELAY > GetTickCount())
        !           909:            continue;
        !           910:          SendMessage(hGlobalAddChg, WM_SPINBUTTON, (UINT)hCurrentFocus, (LONG)DOWN);
        !           911:          InvalidateRect(hCurrentFocus, NULL, TRUE);
        !           912:          UpdateWindow(hCurrentFocus);
        !           913:          dwEventTime = GetTickCount();
        !           914:        }
        !           915:        while (GetAsyncKeyState(VK_LBUTTON) & 0x8000);
        !           916:       }
        !           917:       break;
        !           918:   }
        !           919: 
        !           920:   return CallWindowProc((WNDPROC)lpDownButtonDefProc, hWnd, message, uParam, lParam);
        !           921: // jean-marc - end
1.1       root      922: }
                    923: 
                    924: 
                    925: 
                    926: /****************************************************************************
                    927: 
                    928:     FUNCTION: DrawBitmap
                    929: 
                    930:     PURPOSE:  Draw default or pushed button bitmap
                    931: 
                    932: ****************************************************************************/
                    933: 
                    934: void DrawBitmap(
                    935:        HDC     hDC,
1.1.1.2 ! root      936:        LONG    xStart,
1.1       root      937:        LONG    yStart,
                    938:        HBITMAP hBitmap,
                    939:        DWORD   rop)
                    940: {
                    941:   BITMAP        bm;
                    942:   HDC           hMemDC;
1.1.1.2 ! root      943:   POINT                 pt;
1.1       root      944: 
                    945:   hMemDC = CreateCompatibleDC (hDC);
                    946:   SelectObject (hMemDC, hBitmap);
                    947:   GetObject (hBitmap, sizeof (BITMAP), (LPSTR) &bm);
                    948:   pt.x = bm.bmWidth;
                    949:   pt.y = bm.bmHeight;
                    950:   BitBlt (hDC, xStart, yStart, pt.x, pt.y, hMemDC, 0, 0, rop);
                    951:   DeleteDC (hMemDC);
                    952: }
                    953: 
                    954: 
                    955: 
                    956: //===========================================================================
                    957: // FUNCTION: HourProc()
                    958: //===========================================================================
                    959: LRESULT APIENTRY HourProc( HWND hWnd, UINT message, UINT uParam, LONG lParam )
                    960: {
1.1.1.2 ! root      961:     UINT  uCurVal;
1.1       root      962:     UCHAR szCurVal[3];
1.1.1.2 ! root      963: 
1.1       root      964:     switch ( message ) {
1.1.1.2 ! root      965: 
1.1       root      966:            case WM_COPY:
                    967:            case WM_PASTE:
                    968:            case WM_CUT:
1.1.1.2 ! root      969: 
1.1       root      970:                        // cut and paste dont seem to work...
1.1.1.2 ! root      971: 
        !           972:                break;
        !           973: 
        !           974: // jean-marc - start
        !           975:       case WM_SETFOCUS:
        !           976:        hCurrentFocus = hWnd;
        !           977:        break;
        !           978: // jean-marc - end
        !           979: 
        !           980:        case WM_CHAR:
        !           981: 
1.1       root      982:                        if ( uParam == VK_BACK ) {
1.1.1.2 ! root      983: 
1.1       root      984:                                if ( uHourChars > 0 ) {
1.1.1.2 ! root      985: 
1.1       root      986:                                        --uHourChars;
1.1.1.2 ! root      987: 
1.1       root      988:                                }
1.1.1.2 ! root      989: 
1.1       root      990:                                return CallWindowProc( (WNDPROC)lpHourDefProc, hWnd, message, uParam, lParam ) ;
1.1.1.2 ! root      991: 
1.1       root      992:                        } else {
1.1.1.2 ! root      993: 
1.1       root      994:                                uHourChars = (UINT) SendMessage( hWnd, WM_GETTEXT, 2, (LPARAM)szCurVal );
1.1.1.2 ! root      995: 
1.1       root      996:                                if ( uHourChars == 0 ) {
1.1.1.2 ! root      997: 
        !           998:                                uCurVal = 0;
        !           999: 
1.1       root     1000:                            } else if ( uHourChars == 1 ) {
1.1.1.2 ! root     1001: 
        !          1002:                                uCurVal = szCurVal[0] - '0';
        !          1003: 
1.1       root     1004:                            } else if ( uHourChars == 2 ) {
1.1.1.2 ! root     1005: 
        !          1006:                                uCurVal  = szCurVal[0] - '0';
        !          1007:                                uCurVal *= 10;
        !          1008:                                uCurVal  = szCurVal[1] - '0';
        !          1009: 
1.1       root     1010:                            } else if ( uHourChars > 2 ) {
1.1.1.2 ! root     1011: 
        !          1012:                                uHourChars = 0;
        !          1013: 
        !          1014:                                SendMessage( hWnd, WM_SETTEXT, 0, (LPARAM)"" );
        !          1015: 
        !          1016:                                return( 0 );
        !          1017: 
1.1       root     1018:                            }
1.1.1.2 ! root     1019: 
1.1       root     1020:                        }
1.1.1.2 ! root     1021: 
1.1       root     1022:                        if ( ( uParam == ' ' )                                     ||  // space
                   1023:                             ( uParam < '0' || uParam > '9')                       ||  // not a number
                   1024:                             ( uParam == '0' && uCurVal == 0 )                     ||  // trying to enter 0 as first char
                   1025:                             ( (uParam > '2' && uCurVal >= 1) && uHourChars >= 1)  ||  // greater than 12
                   1026:                             ( uParam <= '2' && uCurVal > 1)                           // greater than 12
                   1027:                           ) {
1.1.1.2 ! root     1028: 
1.1       root     1029:                                 MessageBeep( MB_OK );
1.1.1.2 ! root     1030: 
1.1       root     1031:                                 return( 0 );
1.1.1.2 ! root     1032: 
1.1       root     1033:                        } else if ( uHourChars < 2 ) {
1.1.1.2 ! root     1034: 
1.1       root     1035:                                ++uHourChars;
1.1.1.2 ! root     1036: 
1.1       root     1037:                        } else {
1.1.1.2 ! root     1038: 
        !          1039:                    MessageBeep( MB_OK );
        !          1040: 
        !          1041:                            return( 0 );
        !          1042: 
        !          1043:                        }
        !          1044: 
        !          1045:                break;
        !          1046: 
1.1       root     1047:        } // switch
1.1.1.2 ! root     1048: 
1.1       root     1049:        return CallWindowProc( (WNDPROC)lpHourDefProc, hWnd, message, uParam, lParam ) ;
1.1.1.2 ! root     1050: 
1.1       root     1051: }
                   1052: 
                   1053: 
                   1054: 
                   1055: //===========================================================================
                   1056: // FUNCTION: JobAdd()
                   1057: //
                   1058: // Routine Description:
                   1059: //
                   1060: //     Adds a new item to schedule.
                   1061: //
                   1062: // Arguments:
                   1063: //
                   1064: //     None.  Uses globals.
                   1065: //
                   1066: // Return Value:
                   1067: //
                   1068: //     NET_API_STATUS return value of remote api call
                   1069: //
                   1070: //===========================================================================
                   1071: NET_API_STATUS
                   1072: JobAdd(
                   1073:     VOID
                   1074:     )
                   1075: {
                   1076: 
                   1077:     NET_API_STATUS          status;
                   1078: 
                   1079:     status = NetScheduleJobAdd(
1.1.1.2 ! root     1080:                GlobalComputerName,
        !          1081:                (LPBYTE)&GlobalAtInfo,
        !          1082:                &GlobalJobId
        !          1083:                );
1.1       root     1084: 
                   1085:     if ( status != NERR_Success ) {
                   1086: 
1.1.1.2 ! root     1087:        /*MessageBox(
        !          1088:            hGlobalhWnd,
        !          1089:            ( status == NERR_ServiceNotInstalled ? "The service has not been started" : "Message could not be added." ),
        !          1090:            SZWINDOWTITLE,
        !          1091:            MB_OK | MB_ICONEXCLAMATION
        !          1092:            );
        !          1093:        */
        !          1094: 
        !          1095:        MessagePrint( status );
        !          1096:     }
        !          1097: 
1.1       root     1098:     return ( status );
                   1099: 
                   1100: }
                   1101: 
                   1102: 
                   1103: 
                   1104: //===========================================================================
                   1105: //
                   1106: // FUNCTION: JobDel()
                   1107: //
                   1108: //
                   1109: // Routine Description:
                   1110: //
                   1111: //     This does all of the processing necessary to dump out the entire
                   1112: //     schedule file.  It loops through on each record and formats its
                   1113: //     information for printing and then goes to the next.
                   1114: //
                   1115: // Arguments:
                   1116: //
                   1117: //     DEL_ALL if to delete all jobs, DEL_ID otherwise.
                   1118: //     Uses globals.
                   1119: //
                   1120: // Return Value:
                   1121: //
                   1122: //     ERROR_SUCCESS                       if everything enumerated OK
                   1123: //     error returned by remote api        otherwise
                   1124: //
                   1125: //===========================================================================
                   1126: NET_API_STATUS
                   1127: JobDel(
                   1128:     UINT Method,
                   1129:     HWND hWnd
                   1130:     )
                   1131: {
                   1132: 
1.1.1.2 ! root     1133:     DWORD                       dwSelection;
1.1       root     1134:     NET_API_STATUS  status;
                   1135:     UCHAR           szAtCommand[MAX_ATCMD_LEN];
                   1136:     UINT            JobId;
1.1.1.2 ! root     1137:     UINT                        uSelection;
        !          1138:     UINT                        uCount;
1.1       root     1139:     char *          ptr;
                   1140: 
                   1141: 
                   1142:     if ( Method != DEL_ID_CHANGE ) {
                   1143: 
1.1.1.2 ! root     1144:        if ( AreYouSure(hWnd) == IDNO ) {
        !          1145: 
        !          1146:                return( ERROR_SUCCESS );
        !          1147: 
        !          1148:        }
1.1       root     1149: 
                   1150:     }
                   1151: 
                   1152:     switch( Method ) {
                   1153: 
1.1.1.2 ! root     1154:        case DEL_ALL:
        !          1155: 
        !          1156:            status = NetScheduleJobDel(
        !          1157:                    GlobalComputerName,
        !          1158:                    0,
        !          1159:                    (DWORD)-1
        !          1160:                    );
        !          1161: 
        !          1162:            if ( status == NERR_Success ) {
        !          1163: 
        !          1164:                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_NONE );
        !          1165:                break;
        !          1166: 
        !          1167:            }
        !          1168: 
        !          1169:            break;
1.1       root     1170: 
1.1.1.2 ! root     1171:        case DEL_ID:
        !          1172:        case DEL_ID_CHANGE:
1.1       root     1173: 
1.1.1.2 ! root     1174:            // compute id
1.1       root     1175: 
1.1.1.2 ! root     1176:            uSelection = SendDlgItemMessage( hWnd, IDC_ATCOMMANDS, LB_GETCURSEL, 0, 0 );
        !          1177:            uCount     = SendDlgItemMessage( hWnd, IDC_ATCOMMANDS, LB_GETCOUNT,  0, 0 );
1.1       root     1178: 
1.1.1.2 ! root     1179:            SendDlgItemMessage(
        !          1180:                hWnd,
        !          1181:                IDC_ATCOMMANDS,
        !          1182:                LB_GETTEXT,
        !          1183:                uSelection,
        !          1184:                (LPARAM)szAtCommand
        !          1185:                );
1.1       root     1186: 
1.1.1.2 ! root     1187:            JobId = 0;
        !          1188:            ptr   = szAtCommand;
1.1       root     1189: 
1.1.1.2 ! root     1190:            while( *ptr >= '0' && *ptr <= '9' ) {
1.1       root     1191: 
1.1.1.2 ! root     1192:                JobId *= 10;
        !          1193:                JobId += (UINT)*ptr - '0';
1.1       root     1194: 
1.1.1.2 ! root     1195:                ptr++;
1.1       root     1196: 
1.1.1.2 ! root     1197:            }
1.1       root     1198: 
1.1.1.2 ! root     1199:            status = NetScheduleJobDel(
        !          1200:                    GlobalComputerName,
        !          1201:                    JobId,
        !          1202:                    JobId
        !          1203:                    );
1.1       root     1204: 
1.1.1.2 ! root     1205:            if ( status != NERR_Success) {
1.1       root     1206: 
1.1.1.2 ! root     1207:                //MessageBox( hWnd, "Problem deleteing a job.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
1.1       root     1208: 
1.1.1.2 ! root     1209:                MessagePrint( status );
1.1       root     1210: 
1.1.1.2 ! root     1211:                break;
1.1       root     1212: 
1.1.1.2 ! root     1213:            }
1.1       root     1214: 
1.1.1.2 ! root     1215:            if ( uCount == 1 ) {
1.1       root     1216: 
                   1217:                                // this was the only job
                   1218: 
1.1.1.2 ! root     1219:                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_NONE );
        !          1220: 
        !          1221:            } else if ( uSelection == 0 ) {
        !          1222: 
        !          1223:                // the first/top job was selected and there is more than 1 job
        !          1224: 
        !          1225:                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_TOP );
        !          1226: 
        !          1227:            } else if ( ( uCount - 1 ) == uSelection ) {
        !          1228: 
        !          1229:                // the last/bottom job was selected
        !          1230: 
        !          1231:                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_BOTTOM );
        !          1232: 
        !          1233:            } else {
        !          1234: 
        !          1235:                // the 2nd thru last-1 job was selected
        !          1236: 
        !          1237:                dwSelection  = 0;
        !          1238:                dwSelection |= uSelection << 16;
        !          1239:                dwSelection |= SCS_SELINHIGHWORD;
        !          1240: 
        !          1241:                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)dwSelection );
        !          1242: 
        !          1243:            }
        !          1244: 
        !          1245:            break;
1.1       root     1246: 
                   1247:     }
                   1248: 
                   1249:     return( status );
                   1250: 
                   1251: }
                   1252: 
                   1253: 
                   1254: 
                   1255: //===========================================================================
                   1256: //
                   1257: // FUNCTION: JobEnum()
                   1258: //
                   1259: //
                   1260: // Routine Description:
                   1261: //
                   1262: //     This does all of the processing necessary to dump out the entire
                   1263: //     schedule file.  It loops through on each record and formats its
                   1264: //     information for printing and then goes to the next.
                   1265: //
                   1266: // Arguments:
                   1267: //
                   1268: //     None.  Uses globals.
                   1269: //
                   1270: // Return Value:
                   1271: //
                   1272: //     ERROR_SUCCESS                       if everything enumerated OK
                   1273: //     error returned by remote api        otherwise
                   1274: //
                   1275: //===========================================================================
                   1276: NET_API_STATUS
                   1277: JobEnum(
                   1278:     DWORD SetCurrentSelection
                   1279:     )
                   1280: {
                   1281: 
                   1282:     BOOL            fFlag;
                   1283:     BOOL            first = TRUE;
                   1284:     DWORD           EntriesRead;
                   1285:     DWORD           ResumeJobId = 0;
                   1286:     DWORD           TotalEntries;
                   1287:     LPVOID          EnumBuffer = NULL;
                   1288:     NET_API_STATUS  status = NERR_Success;
                   1289:     PAT_ENUM        pAtEnum;
                   1290:     //UCHAR           szTemp[80];
1.1.1.2 ! root     1291:     static UINT         uSelection;
        !          1292:     static UINT         uTopIndex;
1.1       root     1293:     int             i;
1.1.1.2 ! root     1294: 
1.1       root     1295:     // initialize to current selection
1.1.1.2 ! root     1296: 
1.1       root     1297:        uSelection = SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_GETCURSEL,   0, 0 );
                   1298:        uTopIndex  = SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_GETTOPINDEX, 0, 0 );
1.1.1.2 ! root     1299: 
1.1       root     1300:        if ( uSelection == LB_ERR ) {
1.1.1.2 ! root     1301: 
1.1       root     1302:                uSelection = 0;
1.1.1.2 ! root     1303: 
1.1       root     1304:        }
                   1305: 
                   1306:     for ( ; ;) {
                   1307: 
1.1.1.2 ! root     1308:        status = NetScheduleJobEnum(
        !          1309:                GlobalComputerName,
        !          1310:                (LPBYTE *)&EnumBuffer,
        !          1311:                (DWORD)-1,
        !          1312:                &EntriesRead,
        !          1313:                &TotalEntries,
        !          1314:                &ResumeJobId
        !          1315:                );
        !          1316: 
        !          1317:        if ( status != ERROR_SUCCESS  &&  status != ERROR_MORE_DATA) {
        !          1318: 
        !          1319:            //
        !          1320:            // not needded since both the if/else(MessagePrint) will set this text now
        !          1321:            //
        !          1322:            //SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_RESETCONTENT, 0, 0 );
        !          1323:            //
        !          1324:            //SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_ADDSTRING, 0, (LPARAM)szError );
        !          1325: 
        !          1326:            EnableWindow( GetDlgItem( hGlobalhWnd, IDC_ADD    ), FALSE );
        !          1327:            EnableWindow( GetDlgItem( hGlobalhWnd, IDC_CHANGE ), FALSE );
        !          1328:                EnableWindow( GetDlgItem( hGlobalhWnd, IDC_REMOVE ), FALSE );
        !          1329: 
        !          1330:                if ( status == NERR_ServiceNotInstalled ) {
        !          1331: 
        !          1332:                SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_RESETCONTENT, 0, 0 );
        !          1333: 
        !          1334:                SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_ADDSTRING, 0, (LPARAM)"Schedule service not started." );
        !          1335: 
        !          1336:                        if ( ServiceNotStartedHandler() == FALSE ) {
        !          1337: 
        !          1338:                                return( status );
        !          1339: 
        !          1340:                        } else {
        !          1341: 
        !          1342:                            continue;
        !          1343: 
        !          1344:                        }
        !          1345: 
        !          1346:                } else  {
        !          1347: 
        !          1348:                /*wsprintf( szTemp, "The computer %s cannot be found.\nError %u.", &szComputerM[2], status );
        !          1349: 
        !          1350:                    MessageBox(
        !          1351:                         hGlobalhWnd,
1.1       root     1352:                                        szTemp,
1.1.1.2 ! root     1353:                        SZWINDOWTITLE,
        !          1354:                        MB_OK | MB_ICONEXCLAMATION
        !          1355:                        );
        !          1356:                    */
        !          1357: 
1.1       root     1358:                                MessagePrint( status );
                   1359: 
1.1.1.2 ! root     1360:                    return( status );
        !          1361: 
        !          1362:                }
        !          1363: 
        !          1364:        }
        !          1365: 
        !          1366:        assert( status == ERROR_SUCCESS ? TotalEntries == EntriesRead : TotalEntries > EntriesRead );
        !          1367: 
        !          1368:        if ( TotalEntries == 0) {
        !          1369: 
        !          1370:            break;  //  no items found
1.1       root     1371: 
1.1.1.2 ! root     1372:        }
1.1       root     1373: 
1.1.1.2 ! root     1374:        if ( first == TRUE) {
1.1       root     1375: 
1.1.1.2 ! root     1376:            ResetListboxExtents( GetDlgItem( hGlobalhWnd, IDC_ATCOMMANDS ) );
        !          1377:            SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_RESETCONTENT, 0, 0 );
1.1       root     1378: 
1.1.1.2 ! root     1379:            first = FALSE;
1.1       root     1380: 
1.1.1.2 ! root     1381:        }
1.1       root     1382: 
1.1.1.2 ! root     1383:        for ( pAtEnum = EnumBuffer;  EntriesRead-- > 0;  pAtEnum++) {
1.1       root     1384: 
1.1.1.2 ! root     1385:            // not sure what this is doing...
1.1       root     1386: 
1.1.1.2 ! root     1387:            /*
        !          1388:            if ( pAtEnum->Flags & JOB_EXEC_ERROR) {
1.1       root     1389: 
1.1.1.2 ! root     1390:                if ( MessageGet( APE2_GEN_ERROR, &smallBuffer, 0 ) == 0) {
1.1       root     1391: 
1.1.1.2 ! root     1392:                    // error reported already
        !          1393:                    exit( -1);
1.1       root     1394: 
1.1.1.2 ! root     1395:                }
1.1       root     1396: 
1.1.1.2 ! root     1397:                printf( DUMP_FMT1, smallBuffer );
        !          1398:                LocalFree( smallBuffer );
1.1       root     1399: 
1.1.1.2 ! root     1400:            } else {
1.1       root     1401: 
1.1.1.2 ! root     1402:                printf( DUMP_FMT1, L"");
1.1       root     1403: 
1.1.1.2 ! root     1404:            }
        !          1405:            */
1.1       root     1406: 
1.1.1.2 ! root     1407:            // replate with...
1.1       root     1408: 
1.1.1.2 ! root     1409:            if ( pAtEnum->Flags & JOB_EXEC_ERROR) {
1.1       root     1410: 
1.1.1.2 ! root     1411:                MessagePrint( APE2_GEN_ERROR );
1.1       root     1412: 
1.1.1.2 ! root     1413:            }
1.1       root     1414: 
1.1.1.2 ! root     1415:            szWhenDay[0] = '\0';
1.1       root     1416: 
1.1.1.2 ! root     1417:            if ( pAtEnum->Flags & JOB_RUN_PERIODICALLY ) {
1.1       root     1418: 
1.1.1.2 ! root     1419:                lstrcat( szWhenDay, "Each " );
1.1       root     1420: 
1.1.1.2 ! root     1421:            } else if ( pAtEnum->DaysOfWeek != 0 || pAtEnum->DaysOfMonth != 0 ) {
1.1       root     1422: 
1.1.1.2 ! root     1423:                lstrcat( szWhenDay, "Next " );
1.1       root     1424: 
1.1.1.2 ! root     1425:            } else if ( pAtEnum->Flags & JOB_RUNS_TODAY ) {
1.1       root     1426: 
1.1.1.2 ! root     1427:                lstrcat( szWhenDay, "Today " );
1.1       root     1428: 
1.1.1.2 ! root     1429:            } else {
1.1       root     1430: 
1.1.1.2 ! root     1431:                lstrcat( szWhenDay, "Tomorrow " );
1.1       root     1432: 
1.1.1.2 ! root     1433:            }
1.1       root     1434: 
1.1.1.2 ! root     1435:            if ( pAtEnum->DaysOfWeek != 0 ) {
1.1       root     1436: 
1.1.1.2 ! root     1437:                for ( i=0; i<7; ++i ) {
1.1       root     1438: 
1.1.1.2 ! root     1439:                    if ( ( pAtEnum->DaysOfWeek & ( 1 << i ) ) != 0 ) {
1.1       root     1440: 
1.1.1.2 ! root     1441:                        lstrcat( szWhenDay, szDayAbbr[i] );
1.1       root     1442: 
1.1.1.2 ! root     1443:                    }
1.1       root     1444: 
1.1.1.2 ! root     1445:                }
1.1       root     1446: 
1.1.1.2 ! root     1447:            }
1.1       root     1448: 
1.1.1.2 ! root     1449:            if ( pAtEnum->DaysOfMonth != 0 ) {
1.1       root     1450: 
1.1.1.2 ! root     1451:                for ( i=0; i<31; ++i ) {
1.1       root     1452: 
1.1.1.2 ! root     1453:                    if ( ( pAtEnum->DaysOfMonth & ( 1L << i ) ) != 0 ) {
1.1       root     1454: 
1.1.1.2 ! root     1455:                        wsprintf( szDateAbbr, "%d ", i+1 );
1.1       root     1456: 
1.1.1.2 ! root     1457:                        lstrcat( szWhenDay, szDateAbbr );
1.1       root     1458: 
1.1.1.2 ! root     1459:                    }
1.1       root     1460: 
1.1.1.2 ! root     1461:                }
1.1       root     1462: 
1.1.1.2 ! root     1463:            }
1.1       root     1464: 
                   1465: 
1.1.1.2 ! root     1466:            dwTime     = pAtEnum->JobTime / 1000 / 60;       // total minutes
1.1       root     1467: 
1.1.1.2 ! root     1468:            szTime[0]  = (UCHAR)( dwTime / 600 ) + '0';      // 10s of hours
        !          1469:            dwTime    %= 600;
1.1       root     1470: 
1.1.1.2 ! root     1471:            szTime[1]  = (UCHAR)( dwTime / 60 )  + '0';      // 1s of hours
        !          1472:            dwTime    %= 60;
1.1       root     1473: 
1.1.1.2 ! root     1474:            szTime[2]  = ':';
1.1       root     1475: 
1.1.1.2 ! root     1476:            szTime[3]  = (UCHAR)( dwTime / 10 )  + '0';      // 10s of minutes
        !          1477:            dwTime    %= 10;
1.1       root     1478: 
1.1.1.2 ! root     1479:            szTime[4]  = (UCHAR)( dwTime )       + '0';      // 1s of minutes
1.1       root     1480: 
1.1.1.2 ! root     1481:            szTime[5]  = '\0';
1.1       root     1482: 
1.1.1.2 ! root     1483:            // convert this 24-hour time to AM/PM form
1.1       root     1484: 
1.1.1.2 ! root     1485:            szTime[5] = 'A';
        !          1486:            szTime[6] = 'M';
        !          1487:            szTime[7] = '\0';
1.1       root     1488: 
                   1489:                        // if it is past 1000 but before 2000 (24-hour time)
1.1.1.2 ! root     1490: 
        !          1491:            if ( szTime[0] == '1' ) {
        !          1492: 
        !          1493:                // if it is past 1100
        !          1494: 
        !          1495:                        if ( szTime[1] >= '2' ) {
        !          1496: 
        !          1497:                                szTime[5] = 'P';
        !          1498: 
        !          1499:                        }
        !          1500: 
        !          1501:                    if( szTime [1] > '2' ) {
        !          1502: 
        !          1503:                        szTime[0] -= 1;
        !          1504:                        szTime[1] -= 2;
        !          1505: 
        !          1506:                    }
        !          1507: 
        !          1508:            } else if ( szTime[0] == '2' ) {
        !          1509: 
        !          1510:                // it is 2000 or later
        !          1511: 
        !          1512:                szTime[5] = 'P';
        !          1513: 
        !          1514:                    // if it is 2200 or later
        !          1515: 
        !          1516:                    if( szTime [1] >= '2' ) {
        !          1517: 
        !          1518:                        szTime[0] -= 1;
        !          1519:                        szTime[1] -= 2;
        !          1520: 
        !          1521:                    } else {
        !          1522: 
        !          1523:                        szTime[0] -= 2;
        !          1524:                        szTime[1] += 8;
        !          1525: 
        !          1526:                    }
        !          1527: 
        !          1528:                }
1.1       root     1529: 
                   1530:                        if ( szTime[0] == '0' ) {
1.1.1.2 ! root     1531: 
1.1       root     1532:                                if ( szTime[1] == '0' ) {
1.1.1.2 ! root     1533: 
1.1       root     1534:                                        // 12 am or pm
1.1.1.2 ! root     1535: 
1.1       root     1536:                                        szTime[0] = '1';
                   1537:                                        szTime[1] = '2';
1.1.1.2 ! root     1538: 
1.1       root     1539:                                } else {
1.1.1.2 ! root     1540: 
1.1       root     1541:                                        szTime[0] = ' ';
1.1.1.2 ! root     1542: 
1.1       root     1543:                                }
                   1544: 
1.1.1.2 ! root     1545:                }
        !          1546: 
        !          1547:            WideCharToMultiByte(
        !          1548:                CP_ACP,
        !          1549:                0,
        !          1550:                pAtEnum->Command,
        !          1551:                -1,
        !          1552:                szCommandM,
        !          1553:                MAXCOMMANDLEN,
        !          1554:                szDefault,
        !          1555:                &fFlag
        !          1556:                );
        !          1557: 
        !          1558:            wsprintf( szAtCommand, "%d\t", pAtEnum->JobId );
        !          1559:            lstrcat( szAtCommand, szWhenDay  );
        !          1560:            lstrcat( szAtCommand, "\t"       );
        !          1561:            lstrcat( szAtCommand, szTime     );
        !          1562:            lstrcat( szAtCommand, "\t"       );
        !          1563:            lstrcat( szAtCommand, szCommandM );
        !          1564: 
        !          1565:            WAddExtentEntry( GetDlgItem( hGlobalhWnd, IDC_ATCOMMANDS ), szAtCommand );
        !          1566:            SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_ADDSTRING, 0, (LPARAM)szAtCommand );
        !          1567: 
        !          1568:        }
        !          1569: 
        !          1570:        if ( EnumBuffer != NULL ) {
1.1       root     1571: 
1.1.1.2 ! root     1572:            (VOID)NetApiBufferFree( (LPVOID)EnumBuffer );
        !          1573:            EnumBuffer = NULL;
1.1       root     1574: 
1.1.1.2 ! root     1575:        }
        !          1576: 
        !          1577:        if ( status == ERROR_SUCCESS ) {
1.1       root     1578: 
1.1.1.2 ! root     1579:            break;  //  we have read & displayed all the items
        !          1580: 
        !          1581:        }
1.1       root     1582: 
                   1583:     } // for
                   1584: 
                   1585:     if ( first == TRUE) {
                   1586: 
1.1.1.2 ! root     1587:        ResetListboxExtents( GetDlgItem( hGlobalhWnd, IDC_ATCOMMANDS ) );
        !          1588:        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_RESETCONTENT, 0, 0 );
        !          1589:        WAddExtentEntry( GetDlgItem( hGlobalhWnd, IDC_ATCOMMANDS ), szNoEntries );
        !          1590:        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_ADDSTRING, 0, (LPARAM)szNoEntries );
        !          1591: 
        !          1592:        EnableWindow( GetDlgItem( hGlobalhWnd, IDC_ADD ), TRUE );
        !          1593:        EnableWindow( GetDlgItem( hGlobalhWnd, IDC_CHANGE ), FALSE );
        !          1594:        EnableWindow( GetDlgItem( hGlobalhWnd, IDC_REMOVE ), FALSE );
        !          1595: 
1.1       root     1596:     } else {
1.1.1.2 ! root     1597: 
        !          1598:        switch ( LOWORD( SetCurrentSelection ) ) {
        !          1599: 
        !          1600:                case SCS_BOTTOM:
        !          1601: 
        !          1602:                        uSelection = SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_GETCOUNT, 0, 0 ) - 1;
        !          1603: 
        !          1604:                        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_SETCURSEL,  uSelection,     0 );
        !          1605: 
        !          1606:                        break;
        !          1607: 
1.1       root     1608:                    case SCS_NOCHANGE:
1.1.1.2 ! root     1609: 
1.1       root     1610:                                // uSelection has already been set
1.1.1.2 ! root     1611: 
        !          1612:                    SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_SETCURSEL,  uSelection, 0 );
        !          1613: 
        !          1614:                    break;
        !          1615: 
        !          1616:                case SCS_TOP:
        !          1617: 
        !          1618:                        uSelection = 0;
        !          1619: 
        !          1620:                                SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_SETCURSEL,  uSelection,     0 );
        !          1621: 
1.1       root     1622:                                break;
1.1.1.2 ! root     1623: 
        !          1624:                case SCS_SELINHIGHWORD:
        !          1625: 
1.1       root     1626:                            uSelection = HIWORD( SetCurrentSelection );
1.1.1.2 ! root     1627: 
        !          1628:                                SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_SETCURSEL,  uSelection,     0 );
        !          1629: 
1.1       root     1630:                                break;
1.1.1.2 ! root     1631: 
1.1       root     1632:                        case SCS_NONE:
                   1633:                        default:
1.1.1.2 ! root     1634: 
        !          1635:                                break;
        !          1636: 
        !          1637:        }
        !          1638: 
        !          1639:        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_SETTOPINDEX,  uTopIndex,    0 );
        !          1640: 
        !          1641:        EnableWindow( GetDlgItem( hGlobalhWnd, IDC_ADD ), TRUE );
        !          1642:        EnableWindow( GetDlgItem( hGlobalhWnd, IDC_CHANGE ), TRUE );
        !          1643:        EnableWindow( GetDlgItem( hGlobalhWnd, IDC_REMOVE ), TRUE );
        !          1644: 
1.1       root     1645:     }
                   1646: 
                   1647:     return( ERROR_SUCCESS );
                   1648: 
                   1649: }
                   1650: 
                   1651: 
                   1652: 
                   1653: 
                   1654: //===========================================================================
                   1655: // FUNCTION: MessagePrint()
                   1656: //===========================================================================
                   1657: DWORD
                   1658: MessagePrint(
                   1659:     IN      DWORD       MessageId,
                   1660:     ...
                   1661:     )
                   1662: /*++
                   1663: 
                   1664: Routine Description:
                   1665: 
                   1666:     Finds the unicode message corresponding to the supplied message id,
                   1667:     merges it with caller supplied string(s), and prints the resulting
1.1.1.2 ! root     1668:     string.
1.1       root     1669: 
                   1670: Arguments:
                   1671: 
                   1672:     MessageId       -   message id
                   1673: 
                   1674: Return Value:
                   1675: 
                   1676:     Count of characters, not counting the terminating null character,
                   1677:     printed by this routine.  Zero return value indicates failure.
                   1678: 
                   1679: --*/
                   1680: {
                   1681:     va_list             arglist;
                   1682:     UCHAR *             buffer = NULL;
1.1.1.2 ! root     1683:     UCHAR *                     ptr;
1.1       root     1684:     DWORD               length;
                   1685:     LPVOID              lpSource;
                   1686:     DWORD               dwFlags = FORMAT_MESSAGE_ARGUMENT_ARRAY |
1.1.1.2 ! root     1687:                                  FORMAT_MESSAGE_ALLOCATE_BUFFER;
        !          1688: 
1.1       root     1689: 
                   1690:     va_start( arglist, MessageId );
                   1691: 
                   1692:     if ( MessageId < NERR_BASE) {
1.1.1.2 ! root     1693:        //
        !          1694:        //  Get message from system.
        !          1695:        //
        !          1696:        lpSource = NULL; // redundant step according to FormatMessage() spec
        !          1697:        dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM;
1.1       root     1698: 
                   1699:     } else if (  ( MessageId >= APE2_AT_DEL_WARNING
1.1.1.2 ! root     1700:                    &&  MessageId <= APE2_AT_DI_COMMAND)
        !          1701:              //
        !          1702:              // I cannot find these definitions!!!!
        !          1703:              //
        !          1704:              //|| ( MessageId >= IDS_LOAD_LIBRARY_FAILURE
        !          1705:              //      &&  MessageId <= IDS_USAGE )
        !          1706:              ) {
        !          1707:        //
        !          1708:        //  Get message from this module.
        !          1709:        //
        !          1710:        lpSource = NULL;
        !          1711:        dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
1.1       root     1712: 
                   1713:     } else {
1.1.1.2 ! root     1714:        //
        !          1715:        //  Get message from netmsg.dll.
        !          1716:        //
        !          1717:        lpSource = GlobalMessageHandle;
        !          1718:        dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
1.1       root     1719:     }
                   1720: 
                   1721:     length = FormatMessage(
1.1.1.2 ! root     1722:            dwFlags,                                          //  dwFlags
        !          1723:            lpSource,                                         //  lpSource
        !          1724:            MessageId,                                        //  MessageId
        !          1725:            0L,                                               //  dwLanguageId
        !          1726:            (LPTSTR)&buffer,                                 //  lpBuffer
        !          1727:            0,                                                //  size
        !          1728:            (va_list *) &arglist                              //  lpArguments
        !          1729:            );
1.1       root     1730: 
                   1731:     if ( length != 0) {
                   1732: 
1.1.1.2 ! root     1733:        //change to MessageBox
        !          1734:        //printf( "%ws", buffer );
1.1       root     1735: 
1.1.1.2 ! root     1736:        ptr = buffer;
        !          1737: 
        !          1738:        while ( *ptr ) {
        !          1739: 
        !          1740:            if ( ( *ptr < ' ' ) || ( *ptr > '~' ) ) {
        !          1741: 
        !          1742:                *ptr = ' ';
        !          1743: 
        !          1744:            }
        !          1745: 
        !          1746:                ptr++;
        !          1747: 
        !          1748:        }
        !          1749: 
        !          1750:        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_RESETCONTENT, 0, 0 );
        !          1751: 
        !          1752:        SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_ADDSTRING, 0, (LPARAM)(LPTSTR)buffer );
        !          1753: 
        !          1754:        MessageBox( hGlobalhWnd, (LPCTSTR)buffer, SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          1755: 
        !          1756:        LocalFree( buffer );
1.1       root     1757: 
                   1758:     }
                   1759: 
                   1760:     return( length);
                   1761: 
                   1762: } // MessagePrint()
                   1763: 
                   1764: 
                   1765: 
                   1766: //===========================================================================
                   1767: // FUNCTION: MinProc()
                   1768: //===========================================================================
                   1769: LRESULT APIENTRY MinProc( HWND hWnd, UINT message, UINT uParam, LONG lParam )
                   1770: {
1.1.1.2 ! root     1771:     UINT  uCurVal;
1.1       root     1772:     UCHAR szCurVal[3];
1.1.1.2 ! root     1773: 
1.1       root     1774:     switch ( message ) {
1.1.1.2 ! root     1775: 
1.1       root     1776:            case WM_COPY:
                   1777:            case WM_PASTE:
                   1778:            case WM_CUT:
1.1.1.2 ! root     1779: 
1.1       root     1780:                        // cut and paste dont seem to work...
1.1.1.2 ! root     1781: 
        !          1782:                break;
        !          1783: 
        !          1784: // jean-marc - start
        !          1785:       case WM_SETFOCUS:
        !          1786:        hCurrentFocus = hWnd;
        !          1787:        break;
        !          1788: // jean-marc - end
        !          1789: 
        !          1790:        case WM_CHAR:
        !          1791: 
1.1       root     1792:                        if ( uParam == VK_BACK ) {
1.1.1.2 ! root     1793: 
1.1       root     1794:                                if ( uMinChars > 0 ) {
1.1.1.2 ! root     1795: 
1.1       root     1796:                                        --uMinChars;
1.1.1.2 ! root     1797: 
1.1       root     1798:                                }
1.1.1.2 ! root     1799: 
1.1       root     1800:                                return CallWindowProc( (WNDPROC)lpMinDefProc, hWnd, message, uParam, lParam ) ;
1.1.1.2 ! root     1801: 
1.1       root     1802:                        } else {
1.1.1.2 ! root     1803: 
1.1       root     1804:                                uMinChars = (UINT) SendMessage( hWnd, WM_GETTEXT, 2, (LPARAM)szCurVal );
1.1.1.2 ! root     1805: 
1.1       root     1806:                                if ( uMinChars == 0 ) {
1.1.1.2 ! root     1807: 
        !          1808:                                uCurVal = 0;
        !          1809: 
1.1       root     1810:                            } else if ( uMinChars == 1 ) {
1.1.1.2 ! root     1811: 
        !          1812:                                uCurVal = szCurVal[0] - '0';
        !          1813: 
1.1       root     1814:                            } else if ( uMinChars == 2 ) {
1.1.1.2 ! root     1815: 
        !          1816:                                uCurVal  = szCurVal[0] - '0';
        !          1817:                                uCurVal *= 10;
        !          1818:                                uCurVal  = szCurVal[1] - '0';
        !          1819: 
1.1       root     1820:                            } else if ( uMinChars > 2 ) {
1.1.1.2 ! root     1821: 
        !          1822:                                uMinChars = 0;
        !          1823: 
        !          1824:                                SendMessage( hWnd, WM_SETTEXT, 0, (LPARAM)"" );
        !          1825: 
        !          1826:                                return( 0 );
        !          1827: 
1.1       root     1828:                            }
1.1.1.2 ! root     1829: 
1.1       root     1830:                        }
1.1.1.2 ! root     1831: 
1.1       root     1832:                        if ( ( uParam == ' ' )                  ||  // space
                   1833:                             ( uParam < '0' || uParam > '9' )   ||  // not a number
                   1834:                             ( uCurVal >= 6  )                      // greater than 59
                   1835:                           ) {
1.1.1.2 ! root     1836: 
1.1       root     1837:                                 MessageBeep( MB_OK );
1.1.1.2 ! root     1838: 
1.1       root     1839:                                 return( 0 );
1.1.1.2 ! root     1840: 
1.1       root     1841:                        } else if ( uMinChars < 2 ) {
1.1.1.2 ! root     1842: 
1.1       root     1843:                                ++uMinChars;
1.1.1.2 ! root     1844: 
1.1       root     1845:                        } else {
1.1.1.2 ! root     1846: 
        !          1847:                    MessageBeep( MB_OK );
        !          1848: 
        !          1849:                            return( 0 );
        !          1850: 
        !          1851:                        }
        !          1852: 
        !          1853:                break;
        !          1854: 
1.1       root     1855:        } // switch
1.1.1.2 ! root     1856: 
1.1       root     1857:        return CallWindowProc( (WNDPROC)lpMinDefProc, hWnd, message, uParam, lParam ) ;
1.1.1.2 ! root     1858: 
1.1       root     1859: }
                   1860: 
                   1861: 
                   1862: 
                   1863: //===========================================================================
                   1864: // FUNCTION: Refresh()
                   1865: //===========================================================================
1.1.1.2 ! root     1866: UINT
1.1       root     1867: Refresh(UINT Command)
                   1868: {
                   1869: 
                   1870:     static BOOL fOkayToRefresh;
1.1.1.2 ! root     1871:        static BOOL     fOkayToRefreshSave;
        !          1872: 
        !          1873:        switch( Command ) {
        !          1874: 
1.1       root     1875:                case REFRESH_FALSE:
1.1.1.2 ! root     1876: 
1.1       root     1877:                    fOkayToRefresh = FALSE;
1.1.1.2 ! root     1878: 
1.1       root     1879:                        break;
                   1880: 
                   1881:                case REFRESH_TRUE:
1.1.1.2 ! root     1882: 
1.1       root     1883:                    fOkayToRefresh = TRUE;
1.1.1.2 ! root     1884: 
1.1       root     1885:                        break;
1.1.1.2 ! root     1886: 
1.1       root     1887:                case REFRESH_QUERY:
1.1.1.2 ! root     1888: 
        !          1889:                        return( fOkayToRefresh );
        !          1890: 
1.1       root     1891:                        break;
1.1.1.2 ! root     1892: 
1.1       root     1893:                case REFRESH_SAVE:
1.1.1.2 ! root     1894: 
1.1       root     1895:                    fOkayToRefreshSave = fOkayToRefresh;
1.1.1.2 ! root     1896: 
1.1       root     1897:                        break;
1.1.1.2 ! root     1898: 
1.1       root     1899:                case REFRESH_RESTORE:
1.1.1.2 ! root     1900: 
1.1       root     1901:                    fOkayToRefresh = fOkayToRefreshSave;
1.1.1.2 ! root     1902: 
        !          1903:                        break;
1.1       root     1904:        }
1.1.1.2 ! root     1905: 
1.1       root     1906:        return( REFRESH_ERROR );
1.1.1.2 ! root     1907: 
1.1       root     1908: }
                   1909: 
                   1910: 
                   1911: 
                   1912: //===========================================================================
                   1913: // FUNCTION: SelectComputerProc()
                   1914: //===========================================================================
                   1915: BOOL APIENTRY SelectComputerProc(
1.1.1.2 ! root     1916:        HWND hWnd,         // window handle
        !          1917:        UINT message,      // type of message
        !          1918:        UINT uParam,       // additional information
1.1       root     1919:                LONG lParam)       // additional information
                   1920: {
                   1921: 
                   1922:     DWORD           dwLen = MAXCOMPUTERNAMELEN + 1;
                   1923:     UCHAR           szSelectComputer[MAXCOMPUTERNAMELEN+1];
                   1924:     int             wmEvent;
                   1925:     int             wmId;
1.1.1.2 ! root     1926: // jean-marc - start
        !          1927:     UCHAR           szComputerMTemp[MAXCOMPUTERNAMELEN+1];  // multibyte comp. name
        !          1928: // jean-marc - end
        !          1929: 
1.1       root     1930:     switch (message) {
                   1931: 
1.1.1.2 ! root     1932:        case WM_INITDIALOG:
        !          1933: // jean-marc - start
        !          1934:            // set the text limit for the IDC_SELECTCOMPUTER edit field to be
        !          1935:            // MAXCOMPUTERNAMELEN
        !          1936:            SendDlgItemMessage(hWnd,
        !          1937:                               IDC_SELECTCOMPUTER,
        !          1938:                               EM_LIMITTEXT,
        !          1939:                               MAXCOMPUTERNAMELEN,
        !          1940:                               0);
        !          1941: // jean-marc - end
        !          1942: 
        !          1943:            if ( !GetComputerName( szSelectComputer, &dwLen ) ) {
1.1       root     1944: 
                   1945:                                        MessageBox( hWnd, "Problem getting computer name.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
1.1.1.2 ! root     1946: 
1.1       root     1947:                        } else {
1.1.1.2 ! root     1948: 
1.1       root     1949:                                SetDlgItemText( hWnd, IDC_SELECTCOMPUTER, szSelectComputer );
                   1950: 
                   1951:                        }
                   1952: 
1.1.1.2 ! root     1953:                break;
        !          1954: 
        !          1955:        case WM_COMMAND:    // message: command from application menu
1.1       root     1956: 
1.1.1.2 ! root     1957:            // Message packing of uParam and lParam have changed for Win32, let us
        !          1958:            // handle the differences in a conditional compilation:
1.1       root     1959: 
                   1960:                        wmId    = LOWORD(uParam);
                   1961:                        wmEvent = HIWORD(uParam);
                   1962: 
                   1963:                        switch (wmId) {
1.1.1.2 ! root     1964: 
1.1       root     1965:                                case IDCANCEL:
1.1.1.2 ! root     1966: 
1.1       root     1967:                                        EndDialog( hWnd, IDCANCEL );
1.1.1.2 ! root     1968: 
1.1       root     1969:                                        break;
1.1.1.2 ! root     1970: 
        !          1971:                case IDOK:
        !          1972: 
        !          1973:                    GetDlgItemText( hWnd, IDC_SELECTCOMPUTER, &szComputerMTemp[0], MAXCOMPUTERNAMELEN );
        !          1974: 
        !          1975: // jean-marc - start
        !          1976:                    // make sure backslashes are there, if not then add them
        !          1977:                    if (szComputerMTemp[0] == '\\' && szComputerMTemp[1] == '\\')
        !          1978:                      lstrcpy(szComputerM, szComputerMTemp);
        !          1979:                    else if (szComputerMTemp[0] != '\\' && szComputerMTemp[1] != '\\')
        !          1980:                      wsprintf(szComputerM, "\\\\%s", szComputerMTemp);
        !          1981:                    else if (szComputerMTemp[0] == '\\' || szComputerMTemp[1] == '\\')
        !          1982:                      wsprintf(szComputerM, "\\%s", szComputerMTemp);
        !          1983:                    if (lstrlen(szComputerM) > MAXCOMPUTERNAMELEN || lstrlen(szComputerM) == 2)
        !          1984:                      MessageBox( hWnd, "Computer names are 1 to 15 characters long.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          1985: // jean-marc - end
        !          1986: 
        !          1987:                    else {
        !          1988: 
        !          1989:                            SetDlgItemText( hGlobalhWnd, IDC_COMPUTER, &szComputerM[2] );
        !          1990: 
1.1       root     1991:                                                MultiByteToWideChar(
1.1.1.2 ! root     1992:                                                CP_ACP,
        !          1993:                                                MB_PRECOMPOSED,
        !          1994:                                                szComputerM,
        !          1995:                                                -1,
        !          1996:                                                szComputerW,
        !          1997:                                                MAXCOMPUTERNAMELEN
        !          1998:                                                );
        !          1999: 
        !          2000:                        GlobalComputerName = szComputerW;
        !          2001: 
        !          2002:                                Refresh( REFRESH_TRUE );
        !          2003: 
        !          2004:                            EndDialog( hWnd, IDOK );
        !          2005: 
        !          2006:                        }
        !          2007: 
        !          2008:                    break;
        !          2009: 
        !          2010:            }
1.1       root     2011: 
                   2012:                        break;
                   2013: 
                   2014:     }
1.1.1.2 ! root     2015: 
1.1       root     2016:     return (0);
                   2017: 
                   2018: }
                   2019: 
                   2020: 
                   2021: 
                   2022: //===========================================================================
                   2023: // FUNCTION: ServiceNotStartedHandler()
1.1.1.2 ! root     2024: //===========================================================================
        !          2025: BOOL
1.1       root     2026: ServiceNotStartedHandler(VOID)
                   2027: {
                   2028: 
                   2029:     BOOL            Done;
                   2030:     SC_HANDLE       schSCManager;
                   2031:     SC_HANDLE       schService;
                   2032:     SERVICE_STATUS  ssServiceStatus;
                   2033:     UCHAR           szService[] = "Schedule";
                   2034:     UCHAR           szTemp[80];
1.1.1.2 ! root     2035: 
1.1       root     2036:     wsprintf( szTemp, "Schedule service on %s not started.\nWould you like to start it?", &szComputerM[2] );
1.1.1.2 ! root     2037: 
1.1       root     2038:        if ( MessageBox( hGlobalhWnd, szTemp, SZWINDOWTITLE, MB_YESNO ) == IDYES ) {
                   2039: 
                   2040:            schSCManager = OpenSCManager( szComputerM, NULL, SC_MANAGER_ALL_ACCESS );
1.1.1.2 ! root     2041: 
1.1       root     2042:            if ( schSCManager == NULL ) {
1.1.1.2 ! root     2043: 
        !          2044:                wsprintf( szTemp, "Problem accessing Service Control Manager.\n\nError %d.", GetLastError() );
        !          2045: 
        !          2046:                MessageBox( hGlobalhWnd, szTemp, SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2047: 
1.1       root     2048:                    return( FALSE );
1.1.1.2 ! root     2049: 
1.1       root     2050:            } else {
1.1.1.2 ! root     2051: 
1.1       root     2052:                        schService = OpenService( schSCManager, szService, SERVICE_ALL_ACCESS );
1.1.1.2 ! root     2053: 
1.1       root     2054:                        if ( schService == NULL ) {
1.1.1.2 ! root     2055: 
        !          2056:                        wsprintf( szTemp, "Problem opening Schedule service.\n\nError %d.", GetLastError() );
        !          2057: 
        !          2058:                        MessageBox( hGlobalhWnd, szTemp, SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2059: 
        !          2060:                        return( FALSE );
        !          2061: 
1.1       root     2062:                    } else {
1.1.1.2 ! root     2063: 
1.1       root     2064:                                if ( StartService( schService, 0, NULL ) == FALSE ) {
1.1.1.2 ! root     2065: 
        !          2066:                                wsprintf( szTemp, "Problem starting Schedule service.\n\nError %d.", GetLastError() );
        !          2067: 
        !          2068:                                MessageBox( hGlobalhWnd, szTemp, SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
1.1       root     2069: 
                   2070:                                        return( FALSE );
1.1.1.2 ! root     2071: 
1.1       root     2072:                            } else {
1.1.1.2 ! root     2073: 
        !          2074:                                // wait for service to start
        !          2075: 
        !          2076:                                Done = FALSE;
        !          2077: 
        !          2078:                                while( !Done ) {
        !          2079: 
        !          2080:                                        if ( QueryServiceStatus( schService, &ssServiceStatus ) == FALSE ) {
        !          2081: 
        !          2082:                                                wsprintf( szTemp, "Problem getting service status.\n\nError %d.", GetLastError() );
        !          2083: 
        !          2084:                                                MessageBox( hGlobalhWnd, szTemp, SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2085: 
1.1       root     2086:                                                        return( FALSE );
1.1.1.2 ! root     2087: 
1.1       root     2088:                                                } else {
1.1.1.2 ! root     2089: 
1.1       root     2090:                                                        switch ( ssServiceStatus.dwCurrentState ) {
1.1.1.2 ! root     2091: 
1.1       root     2092:                                                                case SERVICE_START_PENDING:
1.1.1.2 ! root     2093: 
1.1       root     2094:                                                                        Sleep( ssServiceStatus.dwWaitHint );
1.1.1.2 ! root     2095: 
1.1       root     2096:                                                                        break;
1.1.1.2 ! root     2097: 
1.1       root     2098:                                                                case SERVICE_RUNNING:
1.1.1.2 ! root     2099: 
1.1       root     2100:                                                                    Done = TRUE;
1.1.1.2 ! root     2101: 
1.1       root     2102:                                                                        break;
1.1.1.2 ! root     2103: 
1.1       root     2104:                                                                default:
1.1.1.2 ! root     2105: 
1.1       root     2106:                                                                        wsprintf( szTemp, "Unexpected service state.\n\nState %d.", ssServiceStatus.dwCurrentState );
1.1.1.2 ! root     2107: 
        !          2108:                                                                MessageBox( hGlobalhWnd, szTemp, SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2109: 
        !          2110:                                                                Done = TRUE;
        !          2111: 
        !          2112:                                                                break;
        !          2113: 
1.1       root     2114:                                                        }
1.1.1.2 ! root     2115: 
1.1       root     2116:                                                }
1.1.1.2 ! root     2117: 
1.1       root     2118:                                        }
1.1.1.2 ! root     2119: 
1.1       root     2120:                            }
1.1.1.2 ! root     2121: 
        !          2122:                        CloseServiceHandle(schService);
        !          2123: 
        !          2124:                }
        !          2125: 
        !          2126:                CloseServiceHandle(schSCManager);
        !          2127: 
        !          2128:            }
1.1       root     2129: 
                   2130:                SendDlgItemMessage( hGlobalhWnd, IDC_ATCOMMANDS, LB_RESETCONTENT, 0, 0 );
1.1.1.2 ! root     2131: 
        !          2132:        SendDlgItemMessage(
        !          2133:                hGlobalhWnd,
        !          2134:                IDC_ATCOMMANDS,
        !          2135:                LB_ADDSTRING,
        !          2136:                0,
        !          2137:                (LPARAM)"The Schedule service was started successfully." );
        !          2138: 
        !          2139:                MessageBox(
        !          2140:                        hGlobalhWnd,
        !          2141:                        "The Schedule service was started successfully.",
        !          2142:                        SZWINDOWTITLE,
1.1       root     2143:                        MB_OK );
1.1.1.2 ! root     2144: 
        !          2145:                return( TRUE );
        !          2146: 
1.1       root     2147:        } else {
1.1.1.2 ! root     2148: 
1.1       root     2149:            Refresh( REFRESH_FALSE );
                   2150: 
1.1.1.2 ! root     2151:                MessageBox(
        !          2152:                        hGlobalhWnd,
        !          2153:                        "The display will not be refreshed automatically.  Chose File, Select Computer to refresh the display.",
        !          2154:                        SZWINDOWTITLE,
        !          2155:                        MB_OK | MB_ICONEXCLAMATION );
1.1       root     2156: 
1.1.1.2 ! root     2157:        }
1.1       root     2158: 
1.1.1.2 ! root     2159:        return( FALSE );
1.1       root     2160: 
                   2161: }
                   2162: 
                   2163: 
                   2164: //===========================================================================
                   2165: // FUNCTION: ValidateAddChangeArguments()
1.1.1.2 ! root     2166: //===========================================================================
1.1       root     2167: BOOL
                   2168: ValidateAddChangeArguments(
                   2169:        HWND hWnd
                   2170:        )
                   2171: {
                   2172: 
                   2173:     SYSTEMTIME              SysTime;
                   2174:     UCHAR                   szAmPm[3];
                   2175:     UINT                    Items[NUMDAYITEMS];
                   2176:     UINT                    NumSelected;
                   2177:     UINT                    i;
1.1.1.2 ! root     2178: 
1.1       root     2179:        // initialize
                   2180: 
                   2181:     memset( (PBYTE)&GlobalAtInfo, '\0', sizeof(GlobalAtInfo) );
                   2182: 
                   2183:        // command
                   2184: 
                   2185:     SendDlgItemMessage( hWnd, IDC_NEWCOMMAND, WM_GETTEXT, MAXCOMMANDLEN, (LPARAM)szCommandM );
                   2186: 
                   2187:     if ( szCommandM[0] == 0 ) {
                   2188: 
1.1.1.2 ! root     2189:        MessageBox(
        !          2190:            hWnd,
        !          2191:            "Enter a command.",
        !          2192:            SZWINDOWTITLE,
        !          2193:            MB_OK | MB_ICONEXCLAMATION
        !          2194:            );
        !          2195: 
        !          2196:        SetFocus( GetDlgItem( hWnd, IDC_NEWCOMMAND ) );
        !          2197: 
        !          2198:        return ( FALSE );
1.1       root     2199: 
1.1.1.2 ! root     2200:     }
1.1       root     2201: 
                   2202:        MultiByteToWideChar(
1.1.1.2 ! root     2203:        CP_ACP,
        !          2204:        MB_PRECOMPOSED,
        !          2205:        szCommandM,
        !          2206:        -1,
        !          2207:        szCommandW,
        !          2208:        MAXCOMMANDLEN
        !          2209:        );
1.1       root     2210: 
                   2211:     GlobalAtInfo.Command = szCommandW;
1.1.1.2 ! root     2212: 
1.1       root     2213:        // hours
1.1.1.2 ! root     2214: 
1.1       root     2215:     GlobalAtInfo.JobTime = GetDlgItemInt( hWnd, IDC_HOUR, NULL, FALSE );
1.1.1.2 ! root     2216: 
1.1       root     2217:     GetDlgItemText( hWnd, IDC_AMPM, (LPTSTR)&szAmPm, sizeof(szAmPm) );
1.1.1.2 ! root     2218: 
1.1       root     2219:     if ( szAmPm[0] == 'P' || szAmPm[0] == 'p' ) {
                   2220: 
1.1.1.2 ! root     2221:        if( GlobalAtInfo.JobTime != 12 ) {
        !          2222: 
        !          2223:                GlobalAtInfo.JobTime += 12;
        !          2224: 
        !          2225:        }
1.1       root     2226: 
                   2227:     } else if( GlobalAtInfo.JobTime == 12 ) {
1.1.1.2 ! root     2228: 
        !          2229:                GlobalAtInfo.JobTime = 0;
        !          2230: 
1.1       root     2231:     }
1.1.1.2 ! root     2232: 
        !          2233: 
1.1       root     2234:     // convert to minutes
1.1.1.2 ! root     2235: 
1.1       root     2236:        GlobalAtInfo.JobTime *= 60;
1.1.1.2 ! root     2237: 
1.1       root     2238:        // add minutes
1.1.1.2 ! root     2239: 
1.1       root     2240:        GlobalAtInfo.JobTime += GetDlgItemInt( hWnd, IDC_MIN, NULL, FALSE );
1.1.1.2 ! root     2241: 
1.1       root     2242:        // convert to milliseconds
1.1.1.2 ! root     2243: 
1.1       root     2244:        GlobalAtInfo.JobTime *= 60 * 1000;
1.1.1.2 ! root     2245: 
1.1       root     2246:        GetLocalTime( &SysTime );
1.1.1.2 ! root     2247: 
1.1       root     2248:     if ( SendDlgItemMessage( hWnd, IDC_TODAY, BM_GETCHECK, 0, 0 ) ) {
1.1.1.2 ! root     2249: 
        !          2250:                if ( (DWORD)( (SysTime.wHour * 60 + SysTime.wMinute) * 60 * 1000) >= GlobalAtInfo.JobTime ) {
        !          2251: 
        !          2252:                        MessageBox(
        !          2253:                                hWnd,
        !          2254:                                "The time you have selected has already passed.  The command will run tomorrow.",
        !          2255:                                SZWINDOWTITLE,
        !          2256:                MB_OK | MB_ICONEXCLAMATION
        !          2257:                );
        !          2258: 
1.1       root     2259:                }
1.1.1.2 ! root     2260: 
1.1       root     2261:        }
1.1.1.2 ! root     2262: 
1.1       root     2263:        if ( SendDlgItemMessage( hWnd, IDC_EVERY, BM_GETCHECK, 0, 0 ) ||
1.1.1.2 ! root     2264:             SendDlgItemMessage( hWnd, IDC_NEXT, BM_GETCHECK, 0, 0 )    ) {
        !          2265: 
        !          2266:                // day
1.1       root     2267:                // NOTE: I am assuming that this lisbox will always be correct
                   2268:                //       and if you select Today/Tomorrow the proper day is selected.
1.1.1.2 ! root     2269: 
1.1       root     2270:                NumSelected = SendDlgItemMessage( hWnd, IDC_DAYS, LB_GETSELCOUNT, 0, 0 );
1.1.1.2 ! root     2271: 
1.1       root     2272:                if ( NumSelected == 0 ) {
                   2273: 
1.1.1.2 ! root     2274:                MessageBox(
        !          2275:                    hWnd,
        !          2276:                    "Select the day(s) this command will run.",
        !          2277:                    SZWINDOWTITLE,
        !          2278:                    MB_OK | MB_ICONEXCLAMATION
        !          2279:                    );
        !          2280: 
        !          2281:                SetFocus( GetDlgItem( hWnd, IDC_DAYS ) );
1.1       root     2282: 
1.1.1.2 ! root     2283:                return ( FALSE );
        !          2284: 
        !          2285:        }
        !          2286: 
        !          2287:                SendDlgItemMessage( hWnd, IDC_DAYS, LB_GETSELITEMS, NUMDAYITEMS, (LPARAM)Items );
1.1       root     2288: 
                   2289:                for( i=0; i<NumSelected; ++i ) {
1.1.1.2 ! root     2290: 
1.1       root     2291:                        if ( Items[i] > 6 ) {
1.1.1.2 ! root     2292: 
1.1       root     2293:                                // days of month
                   2294:                                //0-based, 7 and up are dates (1-31)
1.1.1.2 ! root     2295: 
1.1       root     2296:                            GlobalAtInfo.DaysOfMonth |= ( 1 << ( Items[i]-7 ) );
1.1.1.2 ! root     2297: 
1.1       root     2298:                        } else {
1.1.1.2 ! root     2299: 
1.1       root     2300:                            // days of week
1.1.1.2 ! root     2301:                            // 0-based, first 7 are days (M-Su)
        !          2302: 
        !          2303:                        GlobalAtInfo.DaysOfWeek |= ( 1 << Items[i] );
        !          2304: 
        !          2305:                        }
        !          2306: 
1.1       root     2307:                }
1.1.1.2 ! root     2308: 
1.1       root     2309:                // flags
                   2310: 
1.1.1.2 ! root     2311:        if ( SendDlgItemMessage( hWnd, IDC_EVERY, BM_GETCHECK, 0, 0 ) ) {
        !          2312: 
        !          2313:            GlobalAtInfo.Flags |= JOB_RUN_PERIODICALLY;
        !          2314: 
        !          2315:        }
        !          2316: 
        !          2317:        } else if ( SendDlgItemMessage( hWnd, IDC_TOMORROW, BM_GETCHECK, 0, 0 ) ) {
1.1       root     2318: 
                   2319:                i = SendDlgItemMessage( hWnd, IDC_DAYS, LB_GETCURSEL, 0, 0 );
1.1.1.2 ! root     2320: 
1.1       root     2321:                if ( i == 0 ) {
1.1.1.2 ! root     2322: 
1.1       root     2323:                    // set to Sunday
1.1.1.2 ! root     2324: 
1.1       root     2325:                        GlobalAtInfo.DaysOfWeek = ( 1 << 6 );
1.1.1.2 ! root     2326: 
1.1       root     2327:                } else {
1.1.1.2 ! root     2328: 
        !          2329:                    // increment to tomorrow
        !          2330: 
1.1       root     2331:                        GlobalAtInfo.DaysOfWeek |= ( 1 << i );
1.1.1.2 ! root     2332: 
1.1       root     2333:                }
1.1.1.2 ! root     2334: 
1.1       root     2335:        }
1.1.1.2 ! root     2336: 
1.1       root     2337:        return( TRUE );
                   2338: 
                   2339: }
                   2340: 
                   2341: 
                   2342: 
                   2343: //===========================================================================
                   2344: // FUNCTION: WINATDlgProc()
                   2345: //===========================================================================
                   2346: BOOL APIENTRY WINATDlgProc(
1.1.1.2 ! root     2347:        HWND hWnd,         // window handle
        !          2348:        UINT message,      // type of message
        !          2349:        UINT uParam,       // additional information
1.1       root     2350:                LONG lParam)       // additional information
                   2351: {
                   2352: 
                   2353:     FARPROC         lpAddChangeDlgProc;  // pointer to the "AddChange" function
                   2354:     FARPROC         lpProcSelect;
                   2355:     NET_API_STATUS  status;
                   2356:     int             wmEvent;
                   2357:     int             wmId;
1.1.1.2 ! root     2358:     int                         iDlgRetCode;
        !          2359: // jean-marc - start
        !          2360:     LOGFONT         lfComputerName;
        !          2361:     static HFONT    hFontComputerName = NULL;
        !          2362:     BOOL            bGetComputerName = FALSE;
        !          2363: // jean-marc - end
        !          2364: 
1.1       root     2365:     switch (message) {
                   2366: 
1.1.1.2 ! root     2367:        case WM_INITDIALOG:
        !          2368: // jean-marc - start
        !          2369:            // retrieve the font of the field IDC_COMPUTER
        !          2370:            hFontComputerName = (HFONT)SendDlgItemMessage(hWnd,
        !          2371:                                                          IDC_COMPUTER,
        !          2372:                                                          WM_GETFONT,
        !          2373:                                                          0,
        !          2374:                                                          0L);
        !          2375: 
        !          2376:            // now get the logfont description of the font handle
        !          2377:            if (GetObject(hFontComputerName, sizeof(LOGFONT), &lfComputerName))
        !          2378:            {
        !          2379:                // now make the font underlined
        !          2380:                lfComputerName.lfUnderline = 1;
        !          2381: 
        !          2382:                // next recreate a font handle from this logfont
        !          2383:                hFontComputerName = CreateFontIndirect(&lfComputerName);
        !          2384: 
        !          2385:                // finally set the font handle for the edit field
        !          2386:                if (hFontComputerName)
        !          2387:                  SendDlgItemMessage(hWnd,
        !          2388:                                     IDC_COMPUTER,
        !          2389:                                     WM_SETFONT,
        !          2390:                                     (WPARAM)hFontComputerName,
        !          2391:                                     1L);
        !          2392:            }
        !          2393: // jean-marc - end
        !          2394: 
        !          2395:            lf.lfEscapement    = 0;
        !          2396:            lf.lfOrientation   = 0;
        !          2397:            lf.lfOutPrecision  = OUT_DEFAULT_PRECIS;
        !          2398:            lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
        !          2399:            lf.lfHeight        = 14;
        !          2400:            lf.lfWidth         = 0; //6; //5
        !          2401:            lf.lfWeight        = 0;
        !          2402: 
        !          2403:            lf.lfItalic        = 0;
        !          2404:            lf.lfUnderline     = 0;
        !          2405:            lf.lfStrikeOut     = 0;
        !          2406: 
        !          2407:            lf.lfPitchAndFamily=VARIABLE_PITCH | FF_SWISS;
1.1       root     2408: 
1.1.1.2 ! root     2409:            hFont = CreateFontIndirect( &lf );
1.1       root     2410: 
1.1.1.2 ! root     2411:            if ( hFont != NULL ) {
1.1       root     2412: 
1.1.1.2 ! root     2413:                SendDlgItemMessage( hWnd, IDC_ATCOMMANDS, WM_SETFONT, (WPARAM)hFont, 1L );
1.1       root     2414: 
1.1.1.2 ! root     2415:            } else {
        !          2416: 
        !          2417:                MessageBox( hWnd, "Problem creating font.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
1.1       root     2418: 
1.1.1.2 ! root     2419:            }
1.1       root     2420: 
1.1.1.2 ! root     2421:            hCursorWait = LoadCursor( NULL, IDC_WAIT );
1.1       root     2422: 
1.1.1.2 ! root     2423:            if ( !FInitListboxExtents( GetDlgItem( hWnd, IDC_ATCOMMANDS ) ) ) {
1.1       root     2424: 
1.1.1.2 ! root     2425:                MessageBox( hWnd, "Scrolling broken", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
1.1       root     2426: 
1.1.1.2 ! root     2427:            }
1.1       root     2428: 
1.1.1.2 ! root     2429:            hGlobalhWnd = hWnd;
1.1       root     2430: 
1.1.1.2 ! root     2431:            // get values from registry
1.1       root     2432: 
1.1.1.2 ! root     2433:            SendMessage(hWnd, WM_COMMAND, IDM_GET_FROM_REGISTRY, 0);
1.1       root     2434: 
1.1.1.2 ! root     2435:            // set tabstops for commands
1.1       root     2436: 
1.1.1.2 ! root     2437:            {
1.1       root     2438: 
1.1.1.2 ! root     2439:                UINT Tabs[3] = { 25, 110, 145 };
1.1       root     2440: 
1.1.1.2 ! root     2441:                SendDlgItemMessage( hWnd, IDC_ATCOMMANDS, LB_SETTABSTOPS, 3, (LPARAM)Tabs );
1.1       root     2442: 
1.1.1.2 ! root     2443:            }
1.1       root     2444: 
1.1.1.2 ! root     2445:                        // get local computer name
1.1       root     2446: 
                   2447:                        {
1.1.1.2 ! root     2448: 
1.1       root     2449:                                DWORD dwLen = MAXCOMPUTERNAMELEN;
1.1.1.2 ! root     2450: 
        !          2451: // jean-marc - start
        !          2452:                                // process the commandline
        !          2453:                                if (gszCommandLine[0])
        !          2454:                                {
        !          2455:                                  // make sure backslashes are there, if not then add them
        !          2456:                                  if (gszCommandLine[0] == '\\' && gszCommandLine[1] == '\\')
        !          2457:                                    lstrcpy(szComputerM, gszCommandLine);
        !          2458:                                  else if (gszCommandLine[0] != '\\' && gszCommandLine[1] != '\\')
        !          2459:                                    wsprintf(szComputerM, "\\\\%s", gszCommandLine);
        !          2460:                                  else if (gszCommandLine[0] == '\\' || gszCommandLine[1] == '\\')
        !          2461:                                    wsprintf(szComputerM, "\\%s", gszCommandLine);
        !          2462:                                  if (lstrlen(szComputerM) > MAXCOMPUTERNAMELEN || lstrlen(szComputerM) == 2)
        !          2463:                                  {
        !          2464:                                    MessageBox( hWnd, "Computer names are 1 to 15 characters long.\nUsing local computer name.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2465:                                    bGetComputerName = GetComputerName( &szComputerM[2], &dwLen );
        !          2466:                                    if (!bGetComputerName)
        !          2467:                                      MessageBox( hWnd, "Problem getting computer name", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2468:                                  }
        !          2469:                                  else
        !          2470:                                    bGetComputerName = TRUE;
        !          2471:                                }
        !          2472:                                else
        !          2473:                                {
        !          2474:                                  bGetComputerName = GetComputerName( &szComputerM[2], &dwLen );
        !          2475:                                  if (!bGetComputerName)
        !          2476:                                    MessageBox( hWnd, "Problem getting computer name", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2477:                                }
        !          2478: // jean-marc - end
        !          2479: 
        !          2480:                            if (bGetComputerName) {
        !          2481: 
1.1       root     2482:                                    szComputerM[0] = '\\';
1.1.1.2 ! root     2483:                                szComputerM[1] = '\\';
        !          2484: 
1.1       root     2485:                                    MultiByteToWideChar(
1.1.1.2 ! root     2486:                                        CP_ACP,
        !          2487:                                        MB_PRECOMPOSED,
        !          2488:                                        szComputerM,
        !          2489:                                        -1,
        !          2490:                                        szComputerW,
        !          2491:                                        MAXCOMMANDLEN
        !          2492:                                        );
        !          2493: 
        !          2494:                    // set GlobalComputerName for all functions to use
1.1       root     2495:                                        // only Select Computer will ever change this value
                   2496: 
1.1.1.2 ! root     2497:                    GlobalComputerName = szComputerW;
        !          2498: 
        !          2499:                                SendDlgItemMessage( hWnd, IDC_COMPUTER, WM_SETTEXT, 0, (LPARAM)&szComputerM[2]  );
        !          2500: 
        !          2501:                        }
        !          2502: 
        !          2503:                        }
        !          2504: 
        !          2505:            // set initial states of buttons to disabled
        !          2506: 
        !          2507:            EnableWindow( GetDlgItem( hGlobalhWnd, IDC_ADD    ), FALSE );
        !          2508:            EnableWindow( GetDlgItem( hGlobalhWnd, IDC_CHANGE ), FALSE );
        !          2509:                EnableWindow( GetDlgItem( hGlobalhWnd, IDC_REMOVE ), FALSE );
        !          2510: 
        !          2511:                // initialize the commands window
        !          2512: 
        !          2513:                SendDlgItemMessage( hWnd, IDC_ATCOMMANDS, LB_ADDSTRING, 0, (LPARAM)"Initializing" );
1.1       root     2514: 
1.1.1.2 ! root     2515:                // set up timer to go off very soon after the dlgbox is created
1.1       root     2516: 
1.1.1.2 ! root     2517:            uTimer = SetTimer( hWnd, 1, 1000, NULL );
        !          2518:            fTimer = FIRST_TIME;
        !          2519:            Refresh( REFRESH_TRUE );
        !          2520: 
        !          2521: 
        !          2522:            GlobalMessageHandle = LoadLibrary( "netmsg.dll" );
        !          2523: 
        !          2524:            if ( GlobalMessageHandle == NULL ) {
1.1       root     2525: 
                   2526: ;//                MessagePrint( IDS_LOAD_LIBRARY_FAILURE, GetLastError() );
                   2527: 
1.1.1.2 ! root     2528:            }
        !          2529: 
        !          2530:            break;
        !          2531: 
        !          2532:        case WM_TIMER:
1.1       root     2533: 
                   2534:                        if ( fTimer == FIRST_TIME ) {
1.1.1.2 ! root     2535: 
1.1       root     2536:                                uTimer = SetTimer( hWnd, 1, REFRESH_RATE, NULL );
1.1.1.2 ! root     2537: 
1.1       root     2538:                                fTimer = !FIRST_TIME;
1.1.1.2 ! root     2539: 
1.1       root     2540:                        }
                   2541: 
1.1.1.2 ! root     2542:            if ( Refresh( REFRESH_QUERY ) == TRUE ) {
1.1       root     2543: 
1.1.1.2 ! root     2544:                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_NOCHANGE );
        !          2545: 
        !          2546:            }
        !          2547: 
        !          2548:            break;
        !          2549: 
        !          2550:        case WM_COMMAND:    // message: command from application menu
        !          2551: 
        !          2552:            // Message packing of uParam and lParam have changed for Win32, let us
        !          2553:            // handle the differences in a conditional compilation:
1.1       root     2554: 
                   2555:                        wmId    = LOWORD(uParam);
                   2556:                        wmEvent = HIWORD(uParam);
                   2557: 
                   2558:                        switch (wmId) {
                   2559: 
                   2560:                                case IDC_ATCOMMANDS:
                   2561: 
1.1.1.2 ! root     2562:                            if ( LBN_DBLCLK == wmEvent ) {
        !          2563: 
        !          2564:                                if ( IsWindowEnabled( GetDlgItem( hWnd, IDC_CHANGE ) ) ) {
        !          2565: 
        !          2566:                                        PostMessage( hWnd, WM_COMMAND, IDC_CHANGE, 0 );
        !          2567: 
        !          2568:                                }
        !          2569: 
        !          2570:                            }
        !          2571: 
        !          2572:                                break;
        !          2573: 
        !          2574:                case IDC_REFRESH:
        !          2575: 
        !          2576:                    if ( Refresh( REFRESH_QUERY ) == TRUE ) {
        !          2577: 
        !          2578:                            Refresh( REFRESH_FALSE );
        !          2579: 
        !          2580:                            hCursorOld = SetCursor( hCursorWait );
        !          2581: 
        !          2582:                            status = JobEnum( lParam );
        !          2583: 
        !          2584:                            SetCursor( hCursorOld );
        !          2585: 
        !          2586:                            if ( status == NERR_Success || status == ERROR_SUCCESS ) {
        !          2587: 
        !          2588:                                Refresh( REFRESH_TRUE );
        !          2589: 
        !          2590:                            }
        !          2591: 
        !          2592:                        }
1.1       root     2593: 
1.1.1.2 ! root     2594:                    break;
1.1       root     2595: 
                   2596:                                case IDC_ADD:
1.1.1.2 ! root     2597: 
1.1       root     2598:                                    Refresh( REFRESH_FALSE );
1.1.1.2 ! root     2599: 
1.1       root     2600:                                    lpAddChangeDlgProc = MakeProcInstance((FARPROC)AddChangeDlgProc, hInstance);
1.1.1.2 ! root     2601: 
1.1       root     2602:                                    iDlgRetCode = DialogBoxParam(
1.1.1.2 ! root     2603:                                        hInst,
        !          2604:                                        "ADDCHANGEDLG",
        !          2605:                                        hWnd,
        !          2606:                                        (DLGPROC)lpAddChangeDlgProc,
        !          2607:                                        IDC_ADD);
        !          2608: 
1.1       root     2609:                                    hGlobalAddChg = NULL;
1.1.1.2 ! root     2610: 
1.1       root     2611:                                    FreeProcInstance(lpAddChangeDlgProc);
                   2612:                                    FreeProcInstance(lpAmPmProc);
                   2613:                                    FreeProcInstance(lpAmPmDefProc);
                   2614:                                    FreeProcInstance(lpHourProc);
                   2615:                                    FreeProcInstance(lpHourDefProc);
                   2616:                                    FreeProcInstance(lpMinProc);
1.1.1.2 ! root     2617:                                    FreeProcInstance(lpMinDefProc);
1.1       root     2618:                                    FreeProcInstance(lpDownButtonProc);
                   2619:                                    FreeProcInstance(lpDownButtonDefProc);
                   2620:                                    FreeProcInstance(lpUpButtonProc);
                   2621:                                    FreeProcInstance(lpUpButtonDefProc);
                   2622: 
                   2623:                                    Refresh( REFRESH_TRUE );
1.1.1.2 ! root     2624: 
1.1       root     2625:                                    if ( iDlgRetCode == IDOK ) {
1.1.1.2 ! root     2626: 
        !          2627:                                        SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_BOTTOM );
        !          2628: 
1.1       root     2629:                                    }
1.1.1.2 ! root     2630: 
        !          2631:                    break;
        !          2632: 
        !          2633:                case IDC_CHANGE:
        !          2634: 
        !          2635:                        Refresh( REFRESH_FALSE );
        !          2636: 
        !          2637:                    lpAddChangeDlgProc = MakeProcInstance((FARPROC)AddChangeDlgProc, hInstance);
        !          2638: 
1.1       root     2639:                                    iDlgRetCode = DialogBoxParam(
1.1.1.2 ! root     2640:                                        hInst,
        !          2641:                                        "ADDCHANGEDLG",
        !          2642:                                        hWnd,
        !          2643:                                        (DLGPROC)lpAddChangeDlgProc,
        !          2644:                                        IDC_CHANGE);
        !          2645: 
1.1       root     2646:                                    hGlobalAddChg = NULL;
1.1.1.2 ! root     2647: 
1.1       root     2648:                                    FreeProcInstance(lpAddChangeDlgProc);
                   2649:                                    FreeProcInstance(lpAmPmProc);
                   2650:                                    FreeProcInstance(lpAmPmDefProc);
                   2651:                                    FreeProcInstance(lpHourProc);
                   2652:                                    FreeProcInstance(lpHourDefProc);
                   2653:                                    FreeProcInstance(lpMinProc);
                   2654:                                    FreeProcInstance(lpMinDefProc);
                   2655:                                    FreeProcInstance(lpDownButtonProc);
                   2656:                                    FreeProcInstance(lpDownButtonDefProc);
                   2657:                                    FreeProcInstance(lpUpButtonProc);
                   2658:                                    FreeProcInstance(lpUpButtonDefProc);
1.1.1.2 ! root     2659: 
1.1       root     2660:                                        Refresh( REFRESH_TRUE );
1.1.1.2 ! root     2661: 
1.1       root     2662:                                    if ( iDlgRetCode == IDOK ) {
1.1.1.2 ! root     2663: 
        !          2664:                                        SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_BOTTOM );
        !          2665: 
1.1       root     2666:                                    }
                   2667: 
1.1.1.2 ! root     2668:                    break;
1.1       root     2669: 
1.1.1.2 ! root     2670:                case IDC_REMOVE:
1.1       root     2671: 
1.1.1.2 ! root     2672:                    status = JobDel( DEL_ID, hWnd );
1.1       root     2673: 
1.1.1.2 ! root     2674:                        break;
        !          2675: 
        !          2676:                case IDM_GET_FROM_REGISTRY:
1.1       root     2677: 
1.1.1.2 ! root     2678:                    RegCreateKeyEx(REG_HKEY,
        !          2679:                                   szRegistryPath,
        !          2680:                                   0,
        !          2681:                                   "",
        !          2682:                                   REG_OPTION_NON_VOLATILE,
        !          2683:                                   KEY_ALL_ACCESS,
        !          2684:                                   NULL,
        !          2685:                                   &hkHandle,
        !          2686:                                   &dwDisposition);
1.1       root     2687: 
1.1.1.2 ! root     2688:                    if ( dwDisposition == REG_CREATED_NEW_KEY ) {
1.1       root     2689: 
1.1.1.2 ! root     2690:                        RegSetValueEx(hkHandle, "dwX", 0, REG_DWORD, (LPBYTE)DWX, sizeof(DWORD));
        !          2691:                        RegSetValueEx(hkHandle, "dwY", 0, REG_DWORD, (LPBYTE)DWY, sizeof(DWORD));
1.1       root     2692: 
1.1.1.2 ! root     2693:                    }
1.1       root     2694: 
1.1.1.2 ! root     2695:                    {
        !          2696:                        DWORD dwType = REG_DWORD;
        !          2697:                        DWORD dwSize = sizeof(DWORD);
1.1       root     2698: 
1.1.1.2 ! root     2699:                        RegQueryValueEx(hkHandle, "dwX", 0, &dwType, (LPBYTE)&dwX, &dwSize);
        !          2700:                        RegQueryValueEx(hkHandle, "dwY", 0, &dwType, (LPBYTE)&dwY, &dwSize);
1.1       root     2701: 
1.1.1.2 ! root     2702:                    }
1.1       root     2703: 
1.1.1.2 ! root     2704:                    RegCloseKey(hkHandle);
1.1       root     2705: 
1.1.1.2 ! root     2706:                    {
        !          2707:                        RECT Rect;
1.1       root     2708: 
1.1.1.2 ! root     2709:                        if(!GetWindowRect(hWnd, &Rect)) {
1.1       root     2710: 
1.1.1.2 ! root     2711:                            MessageBox(
        !          2712:                                hWnd,
        !          2713:                                "Problem getting window coordinates.",
        !          2714:                                SZWINDOWTITLE,
        !          2715:                                MB_OK | MB_ICONEXCLAMATION
        !          2716:                                );
1.1       root     2717: 
1.1.1.2 ! root     2718:                        } else {
1.1       root     2719: 
1.1.1.2 ! root     2720:                            dwW = Rect.right  - Rect.left;
        !          2721:                            dwH = Rect.bottom - Rect.top;
1.1       root     2722: 
1.1.1.2 ! root     2723:                        }
1.1       root     2724: 
1.1.1.2 ! root     2725:                    }
1.1       root     2726: 
1.1.1.2 ! root     2727:                    MoveWindow(hWnd, (INT)dwX, (INT)dwY, (INT)dwW, (INT)dwH, TRUE);
1.1       root     2728: 
1.1.1.2 ! root     2729:                    break;
1.1       root     2730: 
1.1.1.2 ! root     2731:                 case IDM_SAVE_TO_REGISTRY:
1.1       root     2732: 
1.1.1.2 ! root     2733:                    RegCreateKeyEx(REG_HKEY,
        !          2734:                                   szRegistryPath,
        !          2735:                                   0,
        !          2736:                                   "",
        !          2737:                                   REG_OPTION_NON_VOLATILE,
        !          2738:                                   KEY_ALL_ACCESS,
        !          2739:                                   NULL,
        !          2740:                                   &hkHandle,
        !          2741:                                   &dwDisposition
        !          2742:                                   );
        !          2743: 
        !          2744:                    {
        !          2745:                        RECT Rect;
        !          2746: 
        !          2747:                        if(!GetWindowRect(hWnd, &Rect)) {
        !          2748: 
        !          2749:                            dwX = DWX;
        !          2750:                            dwY = DWY;
        !          2751: 
        !          2752:                            MessageBox(
        !          2753:                                hWnd,
        !          2754:                                "Problem getting coordinates.",
        !          2755:                                SZWINDOWTITLE,
        !          2756:                                MB_OK | MB_ICONEXCLAMATION
        !          2757:                                );
1.1       root     2758: 
1.1.1.2 ! root     2759:                        } else {
1.1       root     2760: 
1.1.1.2 ! root     2761:                            dwX = Rect.left;
        !          2762:                            dwY = Rect.top;
1.1       root     2763: 
1.1.1.2 ! root     2764:                        }
1.1       root     2765: 
1.1.1.2 ! root     2766:                    }
1.1       root     2767: 
1.1.1.2 ! root     2768:                    RegSetValueEx(hkHandle, "dwX", 0, REG_DWORD, (LPBYTE)&dwX, sizeof(DWORD));
        !          2769:                    RegSetValueEx(hkHandle, "dwY", 0, REG_DWORD, (LPBYTE)&dwY, sizeof(DWORD));
1.1       root     2770: 
1.1.1.2 ! root     2771:                    RegCloseKey(hkHandle);
1.1       root     2772: 
1.1.1.2 ! root     2773:                    break;
1.1       root     2774: 
1.1.1.2 ! root     2775:                case IDM_ABOUT:
1.1       root     2776: 
                   2777:                                        Refresh( REFRESH_SAVE );
1.1.1.2 ! root     2778:                    Refresh( REFRESH_FALSE );
        !          2779: 
        !          2780: // jean-marc - start
        !          2781:                    if ( ShellAbout( hGlobalhWnd, SZWINDOWTITLE, NULL, LoadIcon( hInst, (LPSTR)SZAPPTITLE ) ) == -1 ) {
        !          2782: //old line                 if ( ShellAbout( hGlobalhWnd, SZWINDOWTITLE, SZCREDITS, LoadIcon( hInst, (LPSTR)SZAPPTITLE ) ) == -1 ) {
        !          2783: // jean-marc - end
        !          2784: 
        !          2785:                        MessageBox( hGlobalhWnd, "Out of memory error.", SZWINDOWTITLE, MB_OK | MB_ICONEXCLAMATION );
        !          2786: 
        !          2787:                    }
        !          2788: 
1.1       root     2789:                                        Refresh( REFRESH_RESTORE );
1.1.1.2 ! root     2790: 
1.1       root     2791:                                        break;
1.1.1.2 ! root     2792: 
        !          2793:                case IDM_SELECTCOMPUTER:
        !          2794: 
        !          2795:                    Refresh( REFRESH_SAVE );
        !          2796:                    Refresh( REFRESH_FALSE );
        !          2797: 
        !          2798:                    lpProcSelect = MakeProcInstance((FARPROC)SelectComputerProc, hInst);
        !          2799: 
        !          2800:                                        iDlgRetCode = DialogBox(hInst,
        !          2801:                                                "SelectComputer",
        !          2802:                                                hWnd,
1.1       root     2803:                                                (DLGPROC)lpProcSelect);
                   2804: 
                   2805:                                        FreeProcInstance(lpProcSelect);
1.1.1.2 ! root     2806: 
        !          2807:                    Refresh( REFRESH_TRUE );
        !          2808: 
1.1       root     2809:                                        if ( iDlgRetCode == IDOK ) {
1.1.1.2 ! root     2810: 
1.1       root     2811:                                                SendMessage( hWnd, WM_COMMAND, IDC_REFRESH, (LPARAM)SCS_TOP );
1.1.1.2 ! root     2812: 
1.1       root     2813:                                        }
1.1.1.2 ! root     2814: 
        !          2815:                        break;
        !          2816: 
        !          2817:                case IDM_EXIT:
        !          2818: 
        !          2819:                    Refresh( REFRESH_FALSE );
        !          2820:                    FFreeListboxExtents( GetDlgItem( hWnd, IDC_ATCOMMANDS ) );
        !          2821:                    ShowWindow( hWnd, SW_RESTORE );
        !          2822:                    SendMessage( hWnd, WM_COMMAND, IDM_SAVE_TO_REGISTRY, 0 );
        !          2823:                    DeleteObject( hFont );
        !          2824: // jean-marc - start
        !          2825:                    if (hFontComputerName)
        !          2826:                      DeleteObject(hFontComputerName);
        !          2827: // jean-marc - end
        !          2828:                    KillTimer( hWnd, 1 );
        !          2829:                    EndDialog( hWnd, 0 );
        !          2830: 
1.1       root     2831:                                        break;
                   2832: 
1.1.1.2 ! root     2833:                case IDC_HELP:
        !          2834: 
        !          2835:                    if (!WinHelp (hWnd, "WINAT.HLP", HELP_KEY,(DWORD)(LPSTR)"CONTENTS")) {
1.1       root     2836:                                                MessageBox (GetFocus(),
                   2837:                                                        "Unable to activate help",
                   2838:                                                        SZWINDOWTITLE, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);
1.1.1.2 ! root     2839:                    }
1.1       root     2840:                                        break;
                   2841: 
1.1.1.2 ! root     2842:                case IDM_HELPCONTENTS:
        !          2843: 
        !          2844:                    if (!WinHelp (hWnd, "WINAT.HLP", HELP_KEY,(DWORD)(LPSTR)"CONTENTS")) {
1.1       root     2845:                                                MessageBox (GetFocus(),
                   2846:                                                        "Unable to activate help",
                   2847:                                                        SZWINDOWTITLE, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);
1.1.1.2 ! root     2848:                    }
1.1       root     2849: 
1.1.1.2 ! root     2850:                    break;
1.1       root     2851: 
                   2852:                                case IDM_HELPSEARCH:
                   2853: 
1.1.1.2 ! root     2854:                    if (!WinHelp(hWnd, "WINAT.HLP", HELP_PARTIALKEY, (DWORD)(LPSTR)"")) {
1.1       root     2855:                                                MessageBox (GetFocus(),
                   2856:                                                        "Unable to activate help",
                   2857:                                                        SZWINDOWTITLE, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);
1.1.1.2 ! root     2858:                    }
1.1       root     2859: 
1.1.1.2 ! root     2860:                    break;
1.1       root     2861: 
                   2862:                                case IDM_HELPHELP:
                   2863: 
1.1.1.2 ! root     2864:                    if(!WinHelp(hWnd, (LPSTR)NULL, HELP_HELPONHELP, 0)) {
1.1       root     2865:                                                MessageBox (GetFocus(),
                   2866:                                                        "Unable to activate help",
                   2867:                                                        SZWINDOWTITLE, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);
1.1.1.2 ! root     2868:                    }
1.1       root     2869: 
1.1.1.2 ! root     2870:                    break;
1.1       root     2871: 
1.1.1.2 ! root     2872:            }
1.1       root     2873: 
1.1.1.2 ! root     2874:            break;
1.1       root     2875: 
1.1.1.2 ! root     2876:        case WM_CLOSE:
        !          2877:        case WM_ENDSESSION:
1.1       root     2878: 
1.1.1.2 ! root     2879:            SendMessage(hWnd, WM_COMMAND, IDM_EXIT, 0);
1.1       root     2880: 
1.1.1.2 ! root     2881:            break;
1.1       root     2882: 
                   2883:     }
                   2884: 
                   2885:     return (0);
                   2886: 
                   2887: }
                   2888: 
                   2889: 
                   2890: 
                   2891: //===========================================================================
                   2892: // FUNCTION: WinMain()
                   2893: //===========================================================================
                   2894: int APIENTRY WinMain(
                   2895:        HANDLE hInstance,
                   2896:        HANDLE hPrevInstance,
                   2897:        LPSTR lpCmdLine,
                   2898:        int nCmdShow)
                   2899: {
                   2900: 
                   2901:     FARPROC   lpWINATDlgProc;
                   2902:     WNDCLASS  wc;
                   2903: 
                   2904:     hInst       = hInstance;
                   2905: 
                   2906:        // Fill in window class structure with parameters that describe the
                   2907:        // main window.
                   2908: 
                   2909:     wc.style         = CS_HREDRAW | CS_VREDRAW;
                   2910:     wc.lpfnWndProc   = (WNDPROC)DefDlgProc;
                   2911:     wc.cbClsExtra    = 0;
                   2912:     wc.cbWndExtra    = DLGWINDOWEXTRA;
                   2913:     wc.hInstance     = hInstance;
                   2914:     wc.hIcon         = LoadIcon (hInstance, szAppName);
                   2915:     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
                   2916:     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
                   2917:     wc.lpszMenuName  = szAppName;
                   2918:     wc.lpszClassName = szAppName;
                   2919: 
                   2920:     // Register the window class
                   2921: 
                   2922:     RegisterClass(&wc);
                   2923: 
1.1.1.2 ! root     2924: // jean-marc - start
        !          2925:     // store the commandline (only copy over MAXCOMPUTERNAMELEN characters)
        !          2926:     memset(&gszCommandLine, 0, sizeof(gszCommandLine));
        !          2927:     strncpy(gszCommandLine, lpCmdLine, MAXCOMPUTERNAMELEN);
        !          2928:     // the commandline will actually be processed from within the WINATDlgProc
        !          2929: // jean-marc - end
1.1       root     2930: 
                   2931:     //
                   2932:     // this program is only a single dialog box
                   2933:     //
                   2934: 
                   2935:     lpWINATDlgProc = MakeProcInstance((FARPROC)WINATDlgProc, hInstance);
                   2936: 
                   2937:     DialogBox(hInstance,
1.1.1.2 ! root     2938:        "WINATDLG",
        !          2939:        0,
        !          2940:        (DLGPROC)lpWINATDlgProc
        !          2941:        );
1.1       root     2942: 
                   2943:     FreeProcInstance(lpWINATDlgProc);
1.1.1.2 ! root     2944: 
1.1       root     2945:     return 0;
                   2946: 
                   2947: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.