How to create a static derived class with controls inside it

I want to create a CStatic derived class(eg. CMyStatic), which has some
controls inside it.


At first I want to add these controls at "CStatic::PreSubclassWindow", but
if I want to create the CMyStatic programmically, error will appear.

So I'm asking when should I add these controls to my class.

Thank you.


0
zhaoyandong
12/2/2003 3:36:12 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
684 Views

Similar Articles

[PageSpeed] 25

The way I personally got around this problem was to put my creation function
in a Function by itself. override the Create method and the
PreSubclassWindow methods.  From the Create function set a flag that says it
is being created using the create function, rather than being subclassed by
ddx_control. call the create after the create call the function to create my
internal controls.  In the PreSubclassWindow method if the flag is not set
then call the function to create the internal controls.

BOOL CMyStatic::Create(LPCSTR lpszText,DWORD dwStyle,const RECT &rect,CWnd
*pParentWnd,UINT nID)
{
    m_bCreate = true;
    if (CStatic::Create(lpszText,dwStyle......))
    {
        CreateControls();
        return TRUE;
    }
    return FALSE;
}

void CMyStatic::PreSubclassWindow()
{
    CStatic::PreSubclassWindow();
    if (!m_bCreate)
    {
        CreateControls();
    }
}

Ali R.


"zhaoyandong" <zhaoyandong@163.net> wrote in message
news:ujQkepOuDHA.3496@TK2MSFTNGP11.phx.gbl...
> I want to create a CStatic derived class(eg. CMyStatic), which has some
> controls inside it.
>
>
> At first I want to add these controls at "CStatic::PreSubclassWindow", but
> if I want to create the CMyStatic programmically, error will appear.
>
> So I'm asking when should I add these controls to my class.
>
> Thank you.
>
>


0
nospam7515 (2084)
12/2/2003 5:18:57 PM
create them in ur oncreate handler and don't subclass the static ctrl
use create to create it instead at the desired position


"zhaoyandong" <zhaoyandong@163.net> wrote in message news:<ujQkepOuDHA.3496@TK2MSFTNGP11.phx.gbl>...
> I want to create a CStatic derived class(eg. CMyStatic), which has some
> controls inside it.
> 
> 
> At first I want to add these controls at "CStatic::PreSubclassWindow", but
> if I want to create the CMyStatic programmically, error will appear.
> 
> So I'm asking when should I add these controls to my class.
> 
> Thank you.
0
xmontyx (28)
12/3/2003 6:49:05 AM
Reply:

Similar Artilces:

Control "Reply to all" for dl's.
We have a global distribution list that only one user will have access to. How do we stop someone from replying to all when they receive a message from that dl? thanks On Thu, 12 May 2005 12:36:06 -0700, "MJKQB" <MJKQB@discussions.microsoft.com> wrote: >We have a global distribution list that only one user will have access to. >How do we stop someone from replying to all when they receive a message from >that dl? > >thanks Exchange General tab/ Message Restrictions and add the users who can send to that DL. ...

create a boot disk when I have no floppy drive?
I have the XP Upgrade CD. How do I create a boot disk when I have no floppy drive? Thanks for any help. "Bob Tyrka" <rtyrka@cavtel.net> wrote in message news:PPedndBCv5CT7ZjWnZ2dnUVZ_gqdnZ2d@cavtel.net... > I have the XP Upgrade CD. How do I create a boot disk when I have no > floppy drive? > > Thanks for any help. > What do you need a floppy for? The XP CD is bootable in it's own right... "Bob Tyrka" wrote: > I have the XP Upgrade CD. How do I create a boot disk when I have no floppy > drive? > ...

Create Expression from Func? (3.5 SP1)
Hello: Is there are way to create an Expression from a Func? I don't like cluttering up my method signatures with the whole Expression<Func<TResult, T>> type. I would prefer for callers to simply see Func<TResult, T> instead. I'd like to take a Func and create an Expression from it. Is that possible? Thanks, Travis Parks Jehu Galeahsa wrote: > Hello: > > Is there are way to create an Expression from a Func? I don't like > cluttering up my method signatures with the whole > Expression<Func<TResult, T>> type. I would ...

