HDC Clipping issues

Hi,

I am drawing some things in my view.
I wish to draw stuff all over the client window, then set a clip rect, such
as draw a line from one corner of the screen to another, but make sure that
what I draw is only visible on a portion of the view.

CMyView::OnDraw(CDC* pDC) {

    CMyDrawRoutines d;
    d.BeginDraw(pDC->m_hDC);

    d.DrawSomeStuffInEntireClientWindow();

    CRect rc;
    GetClientRect(&rc);
    rc.DelfateRect(100,100,100,100);

    CRgn rgn;
    rgn.CreateRectRgnIndirect(&rc);

    d.SelectClipRgn(&rc);

    d.MoveTo(0,0);
    d.LineTo(rcClient.right, rcClient.bottom);

    d.EndDraw();
}

The last line draws a line from left upper corner to right lower corner of
the client window, but I want the line to only be drawn within the rectangle
that is deflated 100 from all edges.

This works sortoff, but when my view is covered by another window, and I
drag the window around, the screen does not update well. The problem seems
to be my memory draw routines to prevent flickering (non-MFC)

 BOOL BeginDraw(HDC hDC) {
  ASSERT(hDC);
  if (m_bPrinting || !m_bMemoryDraw) {
   m_hDC = hDC;
  }
  else {
   ::GetClipBox(hDC, &m_rcClip);
   m_hDC  = ::CreateCompatibleDC(hDC);
   m_hBitmap = ::CreateCompatibleBitmap(hDC, m_rcClip.right - m_rcClip.left,
m_rcClip.bottom - m_rcClip.top);
   m_hOldBmp = (HBITMAP)::SelectObject(m_hDC, m_hBitmap);
   ::SetWindowOrgEx(m_hDC, m_rcClip.left, m_rcClip.top, NULL);
  }

  return TRUE;
 }

 void EndDraw(HDC hDC=NULL) {
  if (m_bPrinting || !m_bMemoryDraw) {
   m_bPrinting = FALSE;
   return;
  }

  if (hDC == NULL)
   hDC = m_hDC;

  ::BitBlt(hDC, m_rcClip.left, m_rcClip.top, m_rcClip.right - m_rcClip.left,
     m_rcClip.bottom - m_rcClip.top, m_hDC, m_rcClip.left, m_rcClip.top,
SRCCOPY);
  ::SelectObject(m_hDC, m_hOldBmp);
  ::DeleteObject(m_hBitmap);
  ::DeleteDC(m_hDC);

  m_hBitmap = NULL;
  m_hDC = NULL;
 }

Something isn't right with this code. Somehow my clip isn't always working
when portions of the screen gets invalidated by windows moving over my view.
Any clues?


0
no6060 (315)
10/21/2004 3:05:03 AM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
175 Views

Similar Articles

[PageSpeed] 30

Reply:

Similar Artilces:

MS Money Issues
It would be interesting to collect thoughts on the subject of MS Money vs. Quicken. I have been a long time user of Quicken but decided to switch to take advantage of what appeared to be a better user interface and better integration into the web. I have not been disappointed with those Money aspects. But.... I have spent hours 'fixing' (repairing) money (Sm Business 2004). It seems to me that the database employed by MSFT is quite fragile. In the over 10 years of using Quicken, I don't think I had one corrupt file error. MSFT appears to have taken shortcuts in in...

VSS issue on SBS 2008
I am using Backup Exex 12.5 on SBS 2008. For 6+ months my backups have been running fine, but last week they began failing with the following: Backup- SBS2008 - AOFO: Initialization failure on: "\\SBS2008\Microsoft Information Store\First Storage Group". Advanced Open File Option used: Microsoft Volume Shadow Copy Service (VSS). V-79-10000-11226 - VSS Snapshot error. The Microsoft Volume Shadow Copy Service (VSS) snapshot provider selected returned: "Unexpected provider error". Ensure that all provider services are enabled and can be started. Check the Window...

