adding and removing styles and extended styles

Jun 13, 2010 at 8: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.

 

Ahmad

Coordinator
Jun 13, 2010 at 1: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())
{
 ri.Load(filename);
 DialogResource dlg = (DialogResource) ri[Kernel32.ResourceTypes.RT_DIALOG][0];
 dlg.Template.Style |= style-to-add


Jun 15, 2010 at 12: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.

 

Coordinator
Jun 15, 2010 at 2: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 7:00 AM

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

Coordinator
Jun 16, 2010 at 11:41 AM

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