Important alert: (current site time 7/16/2013 2:49:46 AM EDT)
 

winzip icon

LaVolpe Custom Windows: Part I

Email
Submitted on: 11/24/2004 12:48:36 PM
By: LaVolpe 
Level: Advanced
User Rating: By 45 Users
Compatibility: VB 6.0
Views: 22297
author picture
(About the author)
 
     Part 1. Prequel to a full-blown skinning application. This part does not skin but attempts to completely control the window non-client area. Provided in hopes you will help identify any bugs on different O/Ss. Works well on 98/2K. The other parts of this project will be submitted after bugs fixed in this part and feedback has been addressed. Part 2 will be skinned version compatible with MDIs, Part 3 will include routines for custom-drawn menus. Heavily subclassed and heavily commented; but still a work in progress. Feedback is definitely requested especially pertaining to bugs and suggestions.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 72 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
11/24/2004 12:55:23 PMLaVolpe

Have fun playing. The end result will be a skinner. Therefore, no part of this application will draw default nonclient objects. Although, this submission does do default titlebars, menubars & borders; that functionality will be removed from the final project. Please read comments at top of Form1 & top of clsCustomWindow. Thank you.
(If this comment was disrespectful, please report it.)

 
11/24/2004 1:17:15 PMCurtW

5 Globes - always good stuff and this is right in line, leaves us drooling for more. Feel free to add me to an update notification e-mail list if you make one.
(If this comment was disrespectful, please report it.)

 
11/24/2004 1:20:22 PMAndrea Batina[Revelatek]

EXCELLENT!!!

5Globes from me.

You can catch the Me.Caption change by using this message &HAE, but this message is not called in WinXp SP2 and you must use WM_GETICON.

Little strange solution but it works.

Hope it helps.

Rgds,
Andrea Batina
(If this comment was disrespectful, please report it.)

 
11/24/2004 1:28:47 PMLaVolpe

Andrea, what is &HAE? Is that a WM, documented or undocumented? Tried it on Win2K w Spy++ & no such message posted. In addition, catching it still may not prevent VB from doing it. It took a long time to figure out out the prevent VB from drawing min/max/close each time you used keybd to access a menu item (i.e. ALT+F for File).
(If this comment was disrespectful, please report it.)

 
11/24/2004 1:49:57 PMLaVolpe

P.S. If curious what we are talking about... add a Me.Caption='Whatever' and trigger it while subclassed. VB just draws portion btwn windows icon & minimize button
(If this comment was disrespectful, please report it.)

 
11/24/2004 2:57:51 PMGandolf_The_GUI

LaVolpe - you are a VB god. Will you have my Child Forms??
(If this comment was disrespectful, please report it.)

 
11/24/2004 3:24:57 PMLaVolpe

:)
(If this comment was disrespectful, please report it.)

 
11/24/2004 3:56:58 PMVB COMEDIAN

Woooooooooooooooooooaaaah. Hey, Evan Tader.. I'm huge fan of your but...

LaVople is really VB God! The kings of Kings. Yeepeee!!!

This is really cool. LaVople gonna win PSC code of month. So innovating. 5 Globals!

(If this comment was disrespectful, please report it.)

 
11/24/2004 4:57:53 PMAndrea Batina[Revelatek]

LaVolpe, its undocumented message. I don't know which but it works. Try to subclass the main form with this message and change the caption using Me.Caption, and the subclasser should fire. You can check it in action in my submission here:

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=57301&lngWId=1
< /span>
(If this comment was disrespectful, please report it.)

 
11/24/2004 5:12:29 PMxIntegrated Development Group

works fine on XP
(If this comment was disrespectful, please report it.)

 
11/24/2004 5:31:56 PMSteve

Cooooool - an option to add an additional button to the title bar would be even cooler ... ;-) 5 globes
(If this comment was disrespectful, please report it.)

 
11/24/2004 5:34:21 PMLaVolpe

Steve, it's actually in the code you downloaded. I just haven't finalized that yet -- concentrated more on preventing windows from repainting on its own.
(If this comment was disrespectful, please report it.)

 
11/24/2004 5:47:01 PMLaVolpe

Andrea, must be a newer WM. Win98 doesn't catch it & I didn't see Spy+ catch it with Win2K.
(If this comment was disrespectful, please report it.)

 
11/24/2004 6:48:00 PMAnoop Sankar

I was thinking about developing an app and found your buttons ony hard disk. Was thinking what a wonderful coder you are. Then I just come here and see this and find out that you are an even better coder..

And I agree you are VB GOD!!

Thanks for sharing.
(If this comment was disrespectful, please report it.)

 
11/25/2004 12:26:15 AMenmity

