|
Here is basically what I'm trying to do:
<br />
#include <iostream><br />
#include <fstream><br />
<br />
<br />
class Logger<br />
{<br />
public:<br />
static Logger &GetInstance()<br />
{<br />
static Logger logger;<br />
return logger;<br />
};<br />
<br />
void Initialize()<br />
{<br />
if (!Log.is_open())<br />
Log.open("logfile.txt");<br />
};<br />
<br />
void Shutdown()<br />
{<br />
if (Log.is_open())<br />
{<br />
Log.close();<br />
}<br />
};<br />
<br />
<br />
<br />
protected:<br />
Logger()<br />
{<br />
};<br />
std::ofstream Log;<br />
<br />
public:<br />
template <typename T><br />
friend std::ostream & operator << ( std::ostream & os, T data );<br />
};<br />
<br />
template <typename T><br />
std::ostream & operator << ( std::ostream & os, T data )<br />
{<br />
os << data;<br />
std::cout << data;<br />
return os;<br />
};<br />
<br />
int main()<br />
{<br />
std::cout << "Hello world!" << std::endl;<br />
Logger::GetInstance();<br />
Logger::GetInstance().Initialize();<br />
Logger::GetInstance()<< "ciao" << std::endl;<br />
std::cout << "Good nigght world!" << std::endl;<br />
return 0;<br />
}<br />
<br />
...but unfortunately I don't know what I'm doing.
|
|
|
|
|
It seems that CP likes eating #includes... of course I use: fstream and iostream.
|
|
|
|
|
Iam using VC++ as a fonrtend software to communicate with embedded system
through Serial communication(RS-232). Iam using Readfile and Writefile
functions to read and write through COM port. Can anyone Clarify me the
following,
* Is it necessary to Flush the Input and Output buffer for every command
being transmitted/received ???
* If not, how often should i Flush the input and output buffer ???
Madhu
|
|
|
|
|
Hello.
I think you should flush the buffers after every Writefile. Else, chances are that the data will remain in the write buffer. When you do a flush, the data will be sent to the device.
There is (generally) no need for flush before Readfile.
You might considder to search for a serial class. There are several here at CP. I have found them very useful over the years.
Kakan
|
|
|
|
|
hi,
can anybody tell me how to open most recent documents?
|
|
|
|
|
jayshml wrote: can anybody tell me how to open most recent documents?
Search RECENT folder for most recently open Documents
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
double click on it.
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
VivekuniQ wrote: double click on it.
Where ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I want to control data in my Combobox so that, if data I write is not inside my combobox the cursor must stay in the control. If data became exact the cursor can go anywhere.
I don't know how to block the cursor and to release it on the control.
What to do ?
I learn my self
-- modified at 7:18 Tuesday 6th December, 2005
|
|
|
|
|
You will probably have to derive a class from your combo box class, and handle messages when the control loses focus (WM_KILLFOCUS ) or gets deactivated (WM_ACTIVATE ), and deny leaving the control depending on where the user wants to go (I do not know if you would like to block the focus within your application or for the whole system).
~RaGE();
|
|
|
|
|
I want that the cursor stay within this control (ComboBox) because the data I write is wrong.(It is not in its data property)
I learn my self
|
|
|
|
|
C++ is not VB. as the previous answers said, you have to overload the event handler by yourself... WM_KILLFOCUS event occurs when the focus is about to leave from a control to another. there, you can make the tests and only if the content is validated, you call the base class (CWnd ) OnKillFocus() handler to allow it to process the focus change...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
How about sub-classing the CComboBox class, override the OnKillFocus message handler and set the focus to the combobox if the data is erroneous?
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
that's what I do
void Neworder::OnKillfocuscurrency()
{
CComboBox* pcpp = (CComboBox*)GetDlgItem(IDC_currency);
if (CB_ERR == pcpp->FindStringExact(-1,m_devise) )
{
pcpp->SetFocus();
}
else
{
}
}
I learn my self
|
|
|
|
|
Have you made sure that your handler is correctly mapped in the message map and that it actually gets called?
Set a breakpoint in the message handler and debug the application to find out whether your handler gets called or not and if it does verify that the statement pcpp->SetFocus() is executed.
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
I have automated MS word using VC++(MFC) version 6.0 . I create a MS Word Document. In this document i want to insert in the footer "2 of 12" format. Where 2 is the page number and 12 is the total number of pages. Please provide the solution for the same.
Thanking you.
|
|
|
|
|
Sachinpatole wrote: In this document i want to insert in the footer "2 of 12" format.
I think it's something like:
{ PAGE } of { NUMPAGES }
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Yes,
I want to display
(PAGE) of (NUMPAGES).
How can i do it?
Pls reply
Thankx
|
|
|
|
|
Sachinpatole wrote: How can i do it?
I already showed you. Did you try my suggestion?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I didnt get you. Will you please resend me the suggestion. Basically i want to display the footer as "3 of 5" where 3 is the page number and 5 is the total number of pages. I have to achieve this in my VC++ 6.0 (MFC) code where i have created the word document using automation. I have to set the footer as above mentioned, in the MS Word document created through automation.
Please do the needful at the earliest.
Thanking you
|
|
|
|
|
Sachinpatole wrote: Will you please resend me the suggestion.
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi dudes!
I have an especial electronical device that I connect to my computer through USB, and there's a USB-serial driver that emule the RS232 communication through USB.
That's ok.
The fact is that many times I must to point to Control Panel -> Sistem -> Hardware -> Devices -> Comm Ports to see which comm port the device is using.
I want to developed an small application, with just a button. Then when I press it, a MessageBox shows the Comm Port used for that device.
What API function/s should use in the button click event handler to get that kind of information, (in fact, it is the same that control panel display in Comm Ports).
Thank very much guys!
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Help to run my project in Sevice mode
Getting error 1053 , when trying to start from service mode
dil
|
|
|
|
|
Error 1053 means ERROR_SERVICE_REQUEST_TIMEOUT
It seems as if your code isn't responding to some kind of event.
If you want a more detailed answer, please give more details about the problem.
|
|
|
|
|
LPCTSTR name123 = "sangaraju" ;
SC_HANDLE hSCManager =( OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE));
SC_HANDLE hi = OpenService(hSCManager,name123,SERVICE_ALL_ACCESS );
SC_HANDLE hSCreate = CreateService(SCManager,name123,name123 ,SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,SERVICE_AUTO_START,SERVICE_ERROR_IGNORE,
"\"d:\\Shu.exe\"",NULL,NULL,NULL,NULL,NULL);
and then Closed the services......
Opened the Windows services
i found Startup type = automatic , and status is empty
But when iam trying to start in the servics , Error which iam getting is
Error 1053 : " The service did not respond to the start or control request in timly fashion"
Please help me Kakan.......
Thanks in advance
|
|
|
|