Static Chart Data Range
Excel-2007, simple line chart: I have a chart that displays several columns of data for rows 2:84. Whenever I insert a new row #2, the new data range for the chart is now 3:85. How do I keep a static data range for my chart (2:84) whenever I insert new rows into the workbook? I have tried editing $A$2:$E$84 to A2:E84 and then saving the changes ... but it is an excercise in futility, it always reverts back to $A$2:$E$84. I would recommend creating a blank row 2, and hiding it. Then, when you insert a new row, you'll be inserting within the boundaries, instead of moving ...

Create Process
if i call fork() / CreateProcess what is/are duplicated? i know that data space is duplicated for sure how about code space? the code space can be shared to save space.... but the new process may need to do rebasing... so...does the code space also shared? thx Action wrote: >if i call fork() / CreateProcess >what is/are duplicated? >i know that data space is duplicated for sure >how about code space? >the code space can be shared to save space.... >but the new process may need to do rebasing... >so...does the code space also shared? There is no fork in Windows. Creat...

Outlook/Access 2003
I've been doing a lot of research and purchased (but haven't completely read) Sue Mosher's book. However, before I spend much more time I'd like to find out if my idea is even feasible. The basic idea is to create an appointment system for multiple therapists that can be used by a receptionist and other staff. Using Outlook and Exchange is very nice but the appointment data needs to end up in an Access table immediately. We can purchase SBS 2003 with Exchange 2003 or we can buy a third party tool for calendar sharing whichever would be the easiest to use. I currently...

Creating a CFormView application produces errors
Using Visual Studio.Net 2003 I have created a C++ MFC application with Single Document Interface and Document/View support, and have changed the base class for the derived View class to CFormView. All other settings are their defaults. When I compile the source code generated, I get an error stating that the base class CRichEditCntrItem is undefined in the declaration of the CRichEditCntrItem derived class. According to the Help, CRichEditCntrItem requires the header afxrich.h If I add this include into the stdafx.H file and recompile, I get a syntax error in the constructor for the CRic...