is clip art only available online with Publisher 2003
The search results vary the clip art from day to day, does this mean I have not installed software correctly? Office 2003 shipped with very little clipart. You must be online if you want to take advantage of the 100,000 plus images available. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Katy Probation" <KatyProbation@discussions.microsoft.com> wrote in message news:F8FD7045-34B8-4B71-864F-0F8ADA95EA6B@microsoft.com... > The search results vary the clip art from day to day, does this mean I have > not instal...

Filing clippings in One Note
Is it possible to alphabetize your notes in order? ...

how to get hwnd from hdc
Hi, I know how to get a HDC from HWND, but I am given a HDC from window media player and I want to correlate the mouse position with objects on my HDC. In order to use ScreenToClient I need the HDC's hwnd. How is that possible? If I use GetActiveWindow, I have an offset equal to the media player's menu and button panes. -- ------------------------------------------------------------------------- Music, Recipes, Photos, and more: http://www.sequoiagrove.dk "You don�t frighten us, English pig-dogs! Go and boil your bottoms, sons of a silly person. I blow my nose at you, so...

Manufacturing Picklist issue
We are having an issue and I can't find anything on it in the Knowledge Base. We are using Manifacturing and sometimes people have to modify the Strat/End quantity of a workorder. Each time they increment a message appear warning them that they will need to reschedule and rebuild the picklist. After rebuilding the picklist they go back into it to verify the changes and there is always one item that is duplicate instead of incremented as it should be... The only "workaround" we found so far is deleting the picklist and rebuilding it after. It is working but I can't...

SUM() issue
Hi, i have a question for y'all, i have a table D P Partner --------------------------- 1 3 P 5 2 P 6 4 K 8 3 K 7 8 P 7 5 K 2 3 K Ok, what i need, is to find a difference between the SUM(of D column where the Partner is P) and SUM(of P column for all partners)... So, the result should be SUM(D where Partner = P) - SUM(P) If anyone has any ideas, please share it with me,....THANX!! "ApeX" <mmojas@gmail.com> wrote in message news:1182468415.543257.187560@w5g2000hsg.googl...

Listbox and sheet updating issue
I need your assistance with a problem I have with a listbox. I have a sheet containing a range "Reporting_Periods" which has col(1) = a number 1 to 15 (Period), and Col(2) a StartDate and col(3) an EndDate. I have a userform with one listbox, and 3 textboxes - Period, Startdate, Enddate. The users may change the dates in an existing Period, and if the click in the blank line under the last populated row in the listbox, they can create a new Period. The listbox is populated at Userform_Initialize which sets the row source and the bound column (Period). Everything works O...

HDC
Env: WindowsXP, VC++6.0 Who can kindly tell me the different about using hDC1 or hDC2 inside OnDraw() below. CView::OnDraw(CDC* pDC) { HDC hDC1 = pDC->m_hDC; HDC hDC2 = ::GetDC(m_hWnd); } TIA William William wrote: > Env: WindowsXP, VC++6.0 > > Who can kindly tell me the different about using hDC1 or hDC2 inside > OnDraw() below. > > CView::OnDraw(CDC* pDC) > { > HDC hDC1 = pDC->m_hDC; > HDC hDC2 = ::GetDC(m_hWnd); > } > > TIA > William The DC passed to OnDraw is special in several ways. It is normally a CPaintDC, which i...

.pst open issues
Hello, I have a pst file that I pulled out of a crashed HD. It is 1.4 gb in size. I purchased a new HD and reinstalled office and XP. When I go to open the ..pst file nothing happens...when I use import...I can see the status bar, and files in the folders of the .pst file. But when it completes everything is blank. I don't know how to run scanpst.exe. Help please. Ray Use Search to locate Scanpst. it is usually in: It si usually in C:\Program Files\Common Files\System\MSMAPI\1033 Just Open it, use browse to select that PST and then Start. it's that easy! ensure you backup ...

