Where is the best place to load caption strings in a MFC application?
I'm loading control captions in the 开发者_开发问答OnInitialUpdate method of my views and loading menu items captions in the OnCreate method of my frame.
What does not work with your current approach? Why do you want to load them somewhere else? In general, the best place to load them is when you need them (I'm assuming you're talking about loading strings from the resource section with CString::LoadString() ).
If the menu and other controls are part of a dialog then, OnInitDialog()
is a good place to set the captions for the dialog and its controls.
I dont believe there are more than 100 of captions in your program. You can load them in InitInstance
itself - no harm.
If there are more than few hundreds of captions to load, it would take the GUI to appear (irrespective of where you load, since GUI/total thread is one). In that case, you should load all important resources/captions while startup (in InitInstance
), and defer/delegate the loading of other captions to other thread/later-time.
精彩评论