PreTranslateMessage question

I have an MFC application which is based on a modal CDialog. It
contains a Picture control which is resized if the parent dialog size
changes - this keeps the picture control occupying the full width of
the CDialog's client area.

The Picture Control is used to display video, but when the dialog box
size is stretched it causes a lot of flickering because the Picture
Control repeatedly redraws its background while also displaying the
video.

According to the documentation, I just have to trap WM_ERASEBKGND
messages for the Picture Control to prevent it drawing its background.

So I created a PreTranslateMessage function in my CMyDialog class, but
surprisingly the only message belonging to the picture control that
seems to go through this function is the occasional WM_PAINT.

Spy++ seems to show that the Picture Control IS getting WM_ERASEBKGND
messages, so it's a mystery why the parent dialog's
PreTranslateMessage function does not see this message.

Does anyone know what is wrong here? How can I trap the Picture
Control's WM_ERASEBKGND message?

Colin
0
cbdeja (14)
11/1/2003 9:37:58 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
532 Views

Similar Articles

[PageSpeed] 52

"-" <cbdeja@my-deja.com> wrote in message
news:611952a3.0311011337.6ed156a0@posting.google.com...
> I have an MFC application which is based on a modal CDialog. It
> contains a Picture control which is resized if the parent dialog size
> changes...
> According to the documentation, I just have to trap WM_ERASEBKGND
> messages for the Picture Control to prevent it drawing its background.
> So I created a PreTranslateMessage function in my CMyDialog class, but
> surprisingly the only message belonging to the picture control that
> seems to go through this function is the occasional WM_PAINT.
>
> Spy++ seems to show that the Picture Control IS getting WM_ERASEBKGND
> messages, so it's a mystery why the parent dialog's
> PreTranslateMessage function does not see this message.

I can't see why it should do. I think your best bet would be to subclass the
static --  using the wizards, derive a class from CStatic, add a message-map
handler for WM_ERASEBKGND to it, and bind it to a control member variable in
the dialog class.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1712)
11/1/2003 10:46:28 PM
I have no idea why there is this compulsion to rush off and use PreTranslateMessage for a
lot of inappropriate purposes, but this is yet another example. First rule: if you think
you need PreTranslateMessage, you are probably wrong. Second rule: if you still think you
need PreTranslateMessage, you are probably still wrong.

I wouldn't even waste time trying to figure out why this doesn't work. Just ignore the
problem with respect to PreTranslateMessage; that is the wrong solution.

Just subclass the control and add an OnEraseBkgnd handler. So simple. So easy. 
					joe

On 1 Nov 2003 13:37:58 -0800, cbdeja@my-deja.com (-) wrote:

>I have an MFC application which is based on a modal CDialog. It
>contains a Picture control which is resized if the parent dialog size
>changes - this keeps the picture control occupying the full width of
>the CDialog's client area.
>
>The Picture Control is used to display video, but when the dialog box
>size is stretched it causes a lot of flickering because the Picture
>Control repeatedly redraws its background while also displaying the
>video.
>
>According to the documentation, I just have to trap WM_ERASEBKGND
>messages for the Picture Control to prevent it drawing its background.
>
>So I created a PreTranslateMessage function in my CMyDialog class, but
>surprisingly the only message belonging to the picture control that
>seems to go through this function is the occasional WM_PAINT.
>
>Spy++ seems to show that the Picture Control IS getting WM_ERASEBKGND
>messages, so it's a mystery why the parent dialog's
>PreTranslateMessage function does not see this message.
>
>Does anyone know what is wrong here? How can I trap the Picture
>Control's WM_ERASEBKGND message?
>
>Colin

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15973)
11/1/2003 11:53:24 PM
Joseph M. Newcomer <newcomer@flounder.com> wrote in message news:<vmh8qv898urs4f40ei2giv1lmg23n9mbb1@4ax.com>...
> I wouldn't even waste time trying to figure out why this doesn't work. Just ignore the
> problem with respect to PreTranslateMessage; that is the wrong solution.
> 
> Just subclass the control and add an OnEraseBkgnd handler. So simple. So easy. 

Yup. And it works.

Thanks.
0
cbdeja (14)
11/3/2003 4:13:20 PM
Reply:

Similar Artilces:

