Subclassing controls - No WM_NCCALCSIZE???

Hi!

I'm trying to create a custom control with custom NC area, but there's an 
odd problem:
When I create the control using .Create(...), its all fine,
but when I subclass the control, the NC messages are never sent!

Anyone knows why this happens??

Tnx... 


0
10/12/2008 6:52:55 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
779 Views

Similar Articles

[PageSpeed] 35

>I'm trying to create a custom control with custom NC area, but there's an 
>odd problem:
>When I create the control using .Create(...), its all fine,
>but when I subclass the control, the NC messages are never sent!

Which WM_NC* messages in particular? Presumably the WM_NCCREATE
message won't be caught because it's happened before you've subclassed
it?

Dave
0
davidl7375 (2060)
10/12/2008 9:25:10 AM
Some of these messages are only sent once when the window is first created. 
For these messages, you will never see them if you subclass the window after 
it's already created. That sounds like what is happening.

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

"Good man" <goodman@gmail.com> wrote in message 
news:u9iBocDLJHA.5164@TK2MSFTNGP04.phx.gbl...
> Hi!
>
> I'm trying to create a custom control with custom NC area, but there's an 
> odd problem:
> When I create the control using .Create(...), its all fine,
> but when I subclass the control, the NC messages are never sent!
>
> Anyone knows why this happens??
>
> Tnx...
> 

0
jwood (1291)
10/12/2008 7:27:16 PM
Note that by the time you normally get around to doing the subclassing, the messages had
been sent long, long before.  You would need to show the code you are using, but that is
the usual cause.  For example, you will never get an OnCreate for a control you create at
design time in a dialog, because by the time you have attached the control to its MFC
object (done by DoDataExchange, a virtual method invoked by CDialog::OnInitDialog), the
window has already been created.  This means you don't get the various WM_NC* messages
that would happen during the creation cycle.
					joe

On Sun, 12 Oct 2008 08:52:55 +0200, "Good man" <goodman@gmail.com> wrote:

>Hi!
>
>I'm trying to create a custom control with custom NC area, but there's an 
>odd problem:
>When I create the control using .Create(...), its all fine,
>but when I subclass the control, the NC messages are never sent!
>
>Anyone knows why this happens??
>
>Tnx... 
>
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)
10/12/2008 11:59:54 PM
Hi!

Thanks for the replys!

I know that messages lik WM_CREATE wont be sent because it is already 
happened,

But NCCALCSIZE and NCPAINT are messages which happen regularly. NCCALCSIZE 
should be called on every resize, because it is needed to calculate the 
NonClient area for every new size.
But that just does not happen if not create manually!

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:lm35f4tn0gmrvekmvn2dsp8hu0k6jnqilu@4ax.com...
> Note that by the time you normally get around to doing the subclassing, 
> the messages had
> been sent long, long before.  You would need to show the code you are 
> using, but that is
> the usual cause.  For example, you will never get an OnCreate for a 
> control you create at
> design time in a dialog, because by the time you have attached the control 
> to its MFC
> object (done by DoDataExchange, a virtual method invoked by 
> CDialog::OnInitDialog), the
> window has already been created.  This means you don't get the various 
> WM_NC* messages
> that would happen during the creation cycle.
> joe
>
> On Sun, 12 Oct 2008 08:52:55 +0200, "Good man" <goodman@gmail.com> wrote:
>
>>Hi!
>>
>>I'm trying to create a custom control with custom NC area, but there's an
>>odd problem:
>>When I create the control using .Create(...), its all fine,
>>but when I subclass the control, the NC messages are never sent!
>>
>>Anyone knows why this happens??
>>
>>Tnx...
>>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
10/14/2008 7:29:17 PM
Reply:

Similar Artilces:

ActiveX control and events
Hello List, Environment: Windows XP, Visual Studio .NET 2003 Pro. I have a CDialog box as the Main Window of my ActiveX Control, and I need to FireEvents to my container. I've looked high and low, but can't find anything suitable. Does anybody have any ideas on how to fire events from a CDialog to the container application? Thanks, Yury Start here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_activex_controls.3a_.events.asp AliR. "Yury Peskin" <ypeskin@cyclesoftware.com> wrote in message news:eKZra4SeGHA.4040@TK2MSFTNGP...

