Odd border around Edit Box

VC++ 6.00 (MS Developer Studio)

I created some simple edit boxes but wanted to change the background
color to white so I overrode OnCtlColor with this code:

   if (pWnd->GetDlgCtrlID() == IDC_OUTPUT_STRIP)
   {
      // Set color to Black on White
      pDC->SetTextColor(RGB(0,0,0));
      pDC->SetBkColor(RGB(255, 255, 255));

which did have the desired coloring effect but has an odd artifact of
putting a black border around the edit box:

http://www.griffobros.com/EditBox1.jpg

The first box was created with Class Wizard and has only the 'Border'
box checked.  I've dinked a bit with other settings (Client Edge off
and on, etc.) but all I get is other equally bizarre behavior.

This is really only a minor annoyance but still.... anyone know how to
turn that black border off?

0
djarvinen (31)
11/16/2006 7:32:28 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
843 Views

Similar Articles

[PageSpeed] 48

It is better style to subclass the edit control and put this in the OnCtlColor reflected
handler in the subclass (=WM_CTLCOLOR).  Any time you write a comparison to a specific
control ID, this screams for a subclass handler instead.

Note that changing the background color on an edit control has all kinds of nasty
implications because of the way edit controls redraw; furthermore, they don't always
redraw the background, but only the individual cell color (which is what SetBkColor sets),
leaving parts of the edit control outside the character cell in some other color.  

In edit boxes, the background color is normally COLOR_WINDOW and the text color is
COLOR_WINDOWTEXT, which for the default schema are white and black.

Overall, you'll find all kinds of fascinating problems with changing background colors;
for example, take a look at my Validating Edit Control on my MVP Tips site, where I have
to do some extra work to get the background color to change properly.
					joe
On 16 Nov 2006 11:32:28 -0800, "djarvinen@gmail.com" <djarvinen@gmail.com> wrote:

>VC++ 6.00 (MS Developer Studio)
>
>I created some simple edit boxes but wanted to change the background
>color to white so I overrode OnCtlColor with this code:
>
>   if (pWnd->GetDlgCtrlID() == IDC_OUTPUT_STRIP)
>   {
>      // Set color to Black on White
>      pDC->SetTextColor(RGB(0,0,0));
>      pDC->SetBkColor(RGB(255, 255, 255));
>
>which did have the desired coloring effect but has an odd artifact of
>putting a black border around the edit box:
>
>http://www.griffobros.com/EditBox1.jpg
>
>The first box was created with Class Wizard and has only the 'Border'
>box checked.  I've dinked a bit with other settings (Client Edge off
>and on, etc.) but all I get is other equally bizarre behavior.
>
>This is really only a minor annoyance but still.... anyone know how to
>turn that black border off?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
11/17/2006 12:46:29 AM
Joseph M. Newcomer wrote:
> It is better style to subclass the edit control and put this in the OnCtlColor reflected
> handler in the subclass (=WM_CTLCOLOR).  Any time you write a comparison to a specific
> control ID, this screams for a subclass handler instead.
>
> Note that changing the background color on an edit control has all kinds of nasty
> implications because of the way edit controls redraw; furthermore, they don't always
> redraw the background, but only the individual cell color (which is what SetBkColor sets),
> leaving parts of the edit control outside the character cell in some other color.
>
> In edit boxes, the background color is normally COLOR_WINDOW and the text color is
> COLOR_WINDOWTEXT, which for the default schema are white and black.
>
> Overall, you'll find all kinds of fascinating problems with changing background colors;
> for example, take a look at my Validating Edit Control on my MVP Tips site, where I have
> to do some extra work to get the background color to change properly.
> 					joe
> On 16 Nov 2006 11:32:28 -0800, "djarvinen@gmail.com" <djarvinen@gmail.com> wrote:


Heh, found the problem.  Thanks for the tips and the advice.

This is another piece of 'inherited code' I've been managing and I just
didn't check some of the attributes carefully enough.  It had been set
to 'read only' which is what causes the background to be gray instead
of white.  Your comment about the background color made me go
'whaa..??' and then I did the 'doh!' head-slap.

Since there is a 'Change' button associated with this edit box (as the
input involves control characters and the input dialogue makes it much
easier to insert them), I just left the background gray, and then
changed the attributes to 'No border' + 'Static Edge'.  Now the field
doesn't scream for direct editing like it used to.