SumIf Question #2
Hi Can anyone tell me if the SumIf function can work with 2 different sets of criteria. eg: A1 = P B1 = M C1 = 20 A2 = P B2 = M C2 = 10 A3 = U B3 = M C2 = 10 I would like a formula to sum the C column numbers based on if the A column returns the letter U and the B column returns the letter M. But return a zero if the A column returns the letter P and the B column returns the letter M. I can get half way there using the SumIf function but I can't get a 2nd criteria in the formula. I run Excel 2000 Any help would be much appreciated =SUMPRODUCT(--(...

Question (Please)
One of users had a corruption of his profile under W2K3 Enteprise as an Active Directory user who logs on with his Smart Card. I'll call his Domain Name; Bob.Unlucky His profile is; c:\users\Bob.Unlucky When he logged on, he did not get his normal setup (desktop, icons, resolution, etc) and his MS Outlook wasn't setup which was a clear sign of a Profile corruption. I examined his PC and found a new profile; c:\users\TEMP All files in his Documents folder are encrypted using his Smart Card and he could not access any files in; c:\users\Bob.Unlucky\Documents ...

split question
Hello I want to split several lines of text in the TXT file "d:\Names.txt" They are seperated with an asterix (*). Like that: one*two three*four five*six seven *eight Please remember the added space after seven and after eight. I want to search for "seven " with a trailing space and replace it with "eight " with a trailing space. I have tried that: Const sNames = "d:\Names.txt" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oNames = oFSO.OpenTextFile(sNames) aNames = Split(oNames.ReadAll, VbCrLf) I tr...

Owner draw CListCtrl, EnsureVisible, PreTranslateMessage
There is Owner draw CListCtrl with overriden DrawItem. This class has subitems arbitrary controls (CEdit, CButton...). It should be fine to detect arrows keys in controls to jump with caret in CEdit boxes in one column by pressed arrow key. I tried to catch it in CEdit -> PreTranslateMessage() in block if(pMsg->wParam == VK_UP) then to call EnsureVisible() to parent CListCtrl to be caret always visible and CListCtrl scrolls if needed. Problem is when first time it scrolls up, some infinite loop begins and CPU 100% . It seems that something wrong with this... Can be EnsureVisible(...

question about using the offset function
Is there a way to use the offset function (or another function) as a way to supply an expanding range to other functions like 'average'? For my purposes, there may be multiple series of numbers within say a column, with each 'series' (i.e. set of contiguous rows) separated by a few blank cells. The objective of the function would be to supply a limited set of numbers (which can expand) to the function whose result is the main interest. For example, within column D, I might have rows 5-10 representing adult male fish weights, rows 15-20 representing adult female fish weights ...

A few questions
Ok, I am starting to understand this monster... a few questions please: 1) I have all the emails (outgoing and incoming) from a certain account in the same folder grouped by conversation - The conversation title is taken from the subject of the first email, right? Can I change the title (name of) the conversation? 2) Is their a way I can have my outgoing messages in this folder have a special Icon (not just the open envelope) 3) Sorry for being picky but the indent space of the thread is to small. Is there a way I can increase the size of the indent? Tahnk Alot RB Raffi Bearmant ...

emails lost with compression error. Restore question.
I run Vista Home Premium and have Windows Home and Student. I use Windows mail. During a mail compression I got an error saying that the program was in use and an error had occurred. All of the e-mails were lost but there was some kind of automatic e-mail restoration. I was able to retreive what I needed from a restore e-mail folder. My question -- There are now a bunch of files in my trash bin relating to the restored e-mails. They showed up there by themselves. When I click on them they are listed as restored Windows Mail files and Recovered File Fragments. Since I have...

2 questions about CreateProcess(...)
Hi, How would I start an application hidden or minimized? PROCESS_INFORMATION pi; STARTUPINFO si; memset( &pi, 0, sizeof(PROCESS_INFORMATION) ); memset(&si, 0, sizeof(STARTUPINFO)); si.cb= sizeof(STARTUPINFO); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOW; si.lpDesktop = ""; CreateProcess( NULL, (char*)"C:\\WinNT\\System32\\Calc.exe", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi ); If I add "si.wShowWindow = SW_SHOW;", the application doe...

Question -Problem
Has anybody ever seen an error message (0x800cccF6) message? I cannot configure my Outlook to retrieve Hotmail. Works with other profiles on this computer running winxp. Stan-The-Man-2006 wrote: > Has anybody ever seen an error message (0x800cccF6) message? I cannot > configure my Outlook to retrieve Hotmail. Works with other profiles > on this computer running winxp. If you have a free Hotmail account, note that it won't work anymore (even your other profiles will eventually have problems) - see http://www.slipstick.com/addins/services/online.htm#hotmail ...

