|
Dear Holguin:
I must be knowing the display orientation, so that I can process the absolute coordinate to windows desktop.
The Enumdisplaysetting api returns display orientation with different graphic in xp, but same result in win 7.
Does anyelse method to judge the display orientation?(same degree, different graphic, but same result)
best regards, Victor
|
|
|
|
|
cedricvictor wrote: so that I can process the absolute coordinate to windows desktop
This shouldn't matter because coordinates in Windows are always with zero,zero being in the top, left corner of the screen. Whether a screen is rotated 90 degrees to one side, or 270 to the other, you get the same origin reference point (top,left).
|
|
|
|
|
While true, the documentation states "measured clockwise". Provided the user has turned the monitor the same direction using both vendor's drivers, one of them is clearly wrong.
Does WHQL still exist? If so, perhaps Microsoft would like a ping "Hey, you don't check this!".
|
|
|
|
|

modified 2-Jan-15 9:16am.
|
|
|
|
|
Are you and Scholar247 the same person? If so please request removal of one profile.
As to your questions:
- This site does not provide code to order. Google is the place for samples.
- The consequences of a race condition may vary from incorrect results, to a program not responding.
- There are many different situations when this may be appropriate, but it depends on the problem to be solved.
- Impossible to answer as any problem's ease of resolution depends on a lot of factors.
|
|
|
|
|
int g_x = 0;
DWORD WINAPI Add(void* p) //p unused parameter
{
g_x++;
}
void main()
{
HANDLE m_hArr[10];
int i = 0;
for( ; i < 10; i++ )
{
CreateThread( NULL,0,Add,NULL,0,&m_hArr[i]);
}
//Wait for all the 10 threads to complete its execution
::WaitForMultipleObjects(10,m_hArr,TRUE,INDEFENITE);
//Now print the result.You expect 10 but it may not be...
cout<<"g_x = "<
|
|
|
|
|
Because the order of the execution.
Suppose you have 4 floats a,b,c,d
and you want to sum up them.
In case of serial implementation, it will be like a + b + c + d
But in case of parallel, it may execute like
(a+b) + (c+d)
So the result wont be same.
This answers your 4th question.
|
|
|
|
|
2. Consequence of race condition:
Your resource will go to a corrupted state.
Not getting the expected result etc.,
|
|
|
|
|
:
modified 2-Jan-15 9:24am.
|
|
|
|
|
Your question is not clear. What is the connection between mult-threading and rounding errors?
|
|
|
|
|
Richard MacCutchan wrote: What is the connection between mult-threading and rounding errors?
His homework question?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks, I'm not an expert in rounding, but I will stand a round (or around).
|
|
|
|
|
Overheard many years ago that "C is strongly typed language".
So what's up with unspecified / unknown "standard definition " of int abs (int) overloaded by , again unknown source "standard", to <b>float abs ( float)</b>?
Is it just "progress" AKA from plain C to C "whatever is latest derivative of it" or just plain lack of real standards ?
Happy coding in 2015
Cheers Vaclav
|
|
|
|
|
|
Sorry I did not specifically say "C++".
I should have said "is C++ ( and derivatives ) strongly typed " to make the question clearer.
Maybe the question is just irrelevant with overloading, thus academic as I said in title.
Cheers Vaclav
|
|
|
|
|
Exactly, you said "Overheard many years ago that "C is strongly typed language".", and went on to talk about overloading. I responded that it (overloading) was not C it was C++. So I apologise that my answer was not very clear.
|
|
|
|
|
I should have said "is C++ ( and derivatives ) strongly typed "
No need. You just mixed concepts when including overloading - that's like comparing apples with the act of driving a car.
So restricting the question to C, it is indeed a strongly typed language, but in some instances not entirely strict about it. C++ is stricter.
For further reading, see f.ex. this wikipedia page.
|
|
|
|
|
How does one arbitrarily enable or disable a button on the Ribbon bar?
The OnUpdateCommand handler only allows you to specify a change in response to a button-click. But I want to enable or disable the button from elsewhere in the program.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Thanks for your response.
That macro allows me to add an OnUpdateCommandUI handler which gets called right after the button is clicked.
But how does it allow me to do something like ribbonButton.Enabled(FALSE); NOT in response to a button click?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I guess it's just a matter of creating a function that can enable or disable the button, something like:
void EnableButton(CMFCRibbonButton& ribbonButton, bool bEnable)
{
ribbonButton.Enable(bEnable);
}
or better still, a function that enables/disables all the buttons based on a set of rules ...
void EnableButtons(int nRule, bool bEnable)
{
switch (rule)
{
case 1:
ribbonButton1.Enable(bEnable);
ribbonButton2.Enable(bEnable);
break;
case 2:
ribbonButton1.Enable(bEnable);
ribbonButton6.Enable(bEnable);
ribbonButton7.Enable(bEnable);
break;
}
}
You then call this function from elsewhere in response to some arbitrary decision of your own.
|
|
|
|
|
Now you've hit upon the exact problem: The CMFCRibbonButton does not have an "Enable" method, or any method like it, hence my dilemma.
Thanks again for your time.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
I hear what you're saying, but that IsDisabled() property is read-only. And the SO question you link to says basically what we already know about the MFC macros.
That's why I can't figure this out.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Sorry nor can I. But given what I said about Word and the SO question, it must be possible. Unfortunately it is too many years since I used MFC in anger so I can't even try a few things. I wonder where all the CodeProject MFC experts are?
|
|
|
|