PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Mark Strickland on May 29, 2005, 11:57:58 PM

Title: MonthCalendar Use
Post by: Mark Strickland on May 29, 2005, 11:57:58 PM
Is there a set of functions to deal with the new MonthCalendar control?

I could only find one post regarding this new control.

Thanks.
Title: MonthCalendar Use
Post by: TechSupport on May 30, 2005, 12:39:48 AM
The Calendar control is a Microsoft Common Control. The details of its use can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/monthcal/reflist.asp

I expect that the PowerBASIC forum would also have examples of how to interact with it.
Title: Re: MonthCalendar Use
Post by: David Kenny on October 21, 2008, 03:17:10 PM
If I create a new project.  Add a MonthCalendar. First thing you notice is the "Today" circle is a rectangle in both the calendar and below the calendar (both on the design form and at runtime). I think that is one of the symptoms of the problem.  I edit the window styles for the control and select MCS_MULTISELECT and compile.  Then run the program and drag-select multiple days, it draws the selected dates incorrectly.

The Calendar demo that comes with the last three compilers shows exactly what I am trying to do (samples\ddt\calendar\calendar.bas).  You will notice that the "Today" date is circled rather than being contained in a rectangle.

Not sure how to figure this one out. ???

David
Title: Re: MonthCalendar Use
Post by: TechSupport on October 21, 2008, 08:41:02 PM
Hi David,

I am a little stumped about this as well. I checked FireFly's code versus PB's code and it uses the exact same "SysMonthCal32" class and uses the exact same styles and extended styles. I even replaced the InitComCtl32 in the PB code example to use the same as FireFly's. The result did not change. I wonder if maybe PB does something different inside it's DDT engine to use a different CommCtrl DLL version. Weird. I wonder if I'm missing something really basic here?

Here are the screenshots:


[attachment deleted by admin]
Title: Re: MonthCalendar Use
Post by: TechSupport on October 21, 2008, 09:06:15 PM
Okay. I figured it out. It is because FireFly is using WinXP Theme support whereas PB is not. You would need to disable FireFly theme support in the code generation:  "Options", "Environment Options", "Code Generation".

Hope this helps you.
Title: Re: MonthCalendar Use
Post by: David Kenny on October 22, 2008, 03:19:48 AM
Wow, help it did!  That was it. I can't say I think I would have ever tried that.  What clues did you see that helped you figure that out?

I went down another road with my troubleshooting.  I too had thought it might be related to DDT style.  I found a MonthCaledar example using SDK style.  It worked fine compiled with JFP.  It failed when implementing it in FF. I couldn't find the answer even when replacing FF's routine to initialize the CommCtrl with the one from the example.  Now I will have to compile with that option on and off to compare the resulting FF generated code and maybe learn something.  :)

Just exactly what does the theme support provide?  I don't ever change the theme in windows, though I know some do.

Thanks for coming through once again,

David 
Title: Re: MonthCalendar Use
Post by: TechSupport on October 22, 2008, 09:05:33 AM
Hi David,

I think it was one of those "light bulb" moments where it just popped into my head that maybe the control was displaying differently because the WinXP themes were enabled. To be honest, I kind of like the look of the themed Calendar control better. It is cleaner and less cluttered looking.

When FireFly adds theme support is adds a few lines to your Project's resource file. For example, it could look like the following:


// Manifest info for WinXP theme support
#define CREATEPROCESS_MANIFEST_RESOURCE_ID   1
#define RT_MANIFEST                         24
#define CONTROL_PANEL_RESOURCE_ID          123

CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "CODEGEN_PROJECT1.Exe.Manifest"

Title: Re: MonthCalendar Use
Post by: David Kenny on October 22, 2008, 11:32:06 AM
The Manifest info is what I discovered when I compared a compile with themes against one without.

I also discovered that I don't like what happens to the rest of the controls when theme support is turned off.  I don't suppose there is a way to have it both ways?  I suppose I could look into drawing parts of it myself. (I'm getting a headache already).

Anyway, thanks again for your support.

David
Title: Re: MonthCalendar Use
Post by: TechSupport on October 22, 2008, 02:16:16 PM
Quote from: David Kenny on October 22, 2008, 11:32:06 AM
I don't suppose there is a way to have it both ways? 

I knew you were going to ask that!  :)

I guess you could have it both ways but it would be a hell of a lot of work because you would need to manually apply the theme support in some cases and not in orders. Selectively applying themes to every control created is not a trivial task - and one for which I have not had to do. I know that Jose has theme api code on his site but, like you said, it would give you quite the headache implementing it. Likewise, using custom draw or owner draw is overkill and likely to cause you more grief than its worth.