1. Irregular Windows
- Posted by Tony Steward <tony at locksdownunder.com> Oct 04, 2001
- 399 views
--part1_16f.1ecb40f.28ee8039_boundary Hi All, I wish to use the irreg. window routine but don't know what I have done wrong. Follow is my test program which does open an oval window but will not display a bit map or close when clicked on, I have to alt/F4 to close it. What am I doing wrong. Also the was an example posted to the mailing list some time back (by mistake I think) I would appreciate a copy to view if the author doesn't mind. -- start code -- Modified example of irregular window include win32lib.ew include Irregular.ew without warning constant ShapedWin = create( Window, "Irregular", 0, Default, Default, 300, 100, {WS_BORDER , WS_POPUP} ) procedure onLoad_ShapedWin() atom Region atom hBitmap Region = CreateEllipticRgn(0,0,300,100) SetWindowRgn(getHandle(ShapedWin),Region) -- load the bitmap hBitmap = loadBitmapFromFile( "Logo.bmp" ) -- display the bitmap in TheWindow at {1,1} drawBitmap( ShapedWin, hBitmap, 1, 1 ) end procedure procedure onClick_ShapedWin() --It's good to have a way to exit if we hide the close button closeWindow(ShapedWin) end procedure onClick[ ShapedWin ] = routine_id("onClick_ShapedWin") onOpen [ ShapedWin ] = routine_id("onLoad_ShapedWin" ) WinMain( ShapedWin, Modal ) --part1_16f.1ecb40f.28ee8039_boundary Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: 7bit <HTML><FONT FACE=arial,helvetica><BODY BGCOLOR="#ffffff"><FONT SIZE=2>Hi All, <BR>I wish to use the irreg. window routine but don't know what I have done wrong. Follow is my test program which does open an oval window but will not display a bit map or close when clicked on, I have to alt/F4 to close it. <BR> <BR>What am I doing wrong. <BR> <BR>Also the was an example posted to the mailing list some time back (by mistake I think) I would appreciate a copy to view if the author doesn't mind. <BR> <BR>-- start code <BR>-- Modified example of irregular window <BR> <BR>include win32lib.ew <BR>include Irregular.ew <BR>without warning <BR> <BR>constant ShapedWin = create( Window, "Irregular", 0, Default, Default, 300, 100, {WS_BORDER , WS_POPUP} ) <BR> <BR>procedure onLoad_ShapedWin() <BR> atom Region <BR> atom hBitmap <BR> <BR> Region = CreateEllipticRgn(0,0,300,100) <BR> SetWindowRgn(getHandle(ShapedWin),Region) <BR> <BR> -- load the bitmap <BR> hBitmap = loadBitmapFromFile( "Logo.bmp" ) <BR> <BR> -- display the bitmap in TheWindow at {1,1} <BR> drawBitmap( ShapedWin, hBitmap, 1, 1 ) <BR>end procedure <BR> <BR>procedure onClick_ShapedWin() <BR> --It's good to have a way to exit if we hide the close button <BR> closeWindow(ShapedWin) <BR>end procedure <BR> <BR>onClick[ ShapedWin ] = routine_id("onClick_ShapedWin") <BR>onOpen [ ShapedWin ] = routine_id("onLoad_ShapedWin" ) <BR> <BR>WinMain( ShapedWin, Modal ) --part1_16f.1ecb40f.28ee8039_boundary--
2. Re: Irregular Windows
- Posted by euman at bellsouth.net Oct 04, 2001
- 449 views
From: "Tony Steward" <tony at locksdownunder.com> Subject: Irregular Windows > Hi All, > I wish to use the irreg. window routine but don't know what I have done > wrong. Follow is my test program which does open an oval window > <snip> Hi Tony, This is how I do it..... poke4(pt,0) poke4(pt+4,0) junk = c_func(xClientToScreen,{hwnd, pt}) x = peek4s(pt) y = peek4s(pt+4) c_proc(GetWindowRect, {hwnd,rect}) x -= peek4s(rect_Left) y -= peek4s(rect_Top) SetWindowRgn(hwnd,CreateEllipticRgn(x+2,y,165,165)) So, you might try this: SetWindowRgn(ShapedWin,CreateEllipticRgn(0,0,300,100)) instead of this: Region = CreateEllipticRgn(0,0,300,100) SetWindowRgn(getHandle(ShapedWin),Region) These are very much the same, I just eliminate getHandle. Also, if you looked close at my code there-in lies a trick that will eliminate the offset given by all windows due to the titlebar height... "The code upto SetWindowRgn, above" Next part to be concerned with is this... hdc = c_func(GetDC, {hwnd}) memdc = c_func(xCreateCompatibleDC, {hdc}) hDib = createDIB(clockface2[1], clockface2[2], hdc ) junk = c_func(xSelectObject, {memdc,hDib}) c_proc(xDeleteObject, {hDib}) c_proc(ReleaseDC, {hwnd, hdc}) have you created an hdc and copied this to a CompatibleDC? ---- Because you use Win32lib most of this is setup already for you.. Here is the code I'd use to put the bitmap on the window in win32lib atom Buffer Buffer = createDIB( {pal, pixels} ) procedure Paint( integer x1, integer y1, integer x2, integer y2 ) bitBlt(ShapedWin,0,0,Buffer,x1,y1,x2,y2,SRCCOPY) end procedure Next, to exit the Window I would do something like this... MyPopup = create( Popup, "", ShapedWin, 0, 0, 0, 0, 0 ), Item1 = create( MenuItem, "Close", MyPopup, 0, 0, 0, 0, 0 ) procedure exitClock() closeWindow(ShapedWin ) end procedure procedure menu() integer self self = getSelf() if self = Item1 then exitClock() end if end procedure onClick[Item1] = routine_id("menu") ---- If this stuff doesnt help or I mis-understood the ?, let me know. I'll try again... Euman euman at bellsouth.net