home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!paladin.american.edu!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!news
- From: Dmitry Boldyrev <dmitry@chemistry.chem.utah.edu>
- Subject: Re: Volume icons?
- Message-ID: <1992Dec29.183956.26804@fcom.cc.utah.edu>
- Sender: news@fcom.cc.utah.edu
- Organization: University of Utah
- X-Useragent: Nuntius v1.0
- References: <168C3EAA8.UC525655@mizzou1.missouri.edu>
- Date: Tue, 29 Dec 92 18:39:56 GMT
- Lines: 164
-
- >Hi all-
- >Where can i find the icon definition for a mounted volume?
- >I have looked through all the (I think) relevant material in
- >IM I-VI, but obviously I've missed something somewhere, but all
- >IM talks about are file icons. Help!
- >
- >
- >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- >Mark Eaton | Opinions? We're not allowed to have
- >UC525655@MIZZOU1.MISSOURI.EDU | opinions at Mizzou... get back to me
- > | in '94 when I graduate... ;)
-
- Hello Mark,
- Here, I have smth for you...
- ============================ CUT HERE ============================
-
- /* this is the data structure pointed to in the result of the
- disk driver call csCode=21 (get ICN#/comment). This call
- works on all devices.
- */
-
- typedef struct TInfoBlk {
- unsigned char icon[128]; /* icon */
- unsigned char mask[128]; /* mask */
- Str255 infoString; /* info string (for get info) */
- } TInfoBlk,*TInfoPtr;
-
- void GetDiskInfo(short driverRefNum,short driveNum,TInfoPtr *dataBlk);
- void DrawInfo(TInfoPtr infoBlock);
- void GetAllInfo(void);
- void GetAllInfoYourWay(void);
-
-
- void main(void)
- {
- WindowPtr theWindow;
- Rect wBounds;
-
- #ifdef THINK_C
- InitGraf(&thePort);
- #else
- InitGraf(&qd.thePort);
- #endif
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- FlushEvents(everyEvent,0);
- InitCursor();
-
- SetRect(&wBounds,40,40,100,100);
- theWindow = NewWindow
- (nil,&wBounds,(StringPtr)"\pIcons",true,documentProc,
- (WindowPtr)(-1),true,0L);
- SetPort(theWindow);
- GetAllInfo();
- DisposeWindow(theWindow);
- }
-
-
- /* This routine traverses the currently mounted volumes
- index using PBHGetVInfo(). The drive # and device
- driver number for each volume is extracted from the
- parameter block, and passed into GetDiskInfo() to
- call the disk drivers.
-
- Once the data has been retrieved, the icon is plotted
- */
-
- void GetAllInfo(void)
- {
- HParamBlockRec vBlock; /* volume parameter block used to traverse
- mounted vols */
- OSErr err;
- TInfoPtr dataBlk; /* pointer used to point to result of csCode=21 call
- */
-
- vBlock.volumeParam.ioNamePtr = nil;
- vBlock.volumeParam.ioVRefNum = 0;
- vBlock.volumeParam.ioVolIndex = 1;
-
- do {
- err = PBHGetVInfo (&vBlock,false);
- vBlock.volumeParam.ioVolIndex++;
- if (err==noErr) {
- GetDiskInfo(vBlock.volumeParam.ioVDRefNum,
- vBlock.volumeParam.ioVDrvInfo,&dataBlk);
- if (dataBlk)
- DrawInfo(dataBlk);
- }
- } while (err==noErr);
- }
-
-
- /* GetDiskInfo() makes the call to the volume's driver to get the
- volume icon and info string. A pointer to this data is returned
- by reference in dataBlk
-
- This routine tries to call the disk's driver with csCode=22,
- which attempts to get info on a specific physical volume.
-
- If the csCode=22 call fails, I call csCode=21 to get the generalized
- media icon.
-
- Both calls are documented in IM V-470
- */
-
- void GetDiskInfo(short driverRefNum,short driveNum,TInfoPtr *dataBlk)
- {
- CntrlParam pBlock;
- OSErr err;
-
- pBlock.ioVRefNum = driveNum;
- pBlock.ioCRefNum = driverRefNum;
- pBlock.csCode = 22;
-
- err = PBControl(&pBlock,false);
- if (err==controlErr) {
- pBlock.ioVRefNum = driveNum;
- pBlock.ioCRefNum = driverRefNum;
- pBlock.csCode = 21;
- err = PBControl(&pBlock,false);
- }
-
- if (err==noErr)
- *dataBlk = (TInfoPtr) *(Ptr *)pBlock.csParam; /* messy way to get the
- locn out */
- else *dataBlk = nil;
- }
-
-
-
- /* this routine uses CopyBits to draw the icon on the screen (ignoring
- the mask and
- the info string). Make sure you put up a window and call SetPort()
- first!
- */
-
- void DrawInfo(TInfoPtr infoBlock)
- {
- BitMap iconMap;
- Rect destRect;
-
- iconMap.baseAddr = (Ptr)infoBlock;
- iconMap.rowBytes = 4;
- SetRect(&iconMap.bounds,0,0,32,32);
- SetRect(&destRect,0,0,32,32);
- OffsetRect(&destRect,10,10);
- CopyBits(&iconMap,&thePort->portBits,&iconMap.bounds,&destRect,
- srcCopy,nil);
- while (!Button());
- while (Button());
- }
- ============================ CUT HERE ============================
-
- Guess, it make sense..
- .................................................
- Dmitry Boldyrev,
- Department of Chemistry, University of Utah.
- Internet: dmitry@chemistry.chem.utah.edu
-
- -- "I only know that I know nothing"
- - Socrates
-