|
|
Tanks for answering. I'm now reading the MFC internals. I want to know the principle MFC works on.
|
|
|
|
|
Every windows application needs an entry point, to start execution. It's the first thing that gets run when windows starts a new process. This is wWinMainCRTStartup and not 'main', which is the first point of user code run, is because the C-runtime library needs to initialise before user code can be run.
If you just want a barebone executable without CRT support then you could set it to your own function via the compiler.
|
|
|
|
|
I already know that. And I just want more materials. This is the word describing. How can I get the concrete principles and explanations of the related Library sources. I searched the item on MSDN website but there is little materials of that subject.
|
|
|
|
|
It is the "initializer" and "cleaner" of the C-RunTine.
The operating system calls it with a machine code jump after loading the executable in memory and filled up the relocation table.
It takes care of the invocation of the constructors of all the global objects (since the exist "outside of main", they have to be create before main is called). It then invokes "main" (or WinMain) after unpacking the command line, and - when main returns, calls the destructor of the on-fly created static objects and the destructors of the global objects in reverse construction order, then finally, returns the main return value to the OS process who invoked the app.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
You are right. I've followed the source code in crtexe.c and watched the program's executing sequences. And can you tell me why the OS must do this? Is it because of the relocating? Thanks!
|
|
|
|
|
The reason is not because of the OS (it simply adjust the relocation table after copying the executable image in memory BEFORE jumping in it, so the exe itself has no role in that) but because of how C++ works.
Objects has constructors and destructors.
Try this
#include <iostream>
class A
{
public:
A() { std::cout << "A created" << std::endl; }
~A() { std::cout << "A destroyed" << std::endl; }
};
A global_a;
int main()
{
std::cout << "this is main" << std::endl;
return 0;
}
The output will be
A created
this is main
A destroyed
Global objects must be created/destroyed outside the scope of main.
This is not an OS requirement, but a requirement for the C++ specification.
mainCRTSturtup is the "bridge" between the OS (that has no clue about the app language specifications: it just want an address to be called) and a language like C++ that requires some code (constructors and destructors of global objects) to be executed independently of the main() function.
2 bugs found.
> recompile ...
65534 bugs found.
modified on Sunday, August 14, 2011 4:33 AM
|
|
|
|
|
Hi,
I am using a VC++ MFC app to drive Excel through OLE Automation.
I need to insert new row in the Excel.
How to acheive this?
***************
// Code Sample
***************
// excel application object
Application objExcel;
// local var
COleVariant vRet;
// range object
Range objRange;
// set the workbooks object
Workbooks objWorkbooks( V_DISPATCH( (LPVARIANT)vRet ) );
// adding the new workbook
vRet = objWorkbooks.Add( COleVariant( (long)xlWorksheet ) );
// set the workbook object
Workbook objWorkbook( V_DISPATCH( (LPVARIANT)vRet ) );
// adding the worksheet
vRet = objWorkbook.Worksheets( COleVariant( (long)1 ) );
Worksheet objWorksheet( V_DISPATCH( (LPVARIANT)vRet ) );
// get the range
vRet = objWorksheet.Range1( COleVariant( csRange ) );
objRange.AttachDispatch( V_DISPATCH( (LPVARIANT)vRet ) );
From the above code in objRange having the Row position as C8.
Here need to insert a new row.
Reg,
SPala
|
|
|
|
|
Have you tried objRange.Insert() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi David,
Thanks for your reply. I am using Excel 2007.
Yes i tried with Insert method. I don't how to give the Parameter value;
Below is my code:
csRange.Format("C%d", nRow );
vRet = objWorksheet.Range1( COleVariant( csRange ) );
objRange.AttachDispatch( V_DISPATCH( (LPVARIANT)vRet ) );
objRange.Insert(???)
**********************************
synatx for Insert:
objRange.Insert(const VARIANT &shift)
**************************************
How to give the parameter value for Insert method?
Waiting for your reply.
Thanks,
SPala
|
|
|
|
|
spalanivel wrote: How to give the parameter value for Insert method?
Have you tried something like:
objRange.Insert(COleVariant(-4121L), vtOptional);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I tried with the below codes but still no luck...
csRange.Format("C%d", nRow );
objWorksheet.Range( COleVariant(csRange), vtOptional);
and
objRange.Insert(COleVariant(-4121L), vtOptional);
Following Error Message while i tried with the above code "Memeber Not Found"..
Any other option?
Just need to insert a new row i am using Excel 2007 and excel9.h header file.
Thanks.
|
|
|
|
|
spalanivel wrote: Following Error Message while i tried with the above code "Memeber Not Found"..
What member is the compiler referring to?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
HI,
In my application im having one Dialogbar contains Listbox and editbox and i attached this DialogBar to Mainframe.
But i want to display this DialogBar only when some childviews are active.Otherwise this DialgoBar should be in hiding.TO get this in OnTImer() of Mainframe class.I did this..
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
CMDIFrameWnd *pMainWnd = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd ;
CMDIChildWnd *fChWnd = (CMDIChildWnd*)pMainWnd->GetActiveFrame();
CView *pView = (CView*)fChWnd->GetActiveView ();
if(NULL != pView)
{
if(pView->IsKindOf(RUNTIME_CLASS(CGraphView)))
m_RecentAlarms.ShowWindow(SW_SHOW);
else
m_RecentAlarms.ShowWindow(SW_HIDE);
}
m_RecentAlarms.Invalidate();
CMDIFrameWnd::OnTimer(nIDEvent);
}
m_RecentAlarms is DialogBar.
It works for one time only.First when i go to CTuningView(I dont want dialogbar),the dialogbar gets hided.When i go to CGraphView,it shows.
But when again go to tuning view its not get hided.When i debug,the cursor goes to OnTimer() and it goes to SW_HIDE also..but even its showing here.
Pls help me in this issue.
Anu
modified on Friday, August 12, 2011 5:28 AM
|
|
|
|
|
Try Using ShowcontrolBar to show\hide the controlbar.
http://www.mono-project.com/Main_Page
|
|
|
|
|
|
Hi!
What's meant by Thread safe in VC++? How to make a Singleton class or object Thread safe?
|
|
|
|
|
this[^]
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Use EnterCriticalSection and LeaveCriticalSection appropriately.
|
|
|
|
|
Bernhard Hiller wrote: Use EnterCriticalSection and LeaveCriticalSection appropriately.
Hi!
To create a singleton class we've to make the constructor as private and we should return the instance of the class using a static function. Where to use the above? Inside the constructor or inside the function which returns the instance of the class? Can you please elaborate on this or post some code?
|
|
|
|
|
you should use that around any code which should not be used by two threads at once. this includes any code that modifies the internal state of the singleton.
for example, if you have a list of items in your singleton that callers can modify via function calls, you should put a critical section guard around code which can modify the list, to ensure that two threads don't try to modify the list at the same time (which could mess up the internal state of the list).
void CMySingleton::AddToList(int newData)
{
EnterCriticalSection(...);
list.push_back(newData);
LeaveCriticalSection(...);
}
|
|
|
|
|
Errors :-
syntax error : missing ';' before identifier 'IOCounters'
'IO_COUNTERS' : missing storage-class or type specifiers
'IOCounters' : missing storage-class or type specifiers
The Coding is:-
IO_COUNTERS IOCounters; // WARNING! If you get error that IO_COUNTERS is undeclared
// then undefine it's definition above.
// Latest SDK defines this structure in <WinNT.h>
|
|
|
|
|
Try to include this
<WinNT.h> at the top(before any other headers.
|
|
|
|
|
I create an MDI application, with document type ".xyz". I can create, open and save this kind of document with new, open and save items from file menu. But I need to open a document file from the disk in follow way : I open mainframe window with no new document, and from a diferent items from menu, let's say, OnHelpTest open
"D:\Default.xyz" document file , how can I do that ?
I can't call
CMyDocument::OnOpenDocument(_T("D:\\Default.xyz"));
because if I try to get a pointer to CMyDocument with known way,
MDIGetActive()->GetActiveView()->GetDocument(),
failed, because is not document open already as I said ...
|
|
|
|
|
Can you call CWinApp::OpenDocumentFile(_T("D:\\Default.xyz")) ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|