global object dependent on CWinApp global object

hi

I have a global object which depends on the CWinApp global object i.e.
it assumes that the CWinApp global object is created.

After migrating to VS 2005, my global object is getting created before
the CWinApp global object.
Is there any way I can force the CWinApp object to be created first?

I know one of the solution is to avoid a global object and wrap it in a
fuction, however a lot of files use this object directly, so I am
trying to figure out if there is another way.

Regards
Chimanrao

0
chimanrao (10)
8/11/2006 4:55:36 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
482 Views

Similar Articles

[PageSpeed] 49


Chimanrao wrote:

> hi
> 
> I have a global object which depends on the CWinApp global object i.e.
> it assumes that the CWinApp global object is created.
> 
> After migrating to VS 2005, my global object is getting created before
> the CWinApp global object.
> Is there any way I can force the CWinApp object to be created first?
> 
> I know one of the solution is to avoid a global object and wrap it in a
> fuction, however a lot of files use this object directly, so I am
> trying to figure out if there is another way.

An interesting problem, (I don't use 2005 yet.)

The only thing that makes sense here is that you have some dynamic 
dependency on CWinApp in your 'system/whatever' global. I would think a 
bad idea. CWinApp is the entry point for your application and creation 
of other objects should depend on CWinApp's existence. Let a derivative 
of CWinApp determine other 'system/your app' objects lives/creations.

Almost as if everything else in an app is a static without, doesn't 
'know'. I would say that nothing you program should have a 'real' life 
before InitInstance...

> Chimanrao

Best, Dan.

-- 
"We need an energy policy that encourages consumption"
George W. Bush.

"Conservation may be a sign of personal virtue, but it is not a 
sufficient basis for a sound, comprehensive energy policy."
Vice President Dick Cheney

0
public21 (290)
8/11/2006 5:37:15 AM
On 10 Aug 2006 21:55:36 -0700, "Chimanrao" <chimanrao@gmail.com> wrote:

>hi
>
>I have a global object which depends on the CWinApp global object i.e.
>it assumes that the CWinApp global object is created.
>
>After migrating to VS 2005, my global object is getting created before
>the CWinApp global object.
>Is there any way I can force the CWinApp object to be created first?
>
>I know one of the solution is to avoid a global object and wrap it in a
>fuction, however a lot of files use this object directly, so I am
>trying to figure out if there is another way.

Define your global in the same file but after your CWinApp object. This
will ensure the CWinApp is constructed first. Another possibility is to use
#pragma init_seg.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
8/11/2006 7:08:48 AM
Well, the program is incorrect.  There is no guaranteed ordering of when global
initializers, static constructors, etc. are executed, so the program is essentially
incorrect.  The fact that it ever worked is completely accidental.

Remove the dependency on CWinApp.  Rethink the program.  
				joe

On 10 Aug 2006 21:55:36 -0700, "Chimanrao" <chimanrao@gmail.com> wrote:

>hi
>
>I have a global object which depends on the CWinApp global object i.e.
>it assumes that the CWinApp global object is created.
>
>After migrating to VS 2005, my global object is getting created before
>the CWinApp global object.
>Is there any way I can force the CWinApp object to be created first?
>
>I know one of the solution is to avoid a global object and wrap it in a
>fuction, however a lot of files use this object directly, so I am
>trying to figure out if there is another way.
>
>Regards
>Chimanrao
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)
8/11/2006 10:28:41 PM
Reply:

Similar Artilces:

Inconsistency between global catalog in root and global catalog in child domains
Hi, I have a very strange problem in my AD. It seems that there is an inconsistence between global catalog in the root domain and global catalog in the child domains. Global catalog on all root domain controllers are identical. Global catalog on all child domain controllers are identical. However (at least) one orphaned object exist in the global catalog on the child DC's, but not in global catalog on the root DC's. The object is not accessible through adsiedit, ldp, etc. and thus we cannot delete it. Does anybody have a good idea on how to get this object deleted. How the inco...

Catching global keystrokes
Hello. I need my program to react to some key combination no matter if the program's window is active or not. How can this be done? Depends on the details of the key combinations as to what you have to do, precisely, but a WH_GETMESSAGE hook looking for WM_KEYDOWN, WM_SYSKEYDOWN or WM_CHAR is a start. Note if the key combination is Ctrl+Alt+Del, then it will never be possible. In Vista, you will not be able to get ALL keystrokes unless you are running as administrator. See my essay on hooks on my MVP Tips site. joe On Fri, 07 Nov 2008 09:42:52 +0300, Vladimir <thamiorsinister@...

