Selection/Inversion

Not really a C++ or MFC issue but I can't think of anywhere better to ask:

In the old days, the generally accepted method of selecting a block in a
document was simply to invert the colours on the appropriate part of the
document.   This had the advantage of being fast but graphics cards are a
bit better these days and subtler effects tend to be used in controls and
things like Word documents.

As far as I can see, when a selection changes, it must just redraw the whole
window or an appropriate large part of it  (double buffered to avoid
flicker).

(To increase a selection on a white background, I suppose it could draw
shading with transparency, but I'm not sure that could be done as the
selection decreases.)

Rather than me just guessing, does anyone have any tips/pointers to how this
really is done?

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

0
dave9996 (486)
3/18/2008 5:13:58 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
668 Views

Similar Articles

[PageSpeed] 32

David,

> In the old days, the generally accepted method of selecting a block in a
> document was simply to invert the colours on the appropriate part of the
> document.   This had the advantage of being fast but graphics cards are a
> bit better these days and subtler effects tend to be used in controls and
> things like Word documents.
>
> As far as I can see, when a selection changes, it must just redraw the 
> whole
> window or an appropriate large part of it  (double buffered to avoid
> flicker).
>
> (To increase a selection on a white background, I suppose it could draw
> shading with transparency, but I'm not sure that could be done as the
> selection decreases.)
>
> Rather than me just guessing, does anyone have any tips/pointers to how 
> this
> really is done?

In my Cygnus Hex Editor, I simply redraw the selection using the system 
selection colors. I have a routine that invalidates the minimum amount of 
window area to include the changed areas. It is extremely fast. My program 
has an option to use double buffering but, on my latest computer, it is hard 
to see any difference from this setting.

Of course, you didn't mention what type of "document" this was. If you are 
using some type of control like an edit control then this is handled for 
you.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

0
jwood (1292)
3/18/2008 5:21:23 PM
"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
news:OnCnHyRiIHA.3448@TK2MSFTNGP04.phx.gbl...

> In my Cygnus Hex Editor, I simply redraw the selection using the system 
> selection colors. I have a routine that invalidates the minimum amount of 
> window area to include the changed areas. It is extremely fast. My program 
> has an option to use double buffering but, on my latest computer, it is 
> hard to see any difference from this setting.

My music editor is most useful with the window pretty much maximised - to 
see as much music as possible.   In principle there are literally thousands 
of separate music symbols on the screen, and some years ago, when I switched 
to double buffering, the improvement was vast.   [The eye/brain is much 
happier to accept a small delay and then everything appearing instantly than 
even a very fast draw with things appearing one by one.]    So my paint code 
draws on a memory DC and then blits it, and I have no reason to change it.

> Of course, you didn't mention what type of "document" this was.

An MFC doc-view architecture document - in this case showing music notation.

To select areas I am reversing colours on the screen DC - as I haven't 
changed that aspect the code since Windows 3.1 days, when it was the 
recommended procedure.  (My wife always tells me I am not responsive to 
fashion <g>.)        Some applications still do that - Windows mail for 
example - but it is starting to look old fashioned even to me :-)

Shading the area before drawing the symbols could look a lot nicer. 
Invalidating the apporpriate area of the window when the selection changes 
would be fine.  But isn't *particularly* fast as the program spends as much 
time calculating where to draw things as actually drawing them, and 
calcuating what is in any given area takes some CPU time when a small area 
needs to be drawn.   (Inverting the colours is much faster, but I think I 
can relax that now, as the other way will be fast enough, and prettier.)

> If you are using some type of control like an edit control then this is 
> handled for you.

Yes.  That's not the problem.

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm




0
dave9996 (486)
3/20/2008 12:21:09 PM
David,

> My music editor is most useful with the window pretty much maximised - to 
> see as much music as possible.   In principle there are literally 
> thousands of separate music symbols on the screen, and some years ago, 
> when I switched to double buffering, the improvement was vast.   [The 
> eye/brain is much happier to accept a small delay and then everything 
> appearing instantly than even a very fast draw with things appearing one 
> by one.]    So my paint code draws on a memory DC and then blits it, and I 
> have no reason to change it.

No, no one is saying you should change it. Like I said, I do it both ways. 
It's just getting harder to see the difference as computers get faster.

It does, however, also depend on how much flicker shows during normal 
painting. For a long time, I was actually able to update my display in such 
a way that there was no flicker. For example, instead of clearing a 
background area and then printing text, I would simply print the text with 
the required background color. After a while, the display became more 
complex where this didn't seem to make sense any long. So the point is that 
some displays can be painted without flicker while others would tend to show 
flickering more without being double buffered.

