Re: Win32Lib & Multi-open programs
- Posted by Euman <euman at BELLSOUTH.NET> Jan 14, 2001
- 384 views
Hey Brian & everyone I sent this message to Wolf earlier, thanks for the inquiry. Hows it going>? Below is some code that will show on screen a bitmap with rounded corners, the outer edges being transparent. I dreamed this up after looking at McAfee's Windows. If I use a window with no border, no min/max buttons and capture the underlying area of the screen before I Paint the window after which laying the captured screen on the window and transBlt my bitmap onto the captured screen image which resides now ontop of my window this creates an effect that my bitmap is the window, the look is fantastic. The problem with onPaint( ) is that it refreshes too often. I tried to counteract this with integer refresh in the procedure to only refresh once after all images have completed once. The problem is that the controls from other programs are still available and I want the user to be able to task switch out of my program essentially leaveing it open but run something else in the mean time. How based on the code I have would I tell if another program has been screen written over my program (without getPixel) and upon returning focus to my program I want to setVisible(Win, False) my window, capture the underlying screen and reset the images. I would send the image but, it's 500x400 pixels .bmp </snip> include win32lib.ew constant ScreenBuffer = create( Pixmap, "", 0, 50, 50, 600, 500, 0 ) procedure CopyScreenToBuffer() copyBlt( ScreenBuffer, 0, 0, Screen ) end procedure CopyScreenToBuffer() integer Win, MonthCalendar8, refresh MonthCalendar8 = create( MonthCalendar, "MonthCalendar8", Win, 52, 88, 250, 200, 0 ) refresh = 1 procedure cover_up(integer x1, integer y1, integer x2, integer y2) -- draw a bitmap using transparenc atom hDib sequence size if refresh = 1 then bitBlt( Win, -- copy to TheWindow 0, 0, -- put at {10,10} in TheWindow ScreenBuffer, -- copy from Pixmap1 50, 50, -- upper left hand corner is {0,0} 500, 400, -- copy a 40x40 pixel portion SRCCOPY ) -- replace destination with image -- load the bitmap hDib = loadBitmapFromFile( "imain.bmp" ) -- treat the color BrightWhite as transparent setTransparentColor( BrightWhite ) transBlt( Win, -- destination x1, -- x position y1, -- y position hDib ) -- image to copy refresh = 0 end if end procedure -- Confused from here out onPaint[Win]= routine_id("cover_up") procedure noFocus() refresh = 1 setVisible(Win,False) CopyScreenToBuffer() setVisible(Win,True) cover_up(0,0,0,0) end procedure onLostFocus[Win]= routine_id("noFocus") WinMain(Win, Normal ) <snip\> Wolf wrote me back and said I should try Win=createEx(Window,"Test",0,50,50,500,400, {WS_POPUP},{WS_EX_TRANSPARENT}) This would still require the CopyScreenToBuffer() & bitBlt (I think) because the background colors will change as the user task-switches programs. The controls i.e: icons, buttons of the other programs will show thru the Win created by MYPROG the rest of the background wont. I hope I can achieve this with current commands in win32lib but, am pessimistic. TIA euman at bellsouth.net ----- Original Message ----- From: "Brian Broker" <bkb at CNW.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Sunday, January 14, 2001 02:18 Subject: Re: Win32Lib & Multi-open programs > On Sat, 13 Jan 2001 21:57:56 -0500, Euman wrote: > > >Hello > > > > I certainly hope someone can explain why / how > >to find out if MYPROG has been task-switched out > >for another program. (covered up) > > > >I need this info to redisplay certain info in MYPROG > >if and when MYPROG comes back into FOCUS (visible) > > > >onLostFocus( ) -- doesnt tell me when another program > > -- is on top > > > >onGotFocus -- NO > > > >I have tried many times w/ many commands to do this. > > > >onMouse and testing to see if mouse is not within Window > >only works part of the time. > > > >TIA > >euman at bellsouth.net > > Euman, > > onLostFocus should tell you when your program has lost focus, which should > be all you need to know (i.e. just assume another program is on top.) If > you are using controls defined by Win32Lib, then you shouldn't need to > worry about updating them, Windows will do that for you. If you are not > using a label and using something like wPrintf to write to your window and > you are worried about another window erasing your text, then you should be > using your onPaint() routine to remedy the problem. It is a good practice > to use a double buffering technique using a pixmap if your onPaint routine > gets too big. My RGBview.exw program included with Wolf's Win32Lib > tutorials demonstrates this technique. > > If I am misunderstanding your problem, please send me an example and I will > do my best to help. > > -- Brian >