date-based fields changing depending on the time of day
Hello: I created a view that will show inventory item shipments due to customers within different time "buckets", such as Past Due, 0 - 3 Days, etc. as shown by my T-SQL programming below. A client claims that when he runs this view, he gets different data in the afternoon versus in the morning. As you can tell, there are a lot of date-based fields such as DATEADD. Do these date-based fields behave differently in SQL, depending on the time of day that they are run? SELECT ITMCLSCD AS [TYPE], IsNull(ITMCLSDC,'') AS [TYPE DESCRIPTION], ITEMNMBR AS [ITEM #], ITEMDES...

No global address list when trying to send email through excel
In excel, you can send the spreadsheet as an attachment through emai (Outlook). When I try to do this, the global address list on th server doesn't show up, therefore the person I'm trying to send it t doesn't show up. The global address list is available because I ca save the spreadsheet and create a new email and insert it as a attachment...I would like to send the spreadsheet in an email throug excel (File, Send to, mail recipient (as attachment) because it' easier...How do I change the settings to look for the GAL on th server. There was some sort of wizard that walked ...

global rule
I have a program that tags the subject line of all emails that it thinks is spam. Instead of delivering that message to the recipient I would like to create a rule to deliver it to one large spam mailbox. Is there a way to do this? I am running exchange 2003. ...

Global Function
I'm using the following code to set the Datasheet Font on a Split Form using AC 2007. Private Sub Form_Open(Cancel As Integer) Me.DatasheetFontName = "Arial" End Sub I would like to use a global function so I might call the same function from all my forms, but I haven't had much luck. I tried the following: Public Function SetDataSheetFont() Dim frm As Form Set frm = Screen.ActiveForm frm.DatasheetFontName = "Arial" End Function I get no errors but nothing happens when calling this in the OnOpen of a form. Any help will be appreciated, Ja...

Global Footer Options?
Hi there: Does anyone know if there is a global default option in Excel to ALWAY create footers with the pathname and docname for ALL worksheets? I.E. know there is the solution to create the pathname in eac footer/worksheet, but I want to set this feature as a global defaul for any worksheet I work on. Hope springs eternal : -- Message posted from http://www.ExcelForum.com Hi you can create a new template (*.xlt) file including this option. Place this in your template folder and choose this template for your new workbooks -- Regards Frank Kabel Frankfurt, Germany > Hi there: > D...

Various Fill Color depending on variouse versions?
Hi! It seems like the colors of the Fill Color button changes when I load documents created with earlier versions of excel. Anyway to walk around this? /e Custom colors travel with the workbook. If you want to reset those colors. Tools|Options|color tab|click reset (don't forget to save the workbook.) Eric wrote: > > Hi! > > It seems like the colors of the Fill Color button changes when I load > documents created with earlier versions of excel. Anyway to walk around > this? > > /e -- Dave Peterson gr8, thanks! "Dave Peterson" <ec3572...

Set object with a function
Hello, Can I do something like this.....? ............ Dim MyTextBox as Textbox TxtBoxNum = 3 Set MyTextBox = SetTheTextBoxFunc(TxtBoxNum) ............ Public Function SetTheTextBoxFunc(num as integer) as Textbox select case num case 1 SetTheTextBoxFunc = SLNX.Textbox1 case 2 SetTheTextBoxFunc = SLNX.Textbox2 case 3 SetTheTextBoxFunc = SLNX.Textbox3 end select end function ............... SLNX is a form with a bunch of textboxes. Thanks for any help. Cant quite figure this out. Try; Dim MyTextBox As OLEObject -- Regards Dave Hawley www.oz...

global object dependent on CWinApp global object
hi I have a global object which depends on the CWinApp global object i.e. it assumes that the CWinApp global object is created. After migrating to VS 2005, my global object is getting created before the CWinApp global object. Is there any way I can force the CWinApp object to be created first? I know one of the solution is to avoid a global object and wrap it in a fuction, however a lot of files use this object directly, so I am trying to figure out if there is another way. Regards Chimanrao Chimanrao wrote: > hi > > I have a global object which depends on the CWinApp global...

Date formats, culture and globalization
Hi, ASP.NET 3.5 We are creating a 3-tier ASP.NET Web Application that needs just to understand dates as UK shortdate format (dd/MM/yyyy). It will only be used in the UK on intranet. I often come across web server and client machine that are incorrectly set up so I want to protect the app from these incorrectly set up hosts. I understand the safe date formats for passing through to the database. SQLParameters pass through a non-ambiguous format and also that 'yyyyMMdd' is also a safe format. So ignore the database side of things - I get that. At the moment all the bou...

GP8 to GP10 Error ASIV0001 object already exists
Dear All, I tried all the procedure to upgrade my GP8 to GP10, GP8 is already with SP5, then I uninstall the application from the test server, and install the GP10 as I do not want security so I do not need Dynamics.set. I started GP10 SP1, then SP2, SP3 and then the latest one and all these have the same error code like below: This error is coming at the time of view creation in company database, I am not sure what is it? it look it is creating the ASIV00001 view whereas it is already table. IT is funny. ERROR [Microsoft][ODBC SQL Server Driver][SQL Server]There is already ...

Change Query Object's Criteria via code
Let me try again: TIA very much: Is it possible to change and existing Query Object's criteria via VB code?? If so how might it be done? Thanks again, Joel ...

prf question and global address list....
When i fire off my Oulook 2003 and manually create my profile to connect to our exchange server i get to see my GAL and my outlook address book with my contacts folder when i go to create a new message and click TO: to look at my contacts. When i start outlook 2003 using my PRF file it auto creates the profile and connects me to the server but for some reason i can only see my GAL and not my outlook address book or contacts when creating a new message. I have found this line in my PRF file under MSMail DisplayGalOnly=PT_BOOLEAN,0x6625 Im not sure if this is related but the docs say ...

Rule based on Global Address list?
Is there a way to create a rule in Outlook 2000 that says: route all mail from anyone not in my Global Address List to my Junk E-mail folder? ...

scroll a OLE object field
I am using a form to display the contents of a Word Doc in an Access 03 DB. The results are great but the page is too large to show with the form that I'm using. Is there a way to scroll the contents of the OLE field? Thank You! ...

Printing jpeg objects in Excel2003 #2
Hi, I am having problems when printing in Excel. In the header/footer, I have inserted a jpeg object, and when viewing it looks great, however, when I print it off, I will get 5 duplicates. I also have this problem when inserting an object into the spreadsheet, it will print off with 2 duplicates of the object. Hopefully someone can help me with this. Thanks ...

Reference UDT as Object of Picturebox
I'm using an MDI form. Each child form has one (1) picturebox. I would like to append a UDT or an object as a "subset" of the picturebox for easy referencing. Such as: Child(idxChild).Picturebox(idxPBox).TTool(idxTool).Color < Standard VB Objects >< UDT > Currently I do the following with a nested UDT which replicates the Child and Picturebox objects in order to "subset" the Tool UDT to them for tracking purposes. TForm(idxChild).TPBox(idxPBox).TTool(idxTool).Color Is there a way to ...

Global calendar entries
Is there any way of adding calendar entries (such as bank holiday information) globally into exchange so that all users see it in their Outlook calendars? I'd like to avoid users having to import it into their calendars manually if possible. Many thanks in advance (and apologies if this question has been asked before). ...

Converting hyperlink picture object to hyerlink text
I do a reasonable amount of research on the web where I will cut-and-paste an HTML table into Excel to allow for later indexing. When the table is pasted a variety of information is transfered - text, hyperlinks in the form of text, as well as hyperlinks in the form of small icons/pictures... Through this group I have found out how to convert the character-based hyperlinks to benign text (i.e. unclickable but available for reference). Where the hyperlink appears as an icon (or a picture) I would like to extract the URL details and paste them into an adjacent cell and then (possibly) remove ...

Global Listing
A usesr has been terminated. The account has been disabled. What do I do to keep them from coming up in the Global List? Remove them from the GAL "Larry Ehlinger" <lehlinger@liquor.state.nh.us> wrote in message news:00fd01c34711$f8f4ba30$a501280a@phx.gbl... > A usesr has been terminated. > The account has been disabled. > What do I do to keep them from coming up in the Global > List? ...

Setup failed to validate Report Server
I've been having trouble installing CRM 3.0 Professional and connecting to an existing SQL Server 2005 Report Server (on a different machine). The error message is: Setup failed to validate Report Server 'url' - Object Reference not set to an instance of an object I finally figured out the problem. For some reason, it was permissions issue on the C:\Windows\temp folder of the machine where Report Server was installed. After changing permissions so the Report Server was able to read/write that folder, CRM installed. Just thought I'd post this info in case anyone else...

Global
We are using Exchange 2003 Server, How to Access Exchange Global Address list for POP3 and SMTP Client waiting for your reply Regards Sathish kumar Sathish Kumar Nair <SathishKumarNair@discussions.microsoft.com> wrote: >We are using Exchange 2003 Server, > >How to Access Exchange Global Address list for POP3 and SMTP Client You don't. Use LDAP to query the Actve Directory. -- Rich Matheisen MCSE+I, Exchange MVP MS Exchange FAQ at http://www.swinc.com/resource/exch_faq.htm ...

Get The ID of the Parent object in client side script
So If I called the URL http://sandbox/userdefined/areas.aspx?oId={AFBCB664-BBBD-DA11-9864-001320020C86}&oType=10005&security=852023&tabSet=areaActivities to view the list of Activities for a custom enetity and then clicked the new button or doubled on an exsisting activity. In the onload event of the activity I would like to get the parentid for my custom entity? Is there a way using crmForm or some other object to get the parent entity for this activity? I don't want to use regardingid. Is there any link back to the grid of Activities I called? Mike ...

showing a dropdown list dependent on what's selected in the previos drop down box?
In Column 1 I have a drop down box with all of the makes of vehicle (Chevy, ford, dodge, etc...). In Column 2 I have a place to type i the model. I want to make a dropdown box in Column 2 that will show me all of th available models for a particular brand. (If Chevy is selected i Column1, then only Chevy models will be displayed in the dropdown bo next to it.) Like they use on web pages like kelleybluebook.com an cars.com. thanks -- lhernd ----------------------------------------------------------------------- lherndo's Profile: http://www.excelforum.com/member.php?action=getinfo&am...