Updating selected area in OnPaint in a dialog based application

I have a rather difficult to explain issue and would try again if the
information below is unclear.

We have a dialog based application which consists of a few controls
(3/4th screen) and a graphical area (1/4th screen). My job is to
implement selection of any part of the screen and then either paste it
in a document or print to the printer. I am able to implement
selection of any part of the client area and then either copying it to
the clipboard or sending it to printer.

I have a problem with maintaining the selection after the window is
re-painted for any reason. I am basically using PatBlt to invert the
selected portion of the screen. If the dialog needs to be repainted
then the controls of the dialog are re-drawn but my selection goes
away which is understandable. So, I added inverting the selected
portion in the OnPaint after calling the CDialog::OnPaint. But this
does not seem to work very well. It seems that controls on the
selected portion are getting drawn after I invert the selection. Is
there any way for me to know when all the controls in the dialog are
done re-painting, so I can then invert the selected area? I guess I do
not have a clear understanding of how the controls in a dialog are
painted on the screen.

Appreciate any suggestions,
Puneet
0
pjain (4)
2/3/2004 10:12:09 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
416 Views

Similar Articles

[PageSpeed] 48

Puneet,

You explanation is clear enough, but the problem tricky. As you already
might know, the problem is not drawing over controls, but rather keep them
painted :-) You might want to consider each control as a separate entity,
receiving their own redraw instructions. Thus, even if you draw in the
parent OnPaint, the controls will still be invalidated, and will handle call
their own redraw functions, and away goes the selection box...

This can be somewhat alleviated by explicitly validating the selection rect
in the dialog OnPaint-handler, but this will not be enough. If a control is
covered and then displayed, redraw instructions will go to the control
itself, and goodbye selection on that part of the dialog.

As I understand your post, you have a picture control of some kind on the
dialog - but it is not only a part of the picture that can be selected. I
think that the only robust solution is to subclass all controls, adding a
member for the selection rect (in screen coordinates), converting and
validating the rect in the paint-handlers. I think you will find that
validating them from the parent will not work reliably.

This might not be practical, depending on the complexity of the dialog. A
solution I would go for would be to subclass only the picture, so that the
selection rectangle is visible on the dialog background and the picture, and
let the rest of the controls redraw themselves as normal. A less than
optimal solution, but I suspect that it would work conceptually for the
user.

Johan Rosengren
Abstrakt Mekanik AB

"Puneet Jain" <pjain@datatekcorp.com> a �crit dans le message de
news:691b8e39.0402031412.6a6a82db@posting.google.com...
> I have a rather difficult to explain issue and would try again if the
> information below is unclear.
>
> We have a dialog based application which consists of a few controls
> (3/4th screen) and a graphical area (1/4th screen). My job is to
> implement selection of any part of the screen and then either paste it
> in a document or print to the printer. I am able to implement
> selection of any part of the client area and then either copying it to
> the clipboard or sending it to printer.
>
> I have a problem with maintaining the selection after the window is
> re-painted for any reason. I am basically using PatBlt to invert the
> selected portion of the screen. If the dialog needs to be repainted
> then the controls of the dialog are re-drawn but my selection goes
> away which is understandable. So, I added inverting the selected
> portion in the OnPaint after calling the CDialog::OnPaint. But this
> does not seem to work very well. It seems that controls on the
> selected portion are getting drawn after I invert the selection. Is
> there any way for me to know when all the controls in the dialog are
> done re-painting, so I can then invert the selected area? I guess I do
> not have a clear understanding of how the controls in a dialog are
> painted on the screen.
>
> Appreciate any suggestions,
> Puneet


0
2/5/2004 7:59:07 AM
Hey guys,

