|
Hi,
Im using dialog bar. Which has Only one CStatic ctrl.
Now i want to update the text(with current time) in the static ctrl on every second;
How can I achieve this.
Regards,
GAN
|
|
|
|
|
1. Create timer in the beginning of the application:
timer = SetTimer(1, 1000, NULL);
2. Add event ON_WM_TIMER()
void CMainFrame::OnTimer(UINT nIDEvent)
{
if (nIDEvent == 1)
{
// IDC_STAT is an ID of static controll
CStatic* cap = (CStatic*)m_wndDlgBar.GetDlgItem(IDC_STAT);
if (cap)
{
CTime t = CTime::GetCurrentTime();
cap->SetWindowText(t.Format("%d/%m/%y %H:%M:%S"));
}
}
CFrameWnd::OnTimer(nIDEvent);
}
3. At the end of the application don't forget to destroy the timer:
KillTimer(timer);
Nina
|
|
|
|
|
Hi nina
I wud like to make a suggestion (Objcet oriented way i think). it will be better if you write a function inside dialog bar like UpdateHelp(CString &str); and call it from MainFrame.
If u can Dream... U can do it
|
|
|
|
|
I am using this code:
FILE * pFile;<br />
char filename [100];<br />
<br />
pFile = fopen ("\\Settings\\temp.txt" , "rt");<br />
if (pFile == NULL) perror ("Error opening file");<br />
else <br />
{<br />
fgets (filename , 100 , pFile);<br />
fclose (pFile);<br />
}
to get a filename that another part of my program has written. However whatever I put in the text file my program reads 100 Í characters. Now when I open up the text file myself it shows exactly what I want, i.e. not that This is driving me slightly crazy so any help would be great.
P.S. If anyone wants the text file I am quite willing to e-mail it to you.
-- modified at 10:15 Wednesday 23rd August, 2006
|
|
|
|
|
You said another part of your program is writing the file?
Here are a few things to try:
- Initialize your string: char filename[100] = {0};
- Set the file cursor to the beginning explicitly: fseekg(pFile, 0, SEEK_SET);
- Make sure that the file is not currently open by the section of code that is suppose to be writing to it. You may be running into a race condition if you have 2 threads (for example) where thread 1 is writing to the file, but thread 2 is already trying to read from it before the write is complete.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Right, I have made sure that the other program isn't writing to the file. Initializing the char just results in the program returning a blank string. Using fseek doesn't seem to make any difference. Do you think it could be a problem with the format of the file?
|
|
|
|
|
stevelam wrote: Initializing the char just results in the program returning a blank string
That means that fgets isn't reading in anything for some reason. Check its return value to see if it is getting an error.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Ever tried with:
pFile = fopen ("\\Settings\\temp.txt" , "r");
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
|
How do you it returns only a bunch of Ì ? Is this in the debugger ?
Because the snippet you've provided is almost the example of the use of the fgets function in the MSDN, and it should work properly.
Have you tested it with another temp file ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Right OK, I've found it, in the part of my program that wrote first there were some errors that corrupted the file. All is now working again, thanks for all of your help.
|
|
|
|
|
stevelam wrote: fgets (filename , 100 , pFile);
chage that to
if( fgets (filename , 100 , pFile) == NULL )
{
//ERROR
}
this prevent your prog from crashing.
there is nothing wrong with that part of your code the file could have been created in binary mode.
the buffer in this case filename could be currupted after the read op.
G_S
|
|
|
|
|
what don't you do that in a C++ way ?
STL is full of good things you know
|
|
|
|
|
hi,
Can anoboby tell me What are the differences in the debug mode & Release mode in details. what book i should refer to get good grip on this
|
|
|
|
|
debug mode should be used only for developement and debugging.
release mode is what you must use to deliver your apps.
to understand what happens, generate your application in both modes and compare the exe size... yes, the debug version is much bigger !!! that's because the compiler adds inside it some debug informations, lets the comments, don't perform optimizations, etc...
|
|
|
|
|
1. there's no debugging info in a release build - no good way to link the EXE back to the source
2. release builds are usually optimized, debug builds are not
3. some functions will work differently in release vs. debug (ex. new/malloc are quite different because the debug versions are designed to help catch memory leaks - the release versions are not)
4. things like ASSERT(x) behave differently because they rely on certain preprocessor flags (ex. _DEBUG) to control what they do
5. some data types may be initialized to 0 in debug build. they won't be, in release builds
etc..
-- modified at 10:03 Wednesday 23rd August, 2006
|
|
|
|
|
|
you can setup each of them to behave the way they want. even setup debug to work like release and release to work like debug.
we use only one mode for both and call it release_Debug. It has some debug info that is sufficient to get an idea of the problem. It helps as we have had problems in the past where our exe behaves differently in debug and release modes.
|
|
|
|
|
We are moving over to VS2005. We did a release build on a COM server and when registering it fails.
Found the following in the event log:
Source: SideBySide
EventID: 23
Dll redirector contributor unable to add file map entry for file msvcr80.dll; Two or more components referenced directly or indirectly by the application manifest have files by the same name.
Source: SideBySide
EventID: 58
Syntax error in manifest or policy file "C:\WINNT\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.Manifest" on line 5.
Source: SideBySide
EventID: 59
Generate Activation Context failed for C:\Project\Release\MyServer.exe. Reference error message: The operation completed successfully.
.
Registers fine with a debug build! Any thoughts??
Thanks!
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
Hi all
As iam a Beginner in MFC,i want to know how to override the control(ex:edit control)
|
|
|
|
|
You can customize the edit control by Subclassing it to meet your needs.
Derive a class from CEdit and override the functions provided in the class.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
|
Hi,I'm a beginner of vc++.Could someone help me?
I use a class writen by other to add bitmap to menus. this class is easy to use. but I've met a problem:
how to change the checkmarks style of the menu?
the class is here :http://www.codeproject.com/menu/bmpmenu.asp[^]
how to update this class?
|
|
|
|
|
Hello.
If you look at the bottom of the page where the article is, you will find a discussion forum, similar to this one.
When you have a question regarding an article, then that's the place to ask your question(s).
That way, you direct your question to the author of the artice and you will have a better chance to get your questions answered.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|