final endevor on proving VB6 is great? :)
(If this comment was disrespectful, please report it.)

 
11/25/2004 1:34:30 AMenmity

did u ever see vbaccelerator's NeoCaption? its version 2 is somehow mimics the NeoPlanet browser 's UI, but without fully compatible with its skins, it you do fully mimics and make it compatible with its skins, that will be perfect!
(If this comment was disrespectful, please report it.)

 
11/25/2004 6:37:42 AMTerry L

Again the VB King has come back to speak to his VB people with good news! We thank you with the high 5's and your subjects will be waiting your return. SUPER
(If this comment was disrespectful, please report it.)

 
11/25/2004 6:57:02 AMJustin Yates

Great code.
(If this comment was disrespectful, please report it.)

 
11/25/2004 7:08:22 AMrBg

Excellant, please except my 5 balls on your chin
(If this comment was disrespectful, please report it.)

 
11/25/2004 7:37:03 AMStefan Schermer

5 from me too. Excellent like all the others :D
(If this comment was disrespectful, please report it.)

 
11/25/2004 8:37:34 AM

Very nice. I did find 1 thing. I can't drag the form to my 2nd monitor.
(If this comment was disrespectful, please report it.)

 
11/25/2004 12:01:47 PMLaVolpe

Enmity. I'm aware of NeoCaption. I'm generally very impressed with their stuff; but not with that project. Keyboard nav on menubar is horrid, it doesn't handle MDIs, it uses hooks during life of subclassing & a few other things that disappointed me. I thought I could do better, a lot better. When this project is done, it probably will be better
(If this comment was disrespectful, please report it.)

 
11/25/2004 12:04:36 PMFred.cpp

Now I remember why I use to feel like a beginner:)
Supreme work
(If this comment was disrespectful, please report it.)

 
11/25/2004 2:37:25 PMLaVolpe

I think I have a hotfix for the multiple monitor question. Since I can't test it (only 1 monitor), if someone would care to test it for me, please click on my handle above and email me. If it works, I'll update this post with the fix. Thank you.
(If this comment was disrespectful, please report it.)

 
11/25/2004 8:08:19 PMÙmega

Just a suggestion why don't you incorporate your lavolpe submenu v2? then it would be a very complete package. :D
(If this comment was disrespectful, please report it.)

 
11/25/2004 8:13:17 PMenmity

I think LaVolpe is working on his menu stuffs:)
(If this comment was disrespectful, please report it.)

 
11/25/2004 8:17:32 PMLaVolpe

enmity is correct. I have in the works a completely different menu project to allow for custom shaped menus, and a host of other options/improvements over typical owner-drawn menus.
(If this comment was disrespectful, please report it.)

 
11/26/2004 4:38:10 AMPhantom Man

Hi Keith

Very Nice Start.
Well Written Code And Always A Joy.

Kind Regards
Gary
(If this comment was disrespectful, please report it.)

 
11/26/2004 7:50:59 AMPhantom Man

Hi Keith

Bug Report:

Bug 1:
OS: WinXP SP2
Problem: Close Button Not ReEnabling.

Trace: Subclass The Form, Disable The Close Button. Unsubclass The Form = Close Button Still Appears Disabled,
But When You Click On It, It Closes The Form.


Bug 2:
OS: WinXP SP2
Problem: Form Border Style

Trace: Subclass The Form Then Unsubclass The Form = XP Caption Style Not Reverted To Its Original State.

Question: Should The Form Revert Back To It's Original State After SubClassing And Then Unsubclassing It?

Kind Regards
Gary

(If this comment was disrespectful, please report it.)

 
11/26/2004 8:34:52 AMLaVolpe

Gary, yes hopefully. One of the last things done to the form after subclassing is to replace the original style/exstyle, reinstate the menu, and simply force a redraw. Question, if you minimize & then restore -- does the default styles reappear? If so, I can try replacing the styles, hide form, then unhide form with doevents to try to force the window to update.
(If this comment was disrespectful, please report it.)

 
11/26/2004 8:48:20 AMPhantom Man

Keith,

The Answer To Your Question Is No, It Doesn't Restore After You Minimize And Then Restore It. (Tested In Design and Compiled Mode)

Note: When You Change The Forms BorderStyle In Design Mode Say From Sizeable To Fixed Single Then Run The App.

Subclass The Form, The Form Caption Doesn't Inherit The Forms Original Caption Style.

Ie: Normal Form: Fixed Single (Fixed No Max Or Min Button)

When Subclassed: Caption Style Has Max And Min Button.

