0

I'm looking to extract the calendar / dropdown icon from the native Windows DateTimePicker control at runtime. i.e. This little guy on the right (or something similar):

DateTimePicker control

Does anyone know where it's found? (e.g. what API call paints it or what DLL the resource is stored in)?

Details

It's for a C# custom control (WinForms). I don't like the built-in DateTimePicker and am making a better one that allows rapid freeform text entry then parses it with more intelligence and less constraints. I plan to distribute my custom control as a single snippet of source code (.cs file) that's easy to copy/paste (nothing else required).

I know the Segoe MDL2 font has a calendar icon in it (E787) but I can't guarantee my target platforms will have it.

rkagerer
  • 4,157
  • 1
  • 26
  • 29
  • You can handle WM_PAINT and draw it yourself. E.g., [Customizing Border and Button of the DateTimePicker](https://stackoverflow.com/a/66092509/7444103) -- Do you mean you have set `DTS_APPCANPARSE`? Good luck :) – Jimi Aug 14 '21 at 09:46
  • @Jimi Thanks for the lead on `DTS_APPCANPARSE`. I tried it as [demonstrated here](https://stackoverflow.com/a/39321899/589059) but unfortunately it [breaks the Tab key](https://stackoverflow.com/questions/8012784/datetimepicker-class-with-dts-appcanparse-style-cant-tab-out). Shame as that would have been my preferred approach. – rkagerer Aug 14 '21 at 17:53
  • If you're interested: [How can I set the DateTimePicker dropdown to select Years or Months only?](https://stackoverflow.com/a/61287097/7444103) -- [A DateTimePicker to change only month and year](https://stackoverflow.com/a/59690597/7444103) -- [Change Week Display in DateTimePicker Control](https://stackoverflow.com/a/61697311/7444103) -- `DTS_APPCANPARSE` doesn't actually *eat* the TAB key press on its own. It only happens when you click inside the Control, which removes the *special Fields* that defines the Date parts. Restored when you press, e.g., the Enter key. – Jimi Aug 16 '21 at 11:29
  • 1
    You can get the bitmap from the "theme". `OpenThemeData(..., "DATEPICKER")` and then `GetThemeBitmap(..., DP_SHOWCALENDARBUTTONRIGHT, ...)` https://learn.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemebitmap this app allows you to see all classes, parts, states, etc. https://github.com/mity/theme-explorer https://i.imgur.com/mp19tGi.png – Simon Mourier Aug 18 '21 at 10:13

0 Answers0