Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Box Enable Hyperlink Color Problem

Status
Not open for further replies.

PaulHInstincticve

Programmer
May 31, 2006
45
GB
I have a class for edit boxes used throughout my app. Whilst in edit mode the foreground color of this class and all other form object classes is switched to black and then once the record is saved and is protected again it is switched to grey. This makes it very visible when you are or are not in edit mode. Obviously I can set the disabled color on other objects because I set enabled to .f. when not in edit mode, however, with an edit box disabling it prevents use of the scroll bars so I set it to readonly instead and change the forecolor.

All of this has been working fine until I set 'enable hyperlinks' to .t.. This now forces the foreground colour to black regardless of any setting I give it. I even tried to set it to grey in the refresh method and it completely ignored my code. If I set enable hyperlinks to .f. I regain control of my colours.

Is there a way I can control foreground colour in my editbox with 'enable hyperlinks' set to .t.? Any advice appreciated. Thanks

Paul H
 
I created a new form, added an editbox. Then changed the editbox's hyperlink to true. When I finished typing and hit enter I set the readonly to true and the hyperlink is blue and the regular text is black. How are you setting the disabled/enabled forecolor, ie which properties are you using? Are you changing the enabled T/F or the readonly T/F.

Regards,

Rob
 
Rob,

Thanks for getting back to me. Perhaps my earlier explanation was a little lengthy! I am completely leaving enabled alone and simply setting readonly to .t. when I have finished editing. I am using forecolor to change the colour of the text. I want black when I am in edit mode and a dark grey once it is set to readonly. Setting these attributes works fine when enablehyperlinks is set to .f., however, when enablehyperlinks is set to .t., all text except the hyperlink itself remains black and cannot be switched grey and the hyperlink itself remains blue but I don't have a problem with the hyperlink text itself. Obviously once I set the editbox readonly I could set enablehyperlink to .f., however, I want the hyperlink to remain active even when the edit box is readonly. I hope this makes more sense. Thanks

Paul
 
Have you tried creating a new form and setting up this scenario to rule out any quirks with your code/classes?

Regards,

Rob
 
Rob,

I had not tried that as I thought my class code was fairly well written and I was able to trace where the colour problems occurred. I have, however, just set up a new form to prove things. I have created a form based on the VFP form class. On it I have an edit box and three buttons, one labelled 'colour' and one labelled 'readonly' and one labelled 'enablehyperlinks'. When I run the form I can add text in the edit box and it is default black on white. When I press 'colour' it runs the following 'click' code

thisform.edit1.ForeColor = RGB(0,128,255)

This correctly makes the text in the edit box blue instead of black

Now when I press 'readonly' it runs the following click code

thisform.edit1.ReadOnly = .t.

The foreground remains blue and the background changes to grey which is the 'disabled backcolor'. This in itself seems ilogical as I have not disabled the object but simply set it to readonly. Either way I have control over the disabled back color so I set it back to white without any problem.

The problem occurs when I push the 'enable hyperlinks' button which runs the following click code

thisform.edit1.EnableHyperlinks = .t.

This changes the blue forecolor to black (with the exception of hyperlinks which are blue of course) and I have no way of changing the colour of the other text through either forecolor or disabledforecolor properties. What I want is the bulk of the text grey to show that it is protected from editing but hyperlinks are still blue because they are still active.

Paul
 

Paul,

I've been following this thread in the hope of being able to suggest a solution, but I can't understand why this is happening.

What version of VFP are you using? If possible, I will try it in a different version.

By the way, you said you thought it was illogical that the back colour turns grey when the control is read-only. This is normal behaviour, and is what I think users would expect. Of course, the fore colour is different, and the control is able to receive focus when read-only, and not when disabled. But this has got nothing to do with your underlying problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

Thanks for that. I am running VFP 9 SP1. Yes the disabled back color is not part of my problem. I suppose it is logical that it kicks in when the control is set to readonly, what is not is that the disabled fore color does not kick in also - surely they should act as a pair as they do when setting the enabled method? Initially I wanted to disable the edit box as that is what I do to my text boxes but of course that disables the scroll bars too which are need to move up and down in the box which is why I am using readonly to prevent further editing. Thats just for further info, I can live with all that, its the fact that when hyperlinks are enabled that I cannot color the foreground text that I am struggling with. Thanks

Paul
 

Paul,

When I get a moment, I'll try to reproduce the behaviour.

Just as an aside ... I always set editibable controls to read-only rather than disabled. One reason is the scrollbar issue you mentioned. Also, users might need to select text from the control in order to copy it to the clipboard. They can do that if the control is read-only, but not if it's disabled.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

Oh yes, I knew there was another reason I used readonly - I use copying to the clipboard throughout my app but that's been part of the app so long that I had forgotten all about it. I only recently upgraded from VFP6 to 9 and discovered the enablehyperlinks option which looked great until it disturbed the look and feel of a well established application by preventing me controling the colour properly.

Paul
 

Paul,

OK, I've managed to reproduce the behaviour you are seeing.

In fact the behaviour seems to be unrelated to whether the edit box is read-only. As far as I can see, setting EnableHyperlinks to .T. changes the foreground colour to black for the entire control, regardless of the ForeColor property, or the ReadOnly setting.

By the way, the same is true for text boxes.

I feel sure this can't be intentional. It's surely a bug. I can't find anything about it on MSDN, so unless someone can come up with a workaround, maybe we should report it to Microsoft.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

Sorry to mislead you about readonly, I knew that was unrelated but am happy with black when readonly = .f., its when its set to .t. I want a different colour (dark grey). Wow - does this mean I am finally at the leading edge of things - surely I cannot be the first to find this bug?! I have just sent a bug report to vfpfeed@microsoft.com, is that the place where tyou would normally send them? Thanks

Paul
 

Paul,

Well, I don't know if you're the first to find this bug, but you're certainly the first I've heard about. The fact that no-one else in this forum recognised it suggests it's not well known.

Yes, that's the right way to send a bug report.

I'll maybe file one myself as well -- not to detract from your own efforts, but it won't do any harm to re-inforce the point.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top