Not Reporting This As A Bug As I Don't Know If This Is Supposed To Happen.


Gary

(If this comment was disrespectful, please report it.)

 
11/26/2004 10:18:29 AMLaVolpe

Gary, correct in that I don't take the form's original settings. Without caption, maximize covers entire screen & minimize if not on task bar will disappear off the screen completely. In addition, by having user able to toggle min/max/close via code, these buttons are always active on the subclassed form, but may not be drawn depending on toggle value. My guess is that XP (a skinning OS) needs some other API call to completely redraw the form. And truth be told, I don't think it matters anyway::skinned forms will almost never be reverted back to non-skinned in real life. I'll try to borrow an XP machine and see if I can figure it out.
(If this comment was disrespectful, please report it.)

 
11/26/2004 10:44:08 AMLaVolpe

Gary, if you are still in puzzle-solving mindset, can you try posting a WM_THEMECHANGED (&H31A) message to the window immediately after the "TweakSysMenu True" line in the EndSubclass routine? That may do the trick per MSDN.
(If this comment was disrespectful, please report it.)

 
11/27/2004 5:17:54 AMPhantom Man

Hi Keith

It Works To A Certain Extent.
Well Almost, I Have To Resize The Form (Using The Mouse) After I End The Subclassing. The Window Then Reverts Back To It's Original Style.

Sorry To Be The Barer Of Bad News.

Gary.

(If this comment was disrespectful, please report it.)

 
11/27/2004 11:00:54 AMCarles P.V.

Hi,

Yes, same behaviour on XP sp1. After a first look with Spy++:

First messages at time to enable XP themes are: 1) &H13B (P) wP=0 lP=0. 2) &H13B (P) wP=lpStruct? lP=1. 3) (S) &H13A (WM_THEMECHANGED) wP=lpStruct? lP=1. Both lP and wP are reserved (MSDN). Next messages are quite known... WM_WINDOWPOSCHANGING, WM_NCCALCSIZE, WM_NCPAINT, ...

No idea about &H13B message (maybe WM_THEMEISCHANGING ?). And no idea about use of reserved lP and lW.

Also, once I apply XP theme, spy++ shows 13 messages and *pause*. This, while the screen notifying "wait". Then, once (meanwhile) all is redrawn, spy++ continues its message report, starting with WM_WINDOWPOSCHANGING, WM_NCCALCSIZE, WM_NCPAINT, ... WM_MOVE(!), WM_SIZE(!), etc.


Carles.
(If this comment was disrespectful, please report it.)

 
11/27/2004 2:42:55 PMLaVolpe

Carles, I've seen posts on forums where WM_ThemeChanged causes slowdowns to apps. I guess if one is to completely skin at a lower level via APIs, reverting back to a normal state won't be an option on XP without some pain, but applying new skins most likey will be easy enough.
(If this comment was disrespectful, please report it.)

 
11/27/2004 7:17:36 PMOricron

I know 5 g's puts you in fromt of me in the coding contest, but hey, the code is too good to not to vote 5 for you;) not voting would be lame, voting less than five would be a crime;)
(If this comment was disrespectful, please report it.)

 
11/28/2004 1:21:10 AMLaVolpe

Guys/gals, Part II is coming along well. You may not like the way I plan on handling non-rectangular skins for sizing, but rectangular skins, even w/cut edges, draw pretty darn quick. I think Part II will be released as SDI only, & will work on MDI as time permits.
(If this comment was disrespectful, please report it.)

 
11/28/2004 8:48:45 AMFunny Dog

Can't Wait For Part 2.

(If this comment was disrespectful, please report it.)

 
11/29/2004 12:27:48 AMHeriberto Mantilla Santamaría

Is very good La Volve
(If this comment was disrespectful, please report it.)

 
11/29/2004 2:57:32 AMSyed Muhammad Fahad

Hi ... where were you ???? Thanks to see you back and again to see you that you are leading all the rest again with your unique postings :)
Your code is nice :)
Please, can you let me know the source for learning Win programming in VB ..
I hope you will let me know :)
(If this comment was disrespectful, please report it.)

 
11/29/2004 3:03:26 PMDan Redding - Blue Knot Software

Amazing; you really dream bigger than most.

Can't wait to see the final if this is just a 'test beta'.

If you're entertaining requests; there are a few new options I'd like to see: Expand the 'cannot resize' option to specify a minimum and/or maximum height and/or width. Also, Can you _add_ a button to the titlebar? I'm thinking of "minimize to Systray", but maybe a customizable button would be more 'general purpose'...? Or is that outside the scope of this project?