> To select areas I am reversing colours on the screen DC - as I haven't 
> changed that aspect the code since Windows 3.1 days, when it was the 
> recommended procedure.  (My wife always tells me I am not responsive to 
> fashion <g>.)        Some applications still do that - Windows mail for 
> example - but it is starting to look old fashioned even to me :-)

Eh? Selecting text in Windows Mail (the version that comes with Vista) uses 
the current system select color so I'm not sure what you're referring to 
there.

One problem with reversing the color are areas that are medium gray as 
reversing them has basically no effect. As you put it, this is no longer the 
recommended procedure, but perhaps it looks okay in your case. Frankly, with 
the speed of today's computers, and the fact that you're already double 
buffering, I really don't see why you don't repaint using the system 
selection colors. But, then again, I haven't seen your app.

> Shading the area before drawing the symbols could look a lot nicer. 
> Invalidating the apporpriate area of the window when the selection changes 
> would be fine.  But isn't *particularly* fast as the program spends as 
> much time calculating where to draw things as actually drawing them, and 
> calcuating what is in any given area takes some CPU time when a small area 
> needs to be drawn.   (Inverting the colours is much faster, but I think I 
> can relax that now, as the other way will be fast enough, and prettier.)

I think so.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

0
jwood (1292)
3/20/2008 4:30:33 PM
"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
news:ehq28eqiIHA.5820@TK2MSFTNGP04.phx.gbl...
>...
> Eh? Selecting text in Windows Mail (the version that comes with Vista) 
> uses the current system select color so I'm not sure what you're referring 
> to there.

So it does -  in the reading window.

But in the window into which I'm typing the reply it is black :-)

> One problem with reversing the color are areas that are medium gray as 
> reversing them has basically no effect....

Yes.  I have fallen over that one in the past, but grey surrounded by white 
becomes grey surrounded by black, so there is an effect.

>> Shading the area before drawing the symbols could look a lot nicer. 
>> Invalidating the apporpriate area of the window when the selection 
>> changes would be fine.  But isn't *particularly* fast as the program 
>> spends as much time calculating where to draw things as actually drawing 
>> them, and calcuating what is in any given area takes some CPU time when a 
>> small area needs to be drawn.   (Inverting the colours is much faster, 
>> but I think I can relax that now, as the other way will be fast enough, 
>> and prettier.)
>
> I think so.

I'm becoming more and more keen on this.   Thanks for your comments.

Dave
-- 
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

0
dave9996 (486)
3/20/2008 8:10:20 PM
Reply:

Similar Artilces:

How to package up selected emails?
Is there a way that I can package up selected emails in some sort of a delimited file so that I can send them as a single file to another person and they can read them as individual emails? Ideally, I'd like some sort of collection that clearly identifies each individual email. I know I can paste them into a Word document, but that is difficult to read and separate the emails from one another. "Square Peg" <SquarePeg@Round.Hole> wrote in message news:0dtfo4llnue2c8v41gs2o0mhaefcan3t28@4ax.com... > Is there a way that I can package up selected emails in some sort of a...

Multiple control selection
Hi Everyone, I have a worksheet that has 100 checkboxes on it. I want to select 50 of them and enable the check on them. I remember in excel2003 i could put a selection box around them and change the property on these, but in excel2007, the seleciton box doesn't seem to work... can somebody help? Thanks in advance. Hi, Undoubtly a bug. If they are always the same checkboxes you want to select you could group them - select them and then choose Page Layout, Group, Group. Then one click gets them all. -- If this helps, please click the Yes button. Cheers, Shane Devenshire ...

protection of select cells containing formulas
I guess I am not concidered computer literate as I cannot understand the instructions on how to protect others from overwriting cells which contain formulas. I want them to be able to make entries in some, but want to restrict entries in others. Everytime I try to follow the help instructions, I am told the cells are protected and to make entries, I must "unprotect" the worksheet. I am well into my "upper sixties" so please be kind with the answer so I can understand. Thanks for the help. Jack Wildermuth Jack, By default, all cells are locked, so when you pr...

