|
|
How to add element to desktop's menu and to control this element from my MFC application?
|
|
|
|
|
I have this piece of code :
CString tmp;
int x = 1;
tmp.Format("%d,%d,%d",++x,++x,++x);
AfxMessageBox(tmp);
x = 1;
tmp.Format("%d,%d,%d",x++,x++,x++);
AfxMessageBox(tmp);
I always thought that output of this will look like this :
4,3,2 and 3,2,1.
But when i compile that in debug mode (no optimalisations) :
4,3,2 and 1,1,1
Release mode :
4,4,4 and 1,1,1
What's wrong ? Even if my assumptions was incorrect, i think that such trivial code should work by the same way in debug and release version.
Who knows the answer ?
(I use VC++ 6.0 with some service pack, i think
rrrado
|
|
|
|
|
rrrado wrote:
What's wrong ? Even if my assumptions was incorrect, i think that such trivial code should work by the same way in debug and release version.
Well, for me it does.
Your Problem is somewhere else, I think.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
What version do you use ? What are your results ?
rrrado
|
|
|
|
|
Both Times what you report for Debug version (4,3,2 and 1,1,1).
And I have VC++6.0 Professional, SP4 (I think, but definetly more than 3).
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
To the best of my knowledge, this is not a VC++ bug. First of all, the order of evaluation of parameters in a function invocation is unspecified, so hoping for 4,3,2 is as reasonable as 3,4,2 or whatever order. But, as you point out, this does not explain the 1,1,1 output and the difference between release and debug mode. The standard says with respect to the modification of values (¶5.4):
Between the previous and next sequence point a scalar object shall
have its stored value modified at most once by the evaluation of an
expression. Furthermore, the prior value shall be accessed only to
determine the value to be stored. The requirements of this paragraph
shall be met for each allowable ordering of the subexpressions of a
full expression; otherwise the behavior is undefined. [Example:
i = v[i++];
i = 7, i++, i++;
i = ++i + 1;
i = i + 1;
--- end example] In layman's words, you cannot increment the value of a variable more than once in a single expression: if you do so, any behavior can be expected, and VC++ is free to do different things depending on the debug/relase mode (it could even fail to compile and issue this as an error, which would be the most sensible thing to do).
If you're curious as to what's the reason behind this restriction, it probably helps compilers a great deal in optimizing scalar expressions.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
IMHO, it is probably a legacy issue where they can't agree on how it should work. Compiler vendor A says "X" while compiler vendor B says "Y". Both want to avoid having to modify their compiler.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
IMHO, it is probably a legacy issue
No offence, but your opinion and facts are disagreeing. The facts carry more weight.
Both C and C++ have the concept of sequence points. These are well-defined. If you modify something twice or more with no sequence point(s) inbetween those modifications, you are invoking implementation-defined behaviour. I.e. there's no way to tell what the outcome will be.
I believe the stated reason it's specified like this (or not specified, depending on how you look at it) is to allow optimizers to do their job by restructuring the code. And, indeed, non-optimized builds often just evaluates the expressions as-is, while an agressive optimizer generates machine code that bears little or no resemblance to the original source code.
|
|
|
|
|
I am doing an MFC program that needs to position some other windows during startup.
But the program starts maximized, however GetWindowRect() returns the non-maximized rect during the processing of WM_CREATE in OnCreate().
I know that SystemParametersInfo() can return the work area, but unfortunately that is not the same as the maximized window rect.
Is there a way to get that rectangle?
Or can you tell me what value(s) are the maximized windows offset by? Some borders on the sides? Which ones?
|
|
|
|
|
If you have no menu, or know that youe menu fits one line (yuck), you can use
GetClientRect
ClientToScreen
AdjustWindowRectEx
You can also use GetWindowPlacement to get the origin of the frame of the maximized window (it will be off-screen for a top level window!) But heed the "Remarks" section of the GetWindowPlacement documentation, and check your app with the taskbar moved to the left, or top!
Those who not hear the music think the dancers are mad. [sighist] [Agile Programming]
|
|
|
|
|
Thanks, but GetWindowPlacement() says that the maximized top-left corner coords are the same as normal position top-left coords
The MSDN page for it also says that the flags member retrieved is always 0, but it's 2 after I call it.. ???
|
|
|
|
|
??
I get sth. like
ptMinPosition = { -6, -25 }
rcNormalPosition = { 241, 417, ... }
(It's an MDI child, and I set wndplacement.flags = WPF_SETMINPOSITION; before I call, but that should not make a difference...)
WINDOWPLACEMENT wpabs;
wpabs.length = sizeof(wpabs);
wpabs.flags = WPF_SETMINPOSITION;
wnd.GetWindowPlacement(&wpabs);
Those who not hear the music think the dancers are mad. [sighist] [Agile Programming]
|
|
|
|
|
Ehh... ptMinPosition is the minimized position(whatever that would be for...), I need the ptMaxPosition, which is the same as rcNormalPositon's topleft corner for me.
|
|
|
|
|
Oops, sorry, that was jst a typo.
IIRC the min position won't be set only when the window is maximized.
What do you need this coordinates for? What kind of window (MDI child, top level)?
Those who not hear the music think the dancers are mad. [sighist] [Agile Programming]
|
|
|
|
|
Anyone got this error ?
Entry point not found
The procedure entry point__lc_collate_cp could not be located in the dynamic link library msvcrt.dll.
Why do I get this error ?
Thank you
|
|
|
|
|
Yes - The CString::Collate* group of functions is somehow not supported by Win95 SR1 and NT4 pre-SP4 systems.
Regards,
BB
|
|
|
|
|
Oh, that makes sense a little since it's a NT 4.0 SP3 and I thank you very much for this. Now, I didn't use any collate function but I did use concatenation functions and operators (especially +=) so I guess concatenation operators aren't supported either. So, I'll have to use char* ? This sucks.
Thank you anyway !
|
|
|
|
|
Link statically. The problem will go away, forever.
|
|
|
|
|
Suppose I have a shortcut named "ABC" (let's say its object is "C:\Program Files\foo\bar.exe", which is not known at coding time), how do you get this shortcut's object path and name in your C++ code? Thanks.
|
|
|
|
|
I you do not mind COM, you could use IShellLink
|
|
|
|
|
Hi All,
I'm trying to do simple aplication to read data from the serial port and put it into an excel spreadsheet. Acctually I'm not sure about what should I use. I rather use VC++.
Could you give me just some advice to wich way should I go?
Thanks in advance,
Igor Kondrasovas
|
|
|
|
|
hi,
check this link, here the author is converting CSV to excel this might be of some help to u..
http://www.codeguru.com/mfc_database/CSpreadSheet.html
cheers..
Himanshu
|
|
|
|
|
You can find an easy start to Excel and ODBC here. Have a look!
|
|
|
|
|
The easiest would probably be an Excel VBScript "macro" using the MSComm object for reading from serial device. (It's amazing how much you can do in this crude language/environment...)
Another option would be generating a .csv file (Comma-separated Values), which excel tends to open nicely (if lannguage settings are correct)
Those who not hear the music think the dancers are mad. [sighist] [Agile Programming]
|
|
|
|
|