[futurebasic] Re: [FB] desktop pattern

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 1999 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Wed, 6 Jan 1999 14:52:00 +1300
Lucy24@... wrote:
>I want to get at the user's currently selected desktop pattern and use it as a
>color/pattern within an application, the way ResEdit does in its dialog-box
>editors

There's a relevant-looking toolbox call:-

CALL SETDESKCPAT (pPatHndl&)

but the matching GetDeskCPat(), which is what you would like, doesn't seem
to exist. Some other pix pattern calls are:-

pPatHndl&=FN GETPIXPAT(resID)
pPatHndl&=FN NEWPIXPAT
CALL DISPOSPIXPAT(pPatHndl&)
CALL COPYPIXPAT(src&,dst&)
CALL PENPIXPAT(pPatHndl&)
CALL BACKPIXPAT(pPatHndl&)

The following short program shows how a pixPatt may be drawn (FILLCRECT, or
FILLCRGN etc). But it fails to accomplish the task given. Neither of the
two plausible offsets into the CGrafPort (_pnPixPat and _bkPixPat) gives
the desktop pattern -- perhaps someone can spot an error in my code.

If you create a resource file "MyPPat.rsrc" containing a ppat resource with
id 128, and uncomment the 3 singly-commented lines of the program, the ppat
specified is drawn correctly. Having got that to work, if you uncomment the
triply-commented line, the desktop pattern is set to your ppat (this change
is lost when you reboot).

LOCAL FN DrawPixPattern(pPatHndl&,x,y)
 DIM aRect.8
 CALL SETRECT(aRect,x,y,x+120,y+200)
 IF pPatHndl&<>_nil THEN CALL FILLCRECT(aRect,pPatHndl&)
 CALL FRAMERECT(aRect)
END FN

DIM wPort&, pPatHndl&
WINDOW 1
CALL GETCWMGRPORT(wPort&)' points to Window Manager's CGrafPort
FN DrawPixPattern([wPort& + _pnPixPat],10,10) ' solid black
FN DrawPixPattern([wPort& + _bkPixPat],140,10) 'uh, oh, solid white
'RESOURCES "MyPPat.rsrc"
'pPatHndl&=FN GETPIXPAT(128)
'FN DrawPixPattern(pPatHndl&,270,10)
'''IF pPatHndl& THEN CALL SETDESKCPAT (pPatHndl&)
DO: UNTIL FN BUTTON

Robert