Tab control colour problem
Hello Access 2003 When I put a tab control on a form that has had it's backgound colour changed I can't seem to find a way to change the colour used to the right of the tab 'buttons' Oddly I can make the whole tab page transparent but not the bit to the right of the buttons ? |Page1|Page2|Page3| <colour of this bit here> + ---------------------------------------------------+ | | | | | | | | +--------------------------------------------------------+ Thanks in advance Andrew On Aug 9, 8:10 pm, "Andrew Kennard" <b...@a.com> wrote: >...

Subclassing
Hello, Im very new to c++ programming so pardon me if this is a dumb question and my bad english. I made a subclass from CListBox. I want to handle all the list controls derived from this class on one function, for example, void CListBox_SC::OnRButtonUp(UINT nFlags, CPoint point) { ..... } on this function I want to manage the OnRButtonUp event, and with a switch or if statement, select the code to execute. The following does work: SetCurSel(ItemFromPoint(point, ifp)); but the following comparison is never true, (IDC_LST_TIPO is a resource for one of the ListBoxes) UINT currLst = It...

Tab Control: Will MS fix "transparency" & "flicker" issues?
I just started using Tabs 1 - and they were not "transparent" on my form. I searched the newsgroup & discovered we had to set all XP desktops to "Windows Classic" Theme to fix this. 2 - To kill the "flicker" issue for unbound Labels we had to convert them all to "Text Box's" and put the Label Text in the "Control Source" field and delete the Text Box Label... and set Properties for the Text Box to make it look like a Label !!! ??? Anyone know if MS is going to fix these issues? (BTW - We are still running Access 2003) Mel ...

