|
You have to declre enum for the strings u want to use.
e.g.
enum {EVERY_MONDAY,EVERY_SUNDAY...}
enum {TWELVE_AM..}
then you can even write a function that will return the strings whenever required.
e.g
CString/char* GetDay(int iVal)
{
switch(iVal)
{
case EVERY_MONDAY:
return "EVERY_MONDAY";
}
...
}
inside code where ever you wan to use you can directly use EVERY_MONDAY...
and offciourse you have to give names to enum you will be creting.
I guess you have never used enums. may be you can read some help for regarding enums.
|
|
|
|
|
All you want to do is, display the time in the combo box.
How about using a loop and CString::Format() function in it to format and display it?
And then you can store all the formatted strings in array.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I am understanding that you want to achieve this with lesser lines of code. If I am right, then:
monsieur_jj wrote: SchedTime[0] = "12:00 AM";
SchedTime[1] = "1:00 AM";
SchedTime[2] = "2:00 AM";
SchedTime[3] = "3:00 AM";
SchedTime[4] = "4:00 AM";
SchedTime[5] = "5:00 AM";
SchedTime[6] = "6:00 AM";
SchedTime[7] = "7:00 AM";
SchedTime[8] = "8:00 AM";
SchedTime[9] = "9:00 AM";
SchedTime[10] = "10:00 AM";
SchedTime[11] = "11:00 AM";
SchedTime[12] = "12:00 PM";
SchedTime[13] = "1:00 PM";
SchedTime[14] = "2:00 PM";
SchedTime[15] = "3:00 PM";
SchedTime[16] = "4:00 PM";
SchedTime[17] = "5:00 PM";
SchedTime[18] = "6:00 PM";
SchedTime[19] = "7:00 PM";
SchedTime[20] = "8:00 PM";
SchedTime[21] = "9:00 PM";
SchedTime[22] = "10:00 PM";
SchedTime[23] = "11:00 PM";
for(timecount = 0; timecount<24; timecount++)
{
c_cbCombo2.InsertString(timecount, _T(SchedTime[timecount].c_str()));
}
You can use this instead of the above quoted code:
CString szTime;
for(int i=0; i<23; ++i)
{
szTime.Format(_T("%d:00 HRS"), i);
c_cbCombo2.InsertString(i, szTime);
}
where c_cbCombo2 is a control variable to the combo box of your interest. I am denoting time in 24 hrs format.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Nibu babu thomas wrote: http://blogs.msdn.com/vcblog/archive/2008/04/30/enums-macros-unicode-and-token-pasting.aspx[^]
This is definitely not the best way of doing things. I don't see any good reason to employ such an ugly solution when using C++. My opinion is that such a technique might look 'cool', but it makes the codebase look horrible, adds unnecessary bloat and makes it difficult to maintain the code in the longer run. Macro substitution is an extremely blind technique; it never cares for semantics or scope in the code. Stroustrup's advise in his book was to avoid macros as much as possible, in fact not to use it at all. And the C++ committee suggests the same too. If there might be a situation where Macros are the only efficient way to do something, I haven't encountered one such situation.
Add: [No, I am not down-voting you, but neither am I going to vote you up in this case]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
modified on Thursday, May 29, 2008 6:15 AM
|
|
|
|
|
monsieur_jj wrote: SchedTime[0] = "12:00 AM"; SchedTime[1] = "1:00 AM"; SchedTime[2] = "2:00 AM"; SchedTime[3] = "3:00 AM"; SchedTime[4] = "4:00 AM"; SchedTime[5] = "5:00 AM"; SchedTime[6] = "6:00 AM"; SchedTime[7] = "7:00 AM"; SchedTime[8] = "8:00 AM"; SchedTime[9] = "9:00 AM"; SchedTime[10] = "10:00 AM"; SchedTime[11] = "11:00 AM"; SchedTime[12] = "12:00 PM"; SchedTime[13] = "1:00 PM"; SchedTime[14] = "2:00 PM"; SchedTime[15] = "3:00 PM"; SchedTime[16] = "4:00 PM"; SchedTime[17] = "5:00 PM"; SchedTime[18] = "6:00 PM"; SchedTime[19] = "7:00 PM"; SchedTime[20] = "8:00 PM"; SchedTime[21] = "9:00 PM"; SchedTime[22] = "10:00 PM"; SchedTime[23] = "11:00 PM"; for(timecount = 0; timecount<24; timecount++) { c_cbCombo2.InsertString(timecount, _T(SchedTime[timecount].c_str())); }
You could shorten this a bit by trying something like:
for (timecount = 0; timecount<24; timecount++)
{
CString str;
int nHour = timecount % 12;
if (0 == nHour) nHour = 12;
str.Format(_T("%d:00 %s"), nHour, (nHour >= 12 && nHour <= 23) ? _T("PM") : _T("AM"));
c_cbCombo2.InsertString(timecount, str);
}
"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
|
|
|
|
|
DavidCrow wrote: str.Format(_T("%d:00 %s"), nHour, (nHour >= 12 && nHour <= 23) ? _T("PM") : _T("AM"));
nHour already wrapped to 12, so the checking might be with timecount,
(timecount>= 12 && timecount <= 23)
|
|
|
|
|
Rajkumar R wrote: ...so the checking might be with timecount,
Possibly. I didn't bother verifying this, just started typing.
"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
|
|
|
|
|
How to know whether our application is focused or not?
|
|
|
|
|
|
Have you looked at GetForegroundWindow() ?
"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
|
|
|
|
|
Can any body tell me How to get URL of current page?
How can I navigate automatically in a web page.
|
|
|
|
|
Your post is an example of "How not to ask a question". Please read the guidelines^ before you post anything further.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
|
sumit.durg wrote: Can any body tell me How to get URL of current page?
Can't you read it? it's always displayed in the address bar of the browser if you don't delete/modify it.
sumit.durg wrote: How can I navigate automatically in a web page.
Try clicking somewhere on the page with your mouse. You might hit a hidden URL
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi to all,
i am using date Timer picker control in my application
at the run time it is displaying current system time
But i want to display my own time , suppose system time is 05:08:07, but i want to display always 10:12:34
that i am doing by using SetFormat function, this function will set this string,
at run time it is displaying 10:12:34,
but the problem is this time is static , i want to modify this time by using up & down arrow ,,
but i can`t ,, arrow keys & up down click buttons are not working
how can i enable arrow keys for changing the time ?
varun
|
|
|
|
|
Here[^] is a very good control that allows you to edit date and time. However you may need to handle the UP/DOWN arrow keys to increment/decrement the date or the time.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
varun01 wrote: i want to modify this time by using up & down arrow ,,
On the keyboard? As long as the control has focus, and assuming you've done nothing to change the default behavior, the navigational keys should work.
"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
|
|
|
|
|
I have designed a program that acts like the oscilloscope. it uses Direct3D.
the problem is when the window of the program is deactivated or loses the focus, the program takes a big amount of cpu time. I don't know whats the problem.
Microsoft DirectX SDK samples also have this behavior.
|
|
|
|
|
most of the DirectX SDK samples have a Game Loop, a while loop for rendering scene, getting input, ... this loop tries to achieve maximum framerate (can be 500 fps) by repeating the task (rendering scene) in a loop, this can consume significant amount of CPU usage, you may try to avoid that processing to a reasonable framerate like 25 fps by inspecting correct framerate and do rendering when necessary. Even when the application is active, you may find significant CPU usage, when deactivate may be you are not rendering the scene making the Game Loop even tighter can cause more cpu usage. I suggest you to inspect the Game Loop and modify it.
|
|
|
|
|
Hello,
I have an application wherin there are a few classes in a dll and when I assemble the code I am getting this linker error.
TableFrame.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const BaseFrame::classBaseFrame" (?classBaseFrame@BaseFrame@@2UCRuntimeClass@@B)
What must be the problem?
Pritha
|
|
|
|
|
are you trying to use runtime calss macros or related functions with class which does not support RTTI (means calss which is not derived from CObject)
|
|
|
|
|
|
Hi,
I have an activeX control which is similar to a List control. When I rightclick on ActiveX control a popup menu appears with menu items suppress and unsuppress. When I press suppress the data in ActiveX control disappears and unsuppress will show the data in ActiveX control.. I am facing a problem.. When user presses Suppress and even before the data gets hidden from ActiveX control if user again presses the Unsuppress menu item then a error message is logged.. I want to handle this situation.. I think of setting a Waitcursor immediately after user presses SuppressAll.. But when I am unable to Set Wait cursor with the following code snippet.
HCURSOR hWaitCursor;
LoadCursor(NULL,IDC_WAIT);
SetCursor(hWaitCursor);
ShowCursor(TRUE);
or
AfxGetApp()->DoWaitCursor(1);
Can anyone suggest me how to set wait cursor in the above scenario..
Thanks
Venkat
|
|
|
|