|
Hi,
As far as I can see in your example any string will go into the if code.
ie
"Cancelled by User" != "Sent" .... therefore it goes into if (the first test)
"Sent" != "Cancelled by User" .... therefore it goes into if (the second test)
"Anything else" != "Sent" ........ therefore it goes into if (the first test)
I think you may need to brush up on your or and ands, then try again!
Happy coding,
Ali
|
|
|
|
|
thanks for that, but that makes no sense at all.
|
|
|
|
|
It might be better to treat it as a truth table - Alison is right.
treat a as your first string check, eg:
bool a = (str != "Whatever");
treat b as your second one:
bool b = (str != "Something else");
then you have (effectively):
if(a || b)<br />
{<br />
}
So if str is "Whatever", then a == false, but b == true, so (a || b) == true as well, and so it goes into the if
If str is "Something else", then a == true, b == false, so (a || b) == true again, so it goes into the if
If str is any other string, then a == true, b == true, so (a || b) == true, and so it goes into the if.
What you probably want is:
if( (str != "Whatever) && (str != "Something else") )<br />
{<br />
// do stuff.<br />
}
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
The statement:
if((str_Status != "Sent" || (...))
is always true because you said you set str_Status to "Cancelled by User".
Art
|
|
|
|
|
If I understand it correctly, you don't want it to run the block of code if status = "sent" or "cancelled by user". Try doing the following if statement:
if (!((str_Status == "Sent") || (str_Status == "Cancelled by User")))
If it's equal to "Sent", then it returns false
If it's equal to "Cancelled by User", then it returns false
If it's equal to "Anything else", then it returns true.
Hope this helps,
Tim
|
|
|
|
|
Step through the != operator code (F11 in the debugger) to see the logic flow. First it tests str_status != "Sent" . Since str_status is, in fact, not equal to "Sent" , the left side of the || is true. Since || short-circuits in C, the || evaluation immediately stops and returns true . Since the if test is true , the block of code following the if runs.
What you want is
if ( str_Status != "Sent" <font color=red>&&</font> str_Status != "Cancelled by User") && not ||
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.
-- Michael P. Butler in the Lounge
|
|
|
|
|
In an or test || if the first condition is true the second conditon is not even tested for, thus in your
if ((str_Status != "Sent") || (str_Status != "Cancelled by User"))
(str_Status != "Sent") is true so the if statement is executed. Just use (str_Status != "Cancelled by User") as the sole condition.
|
|
|
|
|
Hi,
Could anyone tell me how could I implement opening a folder as seen on some of the CD setup, such as Browse CD (MFC).
.
Thank you,
Mariusz
|
|
|
|
|
Do you mean, how to make a window automatically pop up when inserting a CD disk into the CD-drive, then
1.Add a file in your CD's root folder named: autorun.inf
2.Set it's content to
[AutoRun]
open=folderonyourCD/yourexetoberun.exe
icon=folderonyourCD/yourexetoberun.exe,3
Peter Molnar
|
|
|
|
|
In case that some of the buttons' captions (or other resources)of a dialog application have been changed - is it possible at runtime to set all the resources to their original names/values? I tried with AfxSetResourceHandle(), but nothing happened. Any suggestions how to do this? Thanks.
|
|
|
|
|
I assume you used a dialog template to create your dialog ?
Now, mostly all (if not all) controls you place on this template are NOT resources, but control windows. The button is not a resource; it is a window with "Button" class and a title it displays on it as it's caption. If you use an icon or a bitmapped button, then those resources are bound to the button: a window with a bound resource that is drawn to it.
So, once more: the dialog template is a resource, but the controls placed there are not. The template just specifies what controls are placed and where. The Framework will worry about creating these controls and placing them. Consider the template like a drawing plan.
If the captions of buttons have changed, it is possible to change them back by using GetDlgItem and specifying the ID as parameter. If you convert the return value to CButton* , you can use the 'SetWindowText' method of the class to set the button's caption.
Hope this helps. If it doesn't, I suggest you dig up the infamous 'Programming Windows' book by Charles Petzold. This should help you get started by first introducing you to the concept of resources: what and where they are and how they are used in a Windows environment.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
OK, thanks! But I was trying to avoid using GetDlgItem and SetWindowText functions. What I was asking was is it possible to load the default values (caption, size and so on)as they are defined in the *.rc file? Let's say the captions of some button or static controls have been changed (using 'SetWindowText'). Is it possible at runtime to restore the original values as they are defined in the *.rc-file? I mean to load them directly from this file? I can't get Petzold's book and that's why I'm asking here. By the way, is it available somewhere on the net as eBook?
Greetings -J.
|
|
|
|
|
How to get CMenu* for the menu loaded with the document (IDR_xxxTYPE resource) in a MDI app?
|
|
|
|
|
Call AfxGetMainWnd()->GetMenu();
|
|
|
|
|
Rejeesh.T.S wrote:
Call AfxGetMainWnd()->GetMenu();
thanks for your answer, but:
with this you get the default menu. This menu is shown when no document is open. (IDR_MAINFRAME)
I want to get the shared menu loaded by the framework if a document is loaded (IDR_xxxTYPE)
|
|
|
|
|
You need to access it through the relevant CDocTemplate object registered in InitInstance.
If your doing this in a document object, you can use GetDocTemplate()->m_hMenuShared. If you need to access it from elsewhere, you need to use the undocument class CDocManager through the CWinApp:m_pDocMan(ager) pointer. Use the GetFirstDcoTemplatePosition() and GetNExtDocTemplate() iterator functions.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
Hello,
I'm curious about what date type is a HANDLE? Is it an int pointer? Thanks.
|
|
|
|
|
Not exactly a pointer,it just a handle,you can take some operation on it or with it
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Hello ,
As I know from Inside Win2k, when a process creates or opens an object(object is almost everything in Windows ) by name, it receives a handle that represents its access to the object. This is
like a secure pointer taken from OS.
**Object is symbolic link, process, thread, job, section, event, semaphore and ...
|
|
|
|
|
I spoke wrong. I mean literally what is it in terms of size. For example, DWORD is really a 32-bit unsigned integer. I'm trying to read some data that contains HANDLE type in a structure. I'm reading it over in a UNIX app. I have no use for the HANDLE, but my sizing will be wrong if I ignore it.
|
|
|
|
|
me think a HANDLE is the same size as a pointer; so 32 bits.
look into winnt.h
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
How about sizeof(HANDLE) ?
|
|
|
|
|
I think this will give you clear answer !
typedef void *PVOID;
....
#ifdef STRICT
typedef void *HANDLE;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#else
typedef PVOID HANDLE;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
typedef HANDLE *PHANDLE;
** This is taken from WinNT.h
|
|
|
|
|
HANDLE is unsigned long (DWORD). It is like a pointer because it is unique, but it is hashed to some pointed in memory. Windows manages the memory and this can be shifted and moved around to prevent memory fragmentation, but the HANDLE remains the same.
J.
----------------------------
|
|
|
|
|
I have tryed to make a little program, it should load its String from a XML file created like this.
<br />
<DATABASE version="1"><br />
<ACCOUNT id="98">FreeGeG</ACCOUNT><br />
</DATABASE><br />
how do i load that file into my Program, so i can use them at Strings?
Thanks
|
|
|
|