Signature question?
Hello, I can't recall how to setup the signature in Outlook so that it appears as a period on an email and you can right click on it to show and select your signature. Does anyone recall how to do that? Thanks, Bob Use WordMail as your editor in Outlook 2002 or 2003 and set up the default signature in Tools | Options | Mail Format as just a period character. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Ergobob" <ergobob@sonic...

2 Dare (xmlschema question)
Hello, All! It seems the bug (http://groups.google.com/groups?hl=ru&lr=&ie=UTF-8&threadm=a53b01c28a00%242 08bc860%2439ef2ecf%40TKMSFTNGXA08&rnum=8&prev=/groups%3Fq%3DschemaLocation%2 BXmlSchema%2B.NET%26hl%3Dru%26lr%3D%26ie%3DUTF-8%26selm%3Da53b01c28a00%25242 08bc860%252439ef2ecf%2540TKMSFTNGXA08%26rnum%3D8) wasn't fixed neither in v1.1 nor in v2.0. Here is exception Unhandled Exception: System.Xml.Schema.XmlSchemaException: Cannot resolve schema Location attribute. at Modile1.ValidationSchemaCallBack(Object sender, ValidationEventArgs e) at System.Xml.Schema.B...

CRM Sales For Outlook Question
Whenever I go offline, I see the message "If data validation needs to be performed, the exchange type must be bidirectional" in the Downloading Status dialog box. Should I be seeing this message or is there a problem. you have a problem..i have never seen this one before -- John O'Donnell Microsoft CRM MVP http://www.mscrmfaq.us "Brian Hanks" <BrianHanks@discussions.microsoft.com> wrote in message news:B1B98078-9011-4149-B941-A3879FA35560@microsoft.com... > Whenever I go offline, I see the message "If data validation needs to be > performed, the...

How to trap PreTranslateMessage in Win32 (non-MFC) app?
How do you trap PreTranslateMessage in a Win32 (non-MFC) app? I have an existing MFC class called CCustomEditCtrl that I have to convert to pure Win32. I am doing some processing in it's PreTranslateMessage event. Can someone tell me where to put this code in the Win32 version? Do I hvae to trap some WM_ event ? Thanks. Jeff, You would just handle the messages in the control window function. If you want to do something before all other messages, take care of it towards the top of the window function. In pseudo-code: control_function() { // You can, for example, add your proces...

CListCtrl basic question
Hello, I can't figure out what I'm doing wrong with a CListCtrl in my project. Please help. My project is an mfc/sdi application. Using the dialog resource editor, I added a dialog to the project and while the dialog was still open in the editor, I did the following: 1) Used class wizard to create a CDialog-based class called CDlg for this dialog resource, 2) Added a list control to the dialog, and used class wizard to create a CListCtrl-based CDlg member variable called m_TopicList for this list control, After saving the dialog resource and closing the dialog editor, I opene...

Custom color question + smooth chart curves question
I have prepared a large number of Excel templates that have charts I pre-defined for the user. Each of the user-defined charts I set up uses colors that are non-standard (I added them into the color palette using RGB values). These custom colors conform to a corporate palette. These Excel templates were set up so that users could develop charts that they would paste into a Word template that had also been set up to conform to many of the same colors. Within Excel, I actually added the custom swatches to the palette, along the bottom row, which has room for such user-defined colors. The inten...

Check Box Question
Can my form have this code something like this! If cbRemark = -1 then tbRemark colour256 Trouble is that Conditional formatting does not have the colour I want Thanks for any help..........Bob It can if you put the code in a separate sub and call it from the Current event of the form as well as the AfterUpdate event of the "cbRemark" control. You will need to properly address the property you want to change though. (BackColor or ForeColor) Private Sub ColorChange() If Me.cbRemark = True Then Me.tbRemark.ForeColor = 255 Else Me.tbRemark.ForeColor = 0 End If End Sub ...

Beginners Question
I know how to add two cells but I would like the cells to have a title within the cell. Something like 8.5 Hrs, or 32 steaks. Something like that. -- Thank you in Advance Hi Format>Cells>Number>Custom> #.0 "Hrs" or General "Steaks The part before the text can be formatted in any of the standard number formats. It will appear as 32 Steaks, but all that will be held in the cell is 32, which can then be used in further calculations if required. -- Regards Roger Govier "GordyB" <GordyB@discussions.microsoft.com> wrote in mess...

