|
SCENARIO:
From a C++ ATL program I'm submitting database queries to an MSSQL 2000 system in the following formats:
Select * from dbo.table (returns a rowset)
Select * from dbo.table for xml auto (returns an XML stream)
Exec dbo.sproc ... (could return a rowset or an XML stream)
I can't tell before I execute the query whether it will return a rowset or an XML stream, however, after the query is executed I can determine which type of output was returned by checking the rowset's number of columns and first column name.
PROBLEM:
I now have the output in a rowset. This is fine if the output is a rowset, but, if its an XML stream I have a problem. How can I get the output from the rowset into a stream object AND have it properly translate the XML to a readable format?
-- modified at 11:17 Friday 24th August, 2007
The art of conversation is not only saying the right thing at the right time,
but to leave unsaid the wrong thing at a most tempting moment!
|
|
|
|
|
I want to get hwnd of IE main menu,and click one of the items,for example:View->Refresh,I write codes like this:
HWND hwndIE=::FindWindow(_T("IEFrame"),NULL);
HMENU appMenu=::GetMenu(hwndIE);
HMENU subMenu=::GetSubMenu(appMenu,1);
...
Everytime I got zero from subMenu,why?
|
|
|
|
|
It is because IE doesn't have a standard menu, but instead uses a Rebar band with menu in it. Sadly, there's hardly any way to retrieve IE's menu with GetMenu().
Instead, you may want to try using IE's automation interface. I haven't used it to get IE's menu, but it shouldn't be too difficult.
|
|
|
|
|
Dhiraj kumar Saini wrote: how to convert VT_DISPATCH into CString or VT_BSTR
They are not convertable, are they ?
The value returned is in form of VT_DISPATCH , then there must be some property of that interface(object), that might interests you.
Prasad
MS MVP - VC++
|
|
|
|
|
Good morning,
i derived a class CMyStatusBarCtrl from CWindowImpl<mycstatusbarctrl,cstatusbarctrl>
i re-define the create method (private) and i need also to derive the "SubclassWindow" method.
But i don't know from which parent-class i need to derive
For example CStatusBarCtrl::SubclassWindow doesn't exists
Big thanks for help
|
|
|
|
|
Use CWindowImpl::SubclassWindow. It is actually derived from CWindowImplBaseT.
|
|
|
|
|
I have developed an ActiveX control that I want to use on a web site. The general idea is that it won't be accessible from the main page, but rather from a popup window that can be opened from any of the pages on the site. I can open the popup, and the control works just fine. However, when I close the popup, and then close the original (parent) window, I get an exception.
From what I gather in my search on the Internet, an ActiveX control does not get (fully?) unloaded when closing the popup. It only gets unloaded when the first browser windows is closed. However, when closing this first browser window, the exception occurs since the ActiveX control has already been sort of "closed".
The exception occurs on an attempt at closing a socket, but the socket can't be found in the CAsyncSocket classes' socket handle map. Weird.
Some further information... I have nine classes (controls) in the ActiveX DLL. I am calling only one of them - the others are just support controls.
I'm not clear at all on what's going on. Has anybody ever experienced something like this before? I would greatly appreciate any ideas since I'm absolutely stuck at this point.
|
|
|
|
|
in following code:
CString s(_T("hello"));
std::wstringstream oss;
CSimpleStringT<wchar_t> ss = s;
oss << (CSimpleStringT<wchar_t>::PCXSTR) ss; //1
oss << ss; //2
both (1) and (2) use CSimpleString<T>::operator PCXSTR()
however,
(1) uses wstringstream::operator<< for const wchar_t *
(2) uses wstringstream::operator<< for const void *
Why?
Compiled on MSVC2005 with enabled unicode support
|
|
|
|
|
Hi,
I have created an ATL exe server which contains one interface. That interface contains one method. I passed an array of short from client side and is printing value of that array in server side. First value of array is correct but other values are worng. I find myself unable to get the reason.
Please Help.
Server Side
-----------
[
object,
uuid(40290173-0658-4414-9379-106D912396C2),
dual,
helpstring("IExeServer1 Interface"),
pointer_default(unique)
]
interface IExeServer1 : IDispatch
{
[id(1), helpstring("method Display")]HRESULT Display([in]short nCount, [in, size_is(nCount)] short *pnValue);
};
Server side Implementation
--------------------------
STDMETHODIMP CExeServer1::Display(short nCount, short *pnValue)
{
char szBuffer[20] = {0};
short int nCounter;
for(nCounter = 0; nCounter < nCount; nCounter++)
{
sprintf(szBuffer, "%d", pnValue[nCounter]);
MessageBox(NULL, szBuffer, "Message", MB_OK);
}
return(S_OK);
}
Client Side Implementation
--------------------------
HRESULT hResult;
IExeServer1 *pIExeServer = NULL;
int iCounter = 0;
short *pnValue = NULL;
::CoInitialize(NULL);
hResult = CoCreateInstance(CLSID_ExeServer1, NULL, CLSCTX_LOCAL_SERVER, __uuidof(IExeServer1), reinterpret_cast<void **="">(&pIExeServer));
if(SUCCEEDED(hResult))
{
pnValue = reinterpret_cast<short *="">(CoTaskMemAlloc(5 * sizeof(short)));
for(iCounter = 0; iCounter < 5; iCounter++)
{
pnValue[iCounter] = iCounter + 1;
}
pIExeServer->Display(5, pnValue);
CoTaskMemFree(pnValue);
pIExeServer->Release();
}
::CoUninitialize();
Thanks
Manish Rastogi
|
|
|
|
|
Hi AJAX xperts,
I have AJAX autocomplete Textbox, which is a user control. i am getting employee details into this text box. upon typing 3 chars it will fetch 20 records which matchs with the prefix text.
I modified _highligted function(item) in Autocomplete.js in order to store emp fullname in window.status .
upon mouse over on this list i need populate employee details like dept, empid, empmanager, empcost center
here is my autocomplese.asmx C# code :
public string[] GetCompletionList(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}
string peopledata = ConnectionStrings.GetConnectionString("Peopledata");
using (SqlConnection ConnStr = new SqlConnection(peopledata))
{
ConnStr.Open();
SqlCommand sqlcmd = new SqlCommand("GetPeopleDetails", ConnStr);
sqlcmd.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%";
sqlcmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
DataTable dt = new DataTable();
da.Fill(dt);
DataSet ds = new DataSet();
da.Fill(ds);
string[] items = new string[dt.Rows.Count];
int i = 0;
List<string> PeopleData = new List<string>();
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["EmpFullName_MngrName"].ToString(), i);
PeopleData.Add(dr["NBKid"].ToString());
PeopleData.Add(dr["PersonNo"].ToString());
PeopleData.Add(dr["CostCenter"].ToString());
PeopleData.Add(dr["Hierarchy"].ToString());
i++;
}
//return PeopleData.ToArray();
return items;
}//end of sqlconnection
} //end of GetCompletionList
here is my java script code:
var obj;
function GetDataViaAJAX()
{
try
{
obj = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
obj = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e1)
{
obj = null;
}
}
if(obj!=null)
{
obj.onreadystatechange = ProcessResponse;
obj.open("POST", "http://localhost/Autocomplete.asmx/GetEmployeeDetails");
obj.setRequestHeader("Host","localhost");
obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
obj.setRequestHeader("Content-Length","12");
obj.send("Name=" + document.getElementById("lblNamevalue").value);
}
return false;
}
function ProcessResponse()
{
if(obj.readyState == 4)
{
if(obj.status == 200)
{
var dsRoot=obj.responseXML.documentElement;
var ddlOrders = document.getElementById("ListBox1");
for (var count = ddlOrders.options.length-1; count >-1; count--)
{
ddlOrders.options[count] = null;
}
var orders = dsRoot.getElementsByTagName('orderid');
var text;
var listItem;
for (var count = 0; count < orders.length; count++)
{
text = (orders[count].textContent || orders[count].innerText || orders[count].text);
listItem = new Option(text, text, false, false);
ddlOrders.options[ddlOrders.length] = listItem;
}
}
else
{
alert("Error retrieving data!" + obj.status);
}
}
}
function SetValue()
{
var selectedvalue=document.getElementById("ListBox1").value;
document.getElementById("Hidden1").value=selectedvalue;
return true;
}
Can anyone help me on this plzzzz.......Is it possible to work this functionality with Autocomplete
regards,
Menon
|
|
|
|
|
I have a COM dll written using ATL. There is a interface named
"IVehicle". I want to derive 2 new interfaces from this, named
"IToyota" and "IHonda". How can i do that?
The purpose of doing this is that i should be able to use functions
inside both Base interface(IVehicle) from the drived new interfaces.
Thanks in advance.
|
|
|
|
|
[
uuid(XXXXXXXXXXXXXXXXXXXXXXXXXX),
helpstring("IToyota Interface")
]
interface iToyota : IVehicle
{};
Manish Rastogi
|
|
|
|
|
Hi,
What is the Difference between “vector” and “array”?
when to use which one?
Thanks
Nandu.
|
|
|
|
|
There is no "array" in STL. Do you mean Boost Array?
|
|
|
|
|
I wonder if he means the difference between vector and raw arrays?
Kevin
|
|
|
|
|
I mean usind an simple C++ array and STL vector
|
|
|
|
|
Here[^] is a pretty long discussion about that.
|
|
|
|
|
|
hi,
in the code below, i highlighted my points of interest. the declaration of the template function make takes a const char[]. in the call to this function, why is < deque<char> > inserted before the actual parameter? i.e. it's not in the signature and the parameter is not a typename but an explicit const array of characters.
thanks!
<br />
#include "stdafx.h"<br />
<br />
#include <iostream><br />
#include <cassert><br />
#include <deque><br />
#include <algorithm>
using namespace std; <br />
template <typename Container><br />
Container make(const char s[])<br />
{<br />
return Container(&s[0], &s[strlen(s)]);<br />
}<br />
<br />
int main()<br />
{<br />
cout << "Demonstrating generic find algorithm with "<br />
<< "a deque." << endl;<br />
deque<char> deque1 = <br />
make< deque<char> >("C++ is a better C");<br />
<br />
deque<char>::iterator<br />
where = find(deque1.begin(), deque1.end(), 'e');<br />
assert (*where == 'e' && *(where + 1) == 't');<br />
cout << " --- Ok." << endl;<br />
return 0;<br />
}<br />
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
This is the template function declaration.
template <typename Container> Container make(const char s[])<br />
And your example translates to:
template < deque<char> Container> Container make(const char s[])<br />
Which actually translates to:
deque<char> make(const char s[])<br />
{<br />
return deque<char>(&s[0], &s[strlen(s)]);<br />
}<br />
"const char s[]" is just a parameter to the function make, which in your case returns an object of type deque<char>.
- S
50 cups of coffee and you know it's on!
Rock the Vote: John Simmons / outlaw programmer for '08.
|
|
|
|
|
thanks but i was asking about the call to the function template. if you noticed the second highlighted line, the call specifies <deque<char>> before the actual const char array parameter. This <deque<char> is not part of the signature after the function name. But somehow, it is needed to determine what type the instance of the template function is.
cheers!
-- modified at 1:18 Tuesday 7th August, 2007
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
By calling make< deque<char> >, you're telling the compiler which template to use, since it can't "infer" the template type from from the arguments.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
For that particular function, the type of Container isn't indicated by the parameters. IOW, if you wrote:
make("C++ is a better C"); how would the compiler know what type of Container you wanted to make?
|
|
|
|
|
Is this possible? In particular, I just installed copypathext.dll from here: http://www.codeproject.com/shell/copypathext.asp. I'd like to invoke the commands in that dll instead of using the context menu.
|
|
|
|
|
|