|
You are loading menu locally in the function that,s why its not affecting the changes.
make CMenu menuTst; member of class and load (VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));) somewhere like initdialog();
Sudhir Kumar
|
|
|
|
|
Hmm..unfortunately making the CMenu variable member of the class didn't seem to work either. I tried adding an ON_UPDATE_COMMAND_UI function for my menu item to try it in there, with no success!
void CTestDialog::OnUpdateOpenLogfile(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(0);
}
|
|
|
|
|
|
Hi all!
I wonder if there is a simple and safe way to find out the exact coordinates of the Windows Start Menu Button. I am quite familiar with Visual C++ and MFC and yes, I did look for a solution beforehand^^.
I need a robust solution that gives me the icon coordinates, even if the taskbar position is at the top or the side. I use Windows XP and VS 2005.
Thanks for any helping advice,
Christian
|
|
|
|
|
Try This code:
CWnd* m_Window = CWnd::FindWindow("Shell_TrayWnd","");
CRect rc;
m_Window->GetTopWindow()->GetWindowRect(&rc);
Sudhir Kumar
|
|
|
|
|
Hello Sudhir!
Uhh, what can I say? This is pretty much _exactly_ what I wanted! It even works perfectly if the taskbar is autohiding...
Big thanks to quick and helpful answer!
Christian
|
|
|
|
|
You are welcome.
Sudhir Kumar
|
|
|
|
|
|
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}
While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test<br />
Mohsin Ali
|
|
|
|
|
It is because UNICODE is defined. If you want a full understanding, a strongly suggest this article[^].
|
|
|
|
|
It happens because the project is built for UNICODE.
Sudhir Kumar
|
|
|
|
|
Then how can I change...
I mean what I have to do in order to remove this error..
Mohsin Ali
|
|
|
|
|
Use generic text mappings instead of using char arrays. This way if you want to enable UNICODE later on, your program will support it.
|
|
|
|
|
Sorry but I will complain about the answering style of some people.
For example in this question it is obvious that he is a newbie and facing a simple problem. But look at the answers to that simple question.
Its because you are in UNICODE...... is this the answer?
Think about the person expecting a solution : so what? What am I supposed to do? Where should I read?
Would not it be better if you answer it in such a way. (like the way toxcct did for example)
It's because of ......, You should try a code like ......, For more info you can read .... web page
At the top of the forum there is a default subject "How to get an answer to your question" and I think there should be another one "HOW TO ANSWER A QUESTION".
|
|
|
|
|
zafersavas wrote: Its because you are in UNICODE...... is this the answer?
Think about the person expecting a solution : so what? What am I supposed to do? Where should I read?
That would be a good enough clue for most. At this point, the OP simply needs to do this.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In build toolbar select Win32 Release or Win32 debug.
Sudhir Kumar
|
|
|
|
|
Use of this MessageBox(NULL, _T("This is my first windows program\n Author: Mohsin"), _T("Virtual University"), ...
|
|
|
|
|
Did you got any success with these replyes.
Sudhir Kumar
|
|
|
|
|
change you code into the following. and in a general mean, always use _T() around you literal strings to avoid to matter whether Unicode is defined or not :
#include "stdafx.h"
#include "windows.h"
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MessageBox(
NULL,
<code>_T(</code>"This is my first windows program\n Author: Mohsin"<code>)</code>,
<code>_T(</code>"Virtual University"<code>)</code>,
MB_OK|MB_ICONINFORMATION);
}
|
|
|
|
|
What is the difference b/w Unions and Structures...
Mohsin Ali
|
|
|
|
|
Basically the members of a union share the same memory address (while the members of a struct have distinct memory addresses).
The above implies, for instance:
union MyUnion
{
int i;
float f;
};
struct MyStruct
{
int i;
float f;
};
void main()
{
MyUnion u;
MyStruct s;
u.i = 5;
s.i = 5;
}
and, conceptually, sizeof(MyStruct)=sizeof(int)+sizeof(float) while sizeof(MyUnion)= max(sizeof(int), sizeof(float))
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
|
|
|
|
|
With unions all members start at the same base address so they overlap. With structures, the members are "stacked", i.e. each one starts in the byte after the previous one ends.
|
|
|
|
|
Alan Balkany wrote: each one starts in the byte after the previous one ends.
Too specific to be the right answer for this newbie. One poster said "conceptually" the sizes of the members sum, which is correct *CONCEPTUALLY*.
We should probably point out to the original poster that in a structure, the compiler is free to add padding after ANY member (including the last member) to insure the members align correctly. That is, a structure may contain unused bytes that are there only for alignment.
struct example{
char c;
long l;
};
printf( "sizeof(example) = %d", sizeof(example) );
In most compilers, this will NOT print "sizeof(example) = 5" as might be expected, since the compiler must put padding after c to insure that l aligns properly. In most modern compilers this will likely print "sizeof(example) = 8".
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
question before answering : did you bother searching the web/docs/msdn/google/whatever before asking that dumb question asked and answered tons of times ?
the difference between unions and structures (and classes if in C++) is that all the members of the union share the same memory address. in other words, it means that they all start at the same address, and them, it also means that the size of the union equals the size of its largest member.
so, the other question which usually comes after such an answer is : "but what can it be used for, then ?".
good question Sherlock.
in fact, it's not used much in everyday programming, especially in management applications.
I used to use it when I was coding for hardware, when some component had to share the same physical address. so to represent such a material in the software, a union was exactly what was needed.
|
|
|
|
|
I think you are new to c++ so I suggest to see www.cplusplus.com and on that site you can see different union and other helpful info.
|
|
|
|