|
When i try to call SetProcessDPIAware from inside the InitInstance fucntion of the app, it says the fucntion - error C2065: 'SetProcessDPIAware' : undeclared identifier
Why is it so?
Btw, this is a MFC app being developed in Visual Studio 6.
Is there a different way to set it DIPaware?
|
|
|
|
|
The API is only supported from Windows Vista and above.
So you need to define the following macros as below -
_WIN32_WINNT = 0x0600
WINVER = 0x0600
|
|
|
|
|
Hi, I created a dialog based MFC smart device project, I found 2 dialog resources in dialog folder of resource view. one is
IDD_xxx_DIALOG; another is IDD_xxx_DIALOG_WIDE.
Anybody can tell me why VS create 2 dialogs?
And carelessly, I put some controls in IDD_xxx_DIALOG_WIDE, I found in the property view of the control, when I cliked event icon, the event view was empty.
|
|
|
|
|
See if this helps.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
In a dialog I had replaced an CListBox with CListCtrl ... the old CListBox had used SetItemDataPtr, to store a CMyObjects pointers ... but CListCtrl does not have not such a thing (CListCtrl::SetItemDataPtr, only CListCtrl::SetItemData) ... how can I store an object pointers into CListCtrl ? Is it posible ?
modified 2-May-13 8:57am.
|
|
|
|
|
You can store 'pointers' with SetItemData() .
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Pass the pointer value to SetItemData by type casting it to DWORD_PTR .
When reading it back you will need to type cast it back to the original pointer type.
|
|
|
|
|
Thank you so much for your answers (both of you), I will try that right away and tell you what I've done ... but it came into my mind a question ... if I could store pointers into SetItemData(...) , why CListBox does have SetItemData and SetItemDataPtr ... it is not a kind of redundancy ?
|
|
|
|
|
Flaviu2 wrote: but it came into my mind a question ... if I could store pointers into SetItemData(...) , why CListBox does have SetItemData and SetItemDataPtr ... it is not a kind of redundancy ? Doesn't SetItemDataPtr() internally cast and call SetItemData() ?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I think that you are right ... thanks !
|
|
|
|
|
Does function well ... Thanks !
|
|
|
|
|
Dear All,
I'm new to C++\ MFC so I hope my questions are easy to answer.
I tried to add a user defined message-handler to an CDialog derived class by adding the following:
1. defining a message
#define WM_UPDATE_UI WM_USER+1
2. declare method
afx_msg LRESULT OnUpdateUI(WPARAM wParam,LPARAM lParam);
3. extend message map
BEGIN_MESSAGE_MAP(CMyDialog,CDialog)
...
ON_MESSAGE(WM_UPDATE_UI,&CMyDialog::OnUpdateUI)
END_MESSAGE_MAP
4. handle message
LRESULT CMyDialog::OnUpdateUI(WPARAM wParam,LPARAM lParam)
{
return 0;
}
Because of the message map entry i recieve the 14 errors:
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2143: syntax error : missing '}' before ';'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2143: syntax error : missing '}' before ';'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2143: syntax error : missing ';' before ','
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2059: syntax error : ','
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2143: syntax error : missing ';' before '{'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2447: '{' : missing function header (old-style formal list?)
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2059: syntax error : '}'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2653: 'TheBaseClass' : is not a class or namespace name
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2065: 'GetThisMessageMap' : undeclared identifier
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2065: '_messageEntries' : undeclared identifier
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2059: syntax error : 'return'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2059: syntax error : '}'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(40) : error C2143: syntax error : missing ';' before '{'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(40) : error C2447: '{' : missing function header (old-style formal list?)
I really don't know the error, please help!
Thanks in Advanced.
|
|
|
|
|
I can't see anything seriously wrong in the posted code. So the error may be also somewhere else (probably in a line before number 33 in mydialog.cpp). A possible error source is forgetting the trailing semicolon after the class declaration:
class CMyDialog : public CDialog
{
};
I have some more notes:
You should always use parentheses with definitions and macros:
#define WM_UPDATE_UI (WM_USER+1)
The afx_msg prefix is not necessary:
LRESULT OnUpdateUI(WPARAM wParam,LPARAM lParam);
In the message map, just pass the function name:
ON_MESSAGE(WM_UPDATE_UI, OnUpdateUI)
|
|
|
|
|
Oh my goodness!
you're right, it is caused by a semicolon before class definition.
So of course now the error message makes sense.
Sorry for wasting time 
|
|
|
|
|
Thank you for your feedback.
Such mistakes happen (even to me after years of programming). When forgetting the semicolon at the end of a header file, the error is thrown at the first semicolon in the next file which might be another header file or the source file. If you remember this and get such a bulk of messages the next time, you will probably know where to look first.
|
|
|
|
|
Looking at some of those messages they do not look like they are connected to the code you posted. Show us the content of lines 1 to 40 of e:\projects\dummyactivex\dummyactivex\mydialog.cpp.
Use the best guess
|
|
|
|
|
It seems that one of the major obstacles in developing a real application is lack of understanding of one of the fundamental language features – in this case C preprocessor. Majority of coding articles posted here ignore such details.
I am sure this can be applied to any C derivative - C++, C# and other languages.
I think I got the basics, but would like to know how compiler applies stuff like “dependencies” , settings – preprocessor “additional includes” and “Options – directories”.
Of course I am using VS/VC 6.0 terminology and it will be different in later VS IDE's
Any educational commentaries are much appreciated. References, links etc would be great.
And after this discussion is done, I'll ask about usage of #pragma – I am currently using it to stop the compiler when there are too many initial error. Crude but works for me.
Appreciate your time.
Cheers Vaclav
|
|
|
|
|
Vaclav_Sal wrote: would like to know how compiler applies stuff like “dependencies” , settings – preprocessor “additional includes” and “Options – directories”. It doesn't, these are merely convenient ways of indicating how your source code should be compiled, and all are used by Visual Studio to build the command and options used to invoke the compiler. The preprocessor reads the source file, expands #include d sources and macros, and passes the resulting source to the actual compiler. You can set options in VS to get the output of the preprocessor saved to a file.
Vaclav_Sal wrote: And after this discussion is done, I'll ask about usage of #pragma You will find all information on pragmas at http://msdn.microsoft.com/en-us/library/d9x1s805.aspx[^]. And for general information on Visual C++ see http://msdn.microsoft.com/en-us/library/ty9hx077.aspx[^]
Use the best guess
|
|
|
|
|
Thanks Richard,
in VS\VC 6.0 there is an *.opt file which comes from "Options".
(For now I forgot how to get to the compiler command line itself.)
An easy way to change path used during development at once, I am using plain Notepad.
I have not found a way to do it in IDE itself.
Acually this post was promted by me being curious if the sequence of "includes" in Option setting matters. I guess I shall test that after I get my app to work again - my XP crashed!
Thanks for your time.
Vaclav
|
|
|
|
|
I'm afraid it's quite a few years since I used VC 6, and it was quite different in many ways from the Visual Studio versions. However, you should be able to check and see all the various items by using the Project -> Properties link in the solution explorer.
Use the best guess
|
|
|
|
|
Yes, and I think I also remember that the command lines (or at least the parameters for the current settings) for the compiler and the linker were shown in the property window.
Sent from my BatComputer via HAL 9000 and M5
|
|
|
|
|
Yes, I think it was the last item in the property tree for each command, same as the more modern versions.
Use the best guess
|
|
|
|
|
Vaclav_Sal wrote: I think I got the basics, but would like to know how compiler applies stuff like “dependencies” , settings – preprocessor “additional includes” and “Options – directories”.
The phases of translation during program compile are described here[^].
Information about #pragma is compiler specific. The info for Visual Studio can be found here[^].
--
Harvey
|
|
|
|
|
Thanks, very good link. Appreciate that.
|
|
|
|
|
Vaclav_Sal wrote: It seems that one of the major obstacles in developing a real application is lack of understanding of one of the fundamental language features – in this case C preprocessor.
That isn't true.
Vaclav_Sal wrote: I am sure this can be applied to any C derivative - C++, C# and other languages.
It doesn't apply in the same way to C# as it does to C/C++.
Vaclav_Sal wrote: I think I got the basics, but would like to know how compiler applies stuff like “dependencies” , settings – preprocessor “additional includes” and “Options – directories”.
I suspect you are confusing how '#include' resolves stuff versus how similar looking but substantially different idioms work in C#.
Vaclav_Sal wrote: I am currently using it to stop the compiler when there are too many initial error.
Eventually you should stop doing that.
|
|
|
|