Yes I'm goofy, and I like to program with ASM. Is this why I'm so goofy? And one goofy day I was feeling kind of goofy. And I needed something to occupy my goofy self. What can a goofy guy do I thought, I know, I'll geek out on a dialog box and see what cool and nifty things can be done with it.

This source code shows you how simple it is to use the Month Calendar control and the Date Picker control. Look at the resource file and the asm source file to see how easy you can include these controls in your own apps.

The source code also shows several ways you can animate the opening and closing of a dialog box. On Win 98, Me or NT4 machines the effect makes the dialog appear when it opens as if it were expanding out from the middle of the screen and shrinks away to nothing when the dialog is closed.

Now if you happen to be using this example on a Win 2000 or XP machine you will see the dialog appear gradually from nothing when it opens and gradually disappear to nothing when you close the dialog. The OS version is retrieved at the beginning of the dialog proc.

For these tricks to look good you need at least a modest or better machine. I did my testing on all but a Windows 95 OS. The effects didn't look bad at all on a 300 AMD but best on a P4 1.8. By adjusting the delay value you can speed up or slow down the effect.

Also shown in the source code is an added bonus, a simple way to animate small bitmaps on any dialog using the SetTimer function. It's pretty simple stuff and I'm just out for the fun of ASM. Aren't you?

Sorry I'm unable to spend much time here at the WA forums but I seem to be constantly occupied with my work or the up-keep of my small country home. I hope this simple example will help teach a little about ASM and maybe you'll even have fun playing with the source.

I know there are some very talented people here on the WA board and I'm sure they can help you if you get stuck figuring out this source code. And there is always room to improve my effort here. Now think up some of your own neat dialog tricks and show us your results.


Get the zipped file here: http://www.wfcravener.com/downloads/goofy.zip


Regards,
Posted on 2003-04-26 05:26:15 by bcraven
Bill,

This is great stuff, it not only looks great but the zoom in and out on win9x and the fade in and out on later versions is really slick. :alright:

Regards and thanks for posting your URL here.

hutch@movsd.com
Posted on 2003-04-26 07:47:49 by hutch--
Steve,

You?re welcome and thank you for the compliment. I hope it can be of some use to others. I sure had fun making it. Perhaps if I find some free time I?ll see what other trouble I can get into.

Regards,
Posted on 2003-04-26 08:11:48 by bcraven
Definitely cool stuff, bill. I've been wanting to write some calendar and time stuff so you saved me a whole lot of research. Thanks!
Posted on 2003-04-30 11:05:33 by drhowarddrfine
Very nice and useful code, thanks

BTW I go to your site and test your TitleBarClock app. Is great !!!
Posted on 2003-04-30 12:01:42 by pelaillo
Thanks fellows. The Calendar and Date Picker controls are very nice features to add to your application. Look up Calendar or Date Picker control in your SDK for more info on the different settings you can change in the control.

For example here's how easy it is to change the background color of the control:

In the WM_INITDIALOG section of the source code just before the SetTimer add the following invokes.

invoke GetDlgItem,hWin,ID_CALENDAR
invoke SendMessage,eax,MCM_SETCOLOR,iColor,clr

invoke GetDlgItem,hWin,ID_DATETIMEPICKER
invoke SendMessage,eax,DTM_SETMCCOLOR,iColor,clr

In the equates section of the source code file add these equates.

ID_CALENDAR equ 200

MCSC_BACKGROUND equ 0 ; the background color (between months).
MCSC_TEXT equ 1 ; the dates text color.
MCSC_TITLEBK equ 2 ; background of the title.
MCSC_TITLETEXT equ 3 ; text color of the title.
MCSC_MONTHBK equ 4 ; background within the month cal.
MCSC_TRAILINGTEXT equ 5 ; the text color of header & trailing days.

MCM_FIRST equ 1000h
MCM_SETCOLOR equ MCM_FIRST + 10
DTM_SETMCCOLOR equ DTM_FIRST + 6

In the data section of the source code file add these variables.

clr dd 0C0C0C0h ; light gray or whatever color you choose.
iColor dd MCSC_MONTHBK ; value specifying which calendar color to change.


Have fun!

Regards,
Posted on 2003-05-01 08:20:29 by bcraven
Bill, I can't reach your site - could you post the zip here as an attachment?

