adding and removing styles and extended styles

Jun 13, 2010 at 9:55 AM

Hey Guys,

Can someone write me a quick code snippet of how to add and remove styles and/or extended styles from resource types that support styles?

Much appreciated.

Thank you.



Jun 13, 2010 at 2:46 PM

It depends on the resource, but basically load it, modify the Style or ExtendedStyle field and resave.

string filename = ...
using (ResourceInfo ri = new ResourceInfo())
 DialogResource dlg = (DialogResource) ri[Kernel32.ResourceTypes.RT_DIALOG][0];
 dlg.Template.Style |= style-to-add

Jun 15, 2010 at 1:49 PM

Great stuff dblock....thanxxxxxxx

what about menu's? Is there a way I can change the reading order of a menu and its alignment?

Thanks again.


Jun 15, 2010 at 3:46 PM

Certainly, you can do everything that is possible with resources at the lowest level. But you're on your own for this one, I've never done it. Post here if you have a nice implementation.

Jun 16, 2010 at 8:00 AM

to remove styles, do you use XOR instead of OR? ( ^= instead of |= )

Jun 16, 2010 at 12:41 PM

Yes, it's a bit set, you may want to read about bitwise operations.