Outlook 2003 issues w/POP & Network Solutions
I've got a WinXPHome - all up to date. Outlook 2003 - all up to date. Norton Internet Security 2006 - disabled (as far as I can tell) - this was my first thought of being an issue POP mail with Network Solutions has issues sending and receiving. I've adjusting to port 2525 for outgoing and switched back & forth on that. No SSL. If I telnet to mail.domain.com 25 or 2525 no repsonse. I can setup another POP mail account (to my own Exchange 2003 server) and it works fine. I can change the outgoing mail server to an sbcglobal.net and mail will go out - but still encounter issue...

Clip art does not appear in new blank publications when inserted
I am running office 2003 pro. When I use Publisher , the following happens. I open a new blank publication page and go to insert some clip art. The outerframe of the clip art appears but not the actual clip art. There is no clip art to be seen. When I print it out the clip art is there. Can any one help? What am I doing wrong??? View, pictures, "detailed display" -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.msauer.mvps.org/ news://msnews.microsoft.com "doogle" <doogle@discussions.microsoft.com> wrote in message news:6F0BD8FE-3FCD-48A3-8BA8-4C1C86...

shared calendar/printing issues
Hi, I'm new on this forum, but seems to be a very nice folks aroun here! here's the situation I have. there's this manager who shared her calendar with her admin, her admi is able to access the calendar (the manager gave her owner' permissions), so, she's able to access it, to accept, decline, etc etc, the funny thing is that when the admin tries to print he manager's calendar, it works fine on a month view, and on a week view but when she tries to print on a day view, Outlook returns an erro message "the program interface returned an unknown error, close th app...

Exchange 2003 relaying issues
Recently our Exchange 2003 Server started queuing up spam email from different sources. We have had Exchange 2003 up and running for approx. 6 months now. No configuration changes to my knowledge. When I restrict SMTP access through Authentication and uncheck Anonymous Access the SMTP connections stop. But outside email coming to the Exchange server does not get delivered. We have internal users connecting to Exchange, 2 Mac users using IMAP and External users that POP email. Can you offer any suggestions? Any location that gives what the default settings are for Exchange SMTP connectio...

