Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gotcha.cpp

    r13 r30  
    3434PFNWP       OldFrameWP, wpOldButton;
    3535PSETTINGS   pset;
    36 BOOL        g_fQuiet = FALSE;
     36BOOL        g_fQuiet = FALSE, g_fIdle = FALSE, g_fSetPathName = FALSE;
    3737HWND        g_hwndMenuSSW;
    3838HMODULE     g_hmod = NULLHANDLE;
     
    4444#include "savebmp.cpp"
    4545
    46 // ** CheckCmdlineArgs **************************************************** /*fold00*/
     46// ** CheckCmdlineArgs **************************************************** /*FOLD00*/
    4747
    4848BOOL CheckCmdlineArgs (int argc, char *argv[])
     
    7272                    pset->SetFileSaveStyle (FSS_NUMFILES);
    7373                    pset->SetNumSaveDir (argv[i]);
     74                    g_fSetPathName = TRUE;
    7475                }
    7576        }
     
    8283                pset->SetFileSaveStyle (FSS_FORCEFILE);
    8384                pset->SetForceSaveFile (argv[i]);
     85                g_fSetPathName = TRUE;
    8486            }
    8587        }
     
    8789        else if (stricmp (argv[i], "-i") == 0)
    8890        {
     91            g_fIdle = TRUE;
    8992            pset->SetFlag (SEI_IDLEPRIORITY, TRUE);
    9093        }
     
    111114
    112115    //DisplayError("DEBUG", "%d", Version());
    113 #ifdef _USEDLL_
    114     if (g_fQuiet && (Version() < 1))
     116#ifdef _QUIET_
     117    if ((Version() < 1))
    115118    {
    116119        DisplayError("GOTCHA.DLL TO OLD",
     
    123126        exit (0);
    124127    }
     128
     129    bool fPrtScr = FALSE;
     130    ULONG ulDataSize;
     131    int rc;
     132
     133    rc = PrfQueryProfileSize( HINI_PROFILE, "PM_ControlPanel", "PrintScreen",
     134                             &ulDataSize );
     135    rc = PrfQueryProfileData(HINI_USERPROFILE, "PM_ControlPanel", "PrintScreen",
     136                             &fPrtScr, &ulDataSize);
     137    if (fPrtScr || !rc) {
     138        fPrtScr = TRUE;
     139        bool temp = FALSE;
     140        rc = PrfWriteProfileData(HINI_USERPROFILE, "PM_ControlPanel", "PrintScreen",
     141                                 &temp, sizeof(bool));
     142    }
    125143#endif
    126144
     
    134152    pset = new SETTINGS;
    135153
     154    pset->idleSetInIni = pset->QueryFlag(SEI_IDLEPRIORITY);
     155    pset->saveStyle = pset->QuerySaveStyle ();
     156    pset->pNumSaveDir = pset->QueryNumSaveDir ();
     157    pset->pForceSaveFile = pset->QueryForceSaveFile();
     158    pset->bSerialCapture = pset->SerialCapture ();
    136159    // check cmd line args and if "-a" found take screenshot and exit
    137160    if (CheckCmdlineArgs (argc, argv))
    138161    {
    139162        CaptureWindow (HWND_DESKTOP, HWND_DESKTOP, NULL, TRUE);
     163        pset->SetFileSaveStyle(pset->saveStyle);
    140164        delete pset;
    141165        WinDestroyMsgQueue (hmq);
     
    159183
    160184    // init the quiet mode
    161     if (g_fQuiet)
    162     {
    163 #ifdef _USEDLL_
     185    //if (g_fQuiet)
     186    //{
     187#ifdef _QUIET_
     188//#if 1
     189    DebugHereIAm();
    164190        InitDLL (hab, hwndFrame);
    165191        StartInputHook ();
    166192#endif
    167193
    168         CHAR ach[61];
    169         WinQueryWindowText (hwndFrame, sizeof (ach), ach);
    170         strcat (ach, RSTR (IDS_QUIETMODE));
    171         WinSetWindowText (hwndFrame, ach);
    172         WinSetWindowPos (hwndFrame, NULLHANDLE, 0,0, 0,0, SWP_MINIMIZE);
    173     }
     194        //CHAR ach[61];
     195        //WinQueryWindowText (hwndFrame, sizeof (ach), ach);
     196        //strcat (ach, RSTR (IDS_QUIETMODE));
     197        //WinSetWindowText (hwndFrame, ach);
     198        //WinSetWindowPos (hwndFrame, NULLHANDLE, 0,0, 0,0, SWP_MINIMIZE);
     199        //HSWITCH hswitch = WinQuerySwitchHandle(hwndFrame, 0);
     200        //WinRemoveSwitchEntry(hswitch);
     201    //}
    174202
    175203    // position snapshot window
     
    196224        WinDispatchMsg (hab, &qmsg);
    197225
     226
     227    // Set priorty to unless user set regular since running -q sets it to idle in the ini
     228    if (g_fIdle || g_fQuiet) {
     229        pset->SetFlag (SEI_IDLEPRIORITY, pset->idleSetInIni);
     230        if (g_fQuiet) {
     231            pset->SetFileSaveStyle (pset->saveStyle); // changed with -q
     232            pset->SerialCapture (pset->bSerialCapture); // changed with -q
     233        }
     234    }
     235    // Don't change the ini stored paths if the paths were set from the command line
     236    if (g_fSetPathName) {
     237        pset->SetFileSaveStyle(pset->saveStyle);
     238        pset->SetForceSaveFile (pset->pForceSaveFile);
     239        pset->SetNumSaveDir (pset->pNumSaveDir);
     240    }
    198241    // save size, etc. of snapshot window
    199242    WinQueryWindowPos (hwndSnapshot, &swp);
     
    208251    WinDestroyWindow (hwndFrame);
    209252
    210 #ifdef _USEDLL_
    211     if (g_fQuiet)
     253#ifdef _QUIET_
     254//#if 1
     255    if (fPrtScr || !rc) {
     256        PrfWriteProfileData(HINI_USERPROFILE, "PM_ControlPanel", "PrintScreen",
     257                            &fPrtScr, sizeof(bool));
     258    }
     259    //if (g_fQuiet)
    212260        StopInputHook ();
    213261#endif
     
    242290}
    243291
    244 // ** AddSysMenuItem ****************************************************** /*fold00*/
     292APIRET saymsg2(int DefaultButton, HWND hwnd,  PCSZ pszTitle, PCSZ pszFmt, ...)
     293{
     294  ULONG i;
     295  APIRET rc;
     296  CHAR szMsg[4096];
     297  va_list va;
     298  MB2INFO *pmbInfo;
     299  MB2D mb2dBut[3];
     300  ULONG ulInfoSize = (sizeof(MB2INFO) + (sizeof(MB2D) * 2));
     301
     302  va_start(va, pszFmt);
     303  szMsg[sizeof(szMsg) - 1] = 0;
     304  vsprintf(szMsg, pszFmt, va);
     305  va_end(va);
     306
     307  if (szMsg[sizeof(szMsg) - 1]) {
     308    fprintf(stderr, "Buffer overflow in saymsg2 - need %u bytes\n", strlen(szMsg) + 1);
     309    fflush(stderr);
     310  }
     311
     312  memset(mb2dBut, 0, sizeof(MB2D) * 3);
     313  strcpy(mb2dBut[0].achText,"Ok");
     314  strcpy(mb2dBut[1].achText,"Cancel");
     315  strcpy(mb2dBut[2].achText,"Settings");
     316  mb2dBut[0].idButton = 1;
     317  mb2dBut[1].idButton = 2;
     318  mb2dBut[2].idButton = 3;
     319  if (DefaultButton)
     320    mb2dBut[DefaultButton - 1].flStyle = BS_DEFAULT;
     321  pmbInfo = (MB2INFO *) malloc(ulInfoSize);
     322  memset(pmbInfo, 0, ulInfoSize);
     323  if (pmbInfo) {
     324    pmbInfo->cb         = ulInfoSize;
     325    pmbInfo->hIcon      = 0;
     326    pmbInfo->cButtons   = 3;
     327    pmbInfo->flStyle    = MB_MOVEABLE | MB_ICONQUESTION ;
     328    pmbInfo->hwndNotify = NULLHANDLE;
     329    for (i = 0; i < 3; i++) {
     330      memcpy( pmbInfo->mb2d+i , mb2dBut+i , sizeof(MB2D));
     331    }
     332    rc = WinMessageBox2(HWND_DESKTOP, hwnd,
     333                        szMsg, pszTitle, SM2_DIALOG,
     334                        pmbInfo);
     335    WinSetFocus(HWND_DESKTOP, SM2_DIALOG);
     336    free(pmbInfo);
     337    return rc;
     338  }
     339  return MBID_ERROR;
     340}
     341// ** AddSysMenuItem ****************************************************** /*FOLD00*/
    245342
    246343VOID AddSysMenuItem (HWND hwndFrame, MENUITEM *Item, PSZ Text)
     
    273370VOID SetIdlePriority (BOOL f)
    274371{
     372#if 0 //#ifndef _QUEIT_
    275373    if (f)
    276374        DosSetPriority(PRTYS_PROCESS, PRTYC_IDLETIME, 0, 0);
    277375    else
    278376        DosSetPriority(PRTYS_PROCESS, PRTYC_REGULAR, 0, 0);
     377#else
     378    DosSetPriority(PRTYS_PROCESS, PRTYC_FOREGROUNDSERVER, 0, 0);
     379#endif
    279380}
    280381
Note: See TracChangeset for help on using the changeset viewer.