|
Such scrollable menu is bad design. Users really dont like it. You should avoid it.
Use spy++ to look for details...
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have a Visual Studio 2008 C++ CLR Windows Form application. The Windows Form has a Timer (timer1), a Status Strip (statusStrip1) which has a label (toolStripStatusLabel1) and a Text Box (textBox1). I am trying to display the local system time (localtime_s) in the Status Strip label (toolStripStatusLabel1). I enabled the Timer (timer1) and added the Timer function time1_Tick) to the Load event of the Windows Form. The application complies with no compiler or link errors. I also inserted some debug code to show the local system time in a Text Box (textBox1) to confirm that the local system time is working. It is. However, the local system time never appears in the Status Strip label (toolStripStatusLabel1). How do I fix this? Please be gentle. I am learning Visual C++. Here is the code:
private:
System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
time_t t = time(NULL);
tm s;
localtime_s(&s, &t);
String^ str = " ";
if (s.tm_hour < 13)
str = "AM";
else
str = "PM";
System::Windows::Forms::StatusStrip toolStripStatusLabel1;
toolStripStatusLabel1.Text = String::Format("{0}:{1}", s.tm_hour,
s.tm_min, str);
textBox1 -> Text = String::Format("{0}:{1} {2}", s.tm_hour,
s.tm_min, str);
}
|
|
|
|
|
I think you may need to force a refresh of your form to get the toolStripStatusLabel to repaint itself. Silly, I know, but ...
|
|
|
|
|
I simplified the code for getting the local system time and added a refreseh for the form, but it still isn't showing the local system time in the Status Stril Label.
<br />
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)<br />
{<br />
DateTime^ thisDate = DateTime::Now;<br />
System::Windows::Forms::StatusStrip toolStripStatusLabel1;<br />
toolStripStatusLabel1.Text = String::Format("{0:t}", thisDate);<br />
Form1::Refresh();<br />
}<br />
|
|
|
|
|
spicture wrote: System::Windows::Forms::StatusStrip toolStripStatusLabel1;
toolStripStatusLabel1.Text = String::Format("{0:t}", thisDate);
I think I see what may be wrong; you are creating a temporary System::Windows::Forms::StatusStrip and setting its text, but it is not a child of your form. You need to update the status strip that is defined on your form.
|
|
|
|
|
Thank you. I finally got it. Here is the code.
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
DateTime^ thisDate = DateTime::Now;
System::Windows::Forms::StatusStrip toolStripStatusLabel1;
Form1::toolStripStatusLabel1 -> Text = String::Format("{0:f}", thisDate);
}
|
|
|
|
|
Thnak you. I fianlly gor it. Here is the code.
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
DateTime^ thisDate = DateTime::Now;
System::Windows::Forms::StatusStrip toolStripStatusLabel1;
Form1::toolStripStatusLabel1 -> Text = String::Format("{0:f}", thisDate);
}
|
|
|
|
|
spicture wrote: System::Windows::Forms::StatusStrip toolStripStatusLabel1;
This line is redundant; you are creating a temporary object but never using it.
|
|
|
|
|
Instead of time, if you put a fixed text string in there, does it show?
|
|
|
|
|
Yes. If I added text to the Status Strip Label's property it shows when the application is run. I have simplified how to get the local system time, but that has not helped.
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
DateTime^ thisDate = DateTime::Now;
System::Windows::Forms::StatusStrip toolStripStatusLabel1;
toolStripStatusLabel1.Text = String::Format("{0:t}", thisDate);
textBox1 -> Text = String::Format("{0:t}", thisDate);
}
|
|
|
|
|
Thank you. I finally got it. Her is the code.
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
DateTime^ thisDate = DateTime::Now;
System::Windows::Forms::StatusStrip toolStripStatusLabel1;
Form1::toolStripStatusLabel1 -> Text = String::Format("{0:f}", thisDate);
}
|
|
|
|
|
here is the code:
int _xC,_yC;
void OnMouse(int button, int state, int x, int y)
{
int xMax = glutGet(GLUT_WINDOW_WIDTH);
int yMax = glutGet(GLUT_WINDOW_HEIGHT);
_xC = x;
_yC = yMax-y;
}
with this code , left click get xC and yC.
use this, i want to make Point array to save x-axis and y-axis of point which is defined by left click by Onmouse code.
but how to stop???
can i use right click or double click to break ???
|
|
|
|
|
hi all,
i am creating an application in which i want to write the content into an excel.
i have two doubts here.
doubt #1
i am actually using CFile.write function to write data into an excel. but,if i happen to write second time into the excel, it is overwriting the first item instead of appending it to the excel as second item. what should we do for this?
myfile.Open("example.xls",CFile::modeCreate|CFile::modeWrite, NULL);
myfile.Write(sUserID,sUserID.GetLength());
doubt #2
while writing in an excel, i have got three parameters to be written. (name,age and sex). all these three parameters are written in one cell. how to write them in a separate cells?
Thanks for your help in advance..
Rakesh.
|
|
|
|
|
Sounds like you need to move the file pointer on after the write. There's probably a method of CFile to do this, just pass it the GetLength() value. If you don't the pointer stays pointing to the 0 position in the file so the next write will overwrite the previous.
|
|
|
|
|
hi jonathan,
thanks alot for your reply..
can u please teach me how to pass the pointer using the getlength method?
thanks once again for patiently replying..
rakesh.
|
|
|
|
|
|
The file pointer gets updated automatically on a read or write operation. The next write to the same file will be positioned after the first write's data.
|
|
|
|
|
Rakesh5 wrote: CFile::modeCreate
You are recreating the file each time with new content using that flag.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
After you open the file, use the SeekToEnd function:
myfile.Open("example.xls",CFile::modeCreate|CFile::modeWrite, NULL);
myfile.SeekToEnd();
myfile.Write(sUserID,sUserID.GetLength());
I can't say that I've ever seen anyone use CFile to write to an excel file, so I'm not sure how you're accomplishing that. Most people would write the data to a .csv file, which can then be opened in excel. Each cell data on the same line would be separated by a comma, with a CR/LF pair at the end of that line.
I don't think you're actually creating a true .xls file - it's most likely just a text file, but with the .xls extension, excel may be able to open it.
Be aware that just because you name a file with .xls as an extension, it's not really an Excel file.
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
|
|
|
|
|
hi,
thanks alot for your info..
i tried using seektoend function. but it is still overwriting the value..
can u please help me to solve this problem?
and i don understand how to write each value in each cell? can u explain me little more?
thanks,
rakesh.
|
|
|
|
|
CFile is not the right object to work with excel. Presently what you are doing is, creating a text file with name "example.xls" and writing/overwriting its data.
Maybe using "modeAppend" may help you to get away with the overwriting issue. But still may not serve your purpose.
To modify an "real" excel file, or creating a new excel you need to use Excel . Microsoft provides a way to start excel.exe invisible through your program and then open an existing/create_new excel file and make changes to it. This is called Excel Automation/Office Automation.
http://support.microsoft.com/kb/196776[^]
Suhredayan
|
|
|
|
|
In addition to the Excel Automation suggestions, you could also try using CRecordset with Excel's ODBC interface.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I you'd prefer the text format over the CRecordset/Automation approaches, you could use a tab character ("\t") or a comma to separate the cells, and a newline to separate the rows. If you only use the CFile::modeCreate flag when opening the file, the file gets truncated to zero length, effectively overwriting your data. Have a look at CFile::modeNoTruncate . Something like this:
CFile theFile;
theFile.Open(_T("example.txt"), CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite, NULL);
CString strOut = _T("Row1Col1\tRow1Col2\tRow1Col3\r\nRow2Col1\tRow2Col2\tRow2Col3");
theFile.Write(strOut, strOut.GetLength() * sizeof(TCHAR));
Note how the file name extension is "txt", you can still open it in Microsoft Excel by right-clicking it. Or you could keep the "xls" extension and keep pretending it's a real binary Excel file. No user will ever notice
|
|
|
|
|
1. FILE * pFile;
pFile = fopen ("C:file.csv","a");
if (pFile!=NULL)
{
CString x2 = "CString1"+","+"CString2"+"\n";
fwrite(x2, x2.GetLength(), 1, pFile);
fclose (pFile);
}
2. Use ,(comma) operator for seperate the objects. use .csv file. it will open in excel.
G.Paulraj
|
|
|
|
|
if it can, show me how to use, please !!!
|
|
|
|