|
Hello,
please tell me how to make a 2d and 3d vector using stl....and also how to assign and get values from it then.....i think i have made the 2d vector correctly but cant seem to assign values to it..THIS IS THE APPROACH I USED
typedef std::vector<int> sArray;
std::vector<sarray> m_map;
std::vector<int> v;
v.resize(m_no_horz_tiles,-1);
for (int i = 0 ; i < m_no_vert_tiles; i++)
{
m_map.push_back(v);
}
but the thing is i cant assign values to my 2d vector like this, given i and j
m_map[i][j] = 1; //value not stored don know why ?????
please guide me...
Thank you
|
|
|
|
|
Interesting.
Try initializing it via constructor.
std::vector v(m_no_horz_tiles, 0);
Kuphryn
|
|
|
|
|
Hello Omar,
I rewrote your code above as follows :
#include <vector>
#include <iostream.h>
#include <stdio.h>
typedef std::vector<int> sArray;
void main()
{
std::vector<sArray> m_map;
std::vector<int> v;
int i = 0, j = 0, m_no_horz_tiles = 5, m_no_vert_tiles = 10;
v.resize(m_no_vert_tiles, 0);
for (i = 0 ; i < m_no_horz_tiles; i++)
{
m_map.push_back(v);
}
for (i = 0 ; i < m_no_horz_tiles; i++)
{
for (j = 0 ; j < m_no_vert_tiles; j++)
{
m_map[i][j] = (i * 10) + j;
}
}
for (i = 0 ; i < m_no_horz_tiles; i++)
{
for (j = 0 ; j < m_no_vert_tiles; j++)
{
cout << "m_map[" << i << "][" << j << "] == " << m_map[i][j] << endl;
}
}
}
The above code yielded the following output :
m_map[0][0] == 0
m_map[0][1] == 1
m_map[0][2] == 2
m_map[0][3] == 3
m_map[0][4] == 4
m_map[0][5] == 5
m_map[0][6] == 6
m_map[0][7] == 7
m_map[0][8] == 8
m_map[0][9] == 9
m_map[1][0] == 10
m_map[1][1] == 11
m_map[1][2] == 12
m_map[1][3] == 13
m_map[1][4] == 14
m_map[1][5] == 15
m_map[1][6] == 16
m_map[1][7] == 17
m_map[1][8] == 18
m_map[1][9] == 19
m_map[2][0] == 20
m_map[2][1] == 21
m_map[2][2] == 22
m_map[2][3] == 23
m_map[2][4] == 24
m_map[2][5] == 25
m_map[2][6] == 26
m_map[2][7] == 27
m_map[2][8] == 28
m_map[2][9] == 29
m_map[3][0] == 30
m_map[3][1] == 31
m_map[3][2] == 32
m_map[3][3] == 33
m_map[3][4] == 34
m_map[3][5] == 35
m_map[3][6] == 36
m_map[3][7] == 37
m_map[3][8] == 38
m_map[3][9] == 39
m_map[4][0] == 40
m_map[4][1] == 41
m_map[4][2] == 42
m_map[4][3] == 43
m_map[4][4] == 44
m_map[4][5] == 45
m_map[4][6] == 46
m_map[4][7] == 47
m_map[4][8] == 48
m_map[4][9] == 49
Hope the above helps.
Thanks,
Bio.
|
|
|
|
|
hi...I am new in the field of ATL...Please suggest some books which take the reader from Beginning to programming stage...
thanks...
utkarsh sharma
"Not everything that counts can be counted, and not everything that can be counted counts."
|
|
|
|
|
The best ATL book so far I've read is ATL Internals[^], by Brent Rector and Chris Sells.
That book together with Essential COM[^] by Don Box is a perfect combo for learning COM. If you're new to COM, I'd suggest you start with Essential COM.
--
You're entertaining at least.
|
|
|
|
|
thanks..for the names ATL Internal and Essential COM...
utkarsh sharma
"Not everything that counts can be counted, and not everything that can be counted counts."
|
|
|
|
|
Hi,,
I make an activeX Control using ATL
I added a full control with the font stock property..
now i want to get notified when this property changes..(after the user changes the property i want to perform some action)...
how can i do this ?
|
|
|
|
|
Take a look at the CStockPropImpl source code (atlctl.h). There you will find code like this:
HRESULT STDMETHODCALLTYPE put_Font(IFontDisp* pFont)
{
...
__if_exists(T::OnFontChanged)
{
pT->OnFontChanged();
}
...
} So, for the property Font you add the OnFontChanged function. For the property Picture, you add OnPictureChanged, etc.
--
They say the most horrible things, but I hear violins.
When I close my eyes, I'm at the center of the sun.
|
|
|
|
|
thank you for the reply but i revised put_Font and it does not contain that code ..
Do you use ATL 7.0 ?
I use ATL 3.0 with VC++6 and I need to implement this functionaliy..
Can you help with this ?
maybe by implementing the OnChange(DISPID) function of IPropertyNotifySink..
Can you help me with this ?
|
|
|
|
|
Sorry, I don't have/use ATL3, so I don't have a fast solution for you.
However, you can always override put_Font et al, and chain the call back to CStockPropImpl<...>::put_Font. If the chain call returns S_OK, then you know the font has been set, and you can perform your specific action.
--
They say the most horrible things, but I hear violins.
When I close my eyes, I'm at the center of the sun.
|
|
|
|
|
thanks again
seems this will be the solution till i get the idea .. or till i use ATL 7.0
|
|
|
|
|
I have the code exactly like the sample OnlineAddressBook from the MSDN library yet I get the error whereas that app does not. Such simple things can stop a programmer for hours.
Here is the code I am using. Note that the Web Service this code is in compiles fine, it's when I compile the SRF (ATL Server) project that the error occurs, let me know if you need to see more code.
// DataConsumerWS.h : Defines the ATL Server request handler class
//
#pragma once
namespace DataConsumerWSService
{
const wchar_t MYDATASOURCE[] = L"Provider=SQLOLEDB.1ersist Security Info=False;User ID=me;Initial Catalog=mine;Data Source=SERVER;Use Procedure for Prepare=1;Auto Translate=Trueacket Size=4096;Use Encryption for Data=False;Tag with column collation when possible=False";
// all struct, enum, and typedefs for your webservice should go inside the namespace
// IDataConsumerWSService - web service interface declaration
//
[
uuid("2E179D71-E436-42EE-A1D6-00758BF3D7AA"),
object
]
__interface IDataConsumerWSService
{
// HelloWorld is a sample ATL Server web service method. It shows how to
// declare a web service method and its in-parameters and out-parameters
[id(1)] HRESULT GetStudents([out] int *arrSize,[out,size_is(*arrSize)] BSTR **NameList,[out,size_is(*arrSize)] LONG **IDList);
// TODO: Add additional web service methods here
};
// DataConsumerWSService - web service implementation
//
[
request_handler(name="Default", sdl="GenDataConsumerWSWSDL"),
soap_handler(
name="DataConsumerWSService",
namespace="urn:DataConsumerWSService",
protocol="soap"
)
]
class CDataConsumerWSService :
public IDataConsumerWSService
{
public:
// uncomment the service declaration(s) if you want to use
// a service that was generated with your ISAPI extension
CDataConnection m_dc;
HTTP_CODE InitializeHandler(AtlServerRequest *pRequestInfo, IServiceProvider *pProvider)
{
if (HTTP_SUCCESS != CSoapHandler::InitializeHandler(pRequestInfo, pProvider))
return HTTP_FAIL;
|
|
|
|
|
Never mind. The problem with using MSDN samples is not being clear on Wizard options selected. Anyway, as I was perusing the process of running sproxy.exe for Console App linkage to ATL Web Services, I came across the .wsdl file that needed to be generated. .NET Studio does this under the Add Rerferences utility, however you first have to open the .disco file to get the http path to your web service. Studio then generates the XML document to link your client to the soap handlers ( .wsdl file). Tis done and tis works.
Whew!
|
|
|
|
|
Hello,
I have a appWizard generated ATL project "with MFC support" (VC++ 6.0 SP5). I try to use Project->Add to Project->Files to add a MFC class (.cpp & .h files). The class shows up in the class view but Class Wizard does not recognize the existance of the new class.
Am I doing something wrong? Any suggestions or different ways to do this. Using Add "New" class works, but I need to use an existing class from files, I do not what to have to recreate a bunch of classes from scratch.
Thanks,
Joe Colosi
|
|
|
|
|
I have a stored procedure that returns more than one result set (mulitiple select statements). I am using ATL Server and have found an example from Microsoft called OnlineAddressBook. This example has helped me considerably with the OLEDB Consumer Template, specifically db_command and db_column. However, all though it indicates the possibility of moving thru more than one result set it doesn't give any clear example, such as syntax or whether or not binding can be manual or has to be automatic. I am sure this is a simple process but it is eluding me and I cannot find any examples or user posts anywhere on this.
I have:
[
db_command(L"{CALL dbo.spTranscriptGetStudents(?, ?, ?) }")
]
class CGetStudents
{
public:
// In order to fix several issues with some providers, the code below may bind
// columns in a different order than reported by the provider
[ db_column(1) ] LONG m_StudentNum;
[ db_column(2) ] TCHAR m_LastName[DB_MAX_FIELDLEN + 1];
[ db_column(3) ] TCHAR m_FirstName[DB_MAX_FIELDLEN + 1];
[ db_param(1) ] DBTIMESTAMP m_asofdate;
[ db_param(2) ] LONG m_schnum;
[ db_param(3) ] LONG m_schyear;
};
|
|
|
|
|
I think I solved this one also. At least it compiled, have to run it to test that it works. Basically bind the columns of the first result set to the db_command using db_column. Then in the receiving method check to see if you can .MoveNext record in the first result set if not use the .GetNextResult method to move to the next one.
Heres the code:
while (S_OK!=GetStudents.MoveFirst())
{
GetStudents.GetNextResult(&numRecs, true);
}
|
|
|
|
|
I'd like to know how to host a windowless ActiveX control in WTL, a Flash control in particular.
In MFC, I add it to the dialog via the resource editor, change the control's window property to transparent and when I run the program I see in the debug output that 'Control wants to be windowless'.
And indeed, the flash control is completely transparent.
But when I follow the same steps in WTL, I can't get the control to lose its window.
Thanks
|
|
|
|
|
You always get a window that hosts the window less control. It might be the case that in MFC, the dialog itself acts as a host for a window less control. Not sure about that.
But if you use the CAxWindow class in ATL (suitable for WTL), it'll contain one window for window less controls (the hosting window) and two windows for windowed controls (one window for hosting the control, and one window which is the control itself).
I'd advise you to use CAxWindow. It's fast and easy. Be aware of problems however if you are using WTL 3.x/7.0 with ATL7. WTL 3.x/7.0 uses the old ATL3 way of dealing with CComModules, which can be a hassle if you don't know the "tricks" (assertions firing all the time )
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Thanks for the reply, but I still have no idea what I have to do
Are you suggesting the problem is with my base class, CAxDialogImpl? Or should I subclass the control's window in a certain way?
Thanks
BTW, I'm using WTL 7.1.
|
|
|
|
|
I just had a peek at the implementation of CAxDialogImpl. I saw that it uses CAxWindow (and CAxWindow2) for hosting the actual controls. It does not host the controls directly, hence you'll always get at least one window per activex control.
There's not much you can do, unless you implement your own dialog which hosts the controls directly (tricky business).
But what's so wrong with an extra window? Your control will function properly!
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
This is bad news, because my intentions were to experiment with a GUI completely built in flash, and I can't do it with window background around it (if I want to use WTL, that is).
Nonetheless, I thank you for your efforts and clarifications!
But before I give up on WTL to do this job, can you give me some hints about hosting the control directly? How much coding and knowledge does it involve?
|
|
|
|
|
Forjer wrote:
This is bad news, because my intentions were to experiment with a GUI completely built in flash, and I can't do it with window background around it (if I want to use WTL, that is).
Interesting concept. How exactly is the flash stuff supposed to be laid out? Should it cover the entire client area, or can you instantiate windowless flash controls and tie them together in some way?
I also don't think you can "escape" the extra window in MFC. I'm not 100% sure about how MFC implements active x control hosting, but I suspect it does it similar to ATL/WTL.
Forjer wrote:
But before I give up on WTL to do this job, can you give me some hints about hosting the control directly? How much coding and knowledge does it involve?
That's quite a daunting task I imagine. There are a number of interfaces you'd need implement. ATL::CAxHostWindow is a good place to start I guess. IIRC, this is the window I've been talking about which hosts the actual control. Perhaps you could derive from it or use code from it to achieve your goal.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Jörgen Sigvardsson wrote:
Interesting concept. How exactly is the flash stuff supposed to be laid out? Should it cover the entire client area, or can you instantiate windowless flash controls and tie them together in some way?
There will be only one flash control which will be the entire client area. Flash can communicate with its hosting program via a special command in its ActionScript, which fires an event. Together with the interface we get a two-way communication.
Jörgen Sigvardsson wrote:
I also don't think you can "escape" the extra window in MFC. I'm not 100% sure about how MFC implements active x control hosting, but I suspect it does it similar to ATL/WTL.
When I try it in MFC I get a debug output of 'control wants to be windowless'. When I override WM_ERASEBKGND, the flash control has no window around it.
A search for the debug message led me to the file occsite.cpp, which led me to the ATL class IOleInPlaceObjectWindowlessImpl.
I don't know if I can make something useful from the information, as I'm very new to the COM architecture, but if I do I'll probably write an article
|
|
|
|
|
Forjer wrote:
There will be only one flash control which will be the entire client area. Flash can communicate with its hosting program via a special command in its ActionScript, which fires an event. Together with the interface we get a two-way communication.
CAxWindow will do just fine for you, honest! CAxWindow offers an interface much like CWindow/CWnd . Just make it span over all your client area.
First create it with (pseudo code) CAxWindow::Create(hWndParent, clientrect, _T("ProgId.For.Flash"), WS_CHILD | WS_VISIBLE); . Then use CAxWindow::QueryControl to acquire a reference to an interface, which you can advise for events.
I'd suggest you create a WTL SDI-project using the WTL wizard. In the wizard, uncheck the "use a view window" checkbox. Click OK to generate project. Then in CMainFrame::OnCreate at the bottom, do something like this:
m_hWndClient = m_activex.Create(*this, rcDefault, _T("flash.prog.id or {clsid}"), WS_CHILD | WS_VISIBLE);
UpdateLayout(); The frame window will then resize your activex control automatically. About _T("flash.prog.id or {clsid}") see the Create method for CWindow in the MSDN docs. CAxWindow interprets the window text as a control class id/prog id. CAxDialogImpl uses this "trick".
It *will* work, and it'll save you from reimplementing the entire OLE hosting code (which is a lot, and not the easiest thing if you're new to COM).
Forjer wrote:
A search for the debug message led me to the file occsite.cpp, which led me to the ATL class IOleInPlaceObjectWindowlessImpl.
That impl stub is used by controls that implement activex interfaces - the interface IOleInPlaceObjectWindowless is used by the container to communicated with the control.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Your efforts are very kind, but I think you missed the point. If I understand the code correctly, it won't make the control windowless, which is my *only* problem.
I have to make it windowless because I only want to show the flash GUI and nothing else. The only way I can achieve this without a windowless control would be to build a square GUI - but that would be unesthetic.
|
|
|
|
|