Congratulations, in advance, for winning the coding contest (again!) ;-)
(If this comment was disrespectful, please report it.)

 
11/29/2004 3:08:16 PMDan Redding - Blue Knot Software

P.S. Can I also vote for Gandolf the GUI's comment? Took me about a minute to be able to continue down the page ;-)
(If this comment was disrespectful, please report it.)

 
11/29/2004 4:28:57 PM

5 Globes, nothing less, unfortunately nothing more :(.
(If this comment was disrespectful, please report it.)

 
11/29/2004 4:55:41 PMLaVolpe

Dan, consider it done. User-defined min/max sizes already a todo item. User-defined added buttons already programmed in, just not finalized. I expect on truly skinned windows, this ability would be in high demand and custom placement on the non-client is also a must-have. :)
(If this comment was disrespectful, please report it.)

 
11/30/2004 8:10:35 AMPhantom Man

Hi Keith

I Don't Know If You Found A Fix For The XP Caption Restore Problem.

Possible Solution:

Place The Following Code Immediately After The "TweakSysMenu True" line In The EndSubclass Routine?

PostMessage mainHwnd, &H31A, 1, 1
PostMessage mainHwnd, &H31B, 1, 1
ProcessSysMenuItem SC_MINIMIZE, True
ProcessSysMenuItem SC_RESTORE, True

Although The Form Minizes And Then Restores It RePaints The Form Border/Caption Style Properly.

Tested On My My XPPro(SP2) Machine.

You Must Post The &H31B For This To Work.

Kind Regards
Gary.



(If this comment was disrespectful, please report it.)

 
11/30/2004 12:20:21 PMLaVolpe

Gary, that might be doable. Maybe a similar routine (without the theme messages) to begin skinning if skin activated after window visible. User will get use to window min/restore before & after as a "that's just the way it is"? Dunno. I'm still convinced that skinned form (generally borderless) will never be unskinned & therefore this may be a "testing" issue only & not a real-world issue. More to think about & thanx.
(If this comment was disrespectful, please report it.)

 
11/30/2004 12:41:15 PMPhantom Man

Hi Keith

I Totally Agree With You On The Fact That A Skinned Form Should Not Be Unskinned (Whats The Point).

But You Never Know!.

Congratulations And Thanks For Sharing Your Code.

Gary.

(If this comment was disrespectful, please report it.)

 
12/1/2004 10:23:43 AM

(nelix)
wow i am exieted about part 2, i wish you had a blog or somthing that i could watch for updates, i hate how pscode has no place to tell you when submissions are updated (only new ones added).

I wish all the pscode leaders had blogs i culd watch :P
(If this comment was disrespectful, please report it.)

 
12/2/2004 10:33:38 AMLaVolpe

nelix, no fear. When Part 2 is posted it will be a separate post.
(If this comment was disrespectful, please report it.)

 
12/12/2004 3:10:35 AM

Can't wait until the entire thing is complete. I've seen nothing but good code/software form LaVolpe. Good luck! :)
(If this comment was disrespectful, please report it.)

 
12/13/2004 1:57:45 AM

A great work!
(If this comment was disrespectful, please report it.)

 
12/15/2004 3:48:04 AMOricron

When can we get our hands on the part two;) I'm very anxious to see it and I suppose others are too:)))
(If this comment was disrespectful, please report it.)

 
12/15/2004 9:58:04 AMLaVolpe

Part II still needs work especially with menubar navigation on a static-height, adjustable width menubar which is too narrow to show all menu items. Part II won't handle MDIs and won't support borderless forms. Part 3 may handle borderless forms & possibly MDI forms. Owner drawn menus will be the last thing I do for this project overall. However, I will make every effort to allow including your own owner-drawn menu code as pain free as I can. I am hoping to have Part II out within the 1st 2 weeks of '05.
(If this comment was disrespectful, please report it.)

 
2/7/2005 10:05:23 PM

Keith, your work very is impressive.
Thanks!
For sharing your knowledge.
(If this comment was disrespectful, please report it.)

 
3/21/2005 8:13:15 PMenmity

Part II? :)
(If this comment was disrespectful, please report it.)

 
4/9/2005 10:57:17 AMAlon Hirsch

Just came across this one Keith - a bit late but still gets 5 from me.
You mention part 2 and part 3 of this project - when do you anticipate them being ready ?
You also mention more menus ;-)
I love what you've done previously with the menus and would be delighted to see more.
Any idea when we can expect them ?

Alon
(If this comment was disrespectful, please report it.)

 
6/19/2005 12:43:22 PM

Hello LaVolpe,
I've been waiting anxiously for the sequel(s). I hope you haven't dropped that project.
Great work!

/Mats
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.