HOWTO create a Mail Merge Template in MSCRM with multiple child records
Hi, I have created successfully a basic Mail Merge template in MS Word in Dynamics CRM 4.0 for Order Entity. My challenge now is how to design a template that retrieves the order details (product and prices) related to the order record? This sounds like a parent-child template. Any idea? On Jun 2, 1:26=A0pm, "Benjie Fallar III" <bfall...@hotmail.com> wrote: > Hi, > I have created successfully a basic Mail Merge template in MS Word in > Dynamics CRM 4.0 for Order Entity. > My challenge now is how to design a template that retrieves the order > details (prod...

Looking for a quick way to create a bunch of labels for annual mailing to diverse contacts
Using Office 2004 (11.2), I have numerous contacts that are part of diverse categories (some have not been categorized yet) I would like to create mailing labels for the annual calendar mailing. As of now I figured out how to select a large number of contacts & mark them as part of the annual card category (Command & click) and go to Word's Data Merge Manager where select the main document & then the address book as a data source. I went to Query Options and selected the category that fits (annual card). Now what? ...

active X control
I have a calandar (active x control) on my form. Does anyone know how to link/sync it to a bound control; i.e., when a user chooses a date control, the calandar appears, and when a date is selected it populates into the requisite field. alex Try this: http://www.datastrat.com/Download/XCalendar2K.zip -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "alex" <sql_aid@yahoo.com> wrote in message news:1182963470.109302.283780@q75g2000hsh.googlegroups.com... >I have a calandar (active x control) on my form. > Does anyo...

increment through controls on form
I have a form that I've name the controls on it in such a way that I could determine through open args if it should be locked or not. Example any text box that begins with txtd would be unlocked with open args of 1. I was hoping there was a way I could just move through the controls in a loop and set that property with one function.....I'm not for sure how to accomplish this though. Does anyone have some sample code on how to "loop" through all the controls on a form and set the locked property? I can write the criteria portion if I could get a sample of how to ...

Possible to create a rule to alert on BCC messages?
Using Outlook 2007/Exchange Server 2007 Hello: I sometimes miss that I'm receiving an email as a blind copy. I was hoping to create a rule to alert me when I'm in the BCC field. However, when using the rules wizard, I only see the options regarding my name in the To or CC field. Is there a way to create this that I may be missing? Thank you. In article <#pJLIK1ALHA.4704@TK2MSFTNGP06.phx.gbl>, victoria@dig.com says... > > Using Outlook 2007/Exchange Server 2007 > > Hello: > > I sometimes miss that I'm receiving an email as ...

How to create an XML document with XmlTextWriter?
Hi, I'm trying to create an XML document with XMLTextWriter but I want to store it in memory (not write it to a file like so many examples do). I tried the following but with no luck. Should I not user this object for this purpose? Thanks, Dave MemoryStream stm = new MemoryStream() XmlTextWriter writer = new XmlTextWriter(stm, System.Text.Encoding.UTF8) writer.WriteStartDocument() writer.WriteComment("This Is A List of My Books") writer.WriteStartElement("MyBooks") writer.WriteStartElement("Book") writer.WriteAttributeString("ISBN", "1861005...

Unable to delete the Dead Domain controller
Dear, Iam working on windows server 2008 Ent Ed I have two doman controllers in the domain both are GC but only one domain controller has all the fsmo roles but iam having replicattion problems with the dead DC (i.e mppkw-database) and Iam unable to delete or remove the dead domain controller from the domain and iam having follwing problems using the ntdsutil :- matadata cleanup select operation target: list domains Found 1 domain(s) 0 - DC=mediaphoneplus,DC=com select operation target: select domain 0 No current site Domain - DC=mediaphoneplus,DC=com No current server N...

Exchange error
Hello, for one week now, my exchange 2000 server crashes nearly every night at random time, the only solution to have it all restart is to restart the entire server. In the application log, multiple error events are reported like these : Event Type: Error Event Source: Userenv Event Category: None Event ID: 1000 Date: 26/07/2005 Time: 01:27:39 User: NT AUTHORITY\SYSTEM Computer: BELLINI Description: Windows cannot establish a connection to *domain name* with (1364). Event Type: Error Event Source: Userenv Event Category: None Event ID: 1000 Date: 26/07/2005 Time: 01:37:41 User: ...

More control over taxation
I would like to be able to exempt items for different levels of taxation while still using "tax by customer." Rather than taxable or non-taxable, I need to be able to exempt from federal and state separately. Thanks, dan@endurosport.com ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree...

Create your personal SMS homepage, let friends send FREE text message to your mobile phone by web
Create your personal SMS homepage, let friends send FREE text message to your mobile phone by web Support over 147 countries and ALL languages (unicode encoding) MSG.to provides a unique personal SMS URL for you. It is easy for friends sending text message to you by web. For example, if your name is Lisa, you can register: http://MSG.to/Lisa (you can use this link to see demo) You can also register your mobile phone number as SMS URL like: http://MSG.to/+886913123456 (you can use this link to see demo) Please visit http://msg.to/ for more information. Related keywords: Short Message Serv...

How do I view my calendar by a label I've created?
I would like to assign label colors to items in my calendars (for home use) and then be able to view my monthly calendar by one label at a time as I choose. Is there anyway to do this? I have gone through all the help menus and can't find anything. I found instructions on how to create a filtered view, but under the instructions, I have no "Add Filtered View" as one of my options. Any suggestions? View | (Arrange By) | Current View | Customize Current VIew | Filter --=20 Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtlefloc...

how can i use countif function inside a filtered range
How can I use countif function inside a filtered range Hi, Not much detail here, so this is the general idea: =SUMPRODUCT(SUBTOTAL(3,OFFSET(C13:C18,ROW(13:18)-13,0,1)),--(C13:C18="Red")) -- If this helps, please click the Yes button Cheers, Shane Devenshire "jayin" wrote: > How can I use countif function inside a filtered range Shane Devenshire wrote on 02/24/2009 02:05 ET : > Hi, > > Not much detail here, so this is the general idea: > > =SUMPRODUCT(SUBTOTAL(3,OFFSET(C13:C18,ROW(13:18)-13,0,1)),--(C13:C18=&quot;Red&quot;)) > > ...

Tab control + having same size for all tabs
Hello All I am working on tab control in which I want to set the same size of all tabs of tab control. I am adding the tabs dynamically . When I saw the .NET style tab control ( Look tab control used in MSDN) , I felt that it is more elegant than the old looked MFC tab control. My ultimate goal is to have the same size for all tabs irrespective of text it has ( MFC's default behaviour shows the full text in tab ) If the text exceeds that width, then It will make it shortened by adding .... ( three dots ) (e.g. "The text of tab...Will Come here" ) , I know that I will have to wri...

dll class constructor problem
I have a class in a dll that looks like: class __declspec(dllexport) MyClass { public: MyClass(void) ; ~MyClass(void) ; int x; };; in the implementation for the constructor, I have: MyClass::MyClass(void) : x(555) { } When I use the dll in the client application to create a MyClass instance, the instance variable x is not initialized; I have a huge value like -842150451. Did I do something wrong? "wanwan" <ericwan78@yahoo.com> wrote in message news:1177618221.977457.144800@r30g2000prh.googlegroups.com... >I have a class in a dll that looks like: > &g...

can I create a new resume?
I would like to create a new resume. Can you help? This is the Microsoft Excel newsgroup. I am unaware of any newsgroup that provides help with resumes, but perhaps you intended to post in the Microsoft Word newsgroup, in which case, this tutorial may help you: http://www.officearticles.com/tutorials/write_your_resume_in_microsoft_word.htm ************ Anne Troy www.OfficeArticles.com "in need of help." <in need of help.@discussions.microsoft.com> wrote in message news:4245D9F3-C5CF-4C64-A70F-E8930F899954@microsoft.com... >I would like to create a new resume. Can you he...

SPC Control Charts
Does anyone know if Excel can create SPC control charts? I can not find them anywhere. Not as a basic chart type. You can roll your own. http://www.peltiertech.com/Excel/Charts/statscharts.html#CtrlCht has suggestions. Jerry Skip wrote: > Does anyone know if Excel can create SPC control charts? > I can not find them anywhere. ...

get speed between device incorrect in Win7 with two controller
when I debug a 1394B image device driver on windows 7 x64, I found the result of REQUEST_GET_SPEED_BETWEEN_DEVICES requesting incorrect sometimes, I have two controller, one 1394B (TI's PCIE chip), one is 1394A, my image device run at S800, and connected on 1394B port. I want to get the speed between device and host is 8 (S800), but sometimes I got 4 when I power on my device with cable had connected. Is there a bug of windows 7 1394 bus stack? thanks for any helps. -- Steven ...

Creating an OWA access only user.
Hello chaps/ladies, The pointy hairs have asked that some one external to our organisation be given access to an email account within our organisation. So my thoughts were to create a user account and lock it down to prevent interactive access to any workstation machines in any way and only allow OWA access, this has prroven trickier than I first assumed. Does anyone have a quick guide going over best practices for this type of situation? TIA. -- Alex Griffin On Tue, 14 Jun 2005 16:26:11 +0100, Alex Griffin <nntpuser@hotmail.com> wrote: >Hello chaps/ladies, > >The pointy...