|
What's the exact error message ? It's really difficult to guess what the problem might be just by looking at your source code (unformatted).
Nik1234 wrote: The reason I am putting them there is that I only want to include my Base class in the main program. If I remove them, then I have to include all the different files (Derive1, Derive2, Join).
Wrong: you just need to include Join.h because it already includes Derive1 and Derive2 and both of them include Base.h. And in general it is bad design to include the header files of the derived classes in the header of your base class (your base class should't be aware of its derived classes).
|
|
|
|
|
Actually you are right, it seems a bad design. True, in this case I would only need to include the Join class, but if I had 100 Join classes, I would need to include all of those...
So, I am changing my design by removing the include files at the end of the base class and creating another include file which will include my derived classes(the 100 Join classes ). By this way I will still include only one file and I will avoid the other conflicts
For your reference, the error I was getting was:
Derive1 class undefined
Derive2 class undefined
in the Join.h file.
Thanx a lot for your help!
|
|
|
|
|
How to set a region without its constructor?
With "new", it is less efficient.
OnMouseMove()
{
Region Rgn;
m_pic.GetRegion(&Rgn);
}
Take the advange of MakeEmpty and Union , it can be done. Not sure if there is a more efficient way.
|
|
|
|
|
followait wrote: Take the advange of MakeEmpty and Union, it can be done.
There's not any other options if you don't want to return
a Region created with new.
Moving the Rgn variable out of the OnMouseMove() function will
help by avoiding the constructor/destructor calls.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
My System is in a Network Domain.
I need to protect a File/Folder from getting copied by other users.I worked on Access
Control Entries and provided permissions to a folder so that it can be accessed programmatically only. If I Click on that folder it says Access Denied.
I have given List Folder contents permission and Traverse and Read Permissions and allowing access to only my user name.
Unfortunately I found that by right clicking on the folder->Security Tab-> Advanced-->owner tab
the user can Replace the owner and and can have full control to folder.
Is there any possibility for me to disable that option?
or else atleast can we remove the security tab option from properties for that specific folder.
I need an approach.
Any thoughts would be greatly appreciated.
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
//iam tring to show progressdialog on click ok button on Main dialog and update the WindowCaption in an interval of 1 sec. my problem described below..
HWND hWnd ;
void ProgressFunc(HWND hwnd , char* progress )
{
SetWindowText( hWnd , progress ) ;
<font color="green">
}
DWORD MyProgressDlgThread(LPVOID Nothing )
{
DialogBox(hInst,MAKEINTRESOURCE(IDD_PROGDLG1), ... ) ;
<font color="green">
return 0 ;
}
MyMainDialog_OkClick()
{
hWnd = NULL ;
char data[ 3 ] ;
HANDLE hTread = CreateThread( ... , (LPTHREAD_START_ROUTINE)MyProgressDlgThread , (LPVOID)NULL , ... ) ;
int i = 0 , n = 10 ;
while( i < n )
{
if( hWnd )
{
sprintf( data ,"%d" , i ) ;
ProgressFunc( hWnd , data ) ;
}
Sleep( 1000 ) ;
};
}
my problem is,
the dialogbox shown only after 2-3 seconds and the value is updated only once. how to
solve this problem ?
i cant use a timer here for some reason.
plz help me
Thanks & Regards
modified on Tuesday, December 11, 2007 2:18:28 AM
|
|
|
|
|
nitin3 wrote: int i = 0 , n = 0 ;
while( i < n )
{
if( hWnd )
{
sprintf( data ,"%d" , i ) ;
ProgressFunc( hWnd , data , 0 ) ;
}
Sleep( 1000 ) ;
}
you're code is somewhat confusing and seems incomplete. though I saw this:
int i = 0, n = 0;
while(i < n) //0 == 0 won't enter this loop
{
}
|
|
|
|
|
looks like you've modified your post.
nitin3 wrote: int i = 0 , n = 10 ;
while( i < n )
{
if( hWnd )
{
sprintf( data ,"%d" , i ) ;
ProgressFunc( hWnd , data ) ;
}
Sleep( 1000 ) ;
};
have you tried placing i++ inside your loop? it will be stuck inside that loop in the first place since you're not moving your counter. placing Sleep( 1000 ); inside the main thread will cause the dialog to be somewhat "stuck" because you are stopping the main thread of your application. I suggest you go for a timer or just place the process inside the thread you have created.
|
|
|
|
|
It is because messages are processed by your main thread. As your main thread is busy (you Sleep 3 times), no messages are processed during this time and your dialog is not updated. Once your function exits, messages are processed and your value is updated. It looks like only once but it is updated 3 times very fast.
You should do the opposite: keep your dialog in the main thread and put the 3 Sleep in the thread function.
|
|
|
|
|
You should be able to solve this by a minor modification to your ProgressFunc:
void ProgressFunc(HWND hwnd , char* progress )
{
SetWindowText( hWnd , progress ) ;
UpdateWindow(hWnd);
}
As mentioned by others, the sleep is generally not a good idea. I'm not sure why you say a timer won't work, but that's a better choice.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi,
I need to create a windows service which should not be stopped unless and until I UnInstall my Program i.e it should be started automatically on startup.
I just want to know whether this is possible or not.If so how?
Any suggestions or relevant links would be helpful.
Thanks
Today is a gift, that's why it is called the present.
modified on Tuesday, December 11, 2007 1:41:42 AM
|
|
|
|
|
narayanagvs wrote: I just want to know whether this is possible or not.If so how?
Yes it's possible. It's the usual way a service works. Your install program uses the Service Control Manager to create the entries for an auto-start service and copies the service to the hard drive, and your uninstall program removes those entries via the SCM and removes the service from the drive.
Services[^]
Judy
|
|
|
|
|
Hello everyone,
I am reading the C++ Programming Language book, but can not find the function of explicit keyword of constructor. Could anyone explain its usage or refer some learning materials please?
thanks in advance,
George
|
|
|
|
|
explicit keyword prevents the behaviour of converting contructor .
Come online at:-
jubinc@skype
|
|
|
|
|
Thanks Don,
Any more information please? What is converting contructor? I am a beginner of explicit keyword.
regards,
George
|
|
|
|
|
|
Thanks Vince,
Looks very comprehensive, are there any docuemnts for beginners for explicit keyword? The paper you referred is about how to enhance existing functions of explicit keyword and best practices.
regards,
George
|
|
|
|
|
I will explain you with an example: suppose you are writing a string class (CMyString). This class has a constructor that accepts a char array:
class CMyString
{
CMyString(const char* pBuffer);
};
Suppose now you have a function that accepts a CMyString as parameter:
void MyFunction(const CMyString& myString)
{
...
}
You can perfectly do something like that in your code:
MyFunction("TestString");
Because of your constructor that accepts a char array, an object of CMyString will be created by calling the constructor. This is an implicit conversion, and sometimes, you do not want that to happen. In that case, you should use the explicit keyword to make sure the user knows what he is doing. He will then need to explicitely create the object when calling the function:
MyFunction(CMyString("TestString"));
|
|
|
|
|
Thanks Cédric Moonen,
Any practical benefits we could get if we use explicit keyword?
regards,
George
|
|
|
|
|
If you create a library, sometimes you want to avoid 'confusion' by disallowing implicit conversions for the end user (like the one I showed you before).
|
|
|
|
|
Cool, thanks Cédric!
But from your sample, I can not see why implicit conversion will cause any confusions. It brings flexibility I think.
Could you point out what confusion do you mean please?
regards,
George
|
|
|
|
|
It is quite clear (or I think so)
Imagine that you derive your CMyString from CString and it can receive a CString as entry parameter, but you have added some funcionality to the derived class by overloading. If you use:
CString strTemp = otherClass.strParameter;
MyFunction (strTemp);
The compiler won't maybe complain, but in the release version you have a bad running result because you are using the added methode inside MyFunction and the CString doesn't have it.
If you force the user by declaring explicit, then the compiler should complain. So it will be needed to use insteads:
CString strTemp = otherClass.strParameter;
MyFunction (CMyString (strTemp));
or
MyFunction (CMyString (otherClass.strParameter));
you will use the data that are comming from the string of otherClass.strParameter but you will be able to use your overloaded/added methodes in CMyString.
The use of that, as cedric already said, Libraries, Dlls that are going to be used by anyone (in example).
Or have I understood you false, cedric?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi Nelek,
I do not quite agree with you in the sample. I think it is a coding error in MyFunction, which it should check (e.g. dynamic cast?) the type should be CMyString other than CString, any comments?
regards,
George
|
|
|
|
|
You just asked for a practical use. I gave you one. if it is the best way to do it or not... I'm not enough skilled to say it.
But the fact is that Cedrics explanation is very good (at least in my opinion, i didn't know it before). You can always use google to try to find usements and/or examples.
BTW there is so much possibilities to do something as programmers in the world. What you find super is maybe nto so good for other people
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Thanks for your help, Nelek!
regards,
George
|
|
|
|