--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100005 Date: 11/29/97 From: CAMERON CLARK Time: 08:27pm \/To: BJOERNAR JENSEN (Read 2 times) Subj: Re: absread() BJ> I'm new to c++ and I'm trying to read the first sector on 'c drive' using BJ> absread. This because absread is supposed to read the sector(s) you tell it BJ> read regardless FAT, directories and files.. BJ> char buf[16384]; Dos the OS you're using use 16k sectors? My OS uses 32k by default. --- GEcho 1.00 * Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100006 Date: 11/26/97 From: FRANOIS DE MEY Time: 12:27pm \/To: CHRISTOPHER BUTLER (Read 2 times) Subj: Sharing Interrupts under Win95 Hi coder, CB> Does anyone know if its possible, under Win95, to share an interrupt? CB> Bascially, what I want to do, is have one routine in memory, that can CB> be called by programs in other windows. CB> Christopher The only way I know to do that is to make Ure prog under windows and to use the message queue ( sending Ure messages and recepting it on another end ) But, i think that there is a shared memory zone, where U can write and read what U want under windows. FeP --- Blue Wave/DOS v2.30 * Origin: Programmer's Paradise -Belgium- 32-10-813088 (2:293/2009) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100007 Date: 11/30/97 From: JONATHAN ROBERTS Time: 10:16am \/To: COY YEARWOOD (Read 2 times) Subj: books RE: books BY: Coy Yearwood to All on Fri Nov 28 1997 11:43 pm > does n e one know of a really good C++ book for someone that is going to tak > the AP class next year and wants to get ahead of the class... > is there n e good books out there where the author isn't all hung up on ne > simple issue of C++??? Anything by Tom Swan is good. Check your local library. Jonathan --- Synchronet+SBBSecho v1.25 * Origin: The Caverns BBS - 504.831.2825 (1:396/20) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100008 Date: 11/30/97 From: BOB STOUT Time: 11:26am \/To: CAMERON CLARK (Read 2 times) Subj: Re: absread() On , Cameron Clark (1:3811/350@fidonet) wrote: > Dos the OS you're using use 16k sectors? My OS uses 32k by default. FAT sectors are always 512 bytes. Clusters can be any size. --- QM v1.00 * Origin: MicroFirm : Down to the C in chips (1:106/2000.6) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100009 Date: 11/30/97 From: ALBERTO MONTEIRO Time: 07:31pm \/To: KURT KUZBA (Read 2 times) Subj: Save Bitmap in M$C AM> I would like to know if there is any function (or AM> whatever) that saves a bitmap to a file. AM> I now have a working routine. Do you want to see it? KK> Yes! One more wheel I won't need to re-invent. :) It's from the labirinthic helps of M$C; the original routines are handle-oriented; I guess they can be adapted to use in MFC, but I didn't dare to do it: #include "stdafx.h" void errhandler(char *s, HWND hwnd) { MessageBox(hwnd, s, "erro", MB_OK); } #if !defined(MAXWRITE) #define MAXWRITE 666666 // don't know what is this, //so I put a demoniac number #endif /* Many applications store images permanently as files. For example, drawing applications store pictures, spreadsheet applications store charts, CAD applications store drawings, and so on. If you are writing an application that will store a bitmapped image in a file, you should use the Windows file format described in Bitmap Storage. In order to store a bitmap in this format, you must initialize a BITMAPINFO structure (consisting of a BITMAPFILEHEADER structure and an array of RGBQUAD structures), as well as an array of palette indices. The following example code defines a function that allocates memory for and initializes members within a BITMAPINFOHEADER structure. */ PBITMAPINFO CreateBitmapInfoStruct(HWND hwnd, HBITMAP hBmp) { BITMAP bmp; PBITMAPINFO pbmi; WORD cClrBits; /* Retrieve the bitmap's color format, width, and height. */ if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)) errhandler("GetObject", hwnd); /* Convert the color format to a count of bits. */ cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel); if (cClrBits == 1) cClrBits = 1; else if (cClrBits <= 4) cClrBits = 4; else if (cClrBits <= 8) cClrBits = 8; else if (cClrBits <= 16) cClrBits = 16; else if (cClrBits <= 24) cClrBits = 24; else cClrBits = 32; /* * Allocate memory for the BITMAPINFO structure. (This structure * contains a BITMAPINFOHEADER structure and an array of RGBQUAD data * structures.) */ if (cClrBits != 24) pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (2^cClrBits)); /* * There is no RGBQUAD array for the 24-bit-per-pixel format. */ else pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER)); /* Initialize the fields in the BITMAPINFO structure. */ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi->bmiHeader.biWidth = bmp.bmWidth; pbmi->bmiHeader.biHeight = bmp.bmHeight; pbmi->bmiHeader.biPlanes = bmp.bmPlanes; pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel; if (cClrBits < 24) pbmi->bmiHeader.biClrUsed = 2^cClrBits; /* If the bitmap is not compressed, set the BI_RGB flag. */ pbmi->bmiHeader.biCompression = BI_RGB; /* * Compute the number of bytes in the array of color * indices and store the result in biSizeImage. */ pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8 * pbmi->bmiHeader.biHeight * cClrBits; /* * Set biClrImportant to 0, indicating that all of the * device colors are important. */ pbmi->bmiHeader.biClrImportant = 0; return pbmi; } /* The following example code defines a function that initializes the remaining structures, retrieves the array of palette indices, opens the file, copies the data, and closes the file. */ void CreateBMPFile(HWND hwnd, LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC); // It comes in next message, to limit messages in 150 lines --- SLMR 2.1a Simple smiles elude psychotic eyes (Slayer-Dead Skin Mask --- FMail/386 1.02 * Origin: CentroIn! +55-21-205-0281, 41 lines, 24h, RJ/Brazil (4:802/21) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100010 Date: 11/30/97 From: ALBERTO MONTEIRO Time: 07:31pm \/To: KURT KUZBA (Read 2 times) Subj: Save Bitmap in M$C/Part 2 // Part 2: // // Part 1 has routine PBITMAPINFO CreateBitmapInfoStruct(HWND hwnd, HBITMAP hBmp); // // Again, those routines were taken from M$C help files // void CreateBMPFile(HWND hwnd, LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC) { HANDLE hf; /* file handle */ BITMAPFILEHEADER hdr; /* bitmap file-header */ PBITMAPINFOHEADER pbih; /* bitmap info-header */ LPBYTE lpBits; /* memory pointer */ DWORD dwTotal; /* total count of bytes */ DWORD cb; /* incremental count of bytes */ BYTE *hp; /* byte pointer */ DWORD dwTmp; pbih = (PBITMAPINFOHEADER) pbi; lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage); if (!lpBits) errhandler("GlobalAlloc", hwnd); /* * Retrieve the color table (RGBQUAD array) and the bits * (array of palette indices) from the DIB. */ if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, DIB_RGB_COLORS)) errhandler("GetDIBits", hwnd); /* Create the .BMP file. */ hf = CreateFile(pszFile, GENERIC_READ | GENERIC_WRITE, (DWORD) 0, (LPSECURITY_ATTRIBUTES) NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); if (hf == INVALID_HANDLE_VALUE) errhandler("CreateFile", hwnd); hdr.bfType = 0x4d42; /* 0x42 = "B" 0x4d = "M" */ /* Compute the size of the entire file. */ hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed * sizeof(RGBQUAD) + pbih->biSizeImage); hdr.bfReserved1 = 0; hdr.bfReserved2 = 0; /* Compute the offset to the array of color indices. */ hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed * sizeof (RGBQUAD); /* Copy the BITMAPFILEHEADER into the .BMP file. */ if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER), (LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)) errhandler("WriteFile", hwnd); /* Copy the BITMAPINFOHEADER and RGBQUAD array into the file. */ if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof (RGBQUAD), (LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)) errhandler("WriteFile", hwnd); /* Copy the array of color indices into the .BMP file. */ dwTotal = cb = pbih->biSizeImage; hp = lpBits; while (cb > MAXWRITE) { if (!WriteFile(hf, (LPSTR) hp, (int) MAXWRITE, (LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)) errhandler("WriteFile", hwnd); cb-= MAXWRITE; hp += MAXWRITE; } if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)) errhandler("WriteFile", hwnd); /* Close the .BMP file. */ if (!CloseHandle(hf)) errhandler("CloseHandle", hwnd); /* Free memory. */ GlobalFree((HGLOBAL)lpBits); } // // Next: It's necessary to extract the initial bitmap // // I do it by copying the pDC (pointer to CDC, in Hungarian notation) // to a bitmap. I guess I do something wrong, as the color code // is lost. Anyway, it follows in Part 3 // --- SLMR 2.1a Sleep with one eye open gripping your pillow tight (Met.) --- FMail/386 1.02 * Origin: CentroIn! +55-21-205-0281, 41 lines, 24h, RJ/Brazil (4:802/21) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100011 Date: 11/30/97 From: ALBERTO MONTEIRO Time: 07:31pm \/To: KURT KUZBA (Read 2 times) Subj: Save Bitmap in M$C/Part 3 // // This is Part 3 // // In Part 1 and Part 2, I put the routines (taken from // M$C help archives) that save a Bitmap (given by its // handle) to a File (given by its handle) // // This routine copies the CDC * associated to the Window // to the CBitmap class // // Of course, I suppose that after invoking this routine, // it will be possible to save the bitmap to a file // #include "stdafx.h" void CreateBMPFile(HWND hwnd, LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC); // Part 1 PBITMAPINFO CreateBitmapInfoStruct(HWND hwnd, HBITMAP hBmp); // Part 2 int CWnd_to_CBitmap(CWnd & cwnd, CBitmap & cbmp) { CDC *pDC = cwnd.GetDC(); CDC pDC1; CBitmap *old_bmp; BITMAP bmp; if (pDC1.CreateCompatibleDC(pDC) == FALSE) { AfxMessageBox("Erro em CreateCompatibleDC"); return -1; } CRect rt; cwnd.GetClientRect(&rt); if (rt.right & 1) rt.right++; // numero par if (cbmp.CreateCompatibleBitmap(pDC, rt.right, rt.bottom) == 0) { AfxMessageBox("Erro em CreateCompatibleBitmap"); return -1; } /* Select the bitmaps into the compatible DC. */ if ((old_bmp = pDC1.SelectObject(&cbmp)) == NULL) { AfxMessageBox("Erro em SelectObject"); return -1; } /* * Copy color data for the entire display into a * bitmap that is selected into a compatible DC. */ cbmp.GetBitmap(&bmp); if (pDC1.BitBlt(0, 0, bmp.bmWidth, bmp.bmHeight, pDC, 0, 0, SRCCOPY) == FALSE) { AfxMessageBox("Erro em BitBlt"); return -1; } pDC1.SelectObject(old_bmp); return 1; } --- SLMR 2.1a Slimy ... yet satisfying (Timon) --- FMail/386 1.02 * Origin: CentroIn! +55-21-205-0281, 41 lines, 24h, RJ/Brazil (4:802/21) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG100012 Date: 11/30/97 From: DARIN MCBRIDE Time: 10:50pm \/To: KURT KUZBA (Read 2 times) Subj: Try blocks KK> You can take advantage of this by using try and catch. KK> try KK> { KK> PlayerClass *Player = new PlayerClass; KK> return Player; KK> } KK> catch er, catch what? catch(XAlloc& xa) { cout << "Error allocating player:" << endl; cout << xa << endl; //... I can't actually remember the exception type that new returns, though. :-) --- Maximus/2 3.01 * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG300000 Date: 12/02/97 From: ADAM MAJER Time: 04:55pm \/To: COY YEARWOOD (Read 2 times) Subj: books CY>does n e one know of a really good C++ book for someone that is going to tak CY>the AP class next year and wants to get ahead of the class... CY>is there n e good books out there where the author isn't all hung up on ne CY>simple issue of C++??? There are lots but the best would be reference manuals that come with the language (eg.Borland C++). And C++ is all hung up on one issue - _classes_. :) --- FMail 0.92 # SLMR 2.1 # 100% Compression: del *.* * Origin: The Programmer's Oasis on FIDONET! (1:348/203) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EG300001 Date: 12/02/97 From: THOMAS MAEDER Time: 08:09am \/To: DARIN MCBRIDE (Read 2 times) Subj: Try blocks DM> I can't actually remember the exception type that new returns, though bad_alloc Thomas --- MM 1.0 #0113 (c) 1997-2002 by Marc Scheuner * Origin: McMeier & Son BBS (2:301/138)