If subclassing the controls beneath the area in question is not to your
liking, another somewhat twisted idea might be to implement the selection
rectangle via four long, thin separate little windows arranged so that each
serves as one side of the selection rectangle. You could possibly make them
WS_POPUP style rather than WS_CHILD with either the desktop or your dialog
as the parent; that way they'd always float above the dialog itself and any
of its children. I've used a similar concept to show a selection mark during
drag/drops to windows that were in another process and it worked quite well.
Another possibility might be to take this one step further and create a
single popup window that is the size of the selection area and use
SetWindowRgn to blow a big transparent whole in the center, leaving perhaps
a 4 to 6-pixel border which represents your selection box. The dialog and
its children would show through the center. The latter would probably be
easiest from a tracking perspective. If your app targets Win2K/XP, perhaps
either of these could be combined with the WS_EX_LAYERED extended style to
alphablend a ghosted-back version of the selection area superimposed over
the content being selected. Either way, you won't get exactly the same look
as with PatBlt, but you could probably make something that served its
purpose and kept you sane along the way. ...Or maybe I've just had too much
caffeine :)...

Regards,
Mike


"Johan Rosengren" <johan.rosengren@telia.com> wrote in message
news:utZFnEV7DHA.2168@TK2MSFTNGP12.phx.gbl...
> Puneet,
>
> You explanation is clear enough, but the problem tricky. As you already
> might know, the problem is not drawing over controls, but rather keep them
> painted :-) You might want to consider each control as a separate entity,
> receiving their own redraw instructions. Thus, even if you draw in the
> parent OnPaint, the controls will still be invalidated, and will handle
call
> their own redraw functions, and away goes the selection box...
>
> This can be somewhat alleviated by explicitly validating the selection
rect
> in the dialog OnPaint-handler, but this will not be enough. If a control
is
> covered and then displayed, redraw instructions will go to the control
> itself, and goodbye selection on that part of the dialog.
>
> As I understand your post, you have a picture control of some kind on the
> dialog - but it is not only a part of the picture that can be selected. I
> think that the only robust solution is to subclass all controls, adding a
> member for the selection rect (in screen coordinates), converting and
> validating the rect in the paint-handlers. I think you will find that
> validating them from the parent will not work reliably.
>
> This might not be practical, depending on the complexity of the dialog. A
> solution I would go for would be to subclass only the picture, so that the
> selection rectangle is visible on the dialog background and the picture,
and
> let the rest of the controls redraw themselves as normal. A less than
> optimal solution, but I suspect that it would work conceptually for the
> user.
>
> Johan Rosengren
> Abstrakt Mekanik AB
>
> "Puneet Jain" <pjain@datatekcorp.com> a �crit dans le message de
> news:691b8e39.0402031412.6a6a82db@posting.google.com...
> > I have a rather difficult to explain issue and would try again if the
> > information below is unclear.
> >
> > We have a dialog based application which consists of a few controls
> > (3/4th screen) and a graphical area (1/4th screen). My job is to
> > implement selection of any part of the screen and then either paste it
> > in a document or print to the printer. I am able to implement
> > selection of any part of the client area and then either copying it to
> > the clipboard or sending it to printer.
> >
> > I have a problem with maintaining the selection after the window is
> > re-painted for any reason. I am basically using PatBlt to invert the
> > selected portion of the screen. If the dialog needs to be repainted
> > then the controls of the dialog are re-drawn but my selection goes
> > away which is understandable. So, I added inverting the selected
> > portion in the OnPaint after calling the CDialog::OnPaint. But this
> > does not seem to work very well. It seems that controls on the
> > selected portion are getting drawn after I invert the selection. Is
> > there any way for me to know when all the controls in the dialog are
> > done re-painting, so I can then invert the selected area? I guess I do
> > not have a clear understanding of how the controls in a dialog are
> > painted on the screen.
> >
> > Appreciate any suggestions,
> > Puneet
>
>


0
Michael
2/8/2004 4:29:25 AM
Reply:

Similar Artilces:

pivot table with dynamic base data
hiya, im trying to create a pivot table where I can change my base data (inserting or deleting rows of data) and still have this reflected in the pivot table. My solution was to use entire columns as my range for input to the pivotTable, but this means including blank rows which seems to muck up the calculations. I cant think how else i can allow for new rows to be added to the base data anyone got any ideas how to do this? thanks loads for your help! You can use a dynamic range as the source. There are instructions here: http://www.contextures.com/xlPivot01.html bb wrote: > hiy...

