|
I need help on just re-writing this function I created to something else that also functions the same for a friend of mine to use. Here is the function code:
*These are just input parameters
NoErrors is a Bool: passed by reference
amp is an int: passed by reference
string g[]: an array
string key: just a string
void Check(string g[], int& i, bool& NoErrors, string key)
{
while(g[i].length()!=4) //Checks to see if it is 4 letters
{
g[i]="";
cout << "Please enter 4 colors!" << endl << endl;
cin >> g[i];
}
NoErrors = IsStringLike(g[i], "RGBCMYrgbcmy"); //Checks for right input
// The IsStringLike is a function I also have but that does not need to be changed
// If checks to see if the string is like the characters in "RGBCMYrgbcmy"
while(NoErrors == false && g[i]!="Fred")
{
g[i]="";
cout << "Please enter appropriate colors!" << endl << endl;
cin >> g[i];
NoErrors = IsStringLike(g[i], "RGBCMYrgbcmy");
}
//Fred Cheat - allows user to display the code before the game is over
if (g[i] == "Fred")
{
cout << key << endl << endl;
g[i]="";
cin >> g[i];
while(g[i].length()!=4) //Checks to see if it is 4 letters
{
cout << "Please enter 4 colors!" << endl << endl;
cin >> g[i];
}
NoErrors = IsStringLike(g[i], "RGBCMYrgbcmy"); //Checks for right input
while(NoErrors == false && g[i]!="Fred")
{
cout << "Please enter appropriate colors!" << endl << endl;
cin >> g[i];
NoErrors = IsStringLike(g[i], "RGBCMYrgbcmy");
}
}
} // End of function
This function is an error checking function and it checks for valid input in a game I'm creating. I hope that the comments in the code are suffice for you to understand what that particular part does. I just need to somehow alter this code and make sure it still does its basic function but written different. It's a little hard to alter something and make it work the same as the initial function. Please email me if you have any questions. Thanks for your time! I hope you can help.
|
|
|
|
|
Larry Park wrote: I just need to somehow alter this code
Alter it into what?
led mike
|
|
|
|
|
Rewrite it by yourself.
Follow these:
use vector instead of array.
<br />
void Check(vector<string> g, int& i,string key)<br />
{<br />
}<br />
btw, I dont understand a point here. If you already know the index, And if you are not making use of it like an offset, like i+n,i+n*2 and simply using [i], why do you send both index and the array to a separate function?
eg:
int nCheckItem = 3;
std::vector<std::string> vec_stCol;
//Assume you have 5 elements inside vec_stCol. You can make the checking function like :
<br />
if(check(vec_stCol[i],"mykey"))<br />
{<br />
. <br />
.<br />
}<br />
<br />
bool check(const string& stToBeCompared,const string& stCompareKey);<br />
<br />
use stToBecompared.Find() to check if the stToBeCompared string contains stComparekey in it.
Rest of the part, it's same, make use of find() algo.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
modified on Thursday, March 13, 2008 1:45 PM
|
|
|
|
|
Larry Park wrote: ...but written different.
French? RPN? Sans STL? If you wrote it, why can't you rewrite it? Please explain what the problem is.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok have to admit, for a potentially needy person your reply is more clearer than mine.
led mike
|
|
|
|
|
Geez, it's a friend - just give him the working function as-is!
I mean, he posted the code on a public message board - the new technology
has already been leaked
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: the new technology
has already been leaked
LMAO I am extremely grateful I did not have a mouth full of coffee when I read that email. Timing is priceless, for everything else there's mastercard.
led mike
|
|
|
|
|
I used it as a image/bitmap in a memory Graphics object.
When client resizes, it should be resized too.
Now I construct a new one every time, any effecient way by GDI+ ?
|
|
|
|
|
Just use a mapping mode like MM_ISOTROPIC or MM_ANISOTROPIC.
output the bitmap in logical coordinates(window) and the device context will automagically transform it to client coordinates(viewport).
It works pretty nice assuming you set everything up correctly.
|
|
|
|
|
followait wrote: When client resizes, it should be resized too.
just find the scale factor
when drawing the image use Matrix::Scale and Graphics::SetTransform or Graphics::ScaleTransform with the scale factor and draw the image.
followait wrote: Now I construct a new one every time
No need to construct every time client resizes.
|
|
|
|
|
There's also Graphics::DrawImage() methods that will stretch the image.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Although you can display a GDI+ Bitmap object at various sizes, the Bitmap class does not allow you to change the actual size of the Bitmap object itself. You do have to construct a new one.
Another note: you may be using a Graphics object in memory, but whenever you use a Graphics object based on a window, you have to construct a new Graphics object each time the window is resized.
|
|
|
|
|
Hi, I'm trying to add a custom header for every HTTP request of a IWebBrowser2 instance.
I known that the param Headers of the method IWebBrowser2::Navigate2 allows me to add custom headers but the problem is that it's valid only for the main request and it's not "propagated" for all the related requests of resources (for example).How can I hook every request and alter the headers?
Plz help!
|
|
|
|
|
berserker_r wrote: How can I hook every request and alter the headers?
DWebBrowserEvents2::BeforeNavigate2[^]
May be this is the hook you are looking for. Defining the event handler is implemented for CHtmlView in MFC source, have look at it or use CHtmlView and get the callback CHtmlView::OnBeforeNavigate2().
you can modify and reissue the request
|
|
|
|
|
Thanks for the reply
I have already tried with OnBeforeNavigate2 but it has the same behaviour of adding custom headers to Navigate2: you can handle only the "main request"...
Other ideas? plz help
|
|
|
|
|
Navigate2 you are calling as a main request, but as per the documentation (as i never tried beyond main request), the request that happens by internal or external automation or user clicking hyperlinks the BeforeNavigate2 will be called back.
First callback will be the main request, i hope will get further callbacks.
I don't know what you are saying about propagated request.
|
|
|
|
|
I want to get notified of every resources (images, css, js and so on...) of a page. BeforeNavigate2 notify me of only the "main request"
|
|
|
|
|
Hi,
I can display tooltips for controls like buttons, dialog etc..but not for CIPAddressCtrl variables!
ref Article: http://support.microsoft.com/kb/q141758 Any help?
Thanks
Vikas
|
|
|
|
|
For some strange reason, it will work if you hover over a dot but won't work if you hover over an octet (i.e., edit) field.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Hi,
I have an application(supporting multiple languages) in which I want to display the time with time marking. When I am running the application on an English OS(WinXP), it is showing the time in appropriate format(hh:mm:ss AM/PM). But when I am running the same application(French version) on an french OS(WinXP), it is showing the time without any AM/PM marking.
I am using the GetTimeFormat() function for the purpose, with appropriate picture string("hh':'mm':'ss tt") and locale set as LOCALE_SYSTEM_DEFAULT and dwFlags set to NULL. Still it is showing the same date format in French OS(without AM/PM).
Please Solve my query.
Thanks and Regards,
Purusottam Mishra
Purusottam Mishra
Software Engineer
|
|
|
|
|
CTime ddate;
ddate=ddate.GetCurrentTime();
iday=ddate.GetDay();
imon=ddate.GetMonth();
iyear=ddate.GetYear();
ihrs=ddate.GetHour();
imin=ddate.GetMinute();
isec=ddate.GetSecond();
sdatef.Format("%.2d%.2d%.4d_%.2d%.2d",imon,iday,iyear,ihrs,imin,isec);
|
|
|
|
|
opps I am sorry, i did not get ur question, i belive
|
|
|
|
|
As a reply to both previous posts, Month/Day/Year is a wrong format for French so GetTimeFormat() is the right way and it does return whatever the locale has set as the format. So quite possibly the French locale has 24 hour format while Enghlish one has 12 hour AM/PM one etc. In the end, if MS was correct then whatever you get is the correct form, you don't have to get AM/PM format, it's not the only "good" one.
|
|
|
|
|
If you have your time in a COleDateTime object, you can use the Format method.
CString Format(
DWORD dwFlags = 0,
LCID lcid = LANG_USER_DEFAULT
) const;
dwFlags
Indicates one of the following locale flags:
LOCALE_NOUSEROVERRIDE Use the system default locale settings, rather than custom user settings.
VAR_TIMEVALUEONLY Ignore the date portion during parsing.
VAR_DATEVALUEONLY Ignore the time portion during parsing.
lcid
Indicates locale ID to use for the conversion.
It returns a CString with the time already formatted for you.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|