SBS 2003 to SBS 2008 question
dear all, I am a consultant and working home where I have a single SBS 2003 server and a normal ADSL router. I have 2 client pc connected to my single SBS 2003. I would like to learn how to install SBS 2008. For that I am running my SBS install in a VM ware virtual machine but I do not want that that VM istallation corrupt somehow my existing network installation manage by my running SBS 2003. My server sbs 2003 is set as follow : IP : 192.168.1.102 Msk:255.255.255.0 Gateway :192.168.1.1 ( my adsl router) then my client PC are receiving IP adress from my sbs server. C...

Calendar Question #3
Does anyone know if you should be able to see appointments in your calendar before accepting them. I have a client who believes this used to work for him and now it does not. After coming back from a week of travelling, he would just go into his calendar and accept meetings from there. Is this possible? Derek Rumig Sorry, connects to an Exchange 2000 server. "Derek Rumig" <derek.rumig@rogers.com> wrote in message news:2tJoc.3301$oq3.18315@newscontent-01.sprint.ca... > Does anyone know if you should be able to see appointments in your calendar > before accepting them....

Question about ISAPI Server Extension
hi, I'm trying to develop something with ISAPI. But so far , I'm not clearly understand on 2 point: 1.How to debug isapi project ? there seems not a effical way to deal with it. 2.I decleared some variants in CTestExtension.How to know whether it's golobal or local? I've tried to declear a member variant like this: private: CString m_Keywords; I find that the value of it is what it is when the last visitor visits . any one can give me some suggestion? many thanks. :) Hi, To debug, go into services in the control panel and shutdown IIS. In VC with your project loaded...

A little question
Using secured version of 'strcpy()' I need to use 'strcpy_s()' version and there lies my problem. In my function I need to copy the result in a char type which is passed to function. I pass a 'char addr[256]' but on my final step function: 'strcpy_s(addr, sizeof(addr), result)' the sizeof operator returns '4' and function chrases. The value of result is lets say an IP address (11 characters). What can I use instead 'sizeof' operater. I cant just use 256 because I use 'myfunction' in few places and passing different kind of char ar...

x-y Line Graph question
I have a line graph. X is dates and Y is numeric data. I am plotting 12/1/2005 through 1/30/2006. The problems is my series does not start at the "left most" point of 12/1/2005, it is shifted slightly. And the line does not end at the "right most" point of 1/30/2006. Any ideas will be appreciated. thanks! XL has two distinct chart types even though they look similar, the XY Scatter chart and the Line chart. There is no XY Line graph. I believe you have a Line graph. Double-click the x-axis and from the Scale tab uncheck the 'Value (Y) axis crosses betwe...

Icon questions
Hello group, I want to assign an icon to my application using Visual C++ 6.0. Here are the problems I'm having: 1. The Visual C++ Graphics editor limits the choice of the colors. If I use a color from the Custom Color Selector dialog box that doesn't exist in the palette, when I build the app the color changes to the nearest one in the palette. 2. Even though I use the available colors to create a 32x32-256-color icon, when I execute my app the icon displayed in the upper left corner of my app's window, in the taskbar, and in Windows Explorer (in the details and list vi...

FE/BE question
Hi, When an environment has a single FE and BE, during the initial setup, do the permissions change on Exchsrvr folder of either Exch server, or do they simply retain the default permissions (as seen in KB 322935)? thanks, Mel On Thu, 12 Oct 2006 04:54:02 -0700, Mel <Mel@discussions.microsoft.com> wrote: >Hi, > >When an environment has a single FE and BE, during the initial setup, do the >permissions change on Exchsrvr folder of either Exch server, or do they >simply retain the default permissions (as seen in KB 322935)? > >thanks, > >Mel The perms st...

Reformat Data Question
How can I get data that looks like this: A B C D E 1 YEAR JAN FEB MAR .... 2 1947 21.5 21.5 21.9 .... 3 1948 23.7 23.5 23.4 .... 4 1949 21.5 21.5 21.9 .... 5 ........ ....... ....... ....... .... Into a format like this: A B 1 1/1/1947 21.5 2 2/1/1947 21.5 3 3/1/1947 21.9 ... .............. ...... 13 1/1/1948 23.7 13 2/1/1948 23.5 -- sslack -------------------------------------------------...