void main (void) { QMSG qmsg; HMQ hmq; HWND hwndClient; ULONG flFrameFlags; WinInitialize(0); hmq = WinCreateMsgQueue(hab, 0); /* get access to shared memory */ DosGetNamedSharedMem((PVOID*)&memptr, MEM_NAME, PAG_READ); if (!memptr) WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, " FreeType/2 is not running!", "Error", 0, MB_OK | MB_ERROR); else { meminfo = memptr->address; if (meminfo->signature != 0x46524545) WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, " FreeType/2 is not running!", "Error", 0, MB_OK | MB_ERROR); else { flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST ; WinRegisterClass(hab, "MyClass", (PFNWP) ClientWndProc, CS_SIZEREDRAW, 0); hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flFrameFlags, "MyClass", "FreeType/2 Heap Usage", 0, (HMODULE) NULL, 0, &hwndClient); WinSetVisibleRegionNotify(hwndClient, TRUE); /* make titlebar text look better */ WinSetPresParam(WinWindowFromID(hwndFrame, FID_TITLEBAR), PP_FONTNAMESIZE, 9, (PVOID)"8.Helv"); WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 350, 42, SWP_MOVE | SWP_SIZE | SWP_SHOW); while (WinGetMsg(hab, &qmsg, (HWND) NULL, 0, 0)) WinDispatchMsg(hab, &qmsg); WinSetVisibleRegionNotify(hwndClient, FALSE); } } /* free shared memory block */ DosFreeMem(memptr); WinDestroyWindow(hwndFrame); WinDestroyMsgQueue(hmq); WinTerminate(hab); }
ULONG rexxFunc1(PSZ name, PLONG argc, RXSTRING argv[], PSZ queuename,PRXSTRING retstring, LONG next) { PRXSTRING prx; char text[200]; DosBeep(1000, 100); DosBeep(2000, 100); DosBeep(3000, 100); DosBeep(2000, 100); DosBeep(1000, 100); prx=&argv[0]; // prx=(RXSTRING*)(*prx); sprintf(text, "%x %x %s %d ", argc, prx->strlength, prx->strptr,123); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE); prx++; sprintf(text, "%x %x %s %d ", argc, prx->strlength, prx->strptr,123); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE); #if 0 if(argc==1) { sprintf(text, "%s %x",argv[0].strptr, atol(argv[0].strptr)); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE); } else { #endif #if 0 } #endif return 0; }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static CHAR *szMenuText [3] = { NULL, "A~bout PoorMenu...", "~Help..." } ; static MENUITEM mi [3] = { MIT_END, MIS_SEPARATOR, 0, 0, 0, 0, MIT_END, MIS_TEXT, 0, IDM_ABOUT, 0, 0, MIT_END, MIS_TEXT, 0, IDM_HELP, 0, 0 } ; HWND hwndSysMenu, hwndSysSubMenu ; INT iItem, idSysMenu ; MENUITEM miSysMenu ; switch (msg) { case WM_CREATE: hwndSysMenu = WinWindowFromID ( WinQueryWindow (hwnd, QW_PARENT), FID_SYSMENU) ; idSysMenu = SHORT1FROMMR (WinSendMsg (hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL)) ; WinSendMsg (hwndSysMenu, MM_QUERYITEM, MPFROM2SHORT (idSysMenu, FALSE), MPFROMP (&miSysMenu)) ; hwndSysSubMenu = miSysMenu.hwndSubMenu ; for (iItem = 0 ; iItem < 3 ; iItem++) WinSendMsg (hwndSysSubMenu, MM_INSERTITEM, MPFROMP (mi + iItem), MPFROMP (szMenuText [iItem])) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_ABOUT: WinMessageBox (HWND_DESKTOP, hwnd, "(C) Charles Petzold, 1993", szCaption, 0, MB_OK | MB_INFORMATION) ; return 0 ; case IDM_HELP: WinMessageBox (HWND_DESKTOP, hwnd, "Help not yet implemented", szCaption, 0, MB_OK | MB_WARNING) ; return 0 ; } break ; case WM_ERASEBACKGROUND: return MRFROMSHORT (1) ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
VOID DispErrorMsg(HAB hab, HWND hwndFrame, PCH FileName, LONG LineNum) { PERRINFO pErrInfoBlk; PSZ pszOffSet, pszErrMsg; ERRORID ErrorId; PCH ErrorStr; CHAR szbuff[125]; DosBeep(800,10); #if defined(DEBUG) DosBeep(800,10); DosBeep(800,10); DosBeep(800,10); DosBeep(800,10); DosBeep(800,10); #endif /* defined(DEBUG) */ if (!hab) { /* Non-PM Error */ WinLoadString( habMain,0, IDS_UNKNOWNMSG, sizeof(szbuff), (PSZ)szbuff); ErrorStr = (char*) malloc(strlen(szbuff)+strlen(FileName)+10); sprintf(ErrorStr, szbuff, FileName, LineNum); WinMessageBox(HWND_DESKTOP, /* Parent window is desk top */ hwndFrame, /* Owner window is our frame */ (PSZ)ErrorStr, /* PMWIN Error message */ szErrorTitle, /* Title bar message */ MSGBOXID, /* Message identifier */ MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL ); /* Flags */ free(ErrorStr); return; } ErrorId = WinGetLastError(hab); if ((pErrInfoBlk = WinGetErrorInfo(hab)) != (PERRINFO)NULL) { pszOffSet = ((PSZ)pErrInfoBlk) + pErrInfoBlk->offaoffszMsg; pszErrMsg = ((PSZ)pErrInfoBlk) + *((PULONG)pszOffSet); WinLoadString( habMain,0, IDS_ERRORMSG, sizeof(szbuff), (PSZ)szbuff); ErrorStr = (char *)malloc(strlen(szbuff)+strlen(pszErrMsg)+strlen(FileName)+10); sprintf(ErrorStr, szbuff, pszErrMsg, FileName, LineNum); WinMessageBox(HWND_DESKTOP, /* Parent window is desk top */ hwndFrame, /* Owner window is our frame */ (PSZ)ErrorStr, /* PMWIN Error message */ szErrorTitle, /* Title bar message */ MSGBOXID, /* Message identifier */ MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL ); /* Flags */ free(ErrorStr); WinFreeErrorInfo(pErrInfoBlk); } }
VOID CheckSystemConfig( VOID ) { // Проверяем настройки в файле "Config.sys". CHAR File_name[ SIZE_OF_NAME ] = "*:\\Config.sys"; ULONG Boot_drive = 0; DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PULONG) &Boot_drive, sizeof( Boot_drive ) ); File_name[ 0 ] = (CHAR) Boot_drive + 64; ULONG Action = OPEN_ACTION_OPEN_IF_EXISTS; ULONG Mode = OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY; HFILE File = NULLHANDLE; ULONG Report = 0; APIRET RC = DosOpen( File_name, &File, &Report, 0, FILE_NORMAL, Action, Mode, NULL ); // Если файл был открыт: if( RC == NO_ERROR ) { // Отводим память для текста. PCHAR Text = NULL; ULONG Length = 65536; if( DosAllocMem( (PPVOID) &Text, Length, PAG_ALLOCATE ) != NO_ERROR ) { DosClose( File ); DosExit( EXIT_PROCESS, 0 ); } // Читаем настройки. memset( Text, 0, Length ); DosRead( File, Text, Length, &Length ); // Проверяем, есть ли в настройках путь к каталогу расширителя. BYTE Path_is_present = 1; if( !stristr( "NICE\\ENHANCER", Text ) ) Path_is_present = 0; // Освобождаем память. DosFreeMem( Text ); Text = NULL; // Закрываем файл. DosClose( File ); File = NULLHANDLE; // Если настройки заданы неправильно: if( !Path_is_present ) { // Показываем сообщение. CHAR Title[ SIZE_OF_TITLE ] = ""; GetEnhancerWindowTitle( Title ); if( QuerySystemCodePage() == RUSSIAN ) WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, StrConst_RU_No_path_in_Config_sys, Title, NULLHANDLE, NULLHANDLE ); else WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, StrConst_EN_No_path_in_Config_sys, Title, NULLHANDLE, NULLHANDLE ); // Выход. DosExit( EXIT_PROCESS, 0 ); } } // Возврат. return; }
/************************************************************************** * * Name : AbortXLogo * * Description: Report an error returned from an API service * * Concepts : use of message box to display information * * API's : DosBeep * WinGetErrorInfo * WinMessageBox * WinFreeErrorInfo * WinPostMsg * * Parameters : hwndFrame = frame window handle * hwndClient = client window handle * * Return : [none] * *************************************************************************/ VOID AbortXLogo(HWND hwndFrame, HWND hwndClient) { PERRINFO pErrInfoBlk; PSZ pszOffSet; void stdprint(void); DosBeep(100,10); if ((pErrInfoBlk = WinGetErrorInfo(hab)) != (PERRINFO)NULL) { pszOffSet = ((PSZ)pErrInfoBlk) + pErrInfoBlk->offaoffszMsg; pszErrMsg = ((PSZ)pErrInfoBlk) + *((PSHORT)pszOffSet); if ((INT)hwndFrame && (INT)hwndClient) WinMessageBox(HWND_DESKTOP, /* Parent window is desktop */ hwndFrame, /* Owner window is our frame */ (PSZ)pszErrMsg, /* PMWIN Error message */ "XLogo Error Message", /* Title bar message */ MSGBOXID, /* Message identifier */ MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL ); /* Flags */ WinFreeErrorInfo(pErrInfoBlk); } WinPostMsg(hwndClient, WM_QUIT, (MPARAM)NULL, (MPARAM)NULL); } /* End of AbortXLogo */
BOOL OpenPort(THREAD *pstThd) { ULONG ulAction; APIRET rc; CHAR szMsgString[200]; CHAR szCaption[80]; if ((rc = DosOpen(pstThd->stCfg.szPortName,&pstThd->hCom,&ulAction,0L,0,0x0001,0x21c2,0L)) != 0) { WinQueryWindowText(pstThd->hwndFrame,sizeof(szCaption),szCaption); // WinLoadString(pstThd->habAnchorBlk,NUL,EATM_DOSOPEN, // sizeof(szMsgString),szMsgString); sprintf(szMsgString,"Error opening %s\nError Code = %04X",pstThd->stCfg.szPortName,rc); WinMessageBox( HWND_DESKTOP, pstThd->hwndDlg, (PSZ)szMsgString, (PSZ)szCaption, NUL, MB_MOVEABLE | MB_OK | MB_CUAWARNING ); pstThd->hCom = 0; return(FALSE); } return(TRUE); }
VOID ExplainParams(VOID) { BOOL f = FALSE; CHAR szMsg[256]; GetNLSString(szMsg, sizeof(szMsg), ID_NDSI_SYNTAX); if (WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szMsg, (PSZ)NETSCDDE_TITLE, 0, MB_YESNO | MB_MOVEABLE) == MBID_YES) { // tell xwp to display the help PXWPGLOBALSHARED pXwpGlobalShared = NULL; if (!(DosGetNamedSharedMem((PVOID*)&pXwpGlobalShared, SHMEM_XWPGLOBAL, PAG_READ | PAG_WRITE))) { f = WinPostMsg(pXwpGlobalShared->hwndAPIObject, APIM_SHOWHELPPANEL, (MPARAM)ID_XSH_NETSCAPEDDE, 0); DosFreeMem(pXwpGlobalShared); } if (!f) DisplayError("Cannot open the %s online help. Maybe XWorkplace is not installed or not running.", NETSCDDE_TITLE); } }
/********************************************************************** * Function: CopyClipBoardData2TempFile * Info : Check clipboard for text data and copy them to temp file * Result : NO_ERROR, ERROR_ACCESS_DENIED, ERROR_OPEN_FAILED **********************************************************************/ ULONG CopyClipBoardData2TempFile(void) { ULONG Result = NO_ERROR, MsgID; PSZ pszMem; FILE *fp; int c; if (WinOpenClipbrd(Hab)) { pszMem = (PSZ) WinQueryClipbrdData(Hab, CF_TEXT); if (NULL == pszMem) Result = ERROR_INVALID_DATA; else { if (NULL != (fp = fopen(TempFile, "wb"))) { while (0 != (c = (int)(*pszMem))) { fputc(c, fp); ++pszMem; } fclose(fp); } else Result = ERROR_OPEN_FAILED; } WinCloseClipbrd(Hab); } else Result = ERROR_ACCESS_DENIED; if (NO_ERROR != Result) { switch(Result) { case ERROR_INVALID_DATA: MsgID = IDS_INVALID_CLIPBOARD_DATA; break; case ERROR_ACCESS_DENIED: MsgID = IDS_NO_CLIPBOARD_ACCESS; break; default: MsgID = IDS_GENERAL_PROCESS_FAILURE; break; } Len = WinLoadString(Hab, hRessourceModule, MsgID, MSGSTRN_MAXLEN, Msg); WinMessageBox(HWND_DESKTOP, hwndMainDialog, Msg, NULL, 0, MB_ERROR | MB_OK); } return Result; }
void MessageBox (ULONG idText, ULONG idTitle, ULONG flStyle) { CHAR szText[CCHMAXMSG]; CHAR szTitle[CCHMAXMSG]; PCHAR pszTitle; /* idTitle = 0 => kein Titel */ /* idTitle = MBTITLE_ERROR => Titel "Fehler" */ /* idTitle sonst => Text ID */ WinLoadString (WinQueryAnchorBlock (HWND_DESKTOP), hmod, idText, CCHMAXMSG, szText); switch (idTitle) { case MBTITLE_ERROR: pszTitle = NULL; break; case 0: pszTitle = ""; break; default: WinLoadString (WinQueryAnchorBlock (HWND_DESKTOP), hmod, idTitle, CCHMAXMSG, szTitle); pszTitle = szTitle; } WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, szText, pszTitle, IDD_MESSAGEBOX, flStyle); return; }
void addClntThrdCD::run( void * ) { HAB thab = WinInitialize( 0 ); HMQ hmq = WinCreateMsgQueue( thab , 0 ); // Attempt to create a new socket VSocket *tmpsock; tmpsock = new VSocket; if (tmpsock!=NULL) { // Connect out to the specified host on the VNCviewer listen port // To be really good, we should allow a display number here but // for now we'll just assume we're connecting to display zero tmpsock->Create(); if (tmpsock->Connect(m_host, m_port)) { // Add the new client to this server m_server->AddClient(tmpsock, TRUE, TRUE); } else { // Print up an error message WinMessageBox( HWND_DESKTOP , HWND_DESKTOP , (PSZ)"Failed to connect to listening VNC viewer", (PSZ)"Outgoing Connection", 10001 , MB_ICONEXCLAMATION | MB_OK ); delete tmpsock; } } WinDestroyMsgQueue( hmq ); WinTerminate( thab ); }
extern MRESULT EXPENTRY ShrInstallDlgProc (HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { MRESULT mr = NULL; CHAR szDLL[CCHMAXPATH]; CHAR szText[256]; PSZ psz; HWND hwndEntryField; switch (msg) { case WM_INITDLG: hwndEntryField = WinWindowFromID(hwndDlg, ID_PATH); WinSetWindowText(hwndEntryField, (PSZ) mp2); mr = (MRESULT) WinSetFocus(HWND_DESKTOP, hwndEntryField); break; case WM_CLOSE: WinDismissDlg(hwndDlg, MBID_CANCEL); break; case WM_COMMAND: if (SHORT1FROMMP(mp1) == MBID_OK) { WinQueryDlgItemText(hwndDlg, ID_PATH, sizeof(szDLL), szDLL); if (strlen(szDLL) >= 2) { psz = strchr(szDLL, '\0') - 1; if (*psz == '\\') strcat(szDLL, "SHARE.DLL"); else strcat(szDLL, "\\SHARE.DLL"); strupr(szDLL); if (ShrInstall(szDLL)) WinDismissDlg(hwndDlg, MBID_OK); } else { sprintf(szText, "The path must include the drive letter." " For example, %s. Please try again.", vszSysDLLPath); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_WARNING); } } else if (SHORT1FROMMP(mp1) == MBID_CANCEL) { WinDismissDlg(hwndDlg, MBID_CANCEL); } break; default: mr = WinDefDlgProc(hwndDlg, msg, mp1, mp2); break; } return mr; }
VOID ReportError(HAB hab) { PERRINFO perriBlk; PSZ pszErrMsg; PSZ pszOffSet; if (!fErrMem){ if ((perriBlk = WinGetErrorInfo(hab)) != (PERRINFO)NULL){ pszOffSet = ((PSZ)perriBlk) + perriBlk->offaoffszMsg; pszErrMsg = ((PSZ)perriBlk) + *((PULONG)pszOffSet); WinMessageBox(HWND_DESKTOP, hwndFrame, (PSZ)(pszErrMsg), (PSZ)szTitle, 0, MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL ); WinFreeErrorInfo(perriBlk); return; } } /* endif */ MessageBox( /* ERROR */ hwndFrame, IDS_ERROR_OUTOFMEMORY, MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL, TRUE); } /* end ReportError() */
void ColorPalProc(void) { char szColors[255]; hColorPalette=WinQueryObject("<WP_LORESCLRPAL>"); if(hColorPalette==NULLHANDLE) WinMessageBox(HWND_DESKTOP,hwndClient, "Could not open Color Palette", szAppName,0,MB_OK|MB_MOVEABLE|MB_ICONEXCLAMATION); else { WinSetObjectData(hColorPalette,"OPEN=DEFAULT"); strcpy(szColors,"COLORS="); strcat(szColors,"0xFFFFFF,");//1 strcat(szColors,"0xFF0000,");//2 strcat(szColors,"0xFF00FF,");//3 strcat(szColors,"0x0000FF,");//4 strcat(szColors,"0x00FFFF,");//5 strcat(szColors,"0x00FF00,");//6 strcat(szColors,"0xFFFF00,");//7 strcat(szColors,"0xCCCCCC,");//8 strcat(szColors,"0x000000,");//9 strcat(szColors,"0x800000,");//10 strcat(szColors,"0x800080,");//11 strcat(szColors,"0x000080,");//12 strcat(szColors,"0x008080,");//13 strcat(szColors,"0x008000,");//14 strcat(szColors,"0x808000,");//15 strcat(szColors,"0x808080");//16 WinSetObjectData(hColorPalette,szColors); hwndColorPalette=WinQueryActiveWindow(HWND_DESKTOP); } }
/* *************************************************************** */ void _catcher(bundle s) { char msg[512]; char *b[4]; HMODULE hmod; PFNWP DlgProc; int c = 0, bx = 0; if (msgHead != NULL) { for (msg[0] = '\0'; *msgHead != NULL; ++msgHead) strcat(msg,*msgHead); b[bx++] = msg; c = strlen(msg) + 1; } for (msg[c] = '\0'; *s != NULL; ++s) strcat(&msg[c],*s); b[bx++] = &msg[c]; b[bx++] = "Application will terminate now"; b[bx] = NULL; if (DosLoadModule(NULL, 0, "GPRTS", &hmod) || DosQueryProcAddr(hmod, 0, "DlgProc", (PFN *)&DlgProc)) WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to load error message","GPM Fatal Error", 0, MB_ICONHAND | MB_OK); else { WinAlarm(HWND_DESKTOP, WA_ERROR); WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DlgProc, hmod, GPRTS_DLG, b); DosFreeModule(hmod); } DosExit(EXIT_PROCESS, 0); }
BOOL SetDisk(HWND hwnd, BYTE newDisk, PBOOL phpfs) { APIRET rc; BYTE buf[128]; ULONG ulAct; CHAR ch = newDisk; newDisk = newDisk > 'Z'? newDisk - 'a' + 1: newDisk - 'A' + 1; DosError(0); // disabilita dialogo errore drive not ready rc = DosQueryFSInfo(newDisk, FSIL_VOLSER, buf, sizeof(buf)); DosError(1); if (rc && rc != 125) { // se drive not ready-> retry, cancel if (WinMessageBox(HWND_DESKTOP, hwnd, DRIVE_NOT_READY, NULL, 0, MB_RETRYCANCEL | MB_ERROR | MB_MOVEABLE) == MBID_RETRY) { return SetDisk(hwnd, newDisk, phpfs); } else { return 1; } /* endif */ } /* endif */ DosSetDefaultDisk(newDisk); *phpfs = isHPFS(ch); if (hwnd != HWND_DESKTOP) { // mostra/nasconde data-ora creazione e ultimo accesso secondo FS DlgShowCtl(hwnd, STB_CREATED, *phpfs); DlgShowCtl(hwnd, STB_ACCESSED, *phpfs); } /* endif */ return 0; }
int main( void) { HAB hab = 0; HMQ hmq = 0; HWND hwnd = 0; int nRtn = 8; QMSG qmsg; do { Morph(); hab = WinInitialize( 0); if (!hab) break; hmq = WinCreateMsgQueue( hab, 0); if (!hmq) break; // avoid compatibility problems // RWSFULLVERSION for RwsTest v0.80 is 0x08000100 if (RwsQueryVersion( 0) < RWSFULLVERSION) { WinMessageBox( HWND_DESKTOP, 0, "Please use a newer version of the RWS08 dlls", "FPos", 1, MB_OK | MB_ERROR | MB_MOVEABLE); break; } hwnd = WinLoadDlg( HWND_DESKTOP, // parent-window NULLHANDLE, // owner-window MainWndProc, // dialog proc NULLHANDLE, // EXE module handle IDD_MAIN, // dialog id NULL); // pointer to create params if (!hwnd) break; while (WinGetMsg( hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg( hab, &qmsg); nRtn = 0; } while (fFalse); if (nRtn) DosBeep( 440, 150); if (hwnd) WinDestroyWindow( hwnd); if (hmq) WinDestroyMsgQueue( hmq); if (hab) WinTerminate( hab); return (nRtn); }
/****************************************************************\ * Message Box procedure *-------------------------------------------------------------- * * Name: MessageBox(hwndOwner, nIdMsg, fsStyle, fBeep) * * Purpose: Displays the message box with the message * given in idMsg retrieved from the message table * and using the style flags in fsStyle * * Usage: Called whenever a MessageBox is to be displayed * * Method: - Message string is loaded from the process' * message table * - Alarm beep is sounded if desired * - Message box with the message is displayed * - WinMessageBox return value is returned * * Returns: return value from WinMessageBox() * \****************************************************************/ ULONG MessageBox(HWND hwndOwner, /* handle of the message box's owner */ ULONG idMsg, /* id if the message in the message table */ ULONG fsStyle, /* style of the message box */ BOOL fBeep) /* if TRUE, beep before message box is displayed */ { CHAR szText[TITLE_LEN]; if(!WinLoadMessage(hab, NULLHANDLE, idMsg, TITLE_LEN, (PSZ)szText)) { WinAlarm(HWND_DESKTOP, WA_ERROR); return MBID_ERROR; } if(fBeep) { WinAlarm(HWND_DESKTOP, WA_ERROR); } return WinMessageBox(HWND_DESKTOP, hwndOwner, (PSZ)szText, (PSZ)NULL, MSGBOXID, fsStyle); } /* MessageBox() */
int CheckFiles(char * szDir) { int iRes; CHAR szCurrentDir[CCHMAXPATH]; CHAR szDirAndFile[CCHMAXPATH+12]; CHAR szFileName[LITTLEBUF]; CHAR szMessage[MAXBUF]; //Copy directory strcpy(szCurrentDir, szDir); //Check ZED.EXE SetStatus(ID_ZEDEXE); WinLoadString(hab, 0, ID_ZED_FILENAME, LITTLEBUF, szFileName); sprintf(szDirAndFile, "%s%s", szCurrentDir, szFileName); iRes=access(szDirAndFile, R_OK); if (iRes!=0) goto ERROR; //Check ZED.HLP SetStatus(ID_ZEDHLP); WinLoadString(hab, 0, ID_ZED_HELP_FILENAME, LITTLEBUF, szFileName); sprintf(szDirAndFile, "%s%s", szCurrentDir, szFileName); iRes=access(szDirAndFile, R_OK); if (iRes!=0) goto ERROR; //Check ZED.ICO SetStatus(ID_ZEDICO); WinLoadString(hab, 0, ID_ZED_ICON_FILENAME, LITTLEBUF, szFileName); sprintf(szDirAndFile, "%s%s", szCurrentDir, szFileName); iRes=access(szDirAndFile, R_OK); if (iRes!=0) goto ERROR; //Check README.TXT SetStatus(ID_ZEDREADME); WinLoadString(hab, 0, ID_ZED_README_FILENAME, LITTLEBUF, szFileName); sprintf(szDirAndFile, "%s%s", szCurrentDir, szFileName); iRes=access(szDirAndFile, R_OK); if (iRes!=0) goto ERROR; //Check REGISTER.TXT //SetStatus(ID_REGISTER); //WinLoadString(hab, 0, ID_REGISTER_FILENAME, LITTLEBUF, szFileName); //sprintf(szDirAndFile, "%s%s", szCurrentDir, szFileName); //iRes=access(szDirAndFile, R_OK); //if (iRes!=0) return -1; return 0; ERROR: sprintf(szMessage,"%s %s", "Can't find the file ", szDirAndFile); WinMessageBox(HWND_DESKTOP, hwndClient, szMessage, "ZED - Install", 0, MB_OK | MB_MOVEABLE | MB_ICONHAND); return -1; }
BOOL StartViewer( char* pszParameters, HWND hTerminateNotify, HWND hAppWindow, HAB hab ) { PROGDETAILS Details; char pszMessageCaption[ 1024 ]; HAPP hApplication; BOOL result; Details.Length = sizeof(PROGDETAILS); Details.progt.progc = PROG_PM; Details.progt.fbVisible = SHE_VISIBLE; Details.pszTitle = "Help Viewer"; Details.pszExecutable = pszViewerFilename; Details.pszParameters = pszParameters; Details.pszStartupDir = ""; Details.pszIcon = NULL; // default app icon Details.pszEnvironment = NULL; Details.swpInitial.fl = SWP_ACTIVATE; Details.swpInitial.cy = 0; Details.swpInitial.cx = 0; Details.swpInitial.y = 0; Details.swpInitial.x = 0; Details.swpInitial.hwndInsertBehind = HWND_TOP; Details.swpInitial.hwnd = hAppWindow; Details.swpInitial.ulReserved1 = 0; Details.swpInitial.ulReserved2 = 0; LogEvent( "Launching: %s %s", Details.pszExecutable, pszParameters ); hApplication = WinStartApp( hTerminateNotify, // window to be notified of termination & Details, // details NULL, // parameters - used Details NULL, // reserved SAF_INSTALLEDCMDLINE ); // options if ( hApplication == NULL ) { LogEvent( " Failed to launch viewer, rc=%8X", WinGetLastError( hab ) ); sprintf( pszMessageCaption, "Unable to start help viewer %s", pszViewerFilename ); WinMessageBox( HWND_DESKTOP, // parent hAppWindow, // owner pszMessageCaption, "Help Error", // title 0, // ID MB_OK | MB_WARNING | MB_MOVEABLE ); result = FALSE; } else { result = TRUE; } free( pszParameters ); return result; }
USHORT CompareFileDate(char szSourceFileSpec[],char szDestFileSpec[]) { FILESTATUS3 stFileInfo; FDATE fdateSourceCreation; char szMessage[200]; char szCaption[40]; APIRET rc; DosQueryPathInfo(szSourceFileSpec,1,&stFileInfo,sizeof(FILESTATUS3)); fdateSourceCreation = stFileInfo.fdateCreation; if ((rc = DosQueryPathInfo(szDestFileSpec,1,&stFileInfo,sizeof(FILESTATUS3))) == NO_ERROR) { if (fdateSourceCreation.year > stFileInfo.fdateCreation.year) return(MBID_YES); else if (fdateSourceCreation.year == stFileInfo.fdateCreation.year) if (fdateSourceCreation.month > stFileInfo.fdateCreation.month) return(MBID_YES); else if (fdateSourceCreation.month == stFileInfo.fdateCreation.month) if (fdateSourceCreation.day >= stFileInfo.fdateCreation.day) return(MBID_YES); sprintf(szMessage,"%s is the same, or newer, version than the file to be installed.\n\nDo you want to replace it?",szDestFileSpec); sprintf(szCaption,"Newer file exists!"); return(WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,szMessage,szCaption, HLPP_MB_OLD_FILE, (MB_MOVEABLE | MB_HELP | MB_YESNOCANCEL | MB_ICONQUESTION))); } else { if (rc == ERROR_SHARING_VIOLATION) { sprintf(szMessage,"%s is currently in open by another process.\n\nPlease correct and reinstall.",szDestFileSpec); sprintf(szCaption,"File Currently in Use!"); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szMessage, szCaption, HLPP_MB_FILE_INUSE, (MB_MOVEABLE | MB_OK | MB_HELP)); return(MBID_CANCEL); } } return(MBID_NO); }
rtl_TextEncoding osl_getTextEncodingFromLocale( rtl_Locale * pLocale ) { const _pair *language = 0; char locale_buf[64] = ""; char *cp; WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, "Please contact technical support and report above informations.\n\n", "Critical error: osl_getTextEncodingFromLocale", 0, MB_ERROR | MB_OK | MB_MOVEABLE); /* default to process locale if pLocale == NULL */ if( NULL == pLocale ) osl_getProcessLocale( &pLocale ); /* convert rtl_Locale to locale string */ if( _compose_locale( pLocale, locale_buf, 64 ) ) { /* check special handling list (EUC) first */ const unsigned int members = sizeof( _full_locale_list ) / sizeof( _pair ); language = _pair_search( locale_buf, _full_locale_list, members); if( NULL == language ) { /* * check if there is a charset qualifier at the end of the given locale string * e.g. de.ISO8859-15 or de.ISO8859-15@euro which strongly indicates what * charset to use */ cp = strrchr( locale_buf, '.' ); if( NULL != cp ) { const unsigned int members = sizeof( _locale_extension_list ) / sizeof( _pair ); language = _pair_search( cp + 1, _locale_extension_list, members); } } /* use iso language code to determine the charset */ if( NULL == language ) { const unsigned int members = sizeof( _iso_language_list ) / sizeof( _pair ); /* iso lang codes have 2 charaters */ locale_buf[2] = '\0'; language = _pair_search( locale_buf, _iso_language_list, members); } } /* a matching item in our list provides a mapping from codeset to * rtl-codeset */ if ( language != NULL ) return language->value; return RTL_TEXTENCODING_DONTKNOW; }
ULONG OKMsgBox(PSZ pszText) { return WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, pszText, "Cell Demo", 0, MB_OK | MB_INFORMATION | MB_APPLMODAL); }
ULONG PM_Error(HAB hab, HWND hwndOwner, ULONG ulWindow, ULONG ulStyle, UCHAR *pucMsg, PSZ pszErrMod, LONG lErrLine) { ERRORID erroridCode; /* Returned by WinGetLastError() */ PERRINFO pErrInfoBlk; /* Pointer to ERRINFO structure that is filled by WinGetErrorInfo */ PSZ pszOffset; /* Pointer to the current error message returned by WinGetErrorInfo */ USHORT usResponse; /* Message box return value */ /* If no special test is given, assume empty string */ if(!pucMsg) pucMsg=""; sprintf(ErrBuffer, "%s\n\nModule: %s\nLinenumber: %ld\nError reported by PM: ", pucMsg, pszErrMod, lErrLine); /* Get the last error set by a PM function */ erroridCode=WinGetLastError(hab); sprintf(ErrBuffer, "%s%08lX", ErrBuffer, (ULONG)erroridCode); /* Get last error for the current thread. We loop until no more error is found, although errors arn't stacked (but things may change) */ pErrInfoBlk=WinGetErrorInfo(hab); /* Do as long as there is an errorinfo available */ while(pErrInfoBlk!=(PERRINFO)NULL) { /* Find offset in array of message offsets */ pszOffset = ((PSZ)pErrInfoBlk) + pErrInfoBlk->offaoffszMsg; /* Address error message in array of messages and append error message to source code linenumber */ strcat(ErrBuffer, "\nInfo: "); strcat(ErrBuffer, (((PSZ)pErrInfoBlk) + *((PSHORT)pszOffset))); WinFreeErrorInfo(pErrInfoBlk); /* Free resource segment */ pErrInfoBlk=WinGetErrorInfo(hab); } /* Broaden titlebar by spaces to make message box wider */ memset(Titlebar, ' ', TITLEBAR_LENGTH); Titlebar[TITLEBAR_LENGTH-1]='\0'; memcpy(Titlebar, "PC/2: PM Error Message Information", sizeof("PC/2: PM Error Message Information")-1); /* If the user requested not to be prompted, don't display the message if it is just an informational one (in the future we might log to file) */ if((pHP!=NULL) && (pHP->ulRuntimeFlag & NOPROMPT) && (ulStyle & MB_INFORMATION)) return(MB_OK); /* Signal to user via speaker */ if((pHP!=NULL) && !(pHP->ulRuntimeFlag & NOPROMPT)) { DosBeep(1000,100); DosBeep(300,100); DosBeep(1000,200); } usResponse=WinMessageBox( HWND_DESKTOP, /* Parent window is DESKTOP */ hwndOwner, /* Owner window */ (PSZ)ErrBuffer, /* General_Error message */ Titlebar, /* Title bar message */ (USHORT)ulWindow, /* Message box identifier for help */ (USHORT)ulStyle); /* Message box style */ return(usResponse); }
/*...sHlpWarning:0:*/ static VOID HlpWarning(HWND hwnd, const CHAR *szFmt, ...) { va_list vars; CHAR sz[256+1]; va_start(vars, szFmt); vsprintf(sz, szFmt, vars); va_end(vars); WinMessageBox(HWND_DESKTOP, hwnd, sz, "Help system", 0, MB_OK | MB_WARNING | MB_MOVEABLE); }
/*...sError:0:*/ static VOID Error(HWND hwnd, const CHAR *szFmt, ...) { va_list vars; CHAR sz [256+1]; va_start(vars, szFmt); vsprintf(sz, szFmt, vars); va_end(vars); WinMessageBox(HWND_DESKTOP, hwnd, sz, NULL, 0, MB_OK | MB_ERROR | MB_MOVEABLE); }
int InitPM(int mode) { if ( ( mainhab = WinInitialize( 0UL ) ) == NULLHANDLE ) return 1; if ( ( mainhmq = WinCreateMsgQueue( mainhab, 32UL ) ) == NULLHANDLE ) return 2; if (WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,"Use DIVE calls?","2D Acceleration",0L, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE) == MBID_YES) OS2_WMesaInitHab(mainhab,1); else OS2_WMesaInitHab(mainhab,0); return 0; }
void FontPalProc(void) { hFontPalette=WinQueryObject("<WP_FNTPAL>"); if(hFontPalette==NULLHANDLE) WinMessageBox(HWND_DESKTOP,hwndClient, "Could not open Font Palette", szAppName,0,MB_OK|MB_MOVEABLE|MB_ICONEXCLAMATION); else WinSetObjectData(hFontPalette,"OPEN=DEFAULT"); hwndFontPalette=WinQueryActiveWindow(HWND_DESKTOP); }
/*--------------------------------------------------------------------------------------*\ * Procedure to display a message box to the user. * * Req: * * pucError ...... Pointer to an error string * * Returns: * * usResponse .... Response of the user (the button pressed) * \*--------------------------------------------------------------------------------------*/ USHORT User_Error(UCHAR *pucError) { return(WinMessageBox( /* Display the error on the screen */ HWND_DESKTOP, /* Handle of parent-window */ HWND_DESKTOP, /* Handle of owner-window */ pucError, /* Message-box window message */ /* Message-box window title */ "SD/2 - ShutDown/2 Error Information", ID_SHUTDOWN, /* ID passed to HK_HELP and WM_HELP */ /* Message-box window style */ MB_OK | MB_ICONEXCLAMATION | MB_DEFBUTTON1)); }
BOOL SystemHandler::killTrace() { OMsgs msg; OString Title(30); OString Question(100); msg.loadString(APP_TITLE, 30, Title.text); msg.loadString(SURE_TO_EXIT, 100, Question.text); if (WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, Question.text, Title.text, GTPM_ICO, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1)==MBID_YES) WinPostMsg(NULLHANDLE, WM_QUIT, (MPARAM)0, (MPARAM)100); return(TRUE); // continue by default }