Have you written your own controls, or are you "only" playing around with the default ones?
Posted on 2003-05-01 08:32:49 by f0dder
f0dder,

Lately I've had trouble myself accessing the site. I've about had it with my wedsite provider, time to look for another.

Anyone else having trouble accessing my website??


This is about Windows Calendar and Date Picker common controls by the way.



Regards,


I attached the file, I think?
Posted on 2003-05-01 09:13:15 by bcraven
Yep, attached a-o-kay.
Sorta cute :) - and thanks for reminding me about the calendar control, I didn't know it was standard. As things are, I probably need to implement a calendar app "right now", and this control might actually do the trick (well, at least make my work easier). Thanks :)
Posted on 2003-05-01 09:33:20 by f0dder
Btw, a couple of tips:

you don't need to LoadLibrary for comctl32.dll - unless the functionality you use is optional and you want to be able to run on NT3.x :). comctl32.dll has been on windows since 95 and NT4.

InitCommonControlsEx is 4.70 and later, so that could give you trouble - I think it's fair to assume 4.70 though, as that's IE3.x . If you want to plead users to upgrade :), you can of course still import InitCommonControlsEx by GetProcAddress (if you link with comctl32.lib instead of LoadLibrarying it, use GetModuleHandle to get the dll handle).

PlatformSDK has an example of using DllGetVersion to determine the common controls version.

Instead of your GetTickCount loops, I would recommend using Sleep() in your FadeInOpen and AnimateOpen routines, so processor usage in task manager wont show ~100% :-).

Cute example :) - for a real-world application, I would suggest determining whether the user has "window animation" disabled, and skip fancy effects if such (of course depending on your app). Most users that disable animation does so for a reason :).
:alright:
Posted on 2003-05-01 09:45:45 by f0dder
Oh, a few more things (not doing this to pick on you, just friendly advice) - the final stage of fadein/fadeout seems a little abrupt? Dunno why this is?

Using gettickcount loop to do the eye blink animation is not a good idea, the rest of the UI will freeze for those ~200msec (try dragging the window around with "show contents of window while dragging" enabled, you'll see it stand still when the eyes blink) - Sleep() wouldn't change anything here, it's the animation method that has to change. You did mention in the original post that it was a simple method though, and it does okay for small stuff like this :)

Oh, and for version detection (am I pointing out every little thing? Sorry if it's too much :-)), it's probably better to check for version >= 5 instead of 5 - and probably even better just to check if the SetLayeredWindowAttributes is present at all.
Posted on 2003-05-01 10:00:11 by f0dder
f0dder,

Look, you appear to be a very brite fellow but I can tell you are bored and have nothing to do. Instead of pointing out what not to do or what should be done why not do it the way you think it should be and post it for all of us to learn from. Come on, I know you can do it.

I?ll leave you with some friendly advice.;)

?He that gives good advice builds with one hand; he that gives good counsel and example builds with both; but he that gives good admonition and no example builds with one hand and pulls down with the other.?

?Never try to teach a pig to sing. It wastes your time and annoys the pig.?


Regards,
Posted on 2003-05-01 11:20:08 by bcraven
bill, sorry if it looked like a "you should do it MY way" sort of command - I was just trying to give some helpful tips. I rather give tips than code, since imo it's easier to to follow than comparing original source with new one. Besides, it's faster giving tips than code - if I was indeed bored, I would be giving code more often than tips ^_^

I'm attaching an updated version of your app, with some of the tips applied. I didn't fix the eye animation, as it would require a little more coding, and I can think of other things to do - besides, it works fine in the example :).

I could do some code testing for DLL version if you want me to. If not, I wont. Could be a good excercise for one of the other members then. I could also have a look at the "window animation" detection if you want me to.

I changed the "header" of the asm file to my personal style - I don't have a default masm32 install, and I dislike hardcoded paths. Sorry for the inconvenience (if any), but it's a 10sec job to change it back (copy+paste from the original source).

Oh, and remember: I'm not doing any of these postings to pick on you - I wouldn't have taken the time to look at this if I didn't like your code. I just want to help improve things, and teach a little of my experience if I can.
Posted on 2003-05-01 11:45:33 by f0dder
f0dder,

Good job, that?s exactly what I mean, you teach best when it is by example. Anyone with an interest in learning assembly language needs to be shown by example. It?s the best approach don?t you think?

