Tips_and_Tricks_[STD] - Skinning Windows | Author | Message |
---|
Tony
| Posted: Sat Sep 21, 2002 11:23:52 PM Post subject: Skinning Windows | |
| Hey everyone,
I'm starting a new thread on creating irregular windows and skinning as Vikki kindly suggested. ;D
Below is the code I originally posted in the following thread:
http://www.pyxia.com/forums/cgi-bin/YaBB.cgi?board=general;action=display;num=1032470809;start=35
I'll be converting the remaining sample code into IBasic ASAP, so stay tuned to this thread. ;D
Tony.
Code: | ' Filename: REGION.IBA ' Description: Demonstrates how to create irregular shaped windows with IBasic ' Date: 9-21-2002 ' Author: Tony Jones - tuesdaysgoneagain@yahoo.com ' Notes: Translated directly from C code in the article ' Win32 Window Skinning by Vander Nunes as listed at ' http://www.flipcode.com/articles/article_win32skins.shtml
' All the credit goes to the original author, all I did was convert it from C to IBasic. :-)
' API Declarations DECLARE "gdi32",CreateEllipticRgn(X1:INT, Y1:INT, X2:INT, Y2:INT),INT DECLARE "gdi32",CombineRgn(hDestRgn:INT, hSrcRgn1:INT, hSrcRgn2:INT, nCombineMode:INT),INT DECLARE "user32",SetWindowRgn(hWnd:WINDOW, hRgn:INT, bRedraw:INT),INT DECLARE "gdi32",DeleteObject(hObject:INT),INT
' Constants SETID "TRUE",1 SETID "FALSE",0 SETID "SPACEBAR",&H20 SETID "RGN_OR",2
' Globals DEF Run:INT DEF Regioned:INT DEF Region1,Region2:INT DEF RegionWin:WINDOW
' Create the main window WINDOW RegionWin,0,0,320,240,@SIZE|@MINBOX|@MAXBOX|@NOAUTODRAW,0," Region Demo",RegionWinProc
' Center the window CENTERWINDOW RegionWin
' Run the program until we're told otherwise Run = @TRUE
Regioned = @FALSE
WAITUNTIL Run = @FALSE
CLOSEWINDOW RegionWin
END
' Message handler for the window SUB RegionWinProc
SELECT @CLASS CASE @IDCLOSEWINDOW Run = @FALSE CASE @IDPAINT MOVE RegionWin,115,90 PRINT RegionWin, "Press SPACE" CASE @IDCHAR SELECT @CODE ' Look for the space bar. CASE @SPACEBAR IF Regioned = @FALSE RegionMe ELSE UnRegionMe ENDIF ENDSELECT ENDSELECT
RETURN
' Creates the regioned window SUB RegionMe
' -------------------------------------------------- ' create an elliptical region. ' we use a negative starting y coordinate to make ' the ellipse cover a bit more of the caption. ' -------------------------------------------------- Region1 = CreateEllipticRgn(20,-20,190,150)
' -------------------------------------------------- ' create one more elliptical region in other place. ' -------------------------------------------------- Region2 = CreateEllipticRgn(140,100,300,240)
' -------------------------------------------------- ' combine the two regions to build a new region ' that will be the sum of the two. ' the resulting region will be stored in region1, ' like if we were making something like: ' hRegion1 = hRegion1 + hRegion2. ' -------------------------------------------------- CombineRgn(Region1, Region1, Region2, @RGN_OR)
' -------------------------------------------------- ' assign the region to the window ' -------------------------------------------------- SetWindowRgn(RegionWin, Region1, @TRUE)
' -------------------------------------------------- ' delete the region objects ' -------------------------------------------------- DeleteObject(Region1) DeleteObject(Region2)
' -------------------------------------------------- ' flag just to make sure our app knows about it. ' -------------------------------------------------- Regioned = @TRUE
RETURN
' Removes the region from the window SUB UnRegionMe
' -------------------------------------------------- ' unassign the region ' -------------------------------------------------- SetWindowRgn(RegionWin, 0, @TRUE);
' -------------------------------------------------- ' flag just to make sure our app knows about it. ' -------------------------------------------------- Regioned = @FALSE
RETURN
|
|
| VDaw
| Posted: Sat Sep 21, 2002 11:31:11 PM Post subject: Re: Skinning Windows | |
| Very cool!
Here's my attempt at just adding an image. I didn't create a special image so use yer imagination some. ;D
http://www.web-helper.net/VeeDaWeb/shapes1.gif
It's not a skin because I still have to learn about device contexts. Well, that and wait for Tony to convert the other samples. ;D
This was done with the LoadImage/ShowImage/DeleteImage stuff from IBasic and the image is included as a resource. ;D
Thanks Tony! |
| Dr._DOS
| Posted: Sat Sep 21, 2002 11:35:30 PM Post subject: Re: Skinning Windows | |
| Thanks Tony. This is interesting, though not something I've thought much about before. That's one great thing about this Forum -- plenty of creative people and stimulating ideas.
I'm still at a point at which I feel lucky to get a "box" up on the screen. ;)
-- Jim.
|
| docmann
| Posted: Sat Sep 21, 2002 11:50:49 PM Post subject: Re: Skinning Windows | |
| Excellent Tony! http://www.pyxia.com/YaBBImages/thumbup.gifhttp://www.pyxia.com/YaBBImages/thumbup.gifhttp://www.pyxia.com/YaBBImages/thumbup.gifhttp://www.pyxia.com/YaBBImages/thumbup.gifhttp://www.pyxia.com/YaBBImages/thumbup.gif
The information provided and your work on the conversion is very much appreciated! This could very easily be the starting place for a whole new breed of IBasic apps...
...thanks for sharing! ;D
-Doc- |
| Anonymous
| Posted: Sun Sep 22, 2002 01:04:35 AM Post subject: Re: Skinning Windows | |
| Reading and watching this thread with great interest,right now I'm working on an app for where I work but this does interest me a great deal and I'll make time to play with it. |
| Tony
| Posted: Sun Sep 22, 2002 03:33:07 AM Post subject: Re: Skinning Windows | |
| Okay, here's the second example of the skinning code. This sample builds on the previous one, it uses a 320x240 bitmap image to skin the window. Some things to point out...In the RegionMe and UnRegionMe SUB's you can see how to remove the caption bar from the window and then restore the caption bar. Also, you can click anywhere in the window and drag it, so have a look at the message handler for the window.
You'll need to supply your own 320x240 BMP image (I just used the one from the sample code I downloaded). The BMP is included as a resource, so you'll need to add it as a resource in the IDE. I used the following values:
ID 100 Type Bitmap Set the Filename to the location of your 320x240 image you want to use and you should be all set to compile and run it.
I'll convert the final example, along with the utility program to create regions for it and post it all tomorrow.
If you have any problems with it or questions, just let me know.
Hope you enjoy it! ;D
Tony.
Code: | ' Filename: SKINREGION.IBA ' Description: Demonstrates how to create irregular shaped windows and skinning with IBasic ' Date: 9-21-2002 ' Author: Tony Jones - tuesdaysgoneagain@yahoo.com ' Notes: Translated directly from C code in the article ' Win32 Window Skinning by Vander Nunes as listed at ' http://www.flipcode.com/articles/article_win32skins.shtml
' All the credit goes to the original author, all I did was convert it from C to IBasic. :-)
' API Declarations DECLARE "gdi32",CreateEllipticRgn(X1:INT, Y1:INT, X2:INT, Y2:INT),INT DECLARE "gdi32",CombineRgn(hDestRgn:INT, hSrcRgn1:INT, hSrcRgn2:INT, nCombineMode:INT),INT DECLARE "user32",SetWindowRgn(hWnd:WINDOW, hRgn:INT, bRedraw:INT),INT DECLARE "gdi32",DeleteObject(hObject:INT),INT DECLARE "user32",InvalidateRect(hwnd:WINDOW, lpRect:INT, bErase:INT),INT DECLARE "user32",GetWindowLongA(hwnd:INT, nIndex:INT),INT DECLARE "user32",SetWindowLongA(hwnd:INT, nIndex:INT, dwNewLong:INT),INT DECLARE "user32",SetWindowPos(hwnd:INT, hWndInsertAfter:INT, x:INT, y:INT, cx:INT, cy:INT, wFlags:INT),INT
' Constants SETID "TRUE",1 SETID "FALSE",0 SETID "SPACEBAR",&H20 SETID "RGN_OR",2 SETID "IDSKIN",100 SETID "GWL_STYLE",-16 SETID "SWP_NOMOVE",&H2 SETID "SWP_NOZORDER",&H4 SETID "WM_NCLBUTTONDOWN",&HA1 SETID "HTCAPTION",2
' Globals DEF Run:INT DEF Skin:INT DEF Style:INT DEF Regioned:INT DEF Region1,Region2:INT DEF RegionWin:WINDOW DEF Temp:INT
' Create the main window WINDOW RegionWin,0,0,320,240,@SIZE|@MINBOX|@MAXBOX|@NOAUTODRAW,0," Region Demo",RegionWinProc
' Center the window CENTERWINDOW RegionWin
' Load the skin image which is stored as a resource Skin = LOADIMAGE(@IDSKIN,@IMGBITMAP)
' Run the program until we're told otherwise Run = @TRUE
Regioned = @FALSE
WAITUNTIL Run = @FALSE
' Free up the memory we used DELETEIMAGE Skin,@IMGBITMAP
CLOSEWINDOW RegionWin
END
' Message handler for the window SUB RegionWinProc
SELECT @CLASS CASE @IDCLOSEWINDOW Run = @FALSE CASE @IDCHAR SELECT @CODE ' Look for the space bar. CASE @SPACEBAR ' Shape the window IF Regioned = @FALSE RegionMe ELSE UnRegionMe ENDIF ENDSELECT CASE @IDPAINT IF Regioned = @TRUE ' Skin the window SkinMe ENDIF DRAWMODE RegionWin,@TRANSPARENT MOVE RegionWin,115,90 FRONTPEN RegionWin, RGB(255,0,0) PRINT RegionWin, "Press SPACE" CASE @IDLBUTTONDN ' --------------------------------------------------------- ' this is a common trick for easy dragging of the window. ' this message fools windows telling that the user is ' actually dragging the application caption bar. ' --------------------------------------------------------- IF Regioned = @TRUE SENDMESSAGE RegionWin, @WM_NCLBUTTONDOWN,@HTCAPTION,0);
ENDSELECT
RETURN
' Creates the regioned window SUB RegionMe
' -------------------------------------------------- ' create an elliptical region. ' we use a negative starting y coordinate to make ' the ellipse cover a bit more of the caption. ' -------------------------------------------------- Region1 = CreateEllipticRgn(20,-20,190,150)
' -------------------------------------------------- ' create one more elliptical region in other place. ' -------------------------------------------------- Region2 = CreateEllipticRgn(140,100,300,240)
' -------------------------------------------------- ' combine the two regions to build a new region ' that will be the sum of the two. ' the resulting region will be stored in region1, ' like if we were making something like: ' hRegion1 = hRegion1 + hRegion2. ' -------------------------------------------------- CombineRgn(Region1, Region1, Region2, @RGN_OR)
' -------------------------------------------------- ' assign the region to the window ' -------------------------------------------------- SetWindowRgn(RegionWin, Region1, @TRUE)
' -------------------------------------------------- ' delete the region objects ' -------------------------------------------------- DeleteObject(Region1) DeleteObject(Region2)
' -------------------------------------------------- ' change window style (get rid of the caption bar) ' -------------------------------------------------- Style = GetWindowLongA(RegionWin, @GWL_STYLE) Style = (Style & (-(@CAPTION|@MINBOX|@MAXBOX)))) SetWindowLongA(RegionWin,@GWL_STYLE,Style)
' -------------------------------------------------- ' force a window repainting ' -------------------------------------------------- InvalidateRect(RegionWin, 0, @TRUE) SetWindowPos(RegionWin, 0, 0,0,320,242, @SWP_NOMOVE|@SWP_NOZORDER)
' -------------------------------------------------- ' flag just to make sure our app knows about it. ' -------------------------------------------------- Regioned = @TRUE
RETURN
' Removes the region from the window SUB UnRegionMe
' -------------------------------------------------- ' unassign the region ' -------------------------------------------------- SetWindowRgn(RegionWin, 0, @TRUE)
' -------------------------------------------------- ' change window style (show caption bar again) ' -------------------------------------------------- Style = GetWindowLongA(RegionWin, @GWL_STYLE) Style = (Style | (@CAPTION|@MINBOX|@MAXBOX)) SetWindowLongA(RegionWin,@GWL_STYLE,Style)
' -------------------------------------------------- ' force a window repainting ' -------------------------------------------------- InvalidateRect(RegionWin, 0, @TRUE) SetWindowPos(RegionWin, 0, 0,0,320,240, @SWP_NOMOVE|@SWP_NOZORDER)
' -------------------------------------------------- ' flag just to make sure our app knows about it. ' -------------------------------------------------- Regioned = @FALSE
RETURN
' Skins the window with the bitmap SUB SkinMe
' Show the image SHOWIMAGE RegionWin,Skin,@IMGBITMAP,0,0,320,240
RETURN
|
|
| Paul Turley
| Posted: Sun Sep 22, 2002 03:47:42 AM Post subject: Re: Skinning Windows | |
| Tony, Excellent tip. Irregular shaped windows can be very useful when your application just doesn't fit in a square ;)
Paul. |
| VDaw
| Posted: Sun Sep 22, 2002 04:46:26 AM Post subject: Re: Skinning Windows | |
| Very cool! I can now put round pegs in a square hole. ;D
Thanks for the work you did here Tony!
You've made this so easy even I might be tempted to use an irregular window for an app. ;D |
| TronDoc
| Posted: Sun Sep 22, 2002 11:40:51 AM Post subject: Re: Skinning Windows | |
| Tony: Many thanks for your efforts. I know several people here, including me, appreciate what you've done! I think this non-square format is particularly appealing to younger folks. My kids (13,13,14,24) seem to prefer that sort of interface. Again, just my[size=4:2b82d940c8]2˘[/size:2b82d940c8] Joe |
| Tony
| Posted: Sun Sep 22, 2002 10:04:47 PM Post subject: Re: Skinning Windows | |
| Okay gang, here's the one you've probably been waiting for a complete custom shaped and skinned window in IBasic. ;D
You can download a zip archive containing the source code, resources and EXE from the following link:
http://members.cox.net/alycat8001/SkinIt.zip
It's about a 240k download. I made some extra notes and comments at the top of the source file, so be sure and check them out.
All that I need to convert now is the utility program that is used to create the region data from bitmaps. Should have that done and up tonight sometime. Once I get it converted, I'll make an archive containing all of the IBasic samples, resources, etc. and put it up or perhaps Paul would like to add it to the Library.
Anyway, hope you enjoy and feel free to ask me questions. ;D
Tony. |
| VDaw
| Posted: Sun Sep 22, 2002 10:13:18 PM Post subject: Re: Skinning Windows | |
| Quote: | convert now is the utility program that is used to create the region data from bitmaps |
Yes!! I'll be waiting for this one!! I'll get this other downloaded and tried out but the one I've been waiting for is the one that does it from the bitmap! WhooooHoooo....
Many, many thanks for converting this code. ;D |
| Fletchie
| Posted: Sun Sep 22, 2002 10:17:47 PM Post subject: Re: Skinning Windows | |
| Tony, very,very good demo. And it works great here on Win98Se.
Just one little thing...... ....... I couldn't 'escape' from the .exe demo (three finger salute time...)
Maybe I missed something ;D
|
| Tony
| Posted: Sun Sep 22, 2002 10:24:41 PM Post subject: Re: Skinning Windows | |
| Fletchie,
Glad you liked the it.
You can exit the demo with ALT-F4....I got lazy and didn't code in the ESC key or anything. ;D I made a note of it at the top of the source code, but if you're probably like me.....I never read the docs. ;D
Tony. |
| VDaw
| Posted: Sun Sep 22, 2002 10:24:53 PM Post subject: Re: Skinning Windows | |
| Tony same here...couldn't escape from the exe....had to end task twice. ;D
Lol! read the source... ;D Ok, I thought that the last one was this one. Gonna go read the source now and see which one it is that I wanted the most. ;D |
| VDaw
| Posted: Sun Sep 22, 2002 10:28:39 PM Post subject: Re: Skinning Windows | |
| Ah, ok I see now. I need to wait for the sknrgn stuff to do this. I can't wait! ;D
Very cool...now back to reading. ;D
With this... I believe you may have converted me. ;D
From the source:
Quote: | All the credit goes to the original author, all I did was convert it from C to IBasic. :-) |
*All* you did was convert it. I think you deserve a little credit too. ;D Well, not a little, a whole lot.
Thanks again Tony! |
| sbrown
| Posted: Mon Sep 23, 2002 12:20:59 AM Post subject: Re: Skinning Windows | |
| Downloading now! I'll try it out later ;D
Scott |
| VDaw
| Posted: Mon Sep 23, 2002 06:11:30 AM Post subject: Re: Skinning Windows | |
| Ho, ho, ho! Read all the code! ;D
Here's another neat little trick if you use a regular shaped window without a caption bar that allows you to drag the window....for example the example custom graphic interface I made can now be dragged just as if there were a caption bar. Works smooth too. ;D
Code: | 'up with your DEFs SETID "WM_NCLBUTTONDOWN",&HA1 SETID "HTCAPTION",2
'in the window handler CASE @IDLBUTTONDN ' --------------------------------------------------------- ' this is a common trick for easy dragging of the window. ' this message fools windows telling that the user is ' actually dragging the application caption bar. ' --------------------------------------------------------- SENDMESSAGE RegionWin, @WM_NCLBUTTONDOWN,@HTCAPTION,0)
|
Major! Thanks again Tony!
With all this stuff and the new toolbar stuff in 1.98, methinks VeeDaWeb is going to have a metamorphosis. ;D |
| Joseph
| Posted: Mon Sep 23, 2002 09:07:39 AM Post subject: Re: Skinning Windows | |
| I quite agree, Tony your conversion work is really excellent
Tested on my Win XP Home system, it works fine
your porting to IBasic seems running even better than the original C code compiled in Visual C :)
thank you
PS: I think the skinning features, hopefully integrated by Pyxia in a next release of the IB compiler itself (ie adding some parameter to the WINDOW command or something like that), could 'attract' many more users, thosepeople currently sticked to some 'multimedia' authoring tools (like medi8tor, multimedia builder, multimedia fusion and similar ones), and i suppose like very much the 'irregular shaped window feature'
hope this helps |
| aeon
| Posted: Mon Sep 23, 2002 02:39:59 PM Post subject: Re: Skinning Windows | |
| Cool beyond cool Tony, you have done an excellent job and made me very very happy as I can see new vistas of opportunity opening up. ;D With the utility program you mention it really will be Christmas come early! ;D
Paul I'm with Joseph as you may already guess on the notion of integrating this kind of functionality in the IDE. I feel sure it will broaden the appeal of iBasic substantially!
...Ian |
| Anonymous
| Posted: Mon Sep 23, 2002 09:05:12 PM Post subject: Re: Skinning Windows | |
| Ya Know this stuff right here is the real strength of IBasic that should be exploited.To have access to windows on this level without oop has got to be a plus. This is the type of stuff that should be out there for people to see,gee whizz bang type of stuff!!! |
| Tony
| Posted: Tue Sep 24, 2002 02:32:44 AM Post subject: Re: Skinning Windows | |
| I appreciate all the feedback and comments.....it's what makes it all worth it. ;D
I just wanted to let you know, that the utility program is almost finished, just a few odds and ends to tie up, so it should be ready by tomorrow afternoon. The original utility program was command line based, so I decided to convert it to a more intuitive GUI app rather than a console program or even writing just a GUI shell for it. Makes it much more user friendly. ;D
I agree, it would be great to have this kind of functionality built into the language, however, I'm not sure of the feasibility of such a feature. But, you did get my creativity going, maybe I can turn this into some kind of component, that would be nice I think. ;D Only problem is, I need more time and more time as Vikki said.....so many projects I want to do and not enough hours in the day. ;D
Tony. |
| Tony
| Posted: Tue Sep 24, 2002 05:39:08 PM Post subject: Re: Skinning Windows | |
| This is it, what you've all been waiting for.....the Region Creator program!! ;D With this program, the code from the SkinIt.zip archive that I posted earlier and your bitmaps, you can create your very own, skinned windows. Woo-hoo!! ;D
Download it from here
http://members.cox.net/alycat8001/RgnCreator.zip
It's about a 200K download. Please make sure you read the instructions at the top of the source file on how to use the program. As I mention there, this is more of a rewrite than a direct port of the C code. I made it into a GUI program and it also works with bitmaps, regardless of their color depth.
I hope you all enjoy it! And please don't hesitate to ask if you have any questions.
Thanks,
Tony. |
| VDaw
| Posted: Tue Sep 24, 2002 06:51:43 PM Post subject: Re: Skinning Windows | |
| Weehoo! Thanks Tony!
I just downloaded it and will start playing. I'll let you know if I run into any troubles. ;D |
| VDaw
| Posted: Tue Sep 24, 2002 07:51:46 PM Post subject: Re: Skinning Windows | |
| Tony, it works perfectly! A quickie screen shot below.
[center]http://www.web-helper.net/VeeDaWeb/ibshapedwintest.jpg[/center]
Now to create a serious interface. ;D
The bluish color you see is my desktop. ;D The actual background color used on the skin was 255,255,0, a very bright yellow so there would not be color alias on the curved areas of the skin. The interface bitmap was 640X480 and I added an RE control. The size of the exe is 395K. :D Pretty good when using a bitmap weighing in at 901K. |
| Tony
| Posted: Tue Sep 24, 2002 07:54:08 PM Post subject: Re: Skinning Windows | |
| Wow Vikki! That is awesome! ;D
Looking forward to seeing some more. :)
Tony. |
| VDaw
| Posted: Tue Sep 24, 2002 08:36:42 PM Post subject: Re: Skinning Windows | |
| Or how 'bout this base design...add custom icons etc and it's an interface...this is tooo much fun...both my loves, graphics and programming all rolled into one! ;D
[center]http://www.web-helper.net/VeeDaWeb/ibshapedwintest1.jpg[/center]
Same thing, the size of the interface is actually 640x480...files sizes the same etc. And yep, that's my boring old blue desktop that you see. ;D |
| Tony
| Posted: Tue Sep 24, 2002 08:44:07 PM Post subject: Re: Skinning Windows | |
| Very impressive Vikki!
I can see that you're having way too much fun with this stuff, but then again that's what it's all about. ;)
Tony.
PS - I know who to get to do my graphics when I need some now. ;) |
| Jerry Muelver
| Posted: Tue Sep 24, 2002 08:48:15 PM Post subject: Re: Skinning Windows | |
| Vikki, it kinda looks like Microsoft Word, as seen by a code-sensitive Martian. |
| aeon
| Posted: Tue Sep 24, 2002 08:53:12 PM Post subject: Re: Skinning Windows | |
| I hear sleigh bells over London - Thanks Tony - Christmas is here!!! ;D
I can see you are having fun there Vikki Hope these creations don't just look funky but will sing and dance soon too! :D |
| VDaw
| Posted: Tue Sep 24, 2002 08:55:34 PM Post subject: Re: Skinning Windows | |
| Hehe Jerry. I'm working on a children's interface right now. I'll post it up when it's done with icons. This is way tooo much fun!
Tony, on the graphics...anytime...let me know. ;D |
| Tony
| Posted: Tue Sep 24, 2002 09:10:37 PM Post subject: Re: Skinning Windows | |
| *lol* An early merry Christmas to you aeon! Enjoy your the new toys. ;)
Vikki, I appreciate the offer on the graphics. :)
Tony. |
| Cor
| Posted: Tue Sep 24, 2002 09:49:39 PM Post subject: Re: Skinning Windows | |
| Woow,
Thank you all.
I just mentioned browserBob and look what a great input you did. ;D |
| TronDoc
| Posted: Tue Sep 24, 2002 11:24:22 PM Post subject: Re: Skinning Windows | |
| I knew somebody had the smarts! Many Many Thanks Tony!!! --Joe |
| VDaw
| Posted: Tue Sep 24, 2002 11:27:21 PM Post subject: Re: Skinning Windows | |
| Ok one more and I promise I'll quit loading up the thread with graphics. ;D *crossing fingers*
So here's a screenie of a child's program interface. A couple of things need to be worked out such as the browser area will be entirely too small, so either there will be a browser or the program will open the default browser *or* I'll redesign the interface. Maybe have a different skinned window open with the browser in it. Also the masking needs to be done better. Have to figure out a color that will mask well with the colors I used in the image.
[center]http://www.web-helper.net/VeeDaWeb/childface1ath.jpg[/center]
Geesh, I gotta quit doing this so I can get some work done.......well maybe just one more...*NO*, work first.
Tony, you've created a monster and a window convert. ;D |
| TronDoc
| Posted: Tue Sep 24, 2002 11:28:54 PM Post subject: Re: Skinning Windows | |
| a RED-stop-sign-shaped "GO"??? tsk, tsk, tsk.. ..you are more talented than THAT Vikki <severe teasing going on here> ;D |
| Tony
| Posted: Wed Sep 25, 2002 12:04:44 AM Post subject: Re: Skinning Windows | |
| Quote: | Tony, you've created a monster and a window convert. ;D |
*lol* Vikki, I accept full responsibilty! ;D
Joe, you're very welcome, Enjoy!
Tony. |
| VDaw
| Posted: Wed Sep 25, 2002 12:15:44 AM Post subject: Re: Skinning Windows | |
| Lol, Joe! ;D
I'm changing it to a different shaped sign with the word go on it. Gotta move the edit window down a little so I can add the buttons for editing.
Decided to add a simple word processor and a calculator so an interface redesign in progress already, ROFL! ;D
Too much fun! |
| sbrown
| Posted: Wed Sep 25, 2002 02:02:51 AM Post subject: Re: Skinning Windows | |
| Vikki,
There's only one thing to say now ... you go girl! ;D
Scott |
| VDaw
| Posted: Wed Sep 25, 2002 02:22:02 AM Post subject: Re: Skinning Windows | |
| Scott! Egads, I wasn't kidding when I said Tony created a monster and a skinned window convert. ;D
VeeDaWeb is on the back burner and I'm gonna finish the little app up in the next day or so...tooo much fun.
Work? what's that....*not answering phone in case it's the boss...* ;D |
| Paul Turley
| Posted: Wed Sep 25, 2002 02:32:17 AM Post subject: Re: Skinning Windows | |
| Tony, If you want to create a zip containing all the IBasic samples and the region creator I would be happy to add it to the library.
Paul. |
| sbrown
| Posted: Wed Sep 25, 2002 02:32:30 AM Post subject: Re: Skinning Windows | |
| Vikki,
It's so evident ya really love graphics. ;D ;D ;D ;D ;D ;D ;D ;D
Scott |
| Tony
| Posted: Wed Sep 25, 2002 11:19:20 AM Post subject: Re: Skinning Windows | |
| Quote: | Tony, If you want to create a zip containing all the IBasic samples and the region creator I would be happy to add it to the library. Paul. |
Paul,
Sounds good. I'll get it all together along with a readme file and send it to you for inclusion in the library.
Thanks,
Tony.
|
| aeon
| Posted: Wed Sep 25, 2002 03:33:35 PM Post subject: Re: Skinning Windows | |
| Skinned apps are great! - Got something small working OK and by checking for @mousex and @mousey I can make actions happen on clicks on different parts of a graphic. What I need to sort now is how to do a roll-over!
All I can figure at the moment is that if the whole graphic interface was broken down into a grid then it should be possible to set what graphic appears in which section by detecting the presence or absence of the mouse cursor and its state (for mousedown graphic change etc). This seems like far too much complexity and a major hassle in the case of any minor control position changes. There ought to be a simple was of showing and hiding a graphic depending on mouse position and/or action.
Any thoughts anyone? You must be there too Vikki judging by your screenshots and I feel sure that you know the answer! In fact I bet you are using the same technique right now to add both graphics changes AND sound to roll-overs and button clicks! ;) |
| VDaw
| Posted: Wed Sep 25, 2002 04:32:49 PM Post subject: Re: Skinning Windows | |
| Aeon,
Actually I ran into a little trouble when trying to use the interface graphic built in buttons. I think it has to do with the *left button down* constant and it's not letting me use left button up for those. I'm not done trying to work around that yet but I've opted for using regular buttons with images for now until I can scope out the problem. Probably I did something silly again when trying to code it. Gonna be out for a couple of hours today so I'll work on it again when I get back.
And yes, I believe you can swap images by detecting the mouse position. I tried it once and I think I had it working. Can't find the code right this minute though. I'll look when I get back.
All of the above, for skinned apps, will depend on whether I can get the messages to behave. Anywhoo, I'll try it again when I get back. Seems I remember yesterday having some other anomalies and it may have just been silly coding like the beep that didnt' work and then did. I'll put some code up when I get back. |
| granada
| Posted: Wed Sep 25, 2002 05:06:33 PM Post subject: Re: Skinning Windows | |
| hi guys take a look at this
http://www.pollensoftware.com/styleskin/index.html
put the two together and you can have some great fun ;D i registerd this some time ago
dave |
| Tony
| Posted: Wed Sep 25, 2002 05:24:18 PM Post subject: Re: Skinning Windows | |
| Hey Dave,
Thanks for the link....downloading it now.
Think I can have some fun playing with this. ;D
Tony. |
| VDaw
| Posted: Thu Sep 26, 2002 05:48:30 AM Post subject: Re: Skinning Windows | |
| Aeon,
Didn't get a chance to work on this today. I'll work on it first thing tomorrow. ;D |
| aeon
| Posted: Sat Sep 28, 2002 11:29:57 AM Post subject: Re: Skinning Windows | |
| Seems like tomorrow is a long time coming Vikki ;) I notice from other threads that you have had other concerns!
I may get a chance to look at this again in the next day or so - if anyone has any hints about where to start in order to create custom buttons with skinned apps I should be very grateful! Basically Roll-overs / button downs need to trigger graphics on/off in defined positions. My initial attempts the other day got a graphic appearing on a roll-over but not disappearing on a 'roll-out'!
Thanks ...Ian |
| VDaw
| Posted: Sat Sep 28, 2002 03:34:19 PM Post subject: Re: Skinning Windows | |
| Ack! Aeon,
Worked on this, got it working and then CRS (can't remember stuff) kicked in. Try the following example. You'll need to add two images as resources, id 7777 and 7778 respectively. I used a normal state image 65x65 and an over state image 65x65. The images were gifs. Remember to compile before running after adding the resources.
Code: | 'Define our variables DEF win:WINDOW DEF imge1,imge2:INT
'create a window WINDOW win,100,100,400,400,@SIZE|@SYSMENU|@CAPTION|@MINBOX|@MAXBOX,0,"What?",mainwin
'create a menu MENU win,"T,File,0,0","I,Quit,0,1"
imge1 = LOADIMAGE (7777, @IMGSCALABLE) imge2 = LOADIMAGE (7778, @IMGSCALABLE)
'program is running run = 1
'wait until we want to end the program WAITUNTIL run = 0
DELETEIMAGE imge1,@IMGSCALABLE DELETEIMAGE imge2,@IMGSCALABLE CLOSEWINDOW win END
'This is the subroutine that will handle any messages SUB mainwin SELECT @CLASS 'if we close the window end the program CASE @IDCLOSEWINDOW run = 0 'menu handler CASE @IDMENUPICK 'menu ids SELECT @MENUNUM CASE 1 run = 0 ENDSELECT CASE @IDMOUSEMOVE IF ((@MOUSEX > 50) & (@MOUSEY > 50)) & ((@MOUSEX < 100) & (@MOUSEY < 100)) SHOWIMAGE win, imge1, @IMGSCALABLE, 50,50,65,65 'RECT win, 50, 50, 50, 50, RGB(0,0,255),RGB(0,0,255) ELSE SHOWIMAGE win, imge2, @IMGSCALABLE, 50,50,65,65 'RECT win, 50, 50, 50, 50, RGB(255,0,0),RGB(255,0,0) move win,20,200 print win,@mousex, " ",@mousey," " ENDIF ENDIF ENDSELECT RETURN |
The commented out code was the tester and just draw rectangles instead of using an image. ;D |
| aeon
| Posted: Sat Sep 28, 2002 10:57:35 PM Post subject: Re: Skinning Windows | |
| Thanks again Vikki - I was getting close before looking back at my previous code but somehow it just hadn't clicked! I now have roll-overs and button downs all working and compiled in with the .exe as resources on a skinned app! Only works with @IMGBITMAP though as far as I can tell.
I notice that when moving the mouse away from a roll-over zone sometimes the graphic does not revert (the 'else' bit does not seem to kick in). Seems more likely to happen if the mouse is moving slowly but I cannot really see a pattern... Have you noticed this? I wonder if it's to do with the skinning going on at the same time?
Also - Have you tried to incorporate your about box code into a skinned app yet? I can get it to work fine from your code, modify it as required and all OK. When I insert it into the skinned apps code and try calling it by clicking on one of my custom controls I get an error. And yes I did define variables as instructed at the head of the code! |
| VDaw
| Posted: Sat Sep 28, 2002 11:42:08 PM Post subject: Re: Skinning Windows | |
| Aeon, ;D
I haven't tried it yet. I've been buried in a bugger bit of boogly woogly code. ::)
I'll do it now. What error do you get. |
| VDaw
| Posted: Sun Sep 29, 2002 12:13:10 AM Post subject: Re: Skinning Windows | |
| Hey Aeon,
Works here with a couple of anomalies. ;D Surprise, surprise.
First it appears in the order of things if you just add the About Window code at the end of your file in a skinned app and leave the main program window as the parent the z-order is a little wierd. If however, you change the About Window not to be a child the z order is better. Meaning that the about window shows up on top.
That problem may be able to be solved with some RCM (random code moving) but I'm right in the middle of that bugger code so I can't work on it right this minute. I'll get to it soon as I get this other code sorted. ;D |
| fidcal
| Posted: Mon Mar 31, 2003 06:09:00 AM Post subject: | |
| Has anyone been able to get the skintest.iba code to work as downloaded from the library? I've been trying to contact the author but had no success yet.
As as test I did the following....
1. Load skintest.iba 2. Resaved it as skintest2.iba 3. Added the exact same resources as in the REMS 4. Saved the program again. 5. Built the exe file (as Windows program not DirectX/3D) 6. Ran the exe from Windows Explorer.
The skin appears OK but if I click it with the mouse at all then I get.....
An error has occured Line number: 39
These are the line number around that area....
0037 SETID "SKIN_WIDTH",283 0038 SETID "SKIN_HEIGHT",301 0039 0040 ' Globals 0041 DEF Run:INT
You can see there is nothing logically wrong there - in fact line 39 is blank line!
The provided skintest.exe doesn't do this but can be dragged. Any ideas? |
| Paul Turley
| Posted: Mon Mar 31, 2003 06:43:03 AM Post subject: | |
| Brian, Run it from the IDE. There were a few mismatched parenthesis in his code that I had found. Thought I had caught all of them. I reuploaded it to the library recently if your working with an old copy
Paul. |
| fidcal
| Posted: Mon Mar 31, 2003 08:06:50 AM Post subject: | |
| I get a load resource error if I try it from the IDE and this crashes IBasic completely - though the same compiles OK into an exe. Can it be a path error? I browsed for the resource and the IDE put the full path in even though the files are in the same folder. Plus the path has long filenames which I noticed were truncated with the ~ symbol. I'll try moving everything to a simple path maybe or reduce the resource path to just the filename.
The version I've got I only downloaded about Friday or Saturday from the library. |
| fidcal
| Posted: Mon Mar 31, 2003 09:15:39 AM Post subject: | |
| This is the date in the listing I downloaded the other day : 9-22-2002
I moved all files to C:\TEST then started again with skintest.iba, renamed it to skintest5.iba, saved it, added the resources, these show in the resource dialog as eg, C:\TEST\skinit.bmp with all the right data given in the listing - even the case is exactly the same. I'm using Windows 98 1st edition but get the same result in Windows XP Pro on the same machine.
When I run it from the IDE I still get 'load resource error'
Hang on - just looking at the User Guide and it says resources cannot be accessed from the IDE. I'd forgot that. Not used resources very much.
So, build an exe in the same folder and run it and get the same problem - it runs and shows the transparent window but it crashes if I click it with the mouse. Is this really the same listing that was used to create the exe supplied in the zip? |
| VDaw
| Posted: Mon Mar 31, 2003 03:43:26 PM Post subject: | |
| Hey Brian! :D
Hmmm, just checked a program I had started with skinning that worked before but now exhibits similar behavior you describe. The difference is that I have some buttons on my skin and if I click a couple of those first and then click anywhere on the skin region I don't get that error but the program closes (not a planned behavior). However, just running the executable and then clicking on the skin results in an error. Don't know if I can figure out what's wrong but I'll work on it. :D
Edit:
I'll add that right clicking does not cause an error and does not close the program. I checked the constants and all seem to be correct according to the API Viewer. :? |
| fidcal
| Posted: Mon Mar 31, 2003 05:35:12 PM Post subject: | |
| Vickie, thanks for checking this out.
If you get this error with a listing that worked before then that suggests some difference in the IBasic version? Wonder if it's worth re-installing an earlier version temporarily.
I admit I have not yet studied the listing as I didn't know how it worked but wondered if it is possible to convert to work without resources, ie, load image from file, etc, so it might be easier to test and see what's happening? |
| VDaw
| Posted: Tue Apr 01, 2003 03:22:36 PM Post subject: | |
| Hey Brian!
I'll try it without loading resources and see what happens but I have a sneeking suspicion that the problem lies somewhere else as the resources load correctly. The version that it worked with I believe was 1.98 if you need to know that.
At any rate, I'm going to be giving notice on one of my jobs this week so I can get back to more coding and SAQ updating. ;-)
I'll reinstall 1.98 and see if I can get it set up without the resources and test. |
| SnarlingSheep
| Posted: Tue Apr 01, 2003 07:29:18 PM Post subject: | |
| I think I had the same problem. There is a ")" that shouldn't be there on the end of: SENDMESSAGE RegionWin, @WM_NCLBUTTONDOWN,@HTCAPTION,0) It's in your handler under @IDLBUTTONDN. Works well once you remove that :) |
| fidcal
| Posted: Tue Apr 01, 2003 07:51:59 PM Post subject: | |
| Good one! Snarling sheep! Never thought of something so simple! :) |
| VDaw
| Posted: Wed Apr 02, 2003 03:02:58 PM Post subject: | |
| Wunderbar! or is that ice-cream-bar or maybe Joe's bar? Erm, Joe's bar...oh, nope, Joe's bar is where I'd of been trying to figure this one out. :D (no reference intended to any of *our* Joes of course)
Great catch SnarlingSheep! :D |
| Joske
| Posted: Thu Feb 12, 2004 08:54:05 PM Post subject: | |
| WOW! This is all very cool!
Joske |
| DennisC
| Posted: Fri Feb 13, 2004 12:56:22 AM Post subject: | |
| I also want to have some fun but get a 404 when I attempt to download skinit.zip and Roncreator.zip. Can someone load them to the SAQ?
Regards
Dennis |
| DennisC
| Posted: Fri Feb 13, 2004 04:28:25 PM Post subject: | |
| Still getting a 404 (page not found) when attempting to download. Can anybody help?
Kind Regards
Dennis |
| Paul Turley
| Posted: Fri Feb 13, 2004 05:21:58 PM Post subject: | |
| Look in the IBasic Library
http://www.pyxia.com/iblibrary.html for SkinWin.zip
Tony is no longer a member of the forums, or the IBasic community. |
| DennisC
| Posted: Sat Feb 14, 2004 01:50:22 AM Post subject: | |
| Thanks Paul
Regards
Dennis |
| DennisC
| Posted: Sat Feb 14, 2004 01:55:06 AM Post subject: | |
| Duh!! Didn't look at the dates of the posts :oops: :oops: Joske's post of 12 Feb made me think it was a new thread. :oops:
Regards
Dennis |
| Joske
| Posted: Mon Feb 16, 2004 08:49:53 AM Post subject: | |
| Well, for me it IS a new tread. I'm using IBasic only for a short time now.
I have played a bit with this stuff, and I created a simple desktop clock that stays always on top.
You can find the code and an executable on my site, www.josdejong.tk -> IBasic programs
This is the code:
Code: |
' Filename: clock.iba
' creates a round clock with Hour, minute and second hand
' that is always on top
' created by Jos de Jong, 2004
' wjosdejong@hotmail.com
' API Declarations
DECLARE "gdi32", CreateEllipticRgn(X1:INT, Y1:INT, X2:INT, Y2:INT),INT
DECLARE "gdi32", CombineRgn(hDestRgn:INT, hSrcRgn1:INT, hSrcRgn2:INT, nCombineMode:INT),INT
DECLARE "user32",SetWindowRgn(hWnd:WINDOW, hRgn:INT, bRedraw:INT),INT
DECLARE "gdi32", DeleteObject(hObject:INT),INT
DECLARE "user32",InvalidateRect(hwnd:WINDOW, lpRect:INT, bErase:INT),INT
DECLARE "user32",GetWindowLongA(hwnd:INT, nIndex:INT),INT
DECLARE "user32",SetWindowLongA(hwnd:INT, nIndex:INT, dwNewLong:INT),INT
DECLARE "user32",SetWindowPos(hwnd:INT, hWndInsertAfter:INT, x:INT, y:INT, cx:INT, cy:INT, wFlags:INT),INT
' Constants
SETID "TRUE",1
SETID "FALSE",0
SETID "SPACEBAR",&H20
SETID "RGN_OR",2
SETID "IDSKIN",100
SETID "GWL_STYLE",-16
SETID "SWP_NOMOVE",&H2
SETID "SWP_NOZORDER",&H4
SETID "WM_NCLBUTTONDOWN",&HA1
SETID "HTCAPTION",2
' Globals
DEF Run:INT
DEF Skin:INT
DEF Style:INT
DEF Region1:INT
DEF main:WINDOW
DEF Temp:INT
DEF Xclock,Yclock,Rclock:int
DEF Pi:double
DEF AlwaysOnTop:int
DEF Left, Top:int
Const Black = rgb(0,0,0)
Const White = rgb(255,255,255)
Const Red = rgb(200,0,0)
Const mnuOnTop = 100
Const mnuExit = 101
Const mnuLine = 102
Pi = 4 * Atan(1)
Xclock=50
Yclock=50
Rclock=30
AlwaysOnTop = 1
' Create the main window
WINDOW main,-200,0,100,100,@nocaption,0,"Clock", mainRoutine
temp = SetWindowPos(Main, -1, 0, 0, 0, 0, 3) :'always on top
setwindowcolor main, rgb(255,255,255)
RegionMe
'place the clock to lefttop of the screen
getscreensize Left,Top
setsize main, Left-150,0, 100,100
starttimer main, 1000
PaintClock
Run = @TRUE
WAITUNTIL Run = @FALSE
CLOSEWINDOW main
END
SUB mainRoutine
' Message handler for the window
SELECT @CLASS
CASE @IDCLOSEWINDOW
Run = @FALSE
Case @idtimer
PaintClock
CASE @IDCHAR
if @code=27 then run=0 :'ESC
CASE @IDLBUTTONDN
SENDMESSAGE main, @WM_NCLBUTTONDOWN,@HTCAPTION,0 :'to move the window by dragging it
CASE @IDRBUTTONDN
if AlwaysOnTop = 0
contextmenu main, @MOUSEX, @MOUSEY, "I,Always on Top,0,mnuOnTop", "I,--,0,mnuLine", "I,Close,0,mnuExit"
else
contextmenu main, @MOUSEX, @MOUSEY, "I,NOT Always on Top,0,mnuOnTop", "I,--,0,mnuLine", "I,Close,0,mnuExit"
endif
CASE @IDMENUPICK
if @menunum = mnuExit then run=@False
if @menunum = mnuOnTop then SetAlwaysOnTop
ENDSELECT
RETURN
SUB RegionMe
' Creates a circular window
Region1 = CreateEllipticRgn(Xclock-Rclock,Yclock-Rclock,Xclock+Rclock+1,Yclock+Rclock+1)
SetWindowRgn(main, Region1, @TRUE)
DeleteObject(Region1)
Style = GetWindowLongA(main, @GWL_STYLE)
SetWindowLongA(main,@GWL_STYLE,Style)
RETURN
sub PaintClock
'repaint the clock
def Point:int
def Angle:double
def Hour:int
def Min:int
def Sec:int
def HourHand:double
def MinHand:double
def SecHand:double
def TimeNow:string
def Xs, Ys, Xe, Ye:int
'calculate the new time
TimeNow = Time$
Sec = Val(Mid$(TimeNow, 7, 2)): SecHand = Sec * Pi / 30 - 0.5 * Pi
Min = Val(Mid$(TimeNow, 4, 2)): MinHand = (Min + Sec / 60) * Pi / 30 - 0.5 * Pi
Hour = Val(Mid$(TimeNow, 1, 2)): HourHand = (Hour + Min / 60 + Sec / 3600) * Pi / 6 - 0.5 * Pi
'now repaint all points and the hands
'paint the border of the clock
SETLINESTYLE main,@LSSOLID, int(Rclock/6)
Circle main, Xclock, Yclock, Rclock, Black, White
'paint 12 small circles for each hour
SETLINESTYLE main,@LSSOLID, int(Rclock/15)
For Point = 0 To 60 Step 5
Angle = Point * Pi / 30 - 0.5 * Pi
Xs = Xclock + Rclock *.8 * Cos(Angle)
Ys = Yclock + Rclock * .8 * Sin(Angle)
line main, Xs, Ys, Xs, Ys, Black
Next Point
'paint a line for 12, 3, 6 and 9 hour
SETLINESTYLE main,@LSSOLID, int(Rclock/15)
For Point = 0 To 60 Step 15
Angle = Point * Pi / 30 - 0.5 * Pi
Xs = Xclock + Rclock *.8 * Cos(Angle)
Ys = Yclock + Rclock * .8 * Sin(Angle)
Xe = Xclock + Rclock *.7 * Cos(Angle)
Ye = Yclock + Rclock * .7 * Sin(Angle)
Line main, Xs,Ys, Xe,Ye, Black
Next Point
'paint the hour hand
SETLINESTYLE main,@LSSOLID, int(Rclock/10)
Xs = Xclock + Rclock *.4 * Cos(HourHand)
Ys = Yclock + Rclock * .4 * Sin(HourHand)
Line main, Xclock,Yclock, Xs,Ys, Black
'paint the minute hand
SETLINESTYLE main,@LSSOLID, int(Rclock/20)
Xs = Xclock + Rclock *.7 * Cos(MinHand)
Ys = Yclock + Rclock * .7 * Sin(MinHand)
Line main, Xclock,Yclock, Xs,Ys, Black
'paint the second hand
SETLINESTYLE main,@LSSOLID, int(Rclock/50)
Xs = Xclock + Rclock *.8 * Cos(SecHand)
Ys = Yclock + Rclock * .8 * Sin(SecHand)
Line main, Xclock,Yclock, Xs,Ys, Red
SETLINESTYLE main,@LSSOLID, int(Rclock/15)
Line main, Xclock,Yclock, Xclock,Yclock, Red
return
sub SetAlwaysOnTop
'adjust the windowposition to normal or to AlwaysOnTop
AlwaysOnTop = 1 - AlwaysOnTop
if AlwaysOnTop = 1
'always on top
temp = SetWindowPos(Main, -1, 0, 0, 0, 0, 3)
else
'normal
temp = SetWindowPos(Main, 1, 0, 0, 0, 0, 3)
temp = SetWindowPos(Main, 0, 0, 0, 0, 0, 3)
endif
return
|
|
| ZeroDog
| Posted: Mon Mar 08, 2004 02:29:31 PM Post subject: | |
| If you are interested in window skinning, don't forget to check out ZeroDog's Custom Window Designer. It's got a nice interface to work with.
http://www.pyxia.com/community/viewtopic.php?t=7331 |
| Joske
| Posted: Mon Mar 08, 2004 02:42:09 PM Post subject: | |
| WOW! thats a great program! I had not seen that before.
great work! |
|
|