Problem with Script Updating
I am using a script to update the “1099 Type” field for Master Vendor table. The script basically is a basic if-then statement. This script is run “Before Document Commit” and it’s not updating correctly, its flip-flopping the results. When the script is set to run Before Document Commit I have the “Destination mapping” field “1099 Type” set to “Use Script”. Script below: If SourceFields("Send 1099") = "N" Then DestinationFields("Options.1099 Type").Value = 1 Else DestinationFields("Options.1099 Type").Value = 4 End If I have also tried this s...

Tallying selections from adrop-down box
I am trying to creat a report or query that will tally the results from a drop down box. my database allows my employees to inform me of the outcome of a phone call placed. There are 8 different possible outcomes to a phone call in the drop down list. I want to be able to calculate how many of each outcome was selected in the whole list. I can have the outcomes displayed either as a number or text in the table. For Example: Name ID Phone Call Outcome Jane Doe ****** (999) 555-1234 No Answer John Doe ****** (999) 555-2345 Lef...

PC Freezes up when selecting the reply button
Windows 2000 SP4, OutlookXP (2002)w/SP2 When a new message comes in, I open the message, click on reply and the message freezes up. I can and do close the email message. Open it again and can select reply with no problems. Any suggestions? Message format is Rich text. I'm having the same problem, with the exception that I am unable to close the email. I have to kill Outlook. I'm running Windows XP with Outlook 2002 SP2. >-----Original Message----- >Windows 2000 SP4, OutlookXP (2002)w/SP2 >When a new message comes in, I open the message, click on >reply and t...

updating sheets based on data in first sheet
Another payroll question, I have a workbook that contains 26 sheets, one for each bi-weekl payroll period. I would like to set it up so when i add a new employe the rest of the sheets also update automatically with that employee name and information. I have been able to acheive this to a limited degree using th =sheet1!a1 formula, but this only updates the info in the first cel and particularly the first column. I would like to acheive this using the first sheet, since at th end of the year I would like to be able to calculate ytd figure easily. Thank -- Message posted from http://www.Exc...

Update for MS Money 2005?
I have Money 2005. Is there an update to MS Money for Canadian users? Thanks in advance for any answers. We need a bit more information! Are you having problems with M2005 or is this just a post-Christmas/New Year random query when you are trying to get away from the in-laws? -- Regards Bob Peel, Microsoft MVP - Money For unofficial FAQs see http://money.mvps.org/ or http://umpmfaq.info/ I do not respond to any emails that I have not specifically asked for. "Daniel" <Daniel@discussions.microsoft.com> wrote in message news:E86EAB89-21DE-4505-ACAD-647278D736BD@microso...

Microsoft Update only updates Windows Defender
iacrosoft Update only updates Windows Defender - I have to use Belarc Advisor to get a list of missing updates, and then go to the Microsoft Download Center to search for the missing updates and download and install them one at a time. I have Windows XP Home SP3, with Microsoft Update set to automatic download - can anyone tell me why I do not get all the necessary upadtes? Is this a sudden, new problem? When was Automatic Updates last working? Can you update manually via http://windowsupdate.microsoft.com? Any chance you've got a beta build of WinXP SP3 installed? What...

Publisher 2007 and Microsoft Updates
I created a newsletter yesterday - everything fine - use Publisher all the time. Then an automatic update came down this morning and I can't open the file - it says "Publisher cannot open file" Other documents in Publisher are opening - any ideas? http://support.microsoft.com/kb/972566/ -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Kim" <Kim@discussions.microsoft.com> wrote in message news:8754339B-99DC-4D09-83AD-6B34D8215274@microsoft.com... >I created a newsletter yesterday - everythin...

Multiple date select calender
I need a calender for MFC in which i can select multiple dates similar to what is there in calender of outlook 2003. Also I need the functionality to be able to select the days i.e. sunday, monday, etc. Is there some activex available freely which i can use. Or is it possible to achieve the same by subclassing the existing CMonthCalCtrl in MFC. Please guide me. Thanks in Anticipation Software Engineer wrote: > I need a calender for MFC in which i can select multiple dates similar to > what is there in calender of outlook 2003. Also I need the functionality to > be able to sel...

