|
COM doesn't support CString
try using BSTR its meant for COM
Read the following article
http://www.codeproject.com/string/bstrsproject1.asp
Regards
Suneet Chandok
|
|
|
|
|
Hy!
I need help!
Can you do for me please the most simple aplications that uses *ini files for a MFC application with multi-language suport?
Please, I really need this!
HHHHHHeeeeeeeeellllllllppppppp!
Thanks!
|
|
|
|
|
writing INI files has been already posted on CP, but if you want it for different language...use ATL and UNI-CODE to re-write the one.
cheers
Balkrishna Talele
|
|
|
|
|
[code]
#include<iostream.h>
#include<math.h>
#include<iomanip.h>
class Watch
{
public:
Watch(int hour,int minute,int second);
Watch();
float get_min();
float get_hour();
float get_seconds();
void get_m_time();
void get_regular_time();
private:
int hrs;
int sec;
int min;
};
void Difference(Watch Watch_start, Watch Watch_end);
void main ()
{
Watch Watch_start, Watch_end;
int start_hour;
int start_minute;
int start_second;
char answer;
int end_hour;
int end_minute;
int end_second;
cout << "Welcome to my program\n";
cout << "This program will tell you the difference in times you enter\n";
cout << "It will also convert the time of day, to military time\n";
do
{
cout << "please enter the time of day you started\n";
cout << "please enter the hours first.\n";
cin >> start_hour;
cout << "now enter the minute you started.\n";
cin >> start_minute;
cout << "now please enter the seconds you started.\n";
cin >> start_second;
Watch_start = Watch(start_hour, start_minute, start_second);
Watch_start.get_regular_time();
Watch_start.get_m_time();
cout << "now please enter the time you ended\n";
cout << "again, please enter the hour first\n";
cin >> end_hour;
cout << "now enter the minute you ended\n";
cin >> end_minute;
cout << "now enter the second you ended\n";
cin >> end_second;
Watch_end = Watch(end_hour, end_minute, end_second);
Watch_end.get_regular_time();
Watch_end.get_m_time();
cout << "------------------------------------------------------------\n";
Difference(Watch_start, Watch_end);
cout << "Do you wish to enter another value?\n";
cin >> answer;
}
while ((answer == 'y') || (answer =='Y'));
};
Watch::Watch(int minute, int hour,int second)
{
hrs = hour;
min = minute;
sec = second;
};
Watch::Watch():hrs(0), min(0), sec(0)
{
};
float Watch::get_min()
{
return(min);
}
float Watch::get_hour()
{
return(hrs);
}
float Watch::get_seconds()
{
return(sec);
}
void Watch::get_m_time()
{
}
void Difference(Watch Watch_start, Watch Watch_end)
{
int diff_hour;
int diff_min;
int diff_sec;
int End_Hours = Watch_end.get_hour();
int End_Minutes = Watch_end.get_min();
int End_Seconds = Watch_end.get_seconds();
int Start_Hours;
int Start_Minutes;
int Start_Seconds;
if (Watch_end.get_hour() < Watch_start.get_hour())
{
End_Hours = Watch_end.get_hour() + 24;
diff_hour = End_Hours - Watch_start.get_hour();
}
else
{
diff_hour = Watch_end.get_hour() - Watch_start.get_hour();
}
if (Watch_end.get_min() < Watch_start.get_min())
{
End_Minutes = Watch_end.get_min() + 60;
diff_min = Watch_end.get_min() - Watch_start.get_min();
diff_hour = diff_hour - 1;
}
else
{
diff_min = Watch_end.get_min() - Watch_start.get_min();
}
if (Watch_end.get_seconds() < Watch_start.get_seconds())
{
End_Seconds = Watch_end.get_seconds() + 60;
diff_sec = Watch_end.get_seconds() - Watch_start.get_seconds();
diff_min = diff_min - 1;
}
else
{
diff_sec = Watch_end.get_seconds() - Watch_start.get_seconds();
}
cout <<setfill('0')<<setw(2)<<diff_hour <<"="" hours="" "<<endl;
="" cout="" <<setfill('0')<<setw(2)<<diff_min<<="" "="" minutes="" <<setfill('0')<<setw(2)<<diff_sec<<"="" seconds=""
}
void="" watch::get_regular_time()
{
="" float="" hour="hrs;
" if="" (hour=""> 12)
hour = hrs - 12;
}[/code]
im getting problems with the difference on minutes and seconds........it displays negative numbers.....any ideas?
|
|
|
|
|
|
Hint#1: Don't post all of your code.
Hint#2: Don't expect anyone else to do your class assignment for you.
Hint#3: You want a difference in times. If you have h,m,and s, convert the whole thing to seconds (you do know how many seconds in a minute, right?), then subtract one time from the other, and convert back to h,m and seconds.
Oh, and
Hint#4: Don't SHOUT, I have a headache...
Steve S
|
|
|
|
|
I think the easiest thing for you to do would be to just figure out how many seconds difference there is between the two times, and then convert that back to the proper time format for displaying purposes only. I'm confused about the hour variable. Is this military time that goes from 0-23, or does it go from 1-12? If this is military time, then your life is really easy. You don't even need an hour and minute variable in your Watch class anymore, just a second variable. Use the following as a model for getting your time (you really should have a function in your class which asks this
int hrs, mins, secs;
cout << "enter the hour\n";
cin >> hrs;
Sec = hrs * 3600;
cout << "enter the minute\n";
cin >> mins;
Sec += mins * 60;
cout << "enter the seconds\n"
cin >> secs;
Sec += secs;
There, now you have the time in the exact second of the day that you started. And you can do the same to get the second time...and I hope you can figure out how to find the difference between times...just subtract the seconds. Now, to display your time back in proper format:
hrs = Sec / 3600;
min = (Sec % hrs)/60;
secs = (Sec % min);
There ya go! Hope you get an A.
|
|
|
|
|
I am trying to write a simple Windows program that monitors and logs the memory usage of programs or tasks in Windows. Basically, I want the information that the Task Manager gets so that I can watch for changes, memory leaks, etc... I am experienced in C++ but have yet to write a Windows application. Any help or information regarding how I might go about this project would be greatly appreciated.
John
|
|
|
|
|
i exactly dont remember the title of the book...but its of MS Press by Jeff Prosise for developing Systems internals...Its CD contains..alots of sample code like...Erro look up, SPY, MFC TRACER, MEMORY DETECTOR..thread and process viewer...
If till evening i get the name of the book, PINGO I shall be gald to let u know...
regards
Balkrishna Talele
|
|
|
|
|
|
I have a problem. When I want to wait for a thread to finish processing, I use the WaitForSingleObject and pass it the handle to the thread I am waiting on. However, that thread never finishes, so my program just hangs. When I step through it in the debugger, it never seems to go into the function that I am waiting to finish, but I still have a handle to the thread, so I don't believe it has finished.
Any Ideas?
|
|
|
|
|
You have to set up some kind of singnalling system to tell your thread to finish. The usual way is to use an event, which your thread perodically checks and if its singaled, exits - something like this:
ThreadFun(LPVOID theEvent)
{
HANDLE hDie = (HANDLE)theEvent;
for(a long loop)
{
do some stuff
if(::WaitForSingleObject(hDie, 0) == WAIT_OBJECT_0)
break;
}
return 0;
}
Then in your main thread where you are doing WaitForSingleObject on the thread:
SetEvent(killTheThreadEvent);
WaitForSingleObject(hTheThreadsHandle, INFINITE);
The threads handle will still be valid even when the thread has died (until you do a CloseHandle on it). To dermin if it is running or dead do WaitForSingleObject passing in 0 as the timeout - if you get WAIT_OBJECT_0 its dead, or WAIT_TIMEOUT its still running. You can also use GetExitCodeThread which will give you STILL_ACTIVE if the thread is still running - though WaitForSingleObject is generally prefered.
|
|
|
|
|
Is there an existing function that can convert text to its associated phonemes? The text could be a single word or a paragraph.
Your help is appreciated.
|
|
|
|
|
|
Thank you very much Chiew Heng Wah! I spent half day yesterday searching on Google, but missed this. 
|
|
|
|
|
hi all really this site is so powerfull i mean it
well i want to capture an image from a camera the application is a dialog based application and i am using visual c++ 6.0 i wanna the view which camera get appear first and make the position nice then a button called capture when i clicked it it capture the image which in the view then open dialog for saving
Hope anyone help me by any ideas
thanks
Gego
|
|
|
|
|
Try the following CodeProject article by Blas5
Title: Capture Sample with DirectX and .NET
Link: http://www.codeproject.com/directx/CapSample1.asp
You should also read DirectShow documentation.
Also DirectX SDK has a sample program called StillCap.exe under <DXSDK Directory>\samples\Multimedia\DirectShow\bin
|
|
|
|
|
Thanks man for replaying but wanna another question
i have read some of the article but my question is to capture a picture from a camera did i have to use directshow and PLZ some introductin of the directshow
thanks again
Gego
|
|
|
|
|
Can I safely assume you are talking about a web-camera (webcam)?
The DirectShow examples in DirectX SDK should work with the web-cam. Codes are included.
Heng Wah.
|
|
|
|
|
Hi all
thanks alot for replaying anyway i got a piece code it talking about a thing called VFW
and yeah man it will be a web cam i have got the sdk of directx but wanna to know is it easy to link it to a visual c++6
thanks anyway
byebye for now
Gego
|
|
|
|
|
Hello, My name is jason.
I am trying to write a program that will track the times and the dates that an employee has worked. I know how to hard code it but, it is the gui that i am having a problem with. Here are my main problems. When the program starts i would like a password screen to appear, where the user or the manager enters her/his password. This part I have accomplished, the password screen. I have placed 9 buttons, when the user clicks on the buttons i record or add to a string, and when the user hits okay, i read the finished string and see if there is an employee. My problem is this, I need to have to different windows, one for a manager, and another for a employee. Meaning, if a manager comes along, types his password, i would like a window appearing where he has the option of looking how has clocked in, how many employees are currently working, total hours ans so forth. When a employee comes along, enters his/her password, i would like them to see when they have started, or if they have not punched in, a punch in button, or a punch out button and so forth..
If anyone could help me out, or give me advice on how to create those two different windows and how to interact or how to dynamilcly pop up those two windows depending on who is entering a password, i would be sooooo happy.
you can email me at jdogan@hotmail.com
none
|
|
|
|
|
Hi Jason how are U man
well man u will create dialogs as u wanna and after handle the button of the manager just inside its function call the dialog which u have make for the manager and in the employee case make a different dialog when the empolyee is chosen after inserting the username and his password call the dialog of the emoplyee and in the two dialogs the one for employees and one for manager make any interface u wanna to make ur times appears
hope that will solve ur problem if ok tell us and if no also tell u
bye now
Gego
|
|
|
|
|
modeonetwo wrote:
My problem is this, I need to have to different windows, one for a manager, and another for a employee.
Sounds like you need some sort of designator that denotes manager vs. non-manager. Are you looking in some sort of file/database to verify the user id and password are correct? If so, just add another field.
You would then need to create two dialog templates: one for managers, and one for non-managers. Then in your code, you could have something like:
DisplayLoginWindow();
if (login_type == manager)
{
CManagerDlg dlg;
dlg.DoModal()
}
else
{
CEmployeeDlg dlg;
dlg.DoModal()
} Make sense?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thank you both very much, that little bit of code makes a lot of sense, i was thinking of doing just that but did not know if it was possible or smart.. I will look into that and probably do that. Thank you soo much.
none
|
|
|
|
|
Using CSplitterWnd class
I’m trying to learn how to work with CSplitterWnd class.
I create a simple SDI application using MFC Application Wizard.
Classes created are:
CMySDIApp
CMySDIDoc
CMySDIView
CMainFrame
I want to have two different views for my document. For the second view, I add a new class to my project – CMySDIView2 class is derived from CView.
I want to have static splitter with two panes. I override OnCreateClient :
CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CMySDIView), CSize(0, 0), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
// add the second splitter pane - an input view in column 1
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CMySDIView2), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
return TRUE;
}
When I build the project, I get two errors:
error C2653: 'CMySDIView' : is not a class or namespace name
//RUNTIME_CLASS(CMySDIView), CSize(0, 0), pContext))
error C2653: 'CMySDIView2' : is not a class or namespace name
//RUNTIME_CLASS(CMySDIView2), CSize(0, 0), pContext))
What am I doing wrong?
Thank you for your help!
|
|
|
|
|