|
toxcct wrote: this is faulty, because you convert a string of TCHARs into a string of wchar_t.
not if you have _UNICODE defined.
(and if you haven't defined it, the compiler will complain about...)
By the way T2WC does not exists on my system (Visual Studio 6) can you tell me, please, how is it defined (I'm curious about...)?
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.
|
|
|
|
|
Pallini, looks like you are missing the closing </font> tag in your name.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Thank you very much.
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.
|
|
|
|
|
No problem.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
>> not if you have _UNICODE defined.
then, it's worse, because if unicode is not defined, CString is still contained of TCHAR, which equates to char, not wchar_t.
you should never make assertions such like UNICODE exists or not. if you use TCHARs, then use them for all. otherwise, use (LPCWSTR) instead
|
|
|
|
|
toxcct wrote: then, it's worse, because if unicode is not defined, CString is still contained of TCHAR, which equates to char, not wchar_t.
And the compiler will camplain about. The world will not end.
toxcct wrote: you should never make assertions such like UNICODE exists or not. if you use TCHARs, then use them for all. otherwise, use (LPCWSTR) instead
I can't agree with this...But, I think, it's a matter of taste.
Again, Can you please tell me about T2WC ?
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.
|
|
|
|
|
Are we supposed to guess what your code looks like that is causing this error?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello all,
I have list box IDC_FILE_LIST and a add and remove (IDC_REMOVE) button.
After adding some items in the list box, I want to remove an item which is selected by the user on clicking on remove button.
For that I have used this code and its not working item selected by the user is not getting deleted can please tell me what is the error in the below code.
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_REMOVE:
{
HWND hList = GetDlgItem(hwnd, IDC_FILE_LIST);
int count = SendMessage(hList, LB_GETCOUNT, 0, 0);
SendMessage(hwnd,(UINT) LB_DELETESTRING,count,lParam);
}
break;
-----------
----------------------
Tanking you,
Suresh HC.
|
|
|
|
|
Hi,
To get selected item you should use LB_GETCURSEL (LB_GETCOUNT returns number of items). Besides if you want to use LB_DELETESTRING you need first retrieve what text is at selected item - LB_GETTEXT.
-----------
Mila
|
|
|
|
|
Thank you very much Mila for your response. Your comments helped me a lot.
|
|
|
|
|
The problem arises in the code below:
Suresh H wrote: int count = SendMessage(hList, LB_GETCOUNT, 0, 0);
SendMessage(hwnd,(UINT) LB_DELETESTRING,count,lParam);
you are asking for the number of list items instead of the item currently selected. Moreover the lParam in the LB_DELETESTRING should be zero.
Try this:
int curSel = SendMessage(hList, LB_GETCURSEL, 0, 0);
SendMessage(hwnd, (UINT) LB_DELETESTRING, curSel, (LPARAM)0);
hope that helps
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.
|
|
|
|
|
Thank you very much sir the solution is working.
int CurSel = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST), LB_GETCURSEL, 0, 0);
SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST), LB_DELETESTRING, CurSel, 0);
|
|
|
|
|
|
|
while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation
any solution
HRESULT hresult;
CLSID clsid;
CoInitialize(NULL);
hresult=CLSIDFromProgID(OLESTR("WartzODLCOM.DBAccess"),&clsid);
_DBAccess *t;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(IDispatch ),(LPVOID *) &t);
if(FAILED(hresult))
{
AfxMessageBox("Creation Failed");
return;
}
else
{
MessageBox("success");
}
SessID=SessionId;
CurrentRequestId=RequestId;
marketno.Format("%d",MarketNo);
bid_d.Format("%c",BidDirection);
ask_d.Format("%c",AskDirection);
marketstate.Format("%d",MarketState);
m_MainEdit= SessionId + RequestId + marketno ;
m_MainEdit=Market + Bid + bid_d + Ask + ask_d + High
m_MainEdit= Low + marketstate + Timestamp ;
UpdateData(FALSE);
iLineCount=m_EditCtrl.GetLineCount();
m_EditCtrl.LineScroll(iLineCount);
if(hresult != NULL)
{
USES_CONVERSION;
BSTR bsTimeStamp = A2BSTR(Timestamp);
BSTR bsMarket = A2BSTR(Market);
BSTR bsBid = A2BSTR(Bid);
BSTR bsAsk = A2BSTR(Ask);
t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
SysFreeString(bsTimeStamp);
SysFreeString(bsMarket);
SysFreeString(bsBid);
SysFreeString(bsAsk);
}
else
{
MessageBox("null");
}
FreeLibrary( hInstance );
CoUninitialize();
return;
}
|
|
|
|
|
With_problem wrote: while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation
At which line ? Have you checked pointers for NULL before using ?
With_problem wrote: if(hresult != NULL)
HRESULT should use this way. Use SUCCEEDED(hresult) instead.
i.e
if(SUCCEEDED(hresult))
{
}
|
|
|
|
|
when it comes to setquotetodb function it gives error...i just dont know what to do,i have given my 100%....pls help me
|
|
|
|
|
t , how it is declared? It seems to be NULL in your case.
With_problem wrote: ,i have given my 100%.
You need to be very precise, while stating probem. Otherwisea, it will be unsolved forever.
|
|
|
|
|
can you pls point me wher i am making big mistake....pls
when i use this code it also give error
error C2787: '_DBAccess' : no GUID has been associated with this object
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_DBAccess),(LPVOID *) &t);
But i have seen in .tlh file clsid is attach with this ....
|
|
|
|
|
With_problem wrote: no GUID has been associated with this object
Google to the rescue
Google to the rescue [^]
Try the second link.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
i have change my code also to laod dll.....now what to do....you have hepled me before also...thank you
|
|
|
|
|
hello som you have helped me a lot to solve my problem....i just mail you here to say thank you very much for your support and help...for coding and corresction...
And yes one more thing this error is just no more when i have used the try,catch block.....and now my project is working fine....
Haappy New Year
Regards
Priyanka
|
|
|
|
|
You are always welcome.
Happy New Year to you,too.
|
|
|
|
|
With_problem wrote: t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
when it comes to setquotetodb function it gives error
Is this a COM DLL written in VB? If that is the case then the issue I believe would have more to do with the translation between the string types. I have gone the other way and had issues ie passing strings from a VB app to a C++ dll. If thats true try using LPSTR (from memory, but it just seems wrong) string instead of BSTR
I only ask this because a Google search reviled this link Calling a VB ActiveX DLL from a MFC Client[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
thanks i have used the same link to proceed with....but still facng the problem....after #import dll
when i use namespace it report the error....why...
|
|
|
|
|