AutoHotkey Community

It is currently May 27th, 2012, 12:31 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: February 20th, 2009, 2:31 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
I'm working on a library that wraps the Control Messages for TreeView and ListView (each will be in a separate AHK file). I need a little help with the syntax for the "Color Setting" functions.

Right now, either a ColorRef or a RGB value can be entered.

Ex.
setLineColor(ThisControl, 0, 0, 255) will set the line color for ThisControl (the hwnd of the specified control) to blue. Likewise, you can use the COLORREF value 0x00FF0000 (hex format 0x00bbggrr) to do the same thing - setLineColor(ThisControl, 0x00FF0000).


What I need suggestions for is how to handle these three cases:

1) There are messages, like TVM_SETLINECOLOR that use CLR_DEFAULT (0xFF000000) as the return / set value to set the color to the default color.

2) Others, like TVM_SETTEXTCOLOR use -1 to set the default.

Then,
3) Some allow use of CLR_DEFAULT or CLR_NONE = (DWord) -1 (0xFFFFFFFF). For example, LVM_SETTEXTBKCOLOR returns CLR_DEFAULT when used on a new script and allows specifing CLR_NONE as the new text background color.

And, in that, lies the problem. The same -1 that some functions use to mean "default", others use it to mean "none". I personally don't like having different uses for the same value - it confuses me, too much to remember. For this reason, I want to standardize this a bit. I'm thinking of having the default parameter for the "setter" function to be the value the message uses to signify "default". This way, for example, calling setLineColor(ThisControl) would set the line color back to the default.

To standardize the values (and make them more user-friendly), the functions will accept and return "Default" if the default value is used (i.e. CLR_DEFAULT or -1, as appropriate); and accept and return "None" if the color is CLR_NONE. I think this is the best solution. Then, you can easily compare the return to see if the default value, no value, or an entered value is used. There will also be included files to help manipulate the POINT and RECT structure (used in some messages), and the COLORREF values (used in the "Color Setting" functions). This will allow easy use of the control messages even if you are unfamilar with structures or COLORREF values.

I think this is the ideal solution, but looking for feedback. I'll post the Wrappers here when I get them done. Also, I'm going to use GenDocs to automatically generate AHK style docs for the library. These docs will be in the form of an included CHM file and on a website that I'll post the link to here, when it's up.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, maul.esel, SKAN and 7 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group