|
Hello all, I have already posted this in the SQL board, but I didn't get any answer. I thought that perhaps this section would be more appropriate for this request. In any case, this is just to say that I am not spamming ...
I have been looking everywhere for a solution to this, but I couldn't find it.
I am trying to access a (generic) database using OLEDB Consumer Templates (of which I have little experience) in a WTL project (VC 2003, WTL 7.5).
Ok, the problem is that when I open a CCommand object passing a DBPropSet structure I get no rows in return.
Let me try to explain with the code..
With the following code everything works fine. I get columns and rows correctly (I removed a lot of stuff such as error handling, to simplify). The code it’s more or less the same used in the MSDN sample DBViewer:
<code>
CCommand<CManualAccessor> oCmd;
oCmd.Open(m_session, sSQL, NULL, &nRows, DBGUID_DEFAULT, FALSE)
if (oCmd.m_spRowset == NULL)
{
//ERROR STUFF
}
if (oCmd.GetColumnInfo(&ulColumns, &pColumnInfo, &pStrings) != S_OK)
ThrowOleDBError(oCmd.m_spRowset, IID_IColumnsInfo);
struct MYBIND* pBind = new MYBIND[ulColumns];
oCmd.CreateAccessor(ulColumns, &pBind[0], sizeof(MYBIND)*ulColumns);
for (ULONG l = 0; l < ulColumns; l++)
oCmd.AddBindEntry(l + 1, DBTYPE_STR, sizeof(TCHAR)*255, &pBind[l].szValue, NULL, &pBind[l].dwStatus);
oCmd.Bind();
ULONG ulFields = oCmd.GetColumnCount();
while(oCmd.MoveNext() == S_OK)
{
for (ULONG j = 1; j <= ulFields; j++)
{
lpszString = pBind[j-1].szValue;
// PRINTING STUFF
}
}
</code>
Now, if I add properties to the command using this:
<code>
CDBPropSet pset( DBPROPSET_ROWSET );
pset.AddProperty(DBPROP_IRowsetView, true);
pset.AddProperty(DBPROP_IRowsetScroll, true);
pset.AddProperty(DBPROP_IRowsetChange, true);
pset.AddProperty(DBPROP_UPDATABILITY,
DBPROPVAL_UP_INSERT | DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE);
pset.AddProperty( DBPROP_CANFETCHBACKWARDS, true, DBPROPOPTIONS_OPTIONAL );
pset.AddProperty( DBPROP_CANSCROLLBACKWARDS, true, DBPROPOPTIONS_OPTIONAL );
/*…*/
oCmd.Open(m_session, sSQL, &pset, &nRows, DBGUID_DEFAULT, FALSE, 1)
/*…*/
</code>
I get the columns shifted right (like if there is an empty column before all the others), and no records.
The m_spRowset member however it’s not null, as I check for it after the call to Open()
Can you please help me out, or at least tell me why this happens?
Thank you very much!
Guybrush Threepwood
|
|
|
|
|
Wow, is it really possible that nobody has an answer for this?
Sorry sorry, I don't mean to be arrogant... It's just that I was able to find two more requests like mine looking through forums and the usenet, and nobody got an answer either.
Is it just a very stupid error on my part? Is it a bug in the templates?
|
|
|
|
|
Hi
I have a ICopyHook extension DLL. But this DLL is coming to effect only when i restart my explorer i.e, by lkilling the explorer.exe. If i register the DLL, i will have to kill the explorer.exe to make it work. Is there any way by which i can make the DLL work wihtout restarting the explorer.
|
|
|
|
|
I have to create a Transparent static text in an ATL Composite control dialog, So that the background image must see from top.
Please help!
ANil
|
|
|
|
|
Add a message handler like list to the dialog:
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic)
Add the handler:
LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
HWND hEdit = GetDlgItem(IDC_STATIC1);<br />
if ( hEdit == reinterpret_cast<LRESULT>(lParam) )<br />
{<br />
HDC hDC = reinterpret_cast<HDC>(wParam);<br />
SetBkMode(hDC, TRANSPARENT);<br />
return reinterpret_cast<LRESULT>(GetStockObject(HOLLOW_BRUSH));<br />
}<br />
<br />
return 0;<br />
}<br />
Steve
|
|
|
|
|
I did as this, but still it Static text is not transparent. Then I check in Debug and found that the control is not enetering in OnCtlColorStatic function.
PS: am subclassing the Dialog to display background image
|
|
|
|
|
The WM_CTLCOLORSTATIC is sent to the parent of the static text control - Make sure you're handling it in the dialog and not the control itself. To handle it in the control you need to use message reflection, don't worry about this for now.
Steve
|
|
|
|
|
Yes, I am handling WM_CTLCOLORSTATIC in dialog itself. But there is no change in behaviour of static text. How to proceed now?
|
|
|
|
|
I'm not sure what could be going wrong - Perhaps if you post some of your code...
Steve
|
|
|
|
|
I have message handler
MESSAGE_HANDLER(WM_CTLCOLORSTATIC,OnCtlColorStatic)
and handler function like
LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HDC hdcStaic = (HDC) wParam; // handle to display context
HWND hwndStaic = (HWND) lParam; // handle to static control
HWND hEdit = GetDlgItem(IDC_STATIC_MESSAGE_BOARD);
if ( hEdit == hwndStaic )
{
HDC hDC = reinterpret_cast<hdc>(wParam);
SetBkMode(hdcStaic, TRANSPARENT);
SetTextColor( hdcStaic, RGB( 0, 0, 255 ) );
return reinterpret_cast<lresult>(GetStockObject(HOLLOW_BRUSH));
}
}
and I did set background image by subclassing the dialog where the Static text placed.
|
|
|
|
|
You got me....This is almost exactly what I tried and it worked fine.
Steve
|
|
|
|
|
I have some code like this in OnInitDialog() to set background image, Does it causing the problem?
m_PictureWindow.SubclassWindow(m_hWnd);
m_PictureWindow.m_nMessageHandler = CPictureWindow::BackGroundPaint;
m_PictureWindow.Load("D:\\image.bmp");
Did there is a Background image for your dialog when you tried?
|
|
|
|
|
Try reversing the tab order. In MSVC 6:
- Select "Layout->Tab order".
- Click on all the control from the highest number to the lowest number.
This is just a hunch.
Steve
|
|
|
|
|
Still no change: Thanks for your suggestions. Lets start again a break!!!
Steve,
How I add a windows media player control to my ATL dialog. I can't add using wizard, since it not support in ATL. Then how i get the pointer to operate the control like set the movie file, start video and stop video etc etc....
|
|
|
|
|
1. Go to the dialog editor.
2. Right click on the dialog and select "Insert ActiveX Control...".
3. Select the ActiveX control you want. I selected "Windows MEdia Player", it was last in the list.
4. Press "OK.
5. Right click on the control and select "Properties".
6. Set the properties.
Try that for a start.
Steve
|
|
|
|
|
Done already, How I identify & get the interface from the control
for example, A brwser control use <iwebbrowser2> & we can get pointer "Navigate" to WebBrowser control. Like this...
CAxWindow wndIE = GetDlgItem(IDC_OCX1);
CComPtr<iwebbrowser2> pWB2;
HRESULT hr;
hr = wndIE.QueryControl ( &pWB2 );
if ( pWB2 )
{
CComVariant v; // empty variant
pWB2->Navigate ( CComBSTR("http://www.codeproject.com/"),&v, &v, &v, &v);
}
So in case of windows media player, what must be given as "IWebBrowser2". I need interface to play, stop, pause video
Please advise I am just new comer to COM interfaces
|
|
|
|
|
There are a number of ways. In the case of the WebBrowser all the files you need already come with the compiler and it's just a matter of including them. I believe the Media Player has an SDK that will the header files you need. Alternatively you can use #import . Follow these steps to use #import :
1. Load up the "OLE View" tool that comes with Visual Studio.
2. Open up "Object Classes->Grouped by Component Category->Contols".
3. Find control in question.
4. Select it.
5. In the right pane under the "Registry" tab find the Type library location. For me it looked like this: "win32 = C:\WINDOWS\System32\wmp.dll".
6. Add #import "<TypeLibrary>" to the dialog - Where <TypeLibrary> is the path to the type library. So for me I add #import C:\WINDOWS\System32\wmp.dll"
This will generate the files you need - Look for .TLH and .TLI files in your output directory, these are what was generated by #import (when you compile).
In OLE View you can right click on a component and select "View Type Information" to view the components interface.
Then you use the control with code like this:
WMPLib::IWMPPlayer4Ptr spWMP4;<br />
HRESULT hr = GetDlgControl(IDC_OCX1, __uuidof(spWMP4), (void**)&spWMP4);<br />
if ( SUCCEEDED(hr) )<br />
{<br />
spWMP4->SOME_FUNCTION();<br />
}
That's the basic idea. I don't know how to drive the Media player control so my example doesn't do much.
Steve
|
|
|
|
|
Thanks, It worked.
But the windows media player show as pop up window, rather than show as embedded control in the parent ATL dialog. How to it in the parent dialog as embedded?
|
|
|
|
|
anilFirst wrote: I
It does? Mine shows up as a little media player on the dialog. Did you add the control to the dialog as I did (right click dialog and select add ActiveX control)?
Steve
|
|
|
|
|
Exactly same way!!! Also the poped up window is same as when we call mediaplayer from Start>programfiles>mplayer.exe
-- modified at 2:32 Tuesday 24th January, 2006
|
|
|
|
|
I always thought you had to get at least the Standard version of VC++ to be able to program WTL apps due to the fact you need ATL. Because of this I was planning on getting Visual Studio Standard 2005 soon.
Now I've just found an article on CP with instructions of how to program WTL apps with VC++ Express 2005 since you can get ATL from the Server 2003 SP1 PSDK.
Can someone who's tried it clarify for me that it is indeed possible to develop fully fledged WTL apps with VC++ Express 2005 ?
What are the drawbacks (if any) of using VC++ Express 2005 to develop WTL apps ?
|
|
|
|
|
I haven't looked at that particular build of the PSDK, but in the earlier builds, any MFC and ATL files that came with it were pre-releases and/or 64-bit versions. Not suitable for production code. (This may have changed, but double-check the SDK to be sure before you start using those files.)
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi,
I am creating a plugin for Outlook. i have created commandbarbutton on Explorer window. Now i have to create those commandbarbuttons on inspetor window.
how can i resolve this .
Thanks in advance
regards,
RamakoteswaraRao
spend every minute for success
|
|
|
|
|
Can anybody help me how to convert MFC DLL to ATL DLL?
Srinu
|
|
|
|
|