|
thanks a lot for your attention, but i want to use just one function to import file to registery editor, something like "import" option in "file" menu of registry editor since there is lots of keys in HKEY_CLASSES_ROOT, HKEY_CURRENT_USER and HKE_LOCAL_MACHINE in this file, and i don't want to import them separately.
moreover be conscious please, i have to use MFC i'm NOT allowed to use .net framework.
thanks for your help
|
|
|
|
|
How to show the time value in edit control which is attached with spin control. I also need increase or decrease the time value with the help of Spin control..
Please help me..
Thanks..
|
|
|
|
|
Use one of the time[^] functions to obtain a string with the current time which you can display in the edit box. Use the spinner controls to adjust the values (based on selected characters) up or down and adjust your time value as necessary.
It's time for a new signature.
|
|
|
|
|
can u please provide me some sample code as I m very new in MFC..
Thanks..
|
|
|
|
|
The link I posted for the time functions should explain all you need to know about obtaining time values as strings. Take a look also at the CSpinButtonCtrl[^], it has links to sample code that should help. You will find similar pages for all the other MFC classes.
It's time for a new signature.
|
|
|
|
|
Why don't use CDateTimeCtrl , which encapsulates the functionality of a date and time picker control. If its set to DTS_TIMEFORMAT it has a spin control and displays formatted time.
|
|
|
|
|
Hi
I want to use MS Excell in VC++ program for recording and plotting data.
Should I use CRecordSet Class or else.
If yes, can I have some example program for it?
Regards
|
|
|
|
|
As far as I know, the CRecordset class is used when you are working with databases.
In your case, you have to use Excell automation, search on CP and google for it and you'll find a lot of tutorials.
QSMZ wrote: I want to use MS Excell in VC++ program for recording and plotting data.
You mean that your program should create an excell file and write data in it then create a chart in the excell file ? If yes, I think this should be feasible through automation.
|
|
|
|
|
QSMZ wrote: I want to use MS Excell in VC++ program for recording and plotting data.
I'm not really clear on what you mean.
Perhaps you would benefit from writing a DLL that you use from Excel for "data recording" depending on the where you get the "data" from.
If you only want Excel for presentation reasons you may record and plot the data in your own application, but save it to an Excel file and draw charts in it using automation as Cédric said.
I've done this about five years ago, but unfortunately that means I don't have any source code to give away and I've forgotten the details.
However, it's not really that hard, just search for Excel and automation and you'll get a lot of useful results.
One tip I remember though, use multidimensional safearrays for writing the data into the Excel sheet if you have a lot of data. I had about 10MB and writing it cell by cell took about 40 minutes. Using a multidimensional safearray it only took a couple of seconds.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
search
BasicExcel on codeproject
|
|
|
|
|
A Simple search of code project yields a number of jewels. ^[]
there are a lot of things to consider when you begin trying to use windows office automation not the least of which C++ isn't the "best choice". VB ultimately is a much better choice for this type of task(native language for excel). Also for deployment will the target users all have office? will they have the "right" version of office? Do you really need to write a full blown app or will VB scripting do the job?
Excel objects are setup just like the in the program books, pages, range and cell.
|
|
|
|
|
Hi!
how do i convert a date to struct tm?
i want to get day of week for this date.
this code has a run time error:
int yy = 2010;
int mm = 07;
int dd = 12;
struct tm tt;
time_t t;
yy -= 1900;
tt.tm_mon = mm;
tt.tm_year = yy;
tt.tm_mday = dd;
t = mktime(&tt);
struct tm *tt2 = localtime(&t);
int ii = tt2->tm_wday;
please help me.
Zo.Naderi-Iran
|
|
|
|
|
zon_cpp wrote: time_t t;
time_t t = {0};
i.e. never, never, never forget variable initialization.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I can't see what's wrong with your code (but there could be something in there, it's a bit convoluted) but this works on my compiler and uses the same function calls:
std::tm t = { 0, 0, 12, 13, 6, 110 };
std::time_t int_rep( std::mktime( &t ) );
t = *std::localtime( &int_rep );
std::cout << std::asctime( &t ) << std::endl;
It's a bit disgusting but seems to get the job done. I'd be tempted to wrap it up in a function though:
int day_of_week( int day, int month, int year )
{
std::tm t = { 0, 0, 12, day, month - 1, year - 1900 };
std::time_t gratuitous_l_value( std::mktime( &t ) );
return std::localtime( &gratuitous_l_value )->tm_wday;
}
If you're programming in C and not C++ just remove the std:: everywhere, include time.h and not ctime and convert the constructor style initialisations to = and it'll probably work.
Cheers,
Ash
|
|
|
|
|
I have a graphics application which is written in Borland C++ using various classes like TDC, TPen, etc. which I have to convert into Visual C++ application with MFC. What is the best approach to make this more efficient and less time consuming? Is there any third-party library which has Visual C++ wrappers for Borland C++? Please suggest.
|
|
|
|
|
I dont think its possile as I did a try to convert a .cbproj to .vcproj. ie: from rad studio to visual studio. but the project used some vcl.h which is unavailable in visual studio. so making gui is totally depended on ide. you can adopt any code from bc++ proj and manipulate in your vcproj but not gui part.
|
|
|
|
|
Would probably use .NET and then compile your C++ code as managed code using the /clr switch (VS2005 and newer supports this).
.NET Winforms is much closer to Borland VCL library.
If .NET is not an option and wanting to stick to the C++ guns, then you should take a look at Qt, as it ressembles the OO principles of VCL. Or maybe tryout the OWLNext as it should actually be the open source version of Borland C++ GUI library (But it is not VCL).
Converting an application to MFC will not win you any awards.
modified on Monday, December 6, 2010 5:34 PM
|
|
|
|
|
Hi I am creating a datetime control derived from the CDateTimeCtrl. I want to place images on the both up and down arrow of the control. Can anyone pplease help me how to do that..
Thanx..
|
|
|
|
|
Hi sir,
I am doing some mathematical calculation.
where i am reading values from Dialog edit box control.
Here is .h file
ex.h
Dialog Data
enum { IDD = IDD_DIALOG_SOURCE_DETAILS };
CMSMask m_val1;
CMSMask m_val2;
CMSMask m_val3;
here is .cpp file
m_val1.GetText();
m_val2.GetText();
m_val3.GetText();
I am using this exp to get the result
A = B Exp(-0.693 * t/T)
B = m_val1.GetText();
t = m_val2.GetText();
T = m_val3.GetText();
I am trying with this.
h = (-0.693 * t/T);
res = B^h;
Can i pass the values(B,t an T) directly to the expression and get the result or i convert it to double(using atof).
Thanks
Raj
|
|
|
|
|
GetText as the name indicates must be returning strings.
You cannot evaluate expressions on strings.
So you have to first do the conversion.
|
|
|
|
|
You'll have to use something like atof (excuse me while I rinse my fingers off for typing that) or another conversion. What you get off the controls is a string of some sort.
Secondly are you sure your maths is correct? Is:
A = Kexp( -kt )
really
A = K ^ (1 / kt )
or is it
A = K * e ^ (-kt)
where ^ is "raising to the power of"? Most maths texts I've read would say the later, which makes your equation something similar to the one describing radioactive decay, capacitor discharge or acoustic attenuation. Actually thinking about it are you sure the equation isn't:
A = K * 10 ^ (-kt )
as -0.693 is the natural log of 0.5 (IIRC)? This is a big hint to me that T is actually a half-life and something's got very bent in translation.
Final point: C++ has an ^ operator, but it's not going to help you with your code. You're going to need either std::exp or std::pow to get a result here.
Cheers,
Ash
|
|
|
|
|
Hi,
I use this code to terminate calc.exe on Windows Vista and Windows 7
DWORD fdwExit = 0;
HANDLE hProcess = GetProcessHandle("calc.exe");
GetExitCodeProcess(hProcess, fdwExit);
TerminateProcess(hProcess, fdwExit);
CloseHandle(hProcess);
On Windows XP SP3 the above code doesn't have any effect!
any idea? thanks
|
|
|
|
|
TerminateProcess is an iffy call, depending on the dlls and child processes, the code could hang.... Microsoft wrote a "better way" to handle termination:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q178893&[^]
basically you send a WM_CLOSE message to the applications main thread and then the application terminates itself. This is similar to what happens to an application when you send a shutdown command while it is running. Of course then you are dependant upon the programmer of the application to have properly handled the WM_CLOSE and terminate.... and we all know all programs exit gracefully and never hang upon shutdown.
_________________________
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....
|
|
|
|
|
Put in some error checking on the return values and debug the program to find out exactly where the problem occurs.
Also, what is GetProcessHandle ?
It is not an API.
It must be a user defined function.
Check if it is returning a valid handle.
|
|
|
|
|
Sorry my mistake, here's the GetProcessHandle void
HANDLE CmyGUIApp::GetProcessHandle(LPSTR szExeName)
{
PROCESSENTRY32 Pc = { sizeof(PROCESSENTRY32) };
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
if(Process32First(hSnapshot, Pc)){
do{
if(!strcmp(Pc.szExeFile, szExeName))
{
return OpenProcess(PROCESS_ALL_ACCESS, TRUE, Pc.th32ProcessID);
}
}while(Process32Next(hSnapshot, Pc));
}
return NULL;
}
Debugging the program on Windows 7 where on I have my VC++ installed doesn't show any error or any thing strange, I can terminate any process just by replacing "calc.exe" with another process name, the void above returns the exact process handle and the process gets terminated. Should I debug the program on Windows XP? How? I have only one license of VC++ which is currently installed on Windows 7, can I use WinDbg to debug my program on XP and how? please guide me I am new to all of this staff! Thanks
|
|
|
|