DrawTextW( hdc, strText, -1, rectB, DT_SINGLELINE); #2
Hi, I have a peice of a code for loading a icon and draw the text below the icon on the same button... i was sucessful in loading an icon but when tried with the DrawText() to insert a text, its not working and the problem is with the hdc parameter of DrawText function. void CNewButtonDlg::CallButton() { CString strText(""); //To place the text on the button RECT rectA = {180, 20, 270, 90}; //left, top, right, bottom //To nullify the error that parameter must be a LPRECT and not RECT type i have done so LPRECT rectB = &rectA; CDC my_newButto...

Windows Mail
Within the past 48 hours I am unable to receive certain emails - specifically those with attachments or sent as part of a group. Contacted my isp provider - they claim it is not their issue. Error message received is : SMTP; 554 Transaction failed. Please provide any suggestions Thanks. -- southernice "southernice" <southernice@discussions.microsoft.com> 写入消息 news:5818A4C8-1C8E-46B9-B838-97464D356114@microsoft.com... > Within the past 48 hours I am unable to receive certain emails - > specifically > those with attachments or sent as part of...

paper clip
Is there a way to download the paper clip to a CD so you can transfer it to a computer that has windows 7 and Microsoft office 7 as well or not. If you're talking about Clippy, I'm pretty sure there isn't. After all the complaints people had about him during his career, I think Microsoft retired him and I doubt they would put the effort into giving people a way to bring him back. He was cute, but too many people considered him way too annoying and useless to keep. Sorry. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/ "we want the p...

Countif across multiple sheets
Hi there, I am using the following formula (see below), but wondering if the sheetnames I enter have to be in the EXACT order that there are in the spreadsheet? =SUMPRODUCT(COUNTIF(INDIRECT("'"&BA2:BA151&"'!e50"),"x")) where BA2:BA151 is a range housing the relevant sheetnames in separate cells ... AND e50 is the cell I am referencing in every sheet. I get a #REF! error. Thanks I get the Ref error only if a sheet name is mispelled or if one of the cells that is supposed to have a sheet name is empty "Tim" wrote: ...

HDC to HDIB
I need to convert hdc to hdib data of 256 colors of size 180*120 But i didn't get output as required plz help me { BITMAPINFO Binf; BITMAPINFOHEADER bi;int ki; HDC hMemDC = CreateCompatibleDC(hDC); int DCWidth = GetDeviceCaps( hDC, HORZRES ); int DCHeight = GetDeviceCaps( hDC, VERTRES ); StretchBlt(hMemDC,0,0,180,120,hDC,0,0,DCWidth,DCHeight,SRCCOPY); bi.biSize = sizeof(BITMAPINFOHEADER);//40; bi.biWidth = 180;//Let it be constant width for our saving bitmaps bi.biHeight = 120;//Let it be constant height for our saving bitmaps bi.biPlanes = 1; bi.biBitCount = 8; bi.b...

Display Issues with X-Axis
Hi All i've some problems with a chart. To be precise, the chart works fine, the only thing that doesn't work the way I want it to is the X-Axis, or even more precisely the labels of the X-Axis. I have a 2-Axis Chart, with a line-chart linked to the primary Y-Axis and a bar-chart linked to the secondary Y-Axis. Now I wanted the X-Axis to display the Label. Not really a miracle that I'm expecting here, but Excel proves me wrong. Excel doesn't want to show me the labels, so i started to change things, like chart-size, fontsize and many other things, even Zoom. Well to be honest,...

Publisher 2003
I am using Publisher 2003 and have set up Styles for easy formatting. The font colors I have set up randomly keep changing back to Black. Example: I have a style set up called Header - Autumn with the font color of Orange. At times when I open my file to print it, all the text I chose Header - Autumn for is now Black. It's showing Black on my monitor and it's printing black. When I go back in to where I set the style up, it's also reverted to Black. This isn't happening to all my Styles. Just randomly enough to drive you nuts. Got any suggestions as to what's...

clip art disappears when page starts printing
using publisher: my clip art disappears from the page when I begin printing. I don't know if it is a publisher thing or my printer thing. I have to remember to save right before I print so if it diappears, I can close it and re-open it again. I sometimes have to do this several times and then, for unknown reasons, it will work and print great. I'd check out new drivers, either for the printer or your graphics card, or both. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "deniseduppee" <deniseduppee@discussion...

Outlook 2003 issues #3
The CEO of our company is having an issue with his Outlook. Within his contacts, the contact header, there is no "background". What I mean is there is normally a blue or grey background just behind the contact name. What I need to know is how to change the "background". Thanks, Aaron Try resetting the view for the contacts folder. See if that helps... "Aaron" <apyle1@comcast.net> wrote in message news:C443B89A-E991-4714-A992-0031D5B345F6@microsoft.com... > The CEO of our company is having an issue with his Outlook. Within his > contacts, ...

error code when searching for clip art in Pub
I get the following error code when searching for clip art in Pub 2003. Is there no clip art supplied with this version? Microsoft Clip Organizer Clip Organizer cannot complete the operation The specified procedure could not be found. Error Code 0x8007007F Please Help Start here: http://www.mvps.org/msauer/clip_organizer_support.htm -- JoAnn Paules - MVP Microsoft Publisher "Kevin Greene" <drgreenedc@aol.com> wrote in message news:137701c42659$a2f8b690$a101280a@phx.gbl... > I get the following error code when searching for clip > art in Pub 2003. Is there no...

Address Book issues ...
Morning everyone … I’ve got a few issues that I’m having a difficult time pinning down and need a hand. I have 2 Exchange servers in different parts of the country. 1 of our Exchange servers is seeing a problem with new email boxes and distribution lists not showing up for hours after they were created in the address list – this pertains for all Outlook 2003 users, for whatever reason Outlook 2000 users don’t seem have this problem. This same Exchange server also has a problem of when creating a new user in A/D that their email account is not available for long periods of time (po...