Docklet Programming

Thursday, February 17, 2005 by Matthew Merritt | Discussion: ObjectDock

I have a question about developing my own Docklet is this were I would post the quetion? If not where might I do that?

Thanks,
Matt.
Koasati
Reply #1 Thursday, February 17, 2005 8:31 PM
Here is fine.
Matthew Merritt
Reply #2 Thursday, February 17, 2005 8:55 PM
Right on!

Ok I have a working Docklet that I started from the SampleDocklet in the SDK. Now, I am working on setting the Image from within my custom Configuration Dialog, I can do that too, but what I can't seem to do is make that image display in my Configuration Dialog. The code that is in the SampleDocklet use SendMessage(...) which does not work. I have tried all the ideas I could come up with to no avail...

So, after all that, simply I am looking for a code snippit or direction to look on how to display the image in my Configuration Dialog.

Thanks,
Matt.
Littleboy
Reply #3 Thursday, February 17, 2005 9:54 PM
Here is the code I use. It might not be the best way to do it, but it works for me

You need to have a Picture Control of Type Bitmap in your form. Replace the size variable with the size of your control


// Load the image
Bitmap* image = lpData->docklet->LoadGDIPlusImage(path); // replace this by a call to the LoadGDIPlusImage function from the SDK

if (image != NULL) {
// Get the background color
Color* background = new Color();
background->SetFromCOLORREF(GetSysColor(COLOR_BTNFACE));

// Create the bitmap
Bitmap bitmap(image->GetHeight(),image->GetWidth());
Graphics bitmapGraphics(&bitmap);
SolidBrush solidBrush(*background);
bitmapGraphics.FillRectangle(&solidBrush, 0, 0, image->GetHeight(), image->GetWidth());

bitmapGraphics.DrawImage(image,0,0,image->GetHeight(),image->GetWidth());

Bitmap* icon = (Bitmap*)bitmap.GetThumbnailImage(size,size,NULL,NULL);
HBITMAP hBitmap;
icon->GetHBITMAP(*background, &hBitmap);

// Display the image
SendDlgItemMessage(hDlg, ID_DIALOG, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM) hBitmap);

delete(icon);
delete(background);
}

delete(image);


If you need more, I can send you the code of my TodoList docklet (leave me your email).

Edit: Wincustomize is inserting < BR > tags in my < pre > < / pre > tags. Grrrrrr....
Matthew Merritt
Reply #4 Thursday, February 17, 2005 10:24 PM
Littleboy, you are the man!

Thanks, works perfectly!

Matt.
Koasati
Reply #5 Thursday, February 17, 2005 11:03 PM
Matthew...What does your new docklet do?
Matthew Merritt
Reply #6 Friday, February 18, 2005 5:31 PM
Well, I will try to explain it. I am a firefighter and work a funny shift. The way it works is there are 3 shifts that work 24 hours. We work 3 out of 5 days, then have 4 days off. This set of days I work is:

Friday, Sunday, Tuesday, then I'm off from Wednesdat to the next Sunday where I work Sunday, Tuesday, Thursday, then I'm off from Friday until Tuesday, etc...


So each year we get a color coded calendar that shows which days we work for the whole year. Well I wrote a Docklet that is a representation of that. It is a monthly view of a calendar, then I calculate each days shift then color code that day appropriately. Then add some numbers for dates, either only Sundays or the Shift that you work. I also blow up today and date it. Not very general purpose, but it is giving me lots of ideas for more.

Here is what it looks like:

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01