• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 734
  • Last Modified:

Stephen's Lebans Month Calendar API, How to suppress the window title and properties bars.

I need a transparent replacement for the MS DTpicker calendar.  I found
Stephen's Lebans AMAZING Month Calendar API but is there a way to suppress the window
title and properties bars.   Basically, I need a like for like replacement
for the DTPicker OCX and need to be able to set the properties in CODE.  The Calendar API can be found at http://www.lebans.com/monthcalendar.htm

Thanks in advance
  • 5
  • 5
  • 2
2 Solutions
Leigh PurvisDatabase DeveloperCommented:
I see you've already posted this same question in CDMA?
You'll quite likely get a reply from Stephen himself there.
Ok, I downloaded the sample DB from that link

looking at the code, I found 4 occurrences of "Monthly Calendar"

U can change that text to be your own word
I believe some text has to be there 'cos it does a Find Window API call

to remove those menu options Properties (is that what u want removed?)

find this function

Public Function ShowMonthCalendar

look for this line

lngRet = InsertMenu(hMenu, 2&, MF_POPUP Or MF_BYPOSITION Or MF_ENABLED, hMenuPopMisc, "Properties")

and comment it
this removes Properties as a menu
ArtBarnwellAuthor Commented:
<Leigh Purvis: I see you've already posted this same question in CDMA?

You'll quite likely get a reply from Stephen himself there.>
I normally do not post questions on multiple boards but I was not sure how often Stephen considering the amount of time he must exhaust developing all the astonishing products he creates and shares with all at know charge.

< rockiroads: to remove those menu options Properties (is that what u want removed?)

Yes, in part.
I also want remove (not show) the calendar’s window title.   I am using Stephen’s Calendar API with a textbox and cmd control to replace many instances of the Date-Time picker control.    The Textbox and CMD button will visually mimic the DT-Picker and I would like the replacement calendar to visually mimic the DTP control, precisely.   The DTP control does not have a property settings bar (which you have addressed) and also does not have a window title bar.  Is there an easy war to suppress the title bare from showing?


Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