HBITMAP on a CStatic control
hi all, as i remember some questions like mine asked before(may be its not directly related to MFC). i have a DIB in memory, what i do now is; first specify a BITMAPINFOHEADER and fill its members (bfType, bfSize etc..) and then using BITMAPINFOHEADER and DIB write to disk. To show this bitmap on a CStatic control i use LoadImage(NULL, "img.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE) which returns a HBITMAP, and then m_ctrl.SetBitmap(HBITMAP). as u can see in some cases (dealing with images which have high resolution) writing/reading to/from disk is very time consuming.. how ...

RichEdit control and zoom
Hi All I'm developing a powerpoint-like application. I'm using RichEdit control for the textbox. The textbox has the zooming feature. To zoom textbox, I call the SetZoom() to the Richedit control. The text in the RichEdit is zoomed correctly, of course, textbox window itself is not zoomed. I calculated the window size according to the zooming factor. That is. if the textbox window size is 200x100 and zooming factor is 200%, I resize the textbox 400x200, But actually, font size is not proportional and word-breaking position is different from the position when not zoomed. For examp...

white text appearance when control is clicked
Working with Access 2003 and XP. I have a white form with a dark colored header. I placed a transparent control (with the company name) in the header and formatted the text to be white. It looks great, but I want users to be able to click in the control to execute a search function on the organization name. When you click in the control, you get white text on a white background. Even after searching, the cursor stays in the field and you can't see the company name. Is there anyway to turn the background of the activated control to any other color than white? Thanks, Ruth On Jun 20, 12:...

Email Out of Control
I can't seem to find an exact "search phrase" for this problem, so here are the details. I am using Office/Outlook 2007. When I open a blank email window to write an email, Outlook automatically is adding the lower case letter 'b' in the "To:" field. It continues on and on until the computer beeps and the field cannot hold any more text. I cannot control it. The only way out is to control-alt-delete and close Outlook. Also when opening any of the folders in "My Documents" (or any folder), the window opens and then the computer scrol...

Line control in VC 2003?
Hi, Is there anyway to place lines (seperators if you like) on a dialog box in VC 2003?. Vb(6?) has a line control that allows one to place lines on a form. I suppose I could mimic a line by using a static text control and resizing it so it looked like a line. The only problem is that I do not know how to change the background colour of the static text control. Does anyone know how to change the background/foreground of a control/dialog box? mtia >Is there anyway to place lines (seperators if you like) on a dialog box Use the picture control and size it to a line. If you want a ...

How do I bind a XAML text box control to a dataset?
Hello; I am new to using WinFx and I am having trouble figuring out how to bind a text box to a field in a dataset. I found an MSDN article: http://msdn2.microsoft.com/en-us/library/ms752057.aspx My question deals with the text box code: <TextBlock Text="{Binding Path=ISBN}" Grid.Column="1" /> How does this text box know to bind to the field "ISBN" in "myDataSet"? How does the control implement the dataset? Thank you Monty ...

How to change the color of a CEdit Control ??
Merry christmass Progeammers, I'm new to MFC programming, and would like to know how to change the CEdit control color aswell other controls colors. thanks in advance Hello To change the color of edit control you need to handle the WM_CTLCOLOR or WM_CTLCOLORSTATIC message depending on the control is read only or not. Then, in the message, return the appropriate color brush handle you want to change. For Ex HBRUSH myframe:: OnCtlColor(CDC *dc,CWnd *wnd,UINT color) { HBRUSH hbr=CWnd::OnCtlColor(dc,wnd,color); if(wnd->GetDlgCtrlID()==ID) /*give here the id of control */ ...

Tab Control #5
Why is it so hard to find a good, inexpensive, easy to use tab control for MFC? VB has had one for years. The one in .net is ok. ...

Custom Drawing CEdit : Subclassing
Hello experts, My objective is simple, but I'm not entirely sure what needs tweaking. I am using MSVC 6, and I would like to subclass the CEdit box so that it appears as the color-picker editbox of a PropertyGrid. There is a color box followed by three values. Like this: [###] 255; 192; 192 Where ### is just a color box representation of the value. So thus far, I've made a masked CEdit box, where I can edit the numbers (or click a button that visually sets the numbers from a different window), and I'm happy with that - but what I would like to do next is to subclass the dra...

No Buttons to Control Subtotal Levels!?!?
When I apply subtotals to my data, I no longer get the 3 buttons in the upper left corner of my spreadsheet. These are the buttons that allow you to access various levels of detail. They are labeled 1, 2, & 3. When I group data 2 buttons appear. However, the subtotals function is not triggering the control buttons and the grouping buttons don't control the subtotals. Please help. Thanks Are you related to Jerry? I've never seen xl fail to put those outlining symbols in, but maybe you could try this: Tools|Options|View Tab|make sure "Outline Symbols" is checked. ...

Control Validation
I am trying to add a validation to a form that I have. To maintain unique course ID numbers, I have set the course ID number as primary key. The instructor has the authority to create their own course number based on what course numbers have not already been used. Over time, the course numbers expire and become available again. But that is a seperate course number that is also a primary key. Students can see the Course ID Number and select the course from there. The course number is used internally to track what courses have been offered, when and by whom. On the form that I am d...

Cannot find Calendar control in my Excel2002, VBE(additional control)
When I tried to add a calendar control, in VBE control toolbox and right click Refedit and select Additional control, there is no calendar control of any version in the list. Any suggestion , Thanks ** Posted via: http://www.ozgrid.com Excel Templates, Training, Add-ins & Software! http://www.ozgrid.com/Services/excel-software-categories.htm ** I'm not sure, but I think I've read that this control is installed when you install Access (just a guess). You may want to use a freeware version of the calendar control. From Ron de Bruin's site: http://www.rondebruin.nl/calendar.h...

Control Source Expression
Hi, I am designing a form and want to have a control that displays First Name and Last name from two fields. I have just two controls on this form "Last Name" which I dragged across from fields onto the from, and "Full Name" which is a text box i created. When I set the full name control source to : =[Last Name]&[First Name] But I get #Name? The interesting thing is that =[Last Name] works, presumeably because it is a control on the form, but =[First Name] doesnt? What am I missing? -Al Okay, I figurered it out, I have to set the forms record source to : SELE...

ActiveX Timer control use
I need more than one timer on a form, so I'm trying to learn how to use the ActiveX Timer control in an Access 2002 form. Here's a snip of my test code: Private Sub cmdTest_Click() Dim bEndTimer4 As Boolean Forms!frmMain!Timer4.Interval = 4000 'Approx 2 Seconds bEndTimer4 = False Forms!frmMain!Timer4.Enabled = True Do DoEvents Sleep 5 Loop Until bEndTimer4 = True 'Forms!frmMain!Timer4.Enabled = False If bEndTimer4 = True Then MsgBox "Timer Timed and Period Ended" Else MsgBox "Timer D...

Controlling Transparency of an Object
This sounds like a simple task: Insert a rectangle, filled with Color, set Tranparency to, say, 15%. I want to do this so that I can get that great effect of overlapping two semi-transparent bars... I insert an object (like an AutoShape), select a Fill Color, but cannot adjust the Transparency because that option is unavailable (the option & the slider are faded-out, so I can't change). Any thoughts?? ~Joe Joe_Amateur <Joe_Amateur@discussions.microsoft.com> was very recently heard to utter: > I insert an object (like an AutoShape), select a Fill Color, but > can...

Help with subclassing a RichEditCtrl
Hi folks, I could use some help. As a side project I am trying to write a DLL that will extend the functionality of an existing application that I do not have source code for, i.e., some autocompletion functionality, word lookup, etc. In the actual DLL, I am going to have to inject it into the existing app and then use FindWindow or something like that to subclass the existing RichEditCtrl. I need to be able to process the WM_CHAR and WM_KEYDOWN messages only. I started out by creating my own sample project using a RichEditCtrl in my project to code my object. I've now moved everythin...

Tab control questions
Using Office 2003 and Windows XP; When using a tab control: 1) Does it wrap automatically so that the tabs are more than one layer deep if additional tabs are inserted? 2) Is there a way to control when the tabs wrap to a second row or where the break will occur or is this just automatic (i.e. whenever it runs out of room)? 3) I'm sure I won't get anywhere near it, but what is the limit on the number of tabs? Thanks in advance. On Dec 17, 10:45 am, XP <X...@discussions.microsoft.com> wrote: > Using Office 2003 and Windows XP; > > When using a tab control: > ...

