|
This is a blanket question that is almost impossible to answer. The only advice I can give is to put well-placed breakpoints in the app, first of all in the "Add information" button handler. Go from there, inspect the contents of the variables, and finally, the saving function for the database.
|
|
|
|
|
Hi Johan, thank you for reply.
I have found the problem, I was using MyOleDB driver...so i change to MyOdbc and everything works fine...
|
|
|
|
|
I have been trying to get the time, but I need the millisec part also.
I used g_Date = CTime::GetCurrentTime(); // Date Time Now
to get
month1 = g_Date.GetMonth()/10;<br />
month2 = g_Date.GetMonth() - (month1 * 10);<br />
day1 = g_Date.GetDay()/10;<br />
day2 = g_Date.GetDay() - (day1 * 10);<br />
hour1 = g_Date.GetHour()/10;<br />
hour2 = g_Date.GetHour() - (hour1 * 10);<br />
min1 = g_Date.GetMinute()/10;<br />
min2 = g_Date.GetMinute() - (min1 * 10);<br />
sec1 = g_Date.GetSecond()/10;<br />
sec2 = g_Date.GetSecond() - (sec1 * 10);<br />
millsec = ?????
I did try
DBTIMESTAMP systemTime;
g_Date.GetAsDBTIMESTAMP (systemTime);
but got compile error GetAsDBTIMESTAMP not a member of CTime.
Any suggestions?
grahamfff
|
|
|
|
|
Just one idea.
You could use the Multimedia timer to maintain a count in milliseconds from some point in your program. Start the timer then save the date information, given this you can determine an approximation of the number of milliseconds. In order to make it more accurate, you would need to figure out how to get a one shot event that would occure the first time the time changed and then start the timer and save the date information. A possible one shot would be to just enter a loop that keeps checking thet date until the seconds change and then, since it should loop for less than a second (at start of program), the user probably would not notice the delay.
Good luck!
INTP
|
|
|
|
|
try to use the GetTickCount function
but you will need to set a timer and store you time somewhere
The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function.
DWORD GetTickCount(VOID);
or like this
VOID GetSystemTime(
LPSYSTEMTIME lpSystemTime // system time
);
Parameters
lpSystemTime
[out] Pointer to a SYSTEMTIME structure to receive the current system date and time.
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;
get it ?
gabby
|
|
|
|
|
I was just working on this a while ago and Mike Dunn pointed me in the direction of the FILETIME . With this you get 100 nanosecond resolution. Here's a quick example of what I did:
FILETIME start, end;
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &start);
GetSystemTime(&st);
SystemTimeToFileTime(&st, &end);
ULARGE_INTEGER time_start = *(ULARGE_INTEGER*)&start;
ULARGE_INTEGER time_end = *(ULARGE_INTEGER*)&end;
__int64 i64time_start = *(__int64 *)&time_start;
__int64 i64time_end = *(__int64 *)&time_end;
__int64 i64time_diff_ns = i64time_end - i64time_start;
__int64 i64time_diff_ms = i64time_diff_ns / 10 / 1000;
__int64 i64time_diff_sec = i64time_diff_ms / 1000;
char strdest_diff_ms[32];
char strdest_diff_sec[32];
_i64toa(i64time_diff_sec, strdest_diff_sec, 10);
_i64toa(i64time_diff_ms - i64time_diff_sec * 1000, strdest_diff_ms, 10);
char buffer[200];
char msg[] = "Time difference is %s.%s second(s).";
sprintf(buffer, msg, strdest_diff_sec, strdest_diff_ms);
::MessageBox(NULL, buffer, "Time Run Results", MB_ICONASTERISK |
MB_ICONINFORMATION);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Heh... But how do you compensate for things like OS tasks, other processes and threads running...?
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
Thanks Nick, that code will do just fine.
Graham.
grahamfff
|
|
|
|
|
The problem is that CTime does not have millisecond resolution (IIRC), so even if you used a method like CTime::GetAsSystemTime(...) to get the time into a SYSTEMTIME structure which includes milliseconds, it will not be a "true" millisecond value.
Use the Win32 GetSystemTime(...) function to get the current time (in UTC, so be sure to "localize" it before storing/using it) into a SYSTEMTIME structure that will contain a more or less accurate millisecond value.
[Edit]
BTW: Just because the database requires a millisecond value does not mean that it has to be a "true" value. If you only need second resolution, you can simply always set the millisecond value to zero...
[/Edit]
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
Hi,
I've asked a similiar a while back. You can check the post [^] and see if it comes any help. I found _ftime64() works quite well for my needs.
|
|
|
|
|
In regards to this thread (which I have yet to find a resolution)
http://www.codeproject.com/script/comments/forums.asp?msg=851353&forumid=1647#xx851259xx
I decided to strip away all header file includes from the code and compile the cpp files one by one in order to find the root of the problem.
All my header files are enclosed in the #ifndef #define #endif statement
and I include all necessary headers for a cpp file in a single header and along with other class and function definitions include that file...
eg.
MyFile.h
--------
#ifndef MYFILE_H
#define MYFILE_H
#include "OtherHeaderFile.h"
#include "OtherHeaderFile2.h"
class {
....
};
extern ...
#endif MYFILE_H
MyFile.cpp
----------
#include "MyFile.h"
As I start going down the list of compiled files I run into the syntax errors (from files that compiled fine higher up in the list in the list; errors are in the header files) when header files include each other as in the previous thread I posted. What are the general rules of header inclusion...there is something crucial I seem to be missing as far as these rules are concerned.
Can someone offer some advice?
|
|
|
|
|
It is hard to say what the problem is without seeing all your files (and you certainly shouldn't post them all on here!) Just from the post above I am wondering what the 'extern' is for, why you are including OtherHeaderFile.h and OtherHeaderFile2.h, and what the errors are.
|
|
|
|
|
I use the extern in each header file for each global class object (all defined in another header file and included in only one cpp file)
I am going to play around with the extern declarations to try and come up w/ a solution.
|
|
|
|
|
Quick tip: look for missing semicolons at the end of struct /class defs, especially files that have no other code after the def. Everytime I get non-obvious syntax errors early on in the compilation phase, that is the cause.
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
If you have a header file that will be included in many other source or header files, include it in stdafx.h
<font=arial>Weiye Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
I am working on an application written in vc++/MFC 7.1. I am looking into a solution for adding scripting support to my application. I have looked at the Microsoft scriping control but it seems limited in its scope and capability. I have also looked into some GNU alternatives (SWIG, Ch, embedded perl interpreter) but it seems they would give me many long nights with integration with MFC. This is my first attempt to integrate a scripting environment with an application so its a learning curve to overcome.
I was curious if anyone with this kind of experience would be so kind as to share some pearls of wisdom on solutions that they have used successfully. What are some things in terms of design to keep in mind when developing an application structure that needs to be extended via scripting environment? Is there any way besides a tangled web of COM interfaces?
Thanks,
padawan
Disclaimer: Any resemblance between the above views and those of my employer, my terminal, or the view out my window are purely coincidental. Any resemblance between the above and my own views is non-deterministic. The question of the existence of views in the absence of anyone to hold them is left as an exercise for the reader. The question of the existence of the reader is left as an exercise for the second god coefficient. (A discussion of non-orthogonal, non-integral polytheism is beyond me)
|
|
|
|
|
|
|
tell please you email addres
gabby
|
|
|
|
|
My e-mail is: irekzielinski -AT- wp.pl
or: author -AT- trayhelper.com
Best regards!
Irek
Check out my software at: http://www.ireksoftware.com
|
|
|
|
|
hello.
Does anybody now how to retrieve the currently selected (highlighted)
filename as shown in the windows explorer window from
a toolbar that is implemented with the TOOL / Desk Band interfaces?
--
When I click on a custom toolbar button, I need to know the
name of the selected file in order to "operate" on that file..
Any help is appreciated!
sas
|
|
|
|
|
Use the SHShellFolderView_Message() function to send the SFVM_GETSELECTEDOBJECTS message to the main browser window.
link : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shshellfolderview_message.asp
This supposedly only works for win 2k+. If you need it for windows 98, there is a trick that might help you - if you're in a deskband, you're in an in-process dll, so you can just send LVM_* messages to the inner list view. I have noticed that the lParam member of the LVITEM structure, for explorer list views, is in fact a pointer to the item's PIDL. This isn't documented, it might not work everywhere, but it does work most of the time.
|
|
|
|
|
thanks.
I am using win XP.
I tried code like this, per your help, but the
app crashes at the SHShellFolderView_Message line:
LPITEMIDLIST* ppidl;
LRESULT numItems = (LPARAM)SHShellFolderView_Message(m_hExplorerHwnd, SFVM_GETSELECTEDOBJECTS, (LPARAM)ppidl);
is there something I'm missing, do I need to instantiate the
array of pidls?
m_hExplorerHwnd is the hwnd of the actual explorer.exe gui
any help is appreciated.
sas
|
|
|
|
|
hmm... I tried it and it crashed too. Never mind, I found a better way. This example lists all the selected items and displays them in a message box:
HWND hWndBrowser = ::GetAncestor(m_hWnd, GA_ROOT);
char szBuf[4096];
IShellBrowser *pISB = (IShellBrowser*)SendMessage(hWndBrowser, WM_USER+7, 0, NULL);
if (pISB)
{
IShellView *pISV = NULL;
if (SUCCEEDED(pISB->QueryActiveShellView(&pISV)))
{
IDataObject *pIDO;
HDROP hDrop;
UINT uNumFiles;
char szFile[MAX_PATH];
pISV->GetItemObject(SVGIO_SELECTION, IID_IDataObject, (void**)&pIDO);
FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM stg = { TYMED_HGLOBAL };
if ( FAILED( pIDO->GetData ( &etc, &stg )))
return E_INVALIDARG;
hDrop = (HDROP) GlobalLock ( stg.hGlobal );
if ( !hDrop )
{
ReleaseStgMedium ( &stg );
return E_INVALIDARG;
}
uNumFiles = DragQueryFile ( hDrop, 0xFFFFFFFF, NULL, 0 );
szBuf[0] = '\0';
for (UINT uFile = 0; uFile < uNumFiles; uFile++)
{
if (!DragQueryFile( hDrop, uFile, szFile, MAX_PATH ))
continue;
wsprintf(szBuf, "%s\n%s", szBuf, szFile);
}
MessageBox(lpcmi->hwnd, szBuf, "Selected Files", MB_OK);
GlobalUnlock ( stg.hGlobal );
ReleaseStgMedium ( &stg );
pIDO->Release();
pISV->Release();
}
}
This is called from within a band object's IContextMenu::InvokeCommand() method, m_hWnd is the band object's window handle. Since you already have the handle to the main explorer window, you won't have to call GetAncestor().
|
|
|
|
|
thank you; that code worked;
it took me a little bit to
get the right hWnd, but once I
did, I was able to read the selected files..
thanks again.
sas
|
|
|
|