|
DougButtimer wrote: ...currently having a problem in OnDraw()...
Could it be that OnDraw() is called so often that CLogFile code can't keep up?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote:
Could it be that OnDraw() is called so often that CLogFile code can't keep up?
Don't see how - I'm running to a break point on the LogFile->Add() function within OnDraw(). Invoke second refresh of screen by maximising it, and off we go through the path that I described earlier and end up at that Call to bad assembler code. Are there any "no, no's " for code within OnDraw() or in OnPrepareDC() functions, or any timing restrictions (we obviously have to access a file) ???
Doug
|
|
|
|
|
Hello everyone,
Now compiler prevents (at least in Visual Studio 2008) us from initialize non-const static member variable in this way,
Class Foo {
statuc int i = 200;
...
};
Anyone know why compiler prevents initialize non-const variable in this way? Any side effects or just a fixed rule from C++ Spec?
thanks in advance,
George
|
|
|
|
|
As far as I know it's per the spec. Allowing intialization at declaration at all is a fairly recent concession, you couldn't do it in VC6. It makes sense to only allow static const initialisation as that is really the same as declaration.
In the past header files tended to be stuffed with namespace polluting #defines like
#define DEFAULT_ARRAY_SIZE 42 .
Now you can add
static const int s_iDefaultArraySize = 200;
to your class declaration instead, much nicer
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi Matthew,
1.
Matthew Faithfull wrote: you couldn't do it in VC6
I am using Visual Studio 2008.
2.
Matthew Faithfull wrote: namespace polluting #defines
Why it is namespace polluting? It is defined in the global/default namespace?
regards,
George
|
|
|
|
|
George_George wrote: Why it is namespace polluting? It is defined in the global/default namespace?
Exactly because it's defined in the global/default namespace and it is NOT really global or shouldn't be. What if I include a third party header file which also has
#define DEFAULT_ARRAYSIZE 400 - potential disaster.
One of the principles of good OO programming is 'locality of reference' which basically means a name should only be defined for the scope where it is meant to be used. That was the whole point of introducing namespace into C++ (which also didn't work in VC6) so that myLib::CString could exist in the same project as CString from MFC and the correct reference can always be resolved rather than refering to whichever one was included first or most recently.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: which basically means a name should only be defined for the scope where it is meant to be used.
No that is not what the Locality of Reference or Principle of Locality[^] is about at all.
In computer science, locality of reference, also known as the principle of locality, is the phenomenon of the same value or related storage locations being frequently accessed. There are three basic types of locality of reference: temporal, spatial and sequential:
led mike
|
|
|
|
|
Four types, the fourth being codespace, scope and extent, the principle is exactly the same it's just another virtual dimensionality.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: Four types, the fourth being codespace
Do you have a citation for that or are you asking use to recognize you as a leader in the industry capable of establishing Principles?
led mike
|
|
|
|
|
Thanks Matthew,
So, your answer to my original question is, it is according to C++ Spec that non-const static variable is not allowed to be initialized at the time when it is declared, right?
I am interested in what the Spec says, could you help to quote the related C++ Spec please?
regards,
George
|
|
|
|
|
Hi,
The 2005 compiler alsoo treats this as an error.
Now the why (Found this on the Net[^]):
"If a static data member is of const integral or const enumeration type, its
declaration in the class definition can specify a constant-initializer which
shall be an integral constant expression. In that case, the member can
appear in integral constant expressions within its scope. The member shall
still be defined in a namespace scope if it is used in the program and the
namespace scope definition shall not contain an initializer."
So the only relaxation is that for static const integral/enum types you can
get away with the definition if you don't use them in their program i.e.
don't treat them as l-values. The key point you are missing is that the
member can still appear in integral constant expressions (like case label).
So this clause is just a relaxation applicable only with integral constant
expressions.
I think the next sample while explain it more:
class MaxBuffer
{
public:
const static int Max = 80;
int m_iBuffer[Max];
};
class ErrorBuffer
{
public:
static int Max;
int m_iBuffer[Max];
};
codito ergo sum
|
|
|
|
|
Thanks BadKarma,
1.
I read the document you quoted. What means "integral constant expression"?
2.
BadKarma wrote: don't treat them as l-values
Means for const static member variable, they are not l-value? Actually, I do not agree since for the const static member variable, it is addressable, so it should be a l-value.
Here is my code to verify,
class Foo{
public:
const static int size = 100;
};
int main()
{
cout << &(Foo::size);
return 0;
}
regards,
George
|
|
|
|
|
Hi, george_george
George_George wrote: What means "integral constant expression"?
They are alsoo known as compile time constants. Look at int const guidelines (boost)[^]
George_George wrote: Means for const static member variable, they are not l-value? Actually, I do not agree since for the const static member variable, it is addressable, so it should be a l-value.
This is not correct.
The meaning of l-value is : on the left side of an assignment.
Since its a const it can't be on the left side. Whether you got the address where that value
is stored doesn't matter. If you try to use it in any way on the left side of an expression
you would have an access violation. I'm guessing the value is placed in an read only segment
of memory.
codito ergo sum
|
|
|
|
|
Thanks BadKarma!
Great reply. I have re-read what you quoted in the Spec before, I am confused about what does the following statement mean?
(what makes me confused is in a class, which type of statement could be looked as definition, and which type of statement could be looked as declaration?)
"get away with the definition if you don't use them in their program"
regards,
George
|
|
|
|
|
Sir,
My COM class not getting registered.
Iam trying to register the COM DLL with .regsvr32.
It is not displaying either Dll Registered or Failed messge.
So, when i try to create instance of thet class, using CoCreateInstance
it returned Failure Code -2147221164 , that means Class not registered.
I want to know the reasons of CoCreateInstance failure.
Help me Plz.
Krishna.
|
|
|
|
|
Royaltvk wrote: It is not displaying either Dll Registered or Failed messge.
The above is unusual. Could you debug your DLLRegisterServer function?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Iam trying to debug this COMDll from my application .So that iam trying to crate instance of this COM DLL
just like this
CoInitialize(NULL);<br />
BSTR str;<br />
<br />
IDUOleServerImpl *pDXOLEServer;<br />
<br />
<br />
HRESULT hr = CoCreateInstance(CLSID_DUOleServerImpl, NULL, CLSCTX_ALL,<br />
IID_IDUOleServerImpl, (LPVOID *)&pDXOLEServer);<br />
if( !pDXOLEServer )<br />
{ <br />
szResponse ="Problem in Creating the DXOLE Engine Server";<br />
<br />
return ;<br />
}<br />
<br />
<br />
pDXOLEServer->ExecuteRequest(10001,bstrConnectionInfo,&str);<br />
But in my application is not be able to locate the server and throwing an error code -2147221164 i.e Class not registered.
But If i try to register the COM DLL for CmdLine Regsvr32, it is not throwing any success or failure notice.
Still iam mess up with this problem .
Please look at this.
|
|
|
|
|
U can create COM Object only if it is successfully Registered.
If u r debugging in this way u cannot find out the installation problem.
u need to debug the DLL while registering it.
Royaltvk wrote: But If i try to register the COM DLL for CmdLine Regsvr32, it is not throwing any success or failure notice.
may be this is because infinite loop, deadlock in the registration path
|
|
|
|
|
Please read CPallini's reply again. He said:
The above is unusual. Could you debug your DLLRegisterServer function?
If your DLL isn't registering properly, then of course CreateInstance won;t work!
Regedit is also your friend - you can see if the keys you need for registration are being created.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
if u don't know how to debug the DLLRegisterServer, following may be useful,
1) put a breakpoint in your DLLRegisterServer function
2) Set your COM DLL project as Startup project
3) IN your COM DLL project Settings set the values such that regsvr32.exe is started,
vsproperty->Debugging->Command = C:\WINDOWS\system32\regsvr32.exe
vsproperty->Debugging->Command Arguments = "$(TargetPath)" // path to COM DLL
4) start debugging
|
|
|
|
|
I am making a small dialog based application where i have an edit box. what needs to be done to display the value that is typed in the editbox. i want the messagebox to dispay the vlaue that is texted. i dont want to use the OK button. click and if the focus is lost the the value should display. any leads.
|
|
|
|
|
Chandrasekharanp wrote: if the focus is lost the the value should display.
Have you tried EN_KILLFOCUS ?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
yes i have tried EN_KILLFOCUS. i am not getting the right result. is there any other way?
|
|
|
|
|
EN_KILLFOCUS did help me in solving the problem. the logic which i gave was wrong.
Thanks
|
|
|
|
|
Why you didnt make your dialog instead use of messagebox?
|
|
|
|