WM_CREATE for a subclass
Hi All, I am fairly new to C++, although I have developed OO windows applications in the past using CTD and Power Builder. I am developeing an edit class based on a CEdit. I am trying to trap the WM_CREATE message to modify the style of the window (i.e. to make is multiline). For some reason the control does not appear to be getting the WM_CREATE message ( or at least it is not implementing the handler I have for it). At present I create an edit control on a form and the Subclass the edit. This appears to work as my user defined menu is used and my color modifications appear as requir...

Customizing a Control Using OnLButtonDown, OnMouseMove, etc.
I'm subclassing a CRichEditCtrl, and I need to override OnLButtonDown, OnMouseMove, etc. handlers so that I can customize the actions that happen upon those event however I'm not really sure what all the default implementations do and how they do it. Is there any way I could find out? I've tried stepping through, but it doesn't seem to provide much info. I get to the point where it calls the Default procedure. Any hints you all could pass on? Thanks! > I'm subclassing a CRichEditCtrl, and I need to override OnLButtonDown, > OnMouseMove, etc. handlers so that ...

control in access report
Is it possible to use the division operator in control source? For example, using =DCount("[Field1]","qryX","[Field1]=True")+DCount("[Field2]",qryX","[Field2]=True")......+DCount("[Field6]","qryX","[Field6]=True") and then I want to divide the number, in the same control, by the number of fields (6 in the example) to obtain the average. regards Yes. You can use / as a divisor, e.g.: =(DCount(...)+ ...) / 6 Since True is -1 and False is zero, you could also sum the fields to get the negative count of t...

Control formula calculation
I have created a "form" where a user enters 2 separate numbers. I wan each of these numbers to input to a running total and the total t subtract from another number... this is what I have come up wit (understand it is a circular ref ..) 1 2 User input 2 User input 2 Prior input 0Prior input 0 Total input 2 Available 36 Remaining 3 -- Message posted from http://www.ExcelForum.com ...