Copy and Paste based on criteria
When Department changes I need to insert the ADDRESS below the Account-Institution Business Office:. Another option I have is that if address = get new address from page 2. HELP xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ending 02/13/10 Account-Institution Business Office: DEPT EMP.NBR EMPLOYEE NAME ADDRESS 883 27903 ROBERSON, JOE abc 883 119245 MUSIL, TODD E abc 883 Total ----------------------------------------------------------------- Account-Institution Business Office: DEPT EMP.NBR EMPLOYEE NAME ADDRES...

Update question
Soory if this is the wrong place to ask this, but cannot find a NG proper to Windows 7. I currently run Windows Vista and am getting tired of Vista's decision to tell me that it is going to shut down in less than a minute. So have decided to upgrade to Windows &. I note that I can purchase an upgrade versiom for 64 quid from Amazon or an apparently full version of Windows 7 Home premium for 89 quid. My question is this - If I buy the upgrade version will I only be able to load it on a new PC in the future if I already have windows Vista installed? i.e For any future cl...

Adding selected numbe in a column
I am using Excel to get results of a competition where there are 100 results of which the top 50 count for each player. Need the Total of the column to only add the best 50 scores. Les Golf wrote: > I am using Excel to get results of a competition where there are 100 > results of which the top 50 count for each player. > Need the Total of the column to only add the best 50 scores. Hi Les, try with this formula: =SUM(LARGE($A$1:$A$100,ROW($A$1:$A$50))) array-entered, i.e. you have to press CTRL + SHIFT + ENTER instead of just ENTER. Where the results I assume are in $A$1:$A$1...