Give me a little time to acquaint myself with your MO f0dder. I am unable to hangout here very much and am not familiar with the regular members here at WA. I do know from reading some of your posts that you are a natural and talented programmer and I hope to see more of your assembly efforts.

The reason I posted my source here in the first place was in the hope of seeing alternatives to my attempt and to maybe teach something to others that are interested in ASM programming.

I am far from being proficient in Windows programming by any measurement to be sure. I?m an old guy from the old days of DOS programming an have only been in this Windows 32 bit ASM stuff for a couple of years. I?m very interested in learning more advanced Windows programming tricks but again I learn best by reading and absorbing source code.


Regards,
Posted on 2003-05-01 13:13:28 by bcraven
By example... well, I think the best is some description + source. If I can choose only one, I'd choose description.


Give me a little time to acquaint myself with your MO f0dder.

MO is an abbreviation for...? My mind is a little burnt out right now, so no luck guessing it :).


The reason I posted my source here in the first place was in the hope of seeing alternatives to my attempt and to maybe teach something to others that are interested in ASM programming.

:) - you got some feedback and some alternative :) - and hopefully somebody can learn something.


I am far from being proficient in Windows programming by any measurement to be sure.

You'll learn, and fast by the looks of it - 32bit is easier than the old 16bit seg/ofs junk, but it takes some time getting adjusted to the event-based model of windows. I cursed it to hell in the beginning - I have a dos background too ;)


I?m very interested in learning more advanced Windows programming tricks but again I learn best by reading and absorbing source code.

Oki doki - I prefer giving hints and tips, pseudocode and code snippets. Unfortunately some people perceive that as me "forcing my view on them" or whatever, while I'm in fact only trying to help and give (what I deem to be) good advice.

Hope to see more from you in the future, and if you have any questions feel free to ask. Hope I've made it clear that I'm here to help, not to point fingers (sorry if it has felt that way).
Posted on 2003-05-01 13:29:07 by f0dder
f0dder,

MO, your method of operation, your way of presenting yourself here on the board.

I?m getting a handle on you now and very aware you are a helpful fellow.

I know you meant no offence nor in anyway did I.

This next winter coming I?ll probably have more time to visit WA, hope so away.

It?s summer time here in PA and I?ve much to keep me busy.

Thanks for offering to answer my questions. I?ll be holding you up to that offer.


Regards,
Posted on 2003-05-01 15:04:41 by bcraven
Ah, Method of Operation - should've been obvious :). Just out of curiosity, do you have an army background? Sounds like an army-ish (not to be confused with amish ;)) term.


It?s summer time here in PA and I?ve much to keep me busy.

Still a bit cold here in scandinavia - some days of excellent heat, some days of cold and rain. Should start getting warmer soon, and then I'll trade the monitor for fresh air and a cold beer in the garden. Will have some stuff to do, too... helping mum with the garden, spending time with friends and the girlie, etc. Should still be some time for the 'puter, though.


Thanks for offering to answer my questions. I?ll be holding you up to that offer.

You do that :). The time I can dedicate to this board varies. Around august my civil service (I prefer serving the community to running confused around with a gun while some army dude is yelling at me) ends, and I will be returning to education - and thus my free time will drop. I should still manage to pop by here, though.

And if not, it's not like I'm the only member around here. A lot of the other guys are pretty clever.
Posted on 2003-05-01 15:30:20 by f0dder
I really really like that incAPI macro f0dder - what a great idea! :tongue:
Posted on 2003-05-01 16:55:17 by bitRAKE
Bill,

I must admit, I saw the original example as a well written clear piece of example code that many others would find clear and easy to understand.

We all know how to write complex and highly optimised code but that is self defeating when it is example code as it goes over the head of many people who are still in the learning stages.

Just keep these clean and simple example coming as your time allows as they are appreciated by people who want to learn the techniques you have used.

Regards,

hutch@movsd.com
Posted on 2003-05-01 22:12:56 by hutch--

We all know how to write complex and highly optimised code but that is self defeating when it is example code as it goes over the head of many people who are still in the learning stages.
I believe f0dder's comments are more in regard to windows programming techniques -- using Sleep() instead of hogging all the resources of the machine should be the practice not the exception; dependancy analysis is important to know for deploying your application, simply testing on each platform is not sufficient.
Posted on 2003-05-01 22:43:28 by bitRAKE