|
thank you, i will give it a try.
|
|
|
|
|
thank you! i know that, but i have to get the big one.
|
|
|
|
|
Hi all. I wrote two functions with void and int main calling them. Problem is only one function is working while the other is not. Here's my code:
<br />
#include <fstream><br />
#include <time.h><br />
#include <windows.h><br />
using namespace std;<br />
<br />
void time(void);<br />
void date(void);<br />
char olddate[9] = {0}; <br />
char oldtime[9] = {0};<br />
<br />
int main (){<br />
time();<br />
date();<br />
return 0;<br />
}<br />
<br />
<br />
void time(void){<br />
while(1){<br />
Sleep(300);<br />
char time [9];<br />
_strtime(time);<br />
bool fNewTime = strcmp(time, oldtime) != 0;<br />
if(fNewTime){<br />
ofstream file1;<br />
file1.open("time.txt",ios::app);<br />
file1 << "[Time]: " << time << endl;<br />
strcpy(oldtime, time);<br />
file1.close();<br />
}<br />
}<br />
}<br />
<br />
void date(void){<br />
while(1){<br />
Sleep(1);<br />
char date[9];<br />
_strdate(date);<br />
bool fNewDate=strcmp(date,olddate) !=0;<br />
if(fNewDate){<br />
ofstream out;<br />
out.open("time.txt",ios::app);<br />
out << "[Date]: " << date << endl;<br />
strcpy(olddate,date);<br />
out.close();<br />
}<br />
}<br />
}<br />
What i'd like for it to do is use both functions at the same time. At first i had them both set at Sleep(3000); So i changed one from 3000 to 4000 because i thought since their running both at same miliseconds that was causing the problem. But it didnt solve anything. Then i changed the main keyword from top to bottom. Bottom to top and still only one function works. Notice the time() and date() function call. If i put one on top of the other the one at the top of the keyword only activates. But the bottom stays idle. I've tried everything and now im coming to everyone here to see if they could lend a hand. Thanx in advance!
|
|
|
|
|
1. for the convenience of the other readers, please edit your message (not repost a new one) and surround the code sample with <pre></pre> tags. also, use < and > instead of < and & , otherwise, they will be interpreted as html tags and the formatting will be broken.
2. you'll need to solve your problem to use threads if you really need parallel execution.
|
|
|
|
|
Thanx for your reply toxcct, but i dont understand what you mean by "you'll need to solve your problem to use threads if you really need parallel execution."
Would anyone else like to add something to shed some light on what i should do to get both functions working together?
|
|
|
|
|
toxcct wrote: if you're not using MFC, use the corresponding Win32 API for starting a thread
This is bad advice. For official documentation on why this is note the following from here[^]:
<quote>A thread in an executable that calls the C run-time library (CRT) should use the _beginthreadex and _endthreadex functions for thread management rather than CreateThread and ExitThread; this requires the use of the multi-threaded version of the CRT. If a thread created using CreateThread calls the CRT, the CRT may terminate the process in low-memory conditions.
Steve
|
|
|
|
|
|
dellthinker wrote: time();
date();
I can't concieve of what would make you think these would run at the same time. I think you need to work through a few books, so you understand the basic principles of how your code is executed.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am trying to develop a MDI application in MFC. I am going thru different books "MFC with Visual C++ 6"-Mike Blaszczak, "Visual C++ MFC Programming by Example"-John Swanke and MSDN (ofcourse). But they are all like bits and pieces for me and I am not able to get a good idea on building an application from scratch.
Does anyone have a good resource on developing a MDI MFC application from scratch? My application is a BMP (mainly a 8bit gray scale BMP) viewer on which the user can select various points and highlight those points, the user should be also able to move/delete selected points and also perform some basic image processing techniques like brightness/contrast enhancement. I have the basic idea on how the interface should look like.
thanks,
-Pavan.
|
|
|
|
|
While MFC puts a nice object-oriented wrapper around much of the common Windows UI, IMO
it's more important to have a good grasp on basic Windows UI development.
Here's a link to a relevant part of the MSDN library. You may find the Windowing and User Input
sections useful for starters.
Windows User Interface[^]
Hope this helps a little!
Mark
|
|
|
|
|
Thanks for your reply. I will go thru those articles and hope I will get some more knowledge on those topics. I am comfortable developing dialog based UI applications, but not MDI and this is the first one I am tyring to develop.
-Pavan.
|
|
|
|
|
I came up with lots of doubts after creating my first MDI application, but for the basic ones..
1) First and foremost, how can I make a MDI applicaiton open with just the main frame (without child frame)?
2) How can I resize the child frame to the size of the image that is been opened by the user?? Say, if the image dimensions are less than the current main frame dimensions it will display in full scale, but if not, it should display the image covering the whole main frame with scrollbars to move down.
3) How can I open the image in child window so that it always resets itself to middle (aligned center)? i.e. even if the user clicks on the maximise button of child frame, the image should reset itself to the center of the main window.
4) How can I update the status bar panes while the user moves his mouse over the image?? I have a status bar in child window with a pane supposed to display the pixel location and intensity value.
thanks,
-Pavan.
|
|
|
|
|
1) An easy way to see is create an MFC multiple document project using the project wizard and
look at what is in the application class' InitInstance() override.
I just did one and it creates the frame like this:
CMDIFrameWnd* pFrame = new CMainFrame;
if (!pFrame)
return FALSE;
m_pMainWnd = pFrame;
if (!pFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
HINSTANCE hInst = AfxGetResourceHandle();
m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_TestMDITYPE));
m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_TestMDITYPE));
pFrame->ShowWindow(m_nCmdShow);
pFrame->UpdateWindow();
2)3) Once you have the image size you can use MoveWindow to resize and reposition the child window
within the parent frame.
4) CStatusBar::SetPaneText() can be used to set the text of the status bar in response to
WM_MOUSEMOVE messages. For each message calculate the cursor position relative to the image,
convert the results to a string, and display the string in the status bar.
|
|
|
|
|
I'm using a list control with the LVS_EX_CHECKBOXES style. Is there any way I can disable this control, or make it read-only, such that the checkboxes cannot be un/checked, yet I can still use the scroll bar?
Thanks.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I did this on a project a few years ago, let me see if I can remember the details.
1. The check boxes are implemented using a state image list, so you'll need to make your own image list that has the check boxes in a disabled state.
2. When you want to disable the check boxes, set your image list as the list control's new state image list
3. Handle the notification that you get when the user clicks on a state image, and eat the message so the list control doesn't see it and toggle the check box.
4. When you want to re-enable the check boxes, swap the image lists back.
|
|
|
|
|
I mainly work in Visual C++ 6.0 and Embedded Visual C++ 4.0 (very close to VS 6.0). From time to time, the IDE will elect to change the definition of a dialog (seemingly at random but I doubt that).
before:
IDD_VERSIONS DIALOG DISCARDABLE 0, 146, 585, 292
after
IDD_VERSIONS DIALOGEX 0, 146, 585, 292
I've seen the IDE change it in both directions. Any ideas as to what exactly DISCARDABLE and DIALOGEX mean? Any ideas as to what is causing this? I have never seen any impact...
Curious.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
charlieg wrote: Any ideas as to what exactly...DIALOGEX mean?
It's the replacement for DIALOG . See here for more.
DISCARDABLE does nothing in 32-bit Windows. It's there for backward compatibility.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks Dave... it had to be something like that
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
Using VS2005 with C+/MFC
How does one rename a menu resource? This is freakin' stupid...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
resource.h ?
what exactly do you want to rename ? the ID or the caption string ?
|
|
|
|
|
Are you trying to rename the identifier, like from IDR_MENU to IDR_CONTEXT_MENU ? If so, can you not just type over the old identifer in the GUI, like we did on 6.0? Or maybe you already tried that and that is why you are asking?
May have to resort to changing the RC and .H files directly if that fails...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
hehe
After adding a new menu resource it's ID is IDR_MENU1. If I select the menu in the Resource Tree I can change the ID (Name) in the Properties window.
Not sure that is what you are looking for.
led mike
|
|
|
|
|
Any WinCE mfc developers around?
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
I have a legacy system that I want to add a new dialog to. Whenever I create the new dialog through the resource tab, it creates my .H file in the 'externals' directory. Even if I move it from the exeternals directory to it's normal place with the .CPP, I still get errors that it can't find the IDD_DIALOG even though I have included the resource.h header file. Anyone have any clues as to what is happening? This is drivig me crazy! BTW, this is VC++ 6.0
Thanks
John P.
|
|
|
|
|
Try to find the IDD_DIALOG in resource.h
may be it not automatic add into resource.h
|
|
|
|