|
basementman wrote:
You could have each thread keep track of it's state by having the threads write a blocked marker to a global area just prior to calling a blocking function, and then write a running marker after the blocking call completes.
In my code this would be to much work because any one of 100+ functions may block... Although I am not throwing this idea away yet.
basementman wrote:
And if you are using real OVERLAPPED structures
No, only in a few of the operations.
basementman wrote:
Bottom line, there is not a GetThreadState() WINAPI that I know of or can find.
I could call SuspendThread then ResumeThread to get the info I need but that seems wasteful. A second idea is to use GetThreadTimes to determine if any work has been done since the last time I checked this again seems wasteful...
Thanks for your help,
John
|
|
|
|
|
Hi,
Is there anyway to tell the difference between the user selects a menu item other than just browse through the menu items without click?
I tried to capture the WM_MENUSELECT message but this message always got sent in both of these situations. That is this message is sent when the user browse from one item to another, and also when user click to select an item.
Is there any message other than WM_COMMAND that i can capture when the user actually clicks on the menu item.
What i want is to tell the difference between a browse and a click inside the OnMenuSelect() function.
Regards
|
|
|
|
|
|
I'm working on Access Database with VC++ 6.0 as frontend using ODBC programming...Functions like SQLBindParameter,SQLExecute....Though the data is correctly saved in the Database,I got troubled while retrieving fields of Date/Time and Integer..Other fields are being retrieved properly..I'm using following snippet of code to retrieve Date
sr = SQLBindCol(hstmt,6,SQL_TYPE_TIMESTAMP,date,sizeof(date),&ld);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
{<br />
displayError(sr, "Error in binding 6");<br />
}<br />
The variable date is CTime date[11].The value comes out weird
Can somebody please give me some suggestions?
Thanks
|
|
|
|
|
This function has been working great for about 8 years now...
SYSTEMTIME *DBStatement::GetDate(int iColumnNum, SYSTEMTIME *spDateTime )
{
short iStatus = -1;
if (!spDateTime)
spDateTime = &m_sDateTime;
memset(spDateTime,0,sizeof(SYSTEMTIME));
if (m_hStmtHdl)
{
ResetError();
SQL_TIMESTAMP_STRUCT sTS;
long lColSize = 0;
iStatus = ::SQLGetData(m_hStmtHdl,iColumnNum,SQL_C_TIMESTAMP,&sTS,sizeof(SQL_TIMESTAMP_STRUCT),&lColSize);
if (iStatus == SQL_SUCCESS || iStatus == SQL_SUCCESS_WITH_INFO)
{
if (iStatus == SQL_SUCCESS_WITH_INFO)
iStatus = SQL_SUCCESS;
SetNullValue(lColSize == SQL_NULL_DATA);
if (lColSize != SQL_NULL_DATA)
{
spDateTime->wYear = sTS.year;
spDateTime->wMonth = sTS.month;
spDateTime->wDay = sTS.day;
spDateTime->wHour = sTS.hour;
spDateTime->wMinute = sTS.minute;
spDateTime->wSecond = sTS.second;
}
}
else
UpdateDBError();
}
else
NoActiveStatement();
return spDateTime;
}
onwards and upwards...
|
|
|
|
|
Hey that was really nice of u too help.Can u tell me what is m_sDateTime...That will be of real help..
Thanks
|
|
|
|
|
It is a class member that allows you to get a pointer to a SYSTEMTIME struct without having to pass one in. This provides some flexibility in that you can pass a param to be filled in, or have the class return a pointer to a struct without passing a param.
onwards and upwards...
|
|
|
|
|
Hey thanks for all the help, I worked out an easier way to do it...Just struck it today..
DATE_STRUCT date;
sr = SQLBindCol(hstmt,1,SQL_C_TYPE_DATE,&date,sizeof(SQL_DATE_STRUCT),&ld);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
{
displayError(sr, "Error in binding 1");
}
The structure is exactly what the SQL query wants and works perfectly...
Thanks for everythng once again
|
|
|
|
|
Hi, pavneet!
I'm trying to go the other way: getting system time from a client PC and sending it to an SQL Server database.
Here's a code snippet. The table column OPENDATE is type datetime and I'm binding it to a variable in my app:
time_t now;<br />
struct tm *localNow;<br />
TIMESTAMP_STRUCT tsOpenDate;<br />
char* szStmt = "INSERT INTO ORDERS (ORDERID, CUSTID, OPENDATE, SALESPERSON, STATUS) VALUES (?, ?, ?, ?, ?)";<br />
<br />
SQLDescribeParam(hstmt, 3, &DataType, &ParamSize, &DecimalDigits, &Nullable);<br />
SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, ParamSize, DecimalDigits, &tsOpenDate, 0, &cbOpenDate); <br />
<br />
time (&now);<br />
localNow = localtime (&now);<br />
<br />
tsOpenDate.year = localNow->tm_year;<br />
tsOpenDate.month = localNow->tm_mon;<br />
tsOpenDate.day = localNow->tm_mday;<br />
tsOpenDate.hour = localNow->tm_hour;<br />
tsOpenDate.minute = localNow->tm_min;<br />
tsOpenDate.second = localNow->tm_sec;<br />
tsOpenDate.fraction = 0;
The problem is that the values in the localNow structure are offsets from a '0' date (I think it's 1.1.1900), whereas the data table wants a real calendar date. Thus, the SQLExecute() call fails.
I know I can use the ASCII time conversion functions to get strings for all the datetime parts (strftime), and then convert those to integers (atoi), but there must be an easier way!!!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
hi jesse,
Actually its easier to add the date as CString's rather then the hard way out.
Ctime time;<br />
CString m_appdate;<br />
time = time.GetCurrentTime();<br />
m_appdate = time.Format("%d-%m-%y");<br />
const char *appdate = (LPCTSTR)m_appdate;<br />
SQLINTEGER cappdate = SQL_NTS;<br />
<br />
<br />
sr = SQLBindParameter(hstmt,6,SQL_PARAM_INPUT,<br />
SQL_C_TCHAR,SQL_C_TCHAR,10,0,<br />
(void *)appdate,sizeof(appdate),&cappdate);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
{<br />
displayError(sr,"Error in Binding 6");<br />
}
I think that will help u out......
Pavneet
|
|
|
|
|
Pavneet,
Thanks for your response. In my case, this will not work, as the datatype of the date column is datetime and the Bind call fails unless you use SQL_C_TYPE_TIMESTAMP to describe it.
After reviewing the documentation on localtime, I found I can fix up the date in the following manner:
time (&now);<br />
localNow = localtime (&now);<br />
printf ("%s", asctime (localNow));<br />
<br />
memset (&tsOpenDate, 0, sizeof(tsOpenDate));<br />
tsOpenDate.year = localNow->tm_year + 1900;<br />
tsOpenDate.month = localNow->tm_mon + 1;<br />
tsOpenDate.day = localNow->tm_mday;<br />
tsOpenDate.hour = localNow->tm_hour;<br />
tsOpenDate.minute = localNow->tm_min;<br />
tsOpenDate.second = localNow->tm_sec;
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Pavneet,
Found another way to get the timestamp without the fixup that locatime needs: An SDK function called GetLocalTime
Here's another code snippet showing its use:
SYSTEMTIME systemTime;<br />
GetLocalTime (&systemTime);<br />
<br />
memset (&tsOpenDate, 0, sizeof(tsOpenDate));<br />
tsOpenDate.year = systemTime.wYear;<br />
tsOpenDate.month = systemTime.wMonth;<br />
tsOpenDate.day = systemTime.wDay;<br />
tsOpenDate.hour = systemTime.wHour;<br />
tsOpenDate.minute = systemTime.wMinute;<br />
tsOpenDate.second = systemTime.wSecond;<br />
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Has anybody here used the CMultiColumnComboBox class written by Xiao Wu Guang? The link is http://www.codeproject.com/combobox/mccombobox.asp#xx737862xx. In the posts at the end of the artice, there are some problems with using this class in Windows 2000/XP. Unfortunately, the link to the fix doesn't work anymore. Does anybody know how to make this class work correctly in Windows 2000/XP? It would be nice if one of the better programmers on here (definitely not me) would update this class and repost it with all the fixes! Thanks 
|
|
|
|
|
Hi, I use the MultiColumnComboBox class, I made some changes (which I found in the forum), here is the additional code :
.cpp :
------
in the DrawItem() function, under :
CRect TextRectangle = lpDrawItemStruct->rcItem;
// **** Additional coding Start ****
if (DropDownWindowPointer == NULL)
{
if((GetWindowLong(m_hWnd, GWL_STYLE) & 0x3) == CBS_DROPDOWN)
{
DropDownWindowPointer = GetWindow (GW_CHILD);
}
if((GetWindowLong(m_hWnd, GWL_STYLE) & 0x3) == CBS_DROPDOWNLIST)
{
DropDownWindowPointer = GetWindow (GW_HWNDFIRST);
}
}
// **** Additional coding End ****
under // if vertical scrool bar is visible : replace :
if ((ColumnIndex == m_TotalColumn - 1 || (ColumnIndex == m_TotalColumn - 2 && m_ColumnWidth[m_TotalColumn - 1] == 0)) && (DropDownWindowPointer->GetStyle() & WS_VSCROLL))
TextRectangle.right -= GetSystemMetrics(SM_CXVSCROLL);
BY :
DeviceContextPointer->DrawText(m_ColumnItemList[ColumnIndex].GetAt(m_ColumnItemList[ColumnIndex].FindIndex(lpDrawItemStruct->itemID)), -1, TextRectangle, m_ColumnAlignStyle[ColumnIndex] | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
I think it's all;
if you still have a problem, just answer and I'll send you the complete file.
BrutalDeath0
|
|
|
|
|
I have an MFC application that displays a modeless dialog during a file transfer with the status information. That all works fine, I can update the info in the dialog box with the current file transfer status info. The problem is the user can still try to interact with the main window while this modeless dialog is displayed. What I would like is to have the modeless dialog behave similar to a modal dialog where the user can only interact with that dialog and not access the main view. I do not want to use a modal dialog because the main program needs to continue processing the file transfer. Any ideas on what is the best way to do this?
|
|
|
|
|
Have the main program process your file transfer in a thread, then you'll be able to use a modal dialog box. That's probably not exactly what you were looking for, but it's what I'd try first. Good luck
|
|
|
|
|
maybe by using CWnd::EnableWindow on the main window can do the trick.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Note that you may have to call CWnd::EnableWindow( TRUE ) on the modeless dialog after calling CWnd::EnableWindow( FALSE ) on the parent...
Disabling the parent tends to take child windows with it.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Delete FXP Files Now!]
|
|
|
|
|
|
The AfxGetMainWnd()->EnableWindow(false) did the trick. Always seems so obvious when you know the answer.
The article in http://www.codeproject.com/threads/TemplatedLengthyOperation.asp answered some other questions I had about function pointers.
Thanks for everyones help. Eric
|
|
|
|
|
Searched MS site but only found WDT for NT/2K/XP.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
This seems like a really simple question, but I can't find the answer anywhere else and I know someone in here has to have faced it before.
At the commandline (at least on NT/2k/XP, which is all that matters in this question), you can rename a file which is currently locked using ren and the program holding the file will adjust, allowing you to put a new file in its place ready for later.
If I try to do this using MoveFileEx then (not entirely surprisingly) it complains that the file is locked.
I could open a new process and use the commandline, and I will if I have to, but if there's some way of convincing MoveFileEx or call something else to rename the file then I'd prefer not to have a DOS box flash up.
Does anyone know if this is possible?
Paul
|
|
|
|
|
Does SHFileOperation() work any better?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
have a look at ShFileOperation I think it works for locked files.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You guys rock, thanks. Serious brain freeze on my part.
Paul
|
|
|
|
|