Psexec vs MFC application
I am having problems starting an MFC application in remote using psexec (from http://www.sysinternals.com/). It works well with most applications (ex: notepad.exe), but it creates problems with MFC applications. The application starts, but it aborts with an "Application Error" saying "Windows cannot continue from this exception". We then wrote our own psexec-like tool to spawn remote applications, but we have the same problem. The way psexec (and our tool) works, is by starting a service on the remote computer, which then waits for a request to start a process locally. ...

Outlook 2003 died mysteriously after update
Setup in a nutshell... System: Lenovo T500 laptop OS: Vista Business SP1 32-bit Software: Office Outlook 2003 SP3 Problem... So I'm using this setup for over a year, everything OK. Yesterday I did two things and now Outlook dies (quietly, sans error message) immediately after startup. It show the splash screen, displays my inbox, and *poof* disappears. What I did earlier... 1. Windows Update installed: KB9766662, KB979306, KB979099, KB975929 2. At the same time, while searching for another program to uninstall I stumbled upon (and uninstalled) Windows LIVE Toolbar and...

Inventory Transfer selecting incorrect stock items
Hello We are doing stock transfers and when we select items from the inventory list, it is putting a completely different item into the transfer????? I have re-indexed but it made no difference. -- Jenny ...

SELECT query as subquery to APPEND
I am trying to use a SELECT query as a subquery to an APPEND query to create a dynaset on the fly and append it into tblEmployeeProduction from the click of a button on a form. The only thing is that my SELECT query takes one parameter and because of that I am unsure how to set up the APPEND portion of the query or if it can be done at all. Here are the opening lines of the SELECT's SQL: PARAMETERS forms![frmSetEmpHours]![txtDate] DateTime; SELECT [FirstName] & " " & [LastName] AS Name, forms!frmSetEmpHours! txtDate AS ProductionDate, 'Do more stuff here.............

How update entity in post update?
I created a handler for Update post callout for Opportunity. I want update some fields of the opportunity on the PostUpdate. However, if I call the Update method of CRMOpportunity in the PostUpdate I will create a recursive post callout. Can somebody help me? Thank you for pay attention []'s Vin�cius Pitta Lima de Ara�jo You need to check the OrigObjectXML field to see what fields were updated and then act appropriately. Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On Wed, 4 Aug 2004 17:43:17 -0300, "Vin�cius ...

Cannot install update KB979906 for .NET Framework 1.1 SP1
Running : Windows XP media center edition SP3 Have tried installing KB979906 a few times and also downloaded update manually but cannot install this update. Receiving error 0x643.Is it safe to uninstall the .NET Framework 1.1 and re-install as possibly corrupt , without having to uninstall/re-install all other .NET frameworks 2 , 3 and 3.5 including the updates that go with them? .. Hello sherlockomes, you might want to look at the following kb article to see if this will help with the error 80070643. <http://windows.microsoft.com/en-US/windows-vista/Windows-Update-error...

Excel 2003 -- Problem selecting link range within an autoshape.
In a multitab worksheet, we have a rectangluar autoshape on each sheet. The rectangluar shapes are not moved or resized with cells. The shapes are set to no fill. On any sheet, if you want to select a range within the rectangle on that sheet, there is no problem. But if you want to link from one sheet to another -- i.e type = for a cell's contents and then go to another sheet to select a cell or cells -- you are not permitted to select a cell within that other sheet's autoshape. One may select a range that overlaps the autoshape, however. One can also manually enter the range,...

Print record once, update Yes/No field verifiying print
I would like to print a group of records, then have a Yes/No field [Printed] updated in my Jobs table with an update query showing the records were printed. Then next time the report runs, In my query criteria I will test for True values on the Yes/No field. Then only the records with the Yes/No field marked No will print. Any suggestions? Thanks Tommyboy,there's more to this question than meets the eye. For an explanation of what's involved, see: Has the record been printed? at: http://allenbrowne.com/ser-72.html The article includes a free sample database that dem...

latest update too MSCFV2
Hi, I have MSCFV2 version 6.5.7825.0. Could someone inform me if this is the latest download? Looks like you have 6.5.7825.0 from 05/21/2006, but there is a newer version - 6.5.7831.0 from 06/01/2006. C. Smith Enso Technologies, Incorporated http://www.ensotech.com On Tue, 13 Jun 2006 04:25:02 -0700, Paul <Paul@discussions.microsoft.com> wrote: >Hi, > >I have MSCFV2 version 6.5.7825.0. Could someone inform me if this is the >latest download? Christopher Smith csmith@ensotech.com Enso Technologies, Incorporated http://www.ensotech.com Also - meant to post this in t...

Dynamic Menu update
Hi All, I need to update a menu item dynamically, setting its SetCheck property to either true or false, based on a user operation. I am trying to do this from a custom function. Usually, the pCmdUI pointer is used. But how do I do it from another function? Thanks Your "other function" should change some setting. In your ON_UPDATE_COMMAND_UI handler, you should check that setting and call SetCheck as needed. -------------- Ajay Kalra ajaykalra@yahoo.com In addition to Ajay's response, this page may help you: http://msdn2.microsoft.com/en-us/library/6kc4d8f...

online updates for money2003(not updating)
Money gets its updates from spcomstock.com and the server has moved to a new site. The default site that money provides has to be changed. At this time I don't know how to do this. If I find out how to do this I will Post it. ...

Payroll Update
HI all, We are running GP 7.5. I installed SP7 and the July 2005 tax update for CDN payroll. Now out payroll administrator gets an error message: 'The modified version of P_Payroll registry is missing'. How do I fix this problem Thanks -- Henry ...

[ANN] Excel X security update
Hi All, A security update for Excel X was also released today: http://www.microsoft.com/mac/downloads.aspx?pid=download&location=/mac/d ownload/officex/ExcelX_Security_1017.xml&secid=5&ssid=17&flgnosysreq=Tru e Or at least: http://www.microsoft.com/mac/downloads.aspx Corentin -- --- Mac:MS MVP (Francophone) --- http://www.mvps.org - http://mvp.support.microsoft.com MVPs are not MS employees - Les MVP ne travaillent pas pour MS Remove "NoSpam" to e-mail me - Retirez "NoSpam" pour m'�crire ...