|
If you want to read access files of your program did you see Database[^]?
|
|
|
|
|
Hi everybody,
I see how the messages travels down in the own application.
But a special key combination (Ctrl+Shift+R) should launch a tool into my application,
but it opens a functionality of another application ...
How can i route the message that it will directly traited by my own application?
Big thanks for any help
|
|
|
|
|
Use RegisterHotKey(HWND hWnd,int id,UINT fsModifiers,UINT vk) to register global hotkeys.
Then handle the message WM_HOTKEY to do what you want.
When you don't need your hotkey anymore, call UnregisterHotKey(HWND hWnd,int id);
rotter
|
|
|
|
|
Are you using an accelerator table to catch the Ctrl+Shift+R key?
If no then that's where I would start.
AliR.
Visual C++ MVP
|
|
|
|
|
Hello everyone,
The following code will result in C4373 warning message. In MSDN,
[url]http://msdn2.microsoft.com/en-us/library/bb384874.aspx[/url]
I do not quite understand the following statement,
1. What means "bind"? Putting function pointer into the vtable of the related class?
2. const is ignored in derived class?
--------------------
This means the compiler must bind a function reference to the method in either the base or derived class.
Versions of the compiler prior to Visual C++ 2008 bind the function to the method in the base class, then issue a warning message. Subsequent versions of the compiler ignore the const or volatile qualifier, bind the function to the method in the derived class, then issue warning C4373. This latter behavior complies with the C++ standard.
--------------------
class Base {
public:
virtual int goo (const int input) {return 200;}
};
class Derived : public Base {
public:
virtual int goo (int input) {return 200;}
};
int main()
{
Derived d;
const int a = 1000;
d.goo (a);
return 0;
}
Compile warning message,
1>d:\visual studio 2008\projects\test_overriding1\test_overriding1\main.cpp(8) : warning C4373: 'Derived::goo': virtual function overrides 'Base::goo', previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
1> d:\visual studio 2008\projects\test_overriding1\test_overriding1\main.cpp(3) : see declaration of 'Base::goo'
regards,
George
|
|
|
|
|
"function arguments of a type modified by const or volatile are not treated differently
than the base type for the purposes of overloading." from msdn;
that is
"int goo (const int)" and "int goo (int)" are not considered as two overloaded function,
it causes redeclaration error. you cannot have two definitions for each of this.
So, while overriding, "virtual int goo (const int )" and "virtual int goo (int input)"
is not considered as two different functions and compiler prior to VS 2008 binds to the
method in base class and issues warning "C4301: 'Derived::goo': overriding virtual function
only differs from 'Base::goo' by const/volatile qualifier"
while VS 2008 bind the function to the method in the derived class, then issue
warning C4373 ignoring qualifiers. "This latter behavior complies with the C++ standard."
George_George wrote: 1. What means "bind"?
Putting function pointer into the vtable of the related class?
yes.
George_George wrote: 2. const is ignored in derived class?
explained above.
|
|
|
|
|
Thanks Rajkumar,
Your reply is so comprehensive covers not only overriding (my question) and overloading (which I do not know).
regards,
George
|
|
|
|
|
The bug in MCVC prior to 2008 is that the compiler doesn't recognise cv-qualifiers
(const and volatile or combination) as modifying the type in all cases. For example when matching template
parameters so int myfunc<volatile int=""> is the same function as int myfunc<int> in some circumstances but not
in others. This is part of the legacy of the almost completely broken template implementation in VC6. I'm
very glad to hear MS have finally fixed the last gits of this that I'm aware of. I would have helped if they'd
admitted to the full reality of how far out of spec their compiler was at some point in the past so we
could have predicted what would and would ot work rather than having to rely on trial an error but that
M$ for you.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks Matthew,
I do not quite understand your sample below. Could you show some pseudo code please? Code clarifies everything.
Matthew Faithfull wrote: For example when matching template
parameters so int myfunc is the same function as int myfunc in some circumstances but not
in others.
regards,
George
|
|
|
|
|
Sorry George the template parameters got dropped, very .
what I meant was older MS compilers get int myfunc<const int> confused with int myfunc<int> and similar. Except that in some cases they get it right so it's very difficult to know exactly what will work and what won't.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks Matthew,
I think you mean something like this? I have tested in Visual Studio 2008, it will result in compile error,
error C2995: 'int myfunc(T)' : function template has already been defined
template <class T> int myfunc (T a) {};
template <class T> int myfunc (const T a) {};
regards,
George
|
|
|
|
|
Yes, that's another case of the same thing. It looks like they still haven't fixed it properly
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi Matthew,
In your mind, you mean they will be treated as different thing? Does C++ Spec mention this?
regards,
George
|
|
|
|
|
actually, this is not problem / bug. They have reasons to do that.
This is because, how initializers can be used.
int myfunc (int );
int myfunc (const int);
myfunc (100); refers to which one?
"They are considered the same because they take the same initializers." from msdn.
compiler determine the corresponding overloaded function, according to the actual parameter type in the function call.
while
int myfunc (int & a);
int myfunc (const int &a); are different as the initializers are unique.
And VS2008 chooses to ignore overrided qualifiers conforming to ISO C++, may be its behaviour is undefined before in C++. And where ever undefined is in standards, implementation takes its own choice.
modified on Wednesday, February 27, 2008 1:23 AM
|
|
|
|
|
Hi Rajkumar,
For your sample,
int myfunc (int a);
int myfunc (const int &a);
even if they are different, they will result in ambiguity in function call. Right? Here is my below code and related compile error message. So, is there any practical benefits to define them both?
int myfunc (int a) {return 100;}
int myfunc (const int &a) {return 200;}
int main()
{
myfunc (100);
return 0;
}
Compile errors
1>d:\visual studio 2008\projects\test_const5\test_const5\main.cpp(7) : error C2668: 'myfunc' : ambiguous call to overloaded function
1> d:\visual studio 2008\projects\test_const5\test_const5\main.cpp(3): could be 'int myfunc(const int &)'
1> d:\visual studio 2008\projects\test_const5\test_const5\main.cpp(1): or 'int myfunc(int)'
1> while trying to match the argument list '(int)'
regards,
George
|
|
|
|
|
yes, you are right, i corrected my typo error.
And I assume ambiguity is the generic case of the same issue iam discussed.
|
|
|
|
|
Thanks Rajkumar,
My question is answered.
regards,
George
|
|
|
|
|
I've been wondering why my recent article 'How To Calculate The Age Of A File' has been getting poor votes. I wondered if the fact that I hadn't used the 'HighPart' and 'LowPart' members of the ULARGE_INTEGER was bad. Then again is my use of the following code bad?
SystemTimeToFileTime (& NowSystemTime, (FILETIME *) & ulSysTime);
SystemTimeToFileTime (&FileSystemTime, (FILETIME *) & ulFileTime);
Since posting my article, I have read 'Date and Time in C++' by RK_2000 and noted that he said
<quote>
Although [FILETIME and LARGE_INTEGER] have the same binary format, the address of all FILETIME structures must begin on a 32 bit boundary whereas the address of all LARGE_INTEGER must begin on 64 bit boundary. So, do not use these interchangeably.
... so this cast I've been using is wrong, then?
In the meantime, I will assume that this is a flaw that people have spotted in my code and rewrite it without this cast.
Thanks for your help,
Ben.
|
|
|
|
|
Ben Aldhouse wrote: I've been wondering why my recent article 'How To Calculate The Age Of A File' has been getting poor votes.
Because if people have the ability to vote low, then for no other reason, they will. Ignore the vote and move on.
Ben Aldhouse wrote: ...I will assume that this is a flaw that people have spotted in my code...
Doubtful. A truly interested and worthy reader will let you know.
"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
|
|
|
|
|
Thanks, David, for your encouraging reply.
I have tried the code without the cast and I can't get sensible results.
This is what I now have...
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strPath, &FindFileData);
CString strYears, strMonths, strDays;
SYSTEMTIME stNow;
GetSystemTime(&stNow);
const FILETIME ftFile = FindFileData.ftCreationTime;
FILETIME ftNow;
ULARGE_INTEGER ulNowTime, ulFileTime, ulAge;
SystemTimeToFileTime (& stNow, &ftNow);
ulNowTime.HighPart = ftNow.dwHighDateTime;
ulNowTime.LowPart = ftNow.dwLowDateTime;
ulFileTime.HighPart = ftFile.dwHighDateTime;
ulFileTime.LowPart = ftFile.dwLowDateTime;
ulAge.HighPart = ulNowTime.HighPart - ulFileTime.HighPart;
ulAge.LowPart = ulNowTime.LowPart - ulFileTime.LowPart;
FILETIME ftAge;
SYSTEMTIME stAge;
ftAge.dwHighDateTime = ulAge.HighPart;
ftAge.dwLowDateTime = ulAge.LowPart;
SystemTimeToFileTime(&stAge,&ftAge);
strYears.Format("%d", stAge.wYear-1601);
strMonths.Format("%d",stAge.wMonth-1);
strDays.Format("%d",stAge.wDay-1);
I'm foxed. I should really take your advice and move on...
Ben.
|
|
|
|
|
What exactly is this code snippet supposed to be doing?
"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
|
|
|
|
|
I was trying to find the difference between a file's creation date, the current time and get the resulting data in a useful format. Doing this I was aware of the following warning from the MSDN library
Remarks
It is not recommended that you add and subtract values from the SYSTEMTIME
structure to obtain relative times. Instead, you should
-Convert the SYSTEMTIME structure to a FILETIME structure.
-Copy the resulting FILETIME structure to a ULARGE_INTEGER structure.
-Use normal 64-bit arithmetic on the ULARGE_INTEGER value.
However, I think at this point I was put off because the promised 'HighPart' and 'LowPart' members of ULARGE_INTEGER didn't appear in the autocomplete list on my editor. I have since written in the members anyway and found that they work without any trouble.
Since your last reply I have had a walk around the block and had another look at the code. I discovered that when I was removing some lines whilst taking out the code that used that (FILETIME *)&ULARGE_INTEGER cast, I removed one line I should have left in and edited and left in another line towards the end of the code that should have been removed...
Here is the (now, at last) working code with comments.
Thanks for your encouragement and for showing an interest,
Ben
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strPath, &FindFileData);
CString strYears, strMonths, strDays;
SYSTEMTIME stNow;
GetSystemTime(&stNow);
const FILETIME ftFile = FindFileData.ftCreationTime;
FILETIME ftNow;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strPath, &FindFileData);
CString strYears, strMonths, strDays;
SYSTEMTIME stNow;
GetSystemTime(&stNow);
const FILETIME ftFile = FindFileData.ftCreationTime;
FILETIME ftNow;
SystemTimeToFileTime (& stNow, &ftNow);
ULARGE_INTEGER ulNowTime, ulFileTime, ulAge;
ulNowTime.HighPart = ftNow.dwHighDateTime;
ulNowTime.LowPart = ftNow.dwLowDateTime;
ulFileTime.HighPart = ftFile.dwHighDateTime;
ulFileTime.LowPart = ftFile.dwLowDateTime;
ulAge.HighPart = ulNowTime.HighPart - ulFileTime.HighPart;
ulAge.LowPart = ulNowTime.LowPart - ulFileTime.LowPart;
FILETIME ftAge;
SYSTEMTIME stAge;
ftAge.dwHighDateTime = ulAge.HighPart;
ftAge.dwLowDateTime = ulAge.LowPart;
FileTimeToSystemTime(&ftAge,&stAge);
strYears.Format("%d", stAge.wYear-1601);
strMonths.Format("%d",stAge.wMonth-1);
strDays.Format("%d",stAge.wDay-1);
|
|
|
|
|
Have you considered the COleDateTimeSpan class?
"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
|
|
|
|
|
Hmm. Looking this up in MSDN I have found out that CTime has constructors for accepting SYSTEMTIME and FILETIME objects.
Looks like I'll be rewriting the code with an even better solution!
|
|
|
|
|
I have got some shortcuts in "All Programs"-> "Accessories" -> "Test Menu".
“Test Menu” contains some shortcuts of applications and those are not sorted, can anyone please tell how to sort those shortcuts programmatically.
Manually I can do this by using popup menu “Sort by Name” as shown in screen shot.
http://img142.imageshack.us/my.php?image=shortcutsortingquestionbl8.jpg
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
modified on Monday, February 25, 2008 6:57 AM
|
|
|
|