|
Sorry guys... PeekMessage doesnt solve the problem.
Any other ideas?
I want to know THE REASON !!!
PS: I solve the problem puting the "anyvalue" in lParam member of LVITEM structure-it works-.
|
|
|
|
|
I realize i have to be more, more specific. Here the code is simplified for you to understand faster. Have fun!
First: RecSet is a member of my CDialog derived class and i never call RecSet->Close()
void CDemosDlg::PopulateList()
{
m_list1.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_list1.InsertColumn(0,"Camp0",LVCFMT_LEFT,100);
m_list1.InsertColumn(1,"Camp1",LVCFMT_LEFT,100);
m_list1.InsertColumn(2,"Camp2",LVCFMT_LEFT,100);
try
{
for (int i=0;i<10;i++)
{
//code for inserting first item -NEVER CALL RecSet-
//code for inseting subitems -NEVER CALL RecSet-
m_list.SetItemData(i,i);
}
}
catch(_com_error &e)
{
MessageBox(e.Description());
MessageBox(e.Source());
}
catch(...)
{
MessageBox("Others");
}
}
THE RESULT?_com_error!!!
MessageBox("The Operation requested by the application is not allowed if the object is closed")
MessageBox("ADODB.Recordset");
OK. If i put
"for(int j=0;j<1.000.000;j++);"
just after "m_list.SetItemData(i,i)" no problem at all.
OK. if i drop "m_list.SetItemData(i,i)" from the code above no problem at all.
OK. Doesnt matter if i use or not the RecSet in code above.The same result.
I hope i made myself clear.
How come "m_list.SetItemData" is so weird???
PS: My application is finished and it is ok. The extra data is placed in lParam of LVITEM structure.
|
|
|
|
|
As others have mentioned, you problem is showing up at the 'SetItemData' call, but unlikely to be caused by this. Your own testing shows you that the error is a COM error reported by ADODB.RecordSet, and is an 'Object is closed' problem. This is very, very unlikely to be in anyway related to "SetItemData". You need to re-examine the ADO record set code - somewhere there lies the problem. The suggestion that you are reading one past the end of the records is worth pursuing.
So why does "SetItemData" trigger the problem ? It probably doesn't - it's just the unlucky 'innocent victm' of some other piece of rogue software. Stop concentrating on "SetItemData", and check the rest of the code.
|
|
|
|
|
Mike Burston told me: "Stop concentrating on "SetItemData", and check the rest of the code."
The code is well finished WITHOUT SetItemData as I always told you.
The code is very simple: Open a connection, open a cursor, bind the cursor and then populate the list. If you have 5 minutes free please try on your computer and let me know the result... Dont forget to put into the code SetItemData.
Thanks.
|
|
|
|
|
Daniel,
I cannot try an exact test of your problem because you have not posted the entire code, only the portions relating to the 'populateList' function, which is where you are getting a crash/error in the SetItemData (after a few iterations). The point I am making is that you probably have an error somewhere else - nothing in the 'populateList' code appears likely to generate the errors you are reporting. The exception you are trapping is telling you clearly that you are attempting an operation on a closed ADO object. "SetListItem" is not related to ADO in any way. A quick search of the MFC source shows that SetItemData is like many MFC functions - a very thin wrapper around the corresponding win32 API calls. In this case, it's essentially just a call to "SendMessage(m_hwnd, LVM_SETITEM, 0, (LPARAM)pItem)".
_AFXCMN_INLINE BOOL CListCtrl::SetItem(const LVITEM* pItem)
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem); }
_AFXCMN_INLINE BOOL CListCtrl::SetItemData(int nItem, DWORD dwData)
{ ASSERT(::IsWindow(m_hWnd)); return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData); }
The point is, and remains, that it is likely you have a subtle problem somewhere in the ADO record set handling code. This problem is subtle enough that it only causes an exception in some circumstances - in other cases (something as apparently simple as removing a call to "SetItemData") the error still occurs, but has not visible effect. In other words, your program may 'appear' to run fine now that you have removed the "SetItemData" call, but it is probable that you have simply curied a symptom, not the disease. Again, I think you need to leave "SetItemData" alone, and concentrate on the rest of the code. Somewhere in there you have a logic error waiting to bite you at some point in the future (probably when you can least afford the time to find it!)
|
|
|
|
|
I don't know about recordsets but with normal files EOF only gets set after you go past the end of file. Meaning while(!eof) produces an extra read resulting in garbage
|
|
|
|
|
I am developing a project using ODBC RecordSet classes. I have a table with a date and time in it. The RecordSet class derived from CRecordSet contains COleDateTime object against the two i.e the date and the time.
Now I want to edit and clear these dates. How do I clear the dates from the Database.
This is urgent.. Anybody.. please
|
|
|
|
|
I have a small problem here, I need to somehow get the parameter from a template, eg <int> passed to a thread function...
I was thinking about something like:
template <typename T>
DWORD WINAPI WorkThread(LPVOID lpParameter);
but the compiler get's mad at me...
"error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'"
Is there any way to do this
I really need it, because I have a template class which get another class as it's parameter, then starts some threads, where the thread parameter is a pointer to the class passed as the template parameter.
In the thread I need to declare a pointer to that class, and then cast my thread parameter to that...
Does that make any sence???
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I don't think that you can take an address of a template function. Even reinterpret_cast or old-style cast will not help.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I was recently trying to do something similar and ended up using a virtual function with an abstract base. The worker thread is implemented as
UINT CMTDataAccess::RunQueryAllocateDataItems(LPVOID pParam)
{
CMTDataAccess* pThis = (CMTDataAccess*)pParam;
pThis->RunQueryAllocateDataItems();
pThis->m_bRunning = false;
return 0;
}
And each class that I implement, must inherit from the CMTDataAccess class. As well, each class must then implement a version of the RunQueryAllocateDataItmes() method.
Drop me an email, if you'd like any other gory details!
Chris
|
|
|
|
|
Hi all,
I want to know for using of Crystal Report 7.0, only i must add the ActiveX in my project ???
If possible write an example about opening the report file and indicate that by this ActiveX
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
why r u using the activex control?? you can use the class lib too if you want ... we do
can give you example code if you need this way
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Hi lauren,
How are you ?
---
I'm very very beginner in Crystal Report ...
So, please say to me:
Q1. Why i must use of LIB instead ActiveX ?
Q2. Which is faster ???
I'm wating for your helps ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi lauren,
So, i want to use of LIB for do it ...
In first please say to me, which libraries i must link to my project ???
And please write small example about opening the Report files by using of LIBs ...
Thanks alooot.
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi all,
I'm developping an onscreen keyboard for a touchmatic system. I have buttons
for scrolling the page and I use IHTMLWindow2::ScrollBy methods. It works
for a single windowed documents (one body - one window) but I have problems
with scrolling of frames. I used 2 approach until now.
One is getting the parent window of active element of the current
document... I was hoping that it would be a frame... but it's always
"FRAMESET" and I know there are 3 frames because I saw them when I get the
list of the frames from IHTMLFramesCollection2...
For example... "www.osym.gov.tr" is a framed url. I must scroll down the
right side frame... (Yes I can scroll it by getting IHTMLWindow2 from
IHTMLFrameCollections2 but think there are 2 scroll-needed frames!...)
The other one is getting the parent window of the current document... this
gives me the "FRAMESET", too... the only exception is when no frame - one
body - one window...
I must find a way of getting the active frame... at least determine an
active frame myself and scroll it... (But the problem for this is the nested
frames... How deep I must go down!!!)... Can you give any advise?
Oguzhan...
|
|
|
|
|
Hello,
I tried to insert Microsoft FlexGrid Control in a console application that supports MFC but during the execution the flexible grid doesn't appeare. How can I solve this problem?
Thanks for any reply.
|
|
|
|
|
My first question is: a console app? How do you expect to see a grid if you don't have a window up? Providing you have a window, then we can talk.
|
|
|
|
|
Dear CodeGuy,
probably it's not clear that I have a console application SUPPORTING MFC, then it's obvious that I can show the windows. My problem is: I have inserted in a window the FlexGrid control and I call this window using the method "DoModal" but it doesn't appear
ASSO boys
|
|
|
|
|
What I mean is to start the application in a docking bar ,
then call different MDI interfaces of differnt functions
by clicking the BitmapButtons on the bar.How to realize
it by using MFC? I have developed a Dialog application by
using APPWIZEARD,then make it topmost ,NO TITLE &SYSMENU,
Drag&Move,but I can not realize the DOC/VIEW architectures
on the next step.How to?
thx everyone, and please forgiving my poor English.
.
|
|
|
|
|
Hi,
I've a question relating to IE.
I'm opening IE from VC, and passing a .htm file as command line arg. It opens fine.
But when I call it for the second time it opens in a new IE window, but I dont want this to happen. What should be done?
Yuvarajan JT
|
|
|
|
|
I have declared a function called Solve like this :
double Solve(double (pFn) (double), double pX);
Here the code for pFn :
double pFn(double pU)
{
return pow( pU*3.14-1.5, 3 );
}
I would like to know how to use the function Solve , which is needed to solve : pFn(X) = X ?
Thank in advance for your help.
Joe
|
|
|
|
|
Do your homework by yourself!!
|
|
|
|
|
VERY VERY FUNNY ANSWER !
I don't know how old are you, but I guess : 10-13.
Don't forget : "Boys will be Boys !", It is so true...
Joe
|
|
|
|
|
Hi,
Could anyone please show me an example how to create a hidden window? Thank you very much.
|
|
|
|
|
Just call ShowWindow with SW_HIDE.
|
|
|
|