I dont know. After looking at the code, it uses FindWindow and it looking for specific text.
Leigh PurvisDatabase DeveloperCommented:
SL used to be very active in CDMA.
Not sure these days (I don't hang out there much really now).
I've often seen him answering the questions of those regarding his own utilities.
It probably is just a case of catching him there.

Personally - I'd guess the answer would be No (as it stands).
As you rightly mention - there's been a lot of effort in making the calendar as it stands.
Multi functional (it's a *very* widely used tool in the Access community) and not intended to mimic anything.

To change the text in the title bar (let alone remove the thing entirely) would be problematic.
I'm sure that if you strip out the calls to create the menu items - subsequent calls to those would cause it to fail.

Personally - I'd just say "No" and if you chase too hard wanting to make it appear identical to the DTP then you're missing the point somewhat.
ArtBarnwellAuthor Commented:

I am only a novice and I know that programming skills exceed mine by far and I do very much appreciate your help and recommendations.  That being said, I must respectively disagree with your responses.  

< I'd just say "No" and if you chase too hard wanting to make it appear identical to the DTP then you're missing the point somewhat.>  

According to information posted on the web, Stephen created the month calendar API to allow access to the underling calendar used by the DTP control but without the versioning issues that can permanently rendered  DTP objects non functional if they are accessed by machines using a different version.

Unfortunately, installing application-specific OCX controls is not allowed in the applications environment and some of the workstations have different versions of the DTP-ocx or it is not present at all.  Stephen does GREAT work and he always goes out of his way to include all foreseeable functionality needs.

In my case, I need his calendar to be displayed without a window title and Stephen has not made and obvious means of accomplishing this.  I am not experienced in API hooks but clearly the OS can display title-less and therefore this can be also accomplished with any window.

I have research the user32.dll properties on MSDN and other threads here and it turns out that Stephens’s code already exposes the property for determining if a title bar is shown (or not shown).  I am including the code changes needed to prevent the title bar and the menu mars from being displayed in the event anyone else may be interested.

To prevent the title bar for being displayed change the following coded as follows:

In modCalendar – declarations change Private Const WS_OVERLAPPEDWINDOW to:


Change “Public Function ShowMonthCalendar” to:

hWnd = CreateWindowEx(lngEXStyle, _
                        CLASSNAME, _
                        TITLE, _
                        WS_POPUPWINDOW Or WS_BORDER, _
                        CW_USEDEFAULT, _
                        CW_USEDEFAULT, _
                        CW_USEDEFAULT, _
                        CW_USEDEFAULT, _
                           mc.hWndForm, _
                        hMenu, _
                        hInstance, _

To hide the menu bars, comment out the following lines found in modCalendar – ShowCalendar  (THANKS rockiroads):

' Misc Properties Menu
'##    lngRet = InsertMenu(hMenu, 2&, MF_POPUP Or MF_BYPOSITION Or MF_ENABLED, hMenuPopMisc, "Properties")

'## lngRet = InsertMenu(hMenu, 1&, MF_BYPOSITION Or MF_ENABLED, 998, "Close Window")

This is a crud fix and disables some niceties included in Stephen’s original code and also requires for some properties to be set in code.   It should be easy enough for me to add some additional code that will allow me my modified version or the more robust version included in the original code.

Please look at the changes I have made and let me know if I am doing something wrong as I have little API experience.

Thanks again
Leigh PurvisDatabase DeveloperCommented:
Wasn't saying it is impossible.  Far from it.
Merely commenting on the balance of effort against result (which will vary from developer to developer - depending on experience).

In any such utility the author has gone to a lot of trouble to provide the functionality and it might well be that subsequent code assumes the presence of objects you try to comment out.
My opinion was that pushing up to and beyond your limits to achieve something cosmetic would be missing the point of what he's laboured to provide.
And in the case of ammending a utility provided by a less considerate developer - potentially catastrophic.  (Well - as much as GPF's and corruption can be :-)

Of course, with the view he takes to utility development - he's left it possible for certain alterations (or just error handling) to provide/allow radical changes.
Great (that would effectively count as provided functionality rather than a full on customisation of his work).

So say he's been considerate and allowed a simple remming out of the InsertMenu API call.
So the question then becomes - what properties are you wanting to set?
You say this should be easy enough?
Setting what values?

Well, I'd imagine if you want to keep this simple - you'd open the calendar without ammendments.
Set everything as you'd want it.  Number of months - Circle today etc.
Then implement your changes and the calendar should continue to run with those same settings.

No problems??
Except - do you know where he stores those values?
If you copy your mdb objects to a new clean mdb (which is necessary from time to time in Access development) then you'd lose those settings.

The preferences are stored as Properties of the local file.
To set the number of months displayed you have to specify the required columns and rows.
If you want one month shown - you can specify 1x1 like so


If you wanted 6 months

Just little quirks determined by pouring over the code and understanding it.
Effort.  Time.  More for some than others.

Hope it helps though.
Good luck with your applications.
ArtBarnwellAuthor Commented:
Thanks Leigh,

First and foremost, I have enormous respect for you, your programming expertise and the huge amount of time you continue to donate while helping others.  I cannot count the times I have been searching the Expert Exchanged archives and found a solution to problem with your name in it.  If my previous reply offended you in anyway, it was not my intention and I truly apologize.  

In actuality, I am in agreement with you and would have preferred to use Stephens’s calendar API with all the functionality in tacked.  Unfortunately, in this case, I cannot.   I also saw a post on CDMA were someone else was also looking for a way to modify Stephen’s API to suppress the window title and menu bars.  He never found the means so I posted what I had here as well as CDMA.  

What I would really like to do is create an add a modified version of the original CreateWindowEx Function along with any other need code so that I can call either version depending on my needs.  Well that will be another topic to discuss in future threads.  

<The preferences are stored as Properties of the local file.>
Thank you for sharing that information and was not aware of that functionality.  That alone will save me bunch of time and many “oops” related headaches.    I have a user level preference manager and, now that I know this, I will probably save those setting there.  

As far as the Calendar API goes, I would like keep all of the current functionality and add additional code to also allow me to call the de-featured version when needed.  I think this is doable and ultimately worth the effort.    Creating a new function based on the original CreateWindowEx Function is the easy part but things that bite hid in the brush.  If you are interested, I will post a separate question asking for any initial suggestions and considerations and then post very concise questions along the way.  


Thanks again for sharing both your time and expertise
ArtBarnwellAuthor Commented:
Also, many thanks for your help.  Your contribution addressed half the battle
Leigh PurvisDatabase DeveloperCommented:
No offense - in fact, it's actually good to have a questioner so dedicated to what they want and willing to learn.
I'm glad you've got the solution you were wanting after all.

I'd imagine it really trivial for you now - to produce the single version.
All you need is an optional parameter in the function call - and depending on it's value you execute either option in a split of in the code (via a simple IF).
So then perhaps...

ShowMonthCalendar(ByRef clsMC As clsMonthCal, _
ByRef StartSelectedDate As Date, _
Optional ByRef EndSelectedDate As Date = 0,
Optional ByRef blnShowOptions As Boolean = True) As Boolean

Dim lngTitleConst as Long

and then in the body of that makes decisions...
If blnShowOptions Then
    lngRet = InsertMenu(hMenu, 2&, MF_POPUP Or MF_BYPOSITION Or MF_ENABLED, hMenuPopMisc, "Properties")
    lngRet = InsertMenu(hMenu, 1&, MF_BYPOSITION Or MF_ENABLED, 998, "Close Window")
End If
hWnd = CreateWindowEx(lngEXStyle, _
                        CLASSNAME, _
                        TITLE, _
                        lngTitleConst, _
                        CW_USEDEFAULT, _ ...etc

Incidentally, I reckon that the section of code regarding alteration of the constant WS_OVERLAPPEDWINDOW isn't required - and you don't need to a) do it in your final version or b) consider it in your full option version.

As for storing useful settings and metadata in the mdb properties - yes that's a common technique employed by developers.
Useful in that it isn't naturally user alterable (unlike data held in tables).
You should find many a use for it over time.

Hope this helps.
ArtBarnwellAuthor Commented:
<I'd imagine it really trivial for you now - to produce the single version>

I appreciate any advice, trivial or not.  I am accustomed to using optional parameters but I will probably need to maintain 2 distinct versions.  I am traveling but I will post another question explaining my dilemma.  I would enjoy for you input there as well.  Is there anyway to direct a question to a particular Exchange Expert.   I know you would continue in this thread but the original help request has been satisfied and you certainly deserve more points.  I am sure that your motivation is much deeper than some superficial recognition but you still deserve the credit.
Leigh PurvisDatabase DeveloperCommented:
Thanks - the chances are I'll see it.
I tend to recognize these things.

Posting questions directed to a particular expert generally doesn't go down too well.
If this question is still open you can always post here that you've opened a new one, but even if not - as I say - I'll likely see it and join in anyway.

Best of luck.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now