Changeset 1686 for trunk/dll/errutil.c


Ignore:
Timestamp:
Mar 10, 2013, 7:34:34 PM (12 years ago)
Author:
Gregg Young
Message:

GKY Improvrd readonly check on delete to allow cancel and don't ask again options; Added saymsg2 for this purpose; Fixes to snapshot file. cs 1685 contained the COMP.C changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/errutil.c

    r1673 r1686  
    3636                works in HIMEM builds
    3737  01 Dec 10 SHL Dos_Error - remap API errors code that with odd oso001*.msg messages
     38  10 Mar 13 GKY Improvrd readonly check on delete to allow cancel and don't ask again options
     39                Added saymsg2 for this purpose
    3840
    3941***********************************************************************/
     
    4244#include <string.h>
    4345#include <stdarg.h>
     46#include <stdlib.h>
    4447
    4548#define INCL_DOS
     
    5457#include "notebook.h"                   // fErrorBeepOff
    5558#include "init.h"                       // Data declares
     59#include "wrappers.h"                   // xmallocz
    5660
    5761#pragma data_seg(DATA1)
     
    348352} // saymsg
    349353
     354APIRET saymsg2(PCSZ pszButtonNames, int DefaultButton, HWND hwnd, PCSZ pszTitle, PCSZ pszFmt, ...)
     355{
     356  ULONG   i;
     357  APIRET  rc;
     358  CHAR szMsg[4096];
     359  va_list va;
     360  MB2INFO *pmbInfo;     
     361  MB2D mb2dBut[4];   
     362  ULONG   ulInfoSize = (sizeof(MB2INFO) + (sizeof(MB2D) * 3));
     363
     364  va_start(va, pszFmt);
     365  szMsg[sizeof(szMsg) - 1] = 0;
     366  vsprintf(szMsg, pszFmt, va);
     367  va_end(va);
     368
     369  if (szMsg[sizeof(szMsg) - 1]) {
     370    fprintf(stderr, "Buffer overflow in saymsg2 - need %u bytes\n", strlen(szMsg) + 1);
     371    fflush(stderr);
     372  }
     373
     374  memset(mb2dBut, 0, sizeof(MB2D) * 4);
     375  //fixme to use GetPString
     376  strcpy(mb2dBut[0].achText, /*pszButtonNames[0] ? &pszButtonNames[0] :*/ GetPString(IDS_MB2DYES));
     377  strcpy(mb2dBut[1].achText, /*pszButtonNames[1] ? &pszButtonNames[1] :*/ GetPString(IDS_MB2DYESDONTASK));
     378  strcpy(mb2dBut[2].achText, /*pszButtonNames[2] ? &pszButtonNames[2] :*/ GetPString(IDS_MB2DNO));
     379  strcpy(mb2dBut[3].achText,/* pszButtonNames[3] ? &pszButtonNames[3] :*/ GetPString(IDS_MB2DCANCELOP));
     380  mb2dBut[0].idButton = 1;
     381  mb2dBut[1].idButton = 2;
     382  mb2dBut[2].idButton = 3;
     383  mb2dBut[3].idButton = 4;
     384  if (DefaultButton)
     385    mb2dBut[DefaultButton - 1].flStyle = BS_DEFAULT;
     386  pmbInfo = xmallocz(ulInfoSize, pszSrcFile, __LINE__);
     387  if (pmbInfo) {
     388    pmbInfo->cb         = ulInfoSize;       
     389    pmbInfo->hIcon      = 0;
     390    pmbInfo->cButtons   = 4;
     391    pmbInfo->flStyle    = MB_MOVEABLE;
     392    pmbInfo->hwndNotify = NULLHANDLE;
     393    for (i = 0; i < 4; i++) {
     394      memcpy( pmbInfo->mb2d+i , mb2dBut+i , sizeof(MB2D));
     395    }
     396    rc = WinMessageBox2(HWND_DESKTOP, hwnd,
     397                        szMsg, pszTitle, 1234,
     398                        pmbInfo);
     399    free(pmbInfo);
     400    return rc;
     401  }
     402  return MBID_ERROR;
     403}
     404
    350405//=== showMsg: display error popup ===
    351406
Note: See TracChangeset for help on using the changeset viewer.