no notification from list control when check box selected?
hi there i have a list control in an MFC app for which i set CheckBoxes ON (LVS_EX_CHECKBOXES) i need to know when the user checks/unchecks any item is there a specific notification sent to the owner when the user checks/unchecks an item? or do i watch for the more general LVN_ITEM_CHANGED notification (which doesn't seem to give info specific to checking/unchecking - the closest thing seems to be a State Image Mask change)? tia bhu >i have a list control in an MFC app for which i set CheckBoxes ON >(LVS_EX_CHECKBOXES) > >i need to know when the user checks/unchecks any ...

disable blinking cursor and selected text in edit box
Hi! I'm using mfc to create a dialog with an edit box in it, to which I write text after an event occurs. Everything works the way I want, except that the text comes out highlighted and the cursor is blinking irritatingly at the end of the line. I looked everywhere on the web to find a way to disable these two but couldn't find a way. Can someone tell me how to disable the cursor and to not have selected text printed in the edit box? thanks, Craig To disable blinking cursor, On the EN_SETFOCUS handler, try m_Edit.HideCaret() ; Here's the remarks from MSDN: Although the caret is...

use pull down menu to select a picture
I use the Combo Box pull down menu buttons a lot. I click on the Box, select an item from the list and the relevant data pops up as expected. How can I make a picture pop up when I select an item from the Combo Box List? please advise use Eccel 2003 Hi Skonnoth, See if you can pass this code to your combo box to activate the form and pictures pop up. http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=46010&lngWId=1 "Skonnoth" wrote: > I use the Combo Box pull down menu buttons a lot. > I click on the Box, select an item from the list and the re...

Allen Browne's Multi-Select Tip
http://allenbrowne.com/ser-50.html The above link is an excellent tip which explains how to use a multi- select list box to select several items at once, and open a report limited to those items. I have this code working on several of my reports, but my "PREFERENCE" would be to run the Report first, and get necessary parameters from the Form. I'm not having any luck in doing this, and in particular, I can't see how to get the value of "strWhere" (the WhereCondition) into my report, after the fact. I have passed the exact same information via a text box to my rep...

Using selection to add cells to formulas
OK, I've pretty well searched though here and haven't found my question or a full answer. Using Excel 10. Building up a formula in a cell by clicking on other cells to fill their addresses. The address filled in is invariably relative, when sometimes I'd like an absolute reference. I know I can hit F4 after the fact, but I'd sure like a shortcut. I've tried all sorts of key combos, thinking maybe ctrl-shift-click (or something) would give me an absolute reference. I'd be willing to use a macro, but so far as I can see, macros are not available in edit mode. Any id...

Select & move more than 1 page
I have Pub. 2003 and I'm trying to move pages around in my document. Moving one page is no problem, but I'm trying to move huge chuncks. Is there a way to select more than one page or say move pages 30-45 to before/after page 2? Thanks. The moving of many pages at once is new feature of 2007, sadly it is not a feature of 2003. You can right-click any toolbar, customize the Edit by dragging *move* to the toolbar, this will make moving the pages go a bit faster. It maybe helpful to rename your pages so you can keep track of them just by hovering over the sort tabs. -- Mary Sau...

Using Option Group to select a range of Queries
Hi there, I'm trying to set a form up to select a range of columns in which I'd like to search for a specific string using presaved queries. I'm thinking of having 10 text boxes, each displaying a single line of the received data. I was then going to have to columns of radio buttons to signify the start and end of the search. The user would then be able to select 'Start button' 3 and 'end button 5', which, after clicking on the 'go' button, would run the 'search column 3', 'search column 4' and 'search column 5' queries. If the Star...

Conditional Printer Selection
I have a report that I would like to print to the default printer if it is less than 5 pages, or to a network printer if it is more than 5 pages (or so many records in the record source). Access 2003 Jack "Powderfinger" <PFinger@msn.com> wrote in message news:ct-dnTzc9cjM_q_bnZ2dnUVZ_syunZ2d@comcast.com... >I have a report that I would like to print to the default printer if it is > less than 5 pages, or to a network printer if it is more than 5 pages (or > so > many records in the record source). > Access 2003 I think a solution here would be to simply &q...

Selecting Check Boxes
Problem: I have two columns which each has a check box. I want only one check post to be selected as the two are related i.e. which contractor will you use contractor 1 contractor 2 who has best rates contractor 1 contractor 2 etc etc when I use radio buttons for some strange reason it only ever allows me to check on radio button on the spreadsheet (could be stupid user syndrome!). Can anyone help with the best way to work this. thanks Not clear what you're saying, however, checkboxes ar...

Basic Select Query Duplicating a single end user's records
I am stumped with a particular problem. My table consists of hundreds of records that are directed to their associated end user. This is my simple Select query shown here: "SELECT [Name Tbl].Mgr, [Name Tbl].Name, [Data Tbl].Survey_CNT, FROM Manager INNER JOIN ([Name Tbl] INNER JOIN [Data Tbl] ON [Name Tbl].ID# = [Data Tbl].Name) ON Manager.OM = [Name Tbl].Mgr" Inside the Data Tbl, one Name shows 4 physical records. However, in this simple query it has duplicated one Name's records so now there is 8 for that one particular name. The other Names show a correct m...

Excel Mouse Selection Problem
Hello everyone, I'm having a strange problem with Excel 2000. After i click for the first time my left mouse button, the mouse enters selection mode, as if i was pressing the shift key. I've browsed the net for a solution, even the MS support site with no success. Has anyone ever had this problem? Or has a clue of what could be appening? Thanks in advance, Paulo Silva Maybe you accidentily pressed F8 (Extend Selection)? -- Kind Regards, Niek Otten Microsoft MVP - Excel "Paulo Silva" <pgoncalves@hotmail.com> wrote in message news:%233O1St70DHA.2572@TK2MSFTNG...

Select records based upon calculated totals
I've created a report that shows the contract price of a project and using a subreport of invoices, a text box to calculate percentage of $ invoiced, which works great. I'd like to now create a report that shows only the projects that have not been invoiced 100%. What about the idea of doing that calculation in the underlying query, then using the query to feed the report? Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein do...

if i select a cell then i want row containing that cell selected
i want to copy all rows that contain a cell with certain value. Do a Data > Filter > Autofilter on the key col, filter out that certain value, then copy the filtered rows, and paste special as values/formats elsewhere as required -- Max Singapore http://savefile.com/projects/236895 xdemechanik --- "Maaz" wrote: > i want to copy all rows that contain a cell with certain value. ...

select name box freezes Outlook
Outlook 2002 sp2 XP Pro When I click the To: button, the select names window opens. I cannot select any names as Outlook freezes completely. I have to close the entire program through Ctl Alt Del. I used the cd to do a fix and repair, but it did not fix or repair the problem. Any solutions or suggestions are appreciated. Jerry ...

Auto select sales rep
Hi All, Is there a way of automatically selecting the sales rep when recalling work orders so that the sales rep that took the initial transaction and deposit is automatically credited with the commission when the customer comes back to pick up / pay for their goods? At the moment we would have to rely on staff being very honest and select the original sales rep and they would also have to check a customers receipt or look through the journal to find out who the original sales rep was. This seems to me to be a common practice as the person that has done all the hard work initially to get the...

Select Last in Range
Hi, I am writing a macro to copy a list of data from one spreadsheet to another. The list includes blank rows as separators. I want to select the entire list minus the blanks. I don't know how many rows it has or how many blanks there are. I would have preferred to use Selection.End(xlDown) but the blanks stop the selection early. My macro goes to the cell named "Start" and offsets one row down. This I know is the top of the list. I then select 1000 rows below that, because I know the list would never be that long. Then I have Selection.SpecialCells(xlCellTypeConstants, 2...

Selective report printing please help
Hi Under Transactions menu > Financials > Series post Say i check mark 2 or 3 records and post them I want to selectively print eg - 1st page of report ok print , 2nd page not required. etc Rick Unfortunately, what you want to do is not possible. -- Charles Allen, MVP "Rick" wrote: > Hi > > Under Transactions menu > Financials > Series post > Say i check mark 2 or 3 records and post them > I want to selectively print eg - 1st page of report ok print , 2nd page not > required. > etc > > Rick ...

Changing cell colour when cell selected/de-selected by mouse/arrow keys
Newbie. Is it possible to get excel to change the colour of a cell when it is selected by mouse pointer, or arrow keys, from default white to yellow then revert to white again when the next cell is selected? Here's one way Private Sub Worksheet_SelectionChange(ByVal Target As Range) Cells.FormatConditions.Delete With Target .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 ...

invert selection
A feature in older operating systems I sometimes found useful was the "invert selection" in the Edit menu (now organize) of Explorer. I do not recall seeing this in the short time I had Vista and do not see ti there in 7. Is there any way to get this back? I have resorted to deleting the entire group and restoring the ones I wanted to keep. Thanks "lb" <ldbrw@my-Dejanews.com> wrote in message news:1343bbb5-087c-4866-8465-3ef492431c9c@m26g2000yqb.googlegroups.com... >A feature in older operating systems I sometimes found useful was the > "inv...

passing a parameter based on multiple selections
Hi, I have a form in which several choices are selected, one of which is a list box in which the user can make multiple selections. I followed the various suggestions to create a String that has the selected items and I set a textbox in the form as that final String as follows: Dim Criteria As String Dim ctl As Control Dim Itm As Variant ' Build a list of the selections. Set ctl = Me![lboSTATID] For Each Itm In ctl.ItemsSelected If Len(Criteria) = 0 Then Criteria = Chr(34) &a...

any way to select multiple folder for properties change?
I would like to apply the same properties change to a number of subfolders of a main folder. Is there any way to do this, except selecting each folder one-at-a-time to make the same propertiies change? I Live On Outlook No. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "I live on Quicken and Outlook" <Private@privacy.org> wrote in message news:vof6l09v3g4bdm119pjo7ujk0j02kur08e@4ax.com... >I would like to apply the same properties ...

selection.copy = "picture too large"
excel 2007. I understand this has something to do with office clipboard changing all copied stuff to picture format? I found one hint to turn off office clipboard but it didn't work. what now? John ...