Thanks again.

0
djarvinen (31)
11/17/2006 4:21:13 PM
Reply:

Similar Artilces:

CRM Small Business Edition
How can I install CRM Small Business Edition in a server that is not in SBS Domain Hi Julio, you cannot, CRM Small Business Edition can only be installed on a Small Business Server. Considering the price difference between SB and Professional editions and the fact that there are no functional differences, that's the whole point, isn't it? Cheers -- George Doubinski CRM Certified Professional - Developer "Julio Gomez" <julio.gomez@teknowlogic.com> wrote in message news:%23p6fhQZzHHA.1184@TK2MSFTNGP04.phx.gbl... > How can I install CRM Small Business Edit...

Changing border thickness
I have a custom dialog box class that overrides the frame/ background drawing. I want to change the thickness of the frame border as well. The window should resize to accomodate the wider border; the client area should remain unchanged. This is what I have now: CMyDialog::OnNcCalcSize( BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp ) { CDialog::OnNcCalcSize( bCalcValidRects, lpncsp ); RECT rect; GetWindowRect( &rect ); rect.left -= m_pSkin->nBorderWidth; rect.top -= m_pSkin->nBorderWidth; rect.right += m_pSkin->nBorderWidth; rect.bottom += m_pS...

how to detect mouse double click on edit box
I was wondering if some could tell me how to detect whether the mouse has been double clicked on an edit box. I tried the standard mouse double click function,but that only works on the form itself. Z.K. Subclass CEdit and put an OnLButtonDblClk handler in it. joe On Sun, 03 Jul 2005 20:00:58 -0700, "Z.K." <nospam@nospam.net> wrote: >I was wondering if some could tell me how to detect whether the mouse >has been double clicked on an edit box. I tried the standard mouse >double click function,but that only works on the form itself. > > Z.K. Joseph ...

Is it possible to have rounded corners in cells with borders.
Just wondered if there is any way to have rounded corners in highlighted cells. I am making up a spreadsheet and the Date box etc and it would look better with rounded corners. Any help is appreciated if not are there any good Freeware invoice design software programs about. Thanks in Advance Ron Not for the cells (and using gridlines or borders). But you could apply some shape from the drawing toolbar. Although, I would only use this on a few cells. Ronnie wrote: > > Just wondered if there is any way to have rounded corners in highlighted > cells. > I am making up a sp...

Check off boxes
Publisher 2003 in use. I am creating a questionnaire that will be included in a newsletter. I am using the publisher software to make this form. Somewhere, in the past, I saw a keyboard shortcut to inset checkoff boxes, however, I cannot remember the key strokes. Any help along this line will be greatly appreciated. Thank you and enjoy your day. Mike Mike Reshetar wrote: > Somewhere, in the past, I saw a keyboard shortcut to inset checkoff boxes, > however, I cannot remember the key strokes. Use Wingdings and the � or q characters. -- Ed Bennett - MVP Microsoft Publisher h...

How to make CTreeCtrl item text editable
I have a CTreeCtrl in a dialog which works quite nicely to display items. The problem I am having is trying to edit the labels. I have the Edit Labels property set to true but not sure what message I have to handle or how much work I will be doing. Sorry for the generic question but I am hoping there is an easy solution to this common functionality. TVN_BEGINLABELEDIT TVN_ENDLABELEDIT Use the pResult value to prevent/allow editing in BEGIN, and to accept/reject the string in END. Bill "Bob Curry" <rjcurry@comcast.net> wrote in message news:FJydna7iO7hXPUHdRVn-ig@comcas...

Edit textbox
Hi, I have textbox that is bound to a field "Task" the data is imported from an Excel worksheet. The problem is that the imported data varies dependant on who entered it. For example: Service, ServiceCall, replace connector, repair cable. I require a field that would display a constant value i.e. "Service Call" For each category (Service Calls, Installations, etc) there is mainly 4 variations that are recieved, I have no control over this data input as it is generated by the 2 companies that I sub-contract to. Could somebody offer some help. Regard...

Borders
When I try to draw a border around a cell, it appears in a very faint shade of grey, almost indistinguishable from the normal gridlines. How can I change the default colour of a border to black? I know how to do it manually for each cell, but I want to know how to change the default colour for the borders icon on the format bar. Thanks On Feb 10, 1:45 pm, "Kieron Capehorn" <kcapehornR.E,M- O'...@blueyonder.co.uk> wrote: > When I try to draw a border around a cell, it appears in a very faint shade > of grey, almost indistinguishable from the normal gridlines....

Edit Priority Rank List
Hi, I am creating a projects data base. I would like to be able to reorder the projects priority ranking without reassigning each ranking to every project. Based on a similar question posed online and advice from ScottGem (see below), I have created an update query to add one to the rank list of projects that have a priority rank of greater than or equal to the edited value. I am having trouble with this. I have created a form called frmUpdateRankList that has an unbound combobox and a list box that displays the current projects sorted by rank order. I would like the user to select a ...

Combo Box Inactive
After opening my Excel file a Combo Box that I created is inactive and won't respond to my mouse click. I can only get it to work by going to the forms menu, click to edit the combo box, and then exit form editing to make it work. How do I get it to work automatically? ...

Found Page Border Template. But How Does it Work?
I have been looking for a way in excel to put a border around each pag printed (similar to Word's Page Border option). Apparently, so hav many other users. I found the attached excel file in response to a similar post b another user on this site but for the life of me a cannot figure ou how it does it. Are their any excel wizard's that can look at the attached excel fil and help me figure out how this file accomplishes the bodering of eac page? I cannot sleep until I know Attachment filename: page border template.xls Download attachment: http://www.excelforum.com...

Userform List boxes - editing
[Excel 2003] I populate text boxes in userforms using the following type of code to retrieve data from the worksheets: Private Sub GetData_Click() Dim ws As Worksheet Set ws = Worksheets("Sheet 1") Me.txt1.Value = ws.Range("A1").Value Me.txt2.Value = ws.Range("B2").Value Me.txt3.Value = ws.Range("C3").Text End Sub I can edit the text boxes and then send the edited information back to the worksheets using: Private Sub PutData_Click() Dim ws As Worksheet Set ws = Worksheets("Sheet 1") ws.Range("A1").Value = Me...

Odd date format
In Column A I need to format a date, without dashes or slashes, in this way: yymmdd In Column B I need Excel to recognize it as a date, in that order and convert it to a regular date such as: mm/dd/yy Is there any way of doing this? It's driving me crazy. Surely there has to be a way. TIA! Cindy Cindy Hi Cindy, Can be done, but a lot simpler is to do it the other way around: Enter the date in Column A as mm/dd/yy In column B: =A1, Format>Cells>Custom, in the Type box, enter yymmdd If you really need it otherwise: post again! -- Kind Regards, Niek Otten Microsoft MVP -...

Is it possible to shade text within a text box?
I would like to be able to add shading to text within a text box. Is this possible? Thanks for your help. Format, font, select the shadow. The text is shadowed gray, that is the only way you can shadow text unless you use WordArt. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "Hair Traders" <HairTraders@discussions.microsoft.com> wrote in message news:A452279C-1C69-4235-9520-54D9CB993ADF@microsoft.com... >I would like to be able to add shading to ...

Resizing File>Open box
Hi, This is a really trivial question but hopefully someone can help me. Many moons ago I maximised my File>Open window so I could see all the "detailed" information. Now I do not need this window so large, but I cannot find a way to restore it back to it's original size. The diagonal lines in the bottom right hand corner are nolonger there/visable and I have tried grabbing the screen in different areas as well without success. This problem is the same for File>Save or Save As -- Loose, fast and on the edge. Your description of your problem leaves a little to be de...

Autofill time schedule with gaps EDIT
I forgot to mention that although I can get Aotofill to use the correct time increments, it inserts in every cell, not in every other. Thanks again. See your previous thread. Please don't start a new thread. Instead, reply to your first post. Starting a new thread tends to fragment any answers you get, and potentially wastes the time of those answering a question that already has been answered. In article <92F938E7-89F0-4027-97C3-CF6FB502780F@microsoft.com>, XLXPertWannabe <XLXPertWannabe@discussions.microsoft.com> wrote: > I forgot to mention that although I can ge...

xsd.exe bug or odd xsd file
I was given a couple of XSD files so that I could generate a client that targeted a SOAP/RPC web service. One of the XSDs includes a definition of an element that is a sequence of row elements, which in turn is defined as a sequence of column elements. The CS class file generated defines the sequence of row elements "rows as column() ()" rather than "row() As row". This seems to give trouble to XmlSerializer. With XmlSerializerPreCompiler I was able to narrow the problem down and guess at the problem. I made the change that I indicated above because this seems...

Shape/Symbol editing
Drawing flowcharts. Rather than adding "Yes" and "No" to every decision symbol to show which line out is which, I want to add six new symbols, each with the output pre labeled. The first should have the bottom exit labeled Yes and the right exit labeled No. I won't list the other five permutations. When I draw them and add the text and save the symbol/shape, the center no longer lines up and the symbol/shape will not change size to accomodate the text I enter within it. What is the difference between a symbol and a shape? This is Visio 2003 SP1 Thanks for y...

Intelligent Message Filter behaves very odd
I have the IMF that comes with Exchange 2003 sp2 installed and working very well, (I never had IMF v1 installed ) the only issue I have is when I set up my custom thresholds and actions under "Gateway blocking configuration" they are changed by it self to defaults the next day and I have to be change them back to my desire settings everyday. Does someone know how to fix this? or is there any registry key or setting in AD where to set this up? I've read the IMF guide but I found nothing about this. I have 2 exchange back-end servers and 1 front-end server, I also have tried ...

Edit IE7 with Word2007
When I try to edit an IE7 intranet page with my newly installed Word2007 I get an error message "The converter failed to save the file." & cannot proceed furether. This did not happen when I had Word2003. Are IE7 & Word2007 compatible? Do I have to change some setting to edit with Word2007? ...

Edit Within a Cell
In order to edit within a cell, I know I can press the F2 key on the keyboard. Isn't there a key combination that also allows you to edit data within a cell as well? Thank you you can double click within the actual cell. that opens all formulas and allows you to modify as needed. "Karen" wrote: > In order to edit within a cell, I know I can press the F2 > key on the keyboard. Isn't there a key combination that > also allows you to edit data within a cell as well? > > Thank you > you can double click within that cell and it opens all formulas an...

Does OE 6 support LDAP writing/editing?
Does Outlook Express 6 support the inserting of new entries in a LDAP server which maintains a shared address book? TIA, -gbosco The Windows Address Book supports the updating of existing records in an Active Directory domain, but not the creation of new items. New records still have to be created via Active Directory Users and Computers or some other method (3rd party solution, in-house solution, .etc). "Gianluca Bosco" <g.bosco@bitache.netGETRIDOFTHIS> wrote in message news:335i3hF3rfcbaU1@individual.net... > Does Outlook Express 6 support the inserting of new en...

Moving around in spreadsheet
OK this should be an easy one. For some reason I cant arrow right an move to the next column anymore. I can enter and move down but th arrows arent moving me to the next or previous columns. Did I mess u my settings somehow? Please help Thanks, Ji -- jsess443 ----------------------------------------------------------------------- jsess4431's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3716 View this thread: http://www.excelforum.com/showthread.php?threadid=56882 It sound link you have the Scroll Lock on. -- HTH Sandy In Perth, the ancient capital of...

Combo box contents doesn't change when filtering combo box is chan
I have 2 combo boxes. Combo1 contains a short list of years 2009,2010 etc which are pulled from a table. Combo2 has the row source of a query which uses criteria selected in Combo1. If I select 2009 in Combo1 then Combo2 shows only rows matching 2009. If I close the form and run again selecting 2010 in Combo1 then Combo2 shows only rows matching 2010. However for this application the form must remain open and when I make a different selection in Combo 1, Combo2 remains unchanged. I'm missing how to force Combo2 to refresh to show the changes. Can anyone help? Thanks, Joe ...

Adding custom list and text boxes to the custom tool bar from Excel C API
Hi All, I am developing an addin excel using Excel C API. I want to know is there any way to add custom list and text boxes to the custom tool bar from Excel C API? If yes how can we do it? Any help would be greatly appreciated. Thanks, Mousam Dubey I have been running office 2007 for several months but have a major problem in that excel crashes 3 or 4 times a day. My spreadsheets have a lot VB code behind them and this seems to be the problem. However, when I compile the code every thing is OK, no error messages but when running the programes excel seems to loose the linkage to...