|
I might be misunderstanding the workings of a VARIANT , but I am trying to pack a SAFEARRAY and assign it to my VARIANT . When I place a break point I can see I am getting data into the array but when I try to debug the component in VB I can only get 1 element back which is 0. Does anyone see something wrong with this, this is the first time I have tried using a SAFEARRAY so bare with me. Thanks in advance.
STDMETHODIMP CMoses::GetNumbers(VARIANT *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
HRESULT h;
long lDimension[2];
int startyear, runyear;
startyear = 3;
runyear = 68;
typedef vector<double> collection;
collection numbers;
for(int i = startyear * 12; i < runyear * 12; i += 12)
{
IColumn col(root.Column("nsv_e_0"));
if(col != NULL)
{
CString num;
num.Format("%d", i);
numbers.push_back(col.value(num));
}
}
SAFEARRAYBOUND bounds[1];
SAFEARRAY *psa = NULL;
bounds[0].lLbound = 1;
bounds[0].cElements = numbers.size();
psa = SafeArrayCreate(VT_R8, 1, bounds);
if (psa == NULL) throw ERROR_NOT_ENOUGH_MEMORY;
int j = 0;
vector<double>::iterator it;
for(it = numbers.begin(); it != numbers.end(); it++, j++)
{
lDimension[1] = j;
lDimension[0] = 0;
h = ::SafeArrayPutElement(psa, lDimension, &it);
}
pVal->parray = psa;
return S_OK;
}
- Nick Parker My Blog
|
|
|
|
|
Try
pVal->vt = VT_ARRAY|VT_R8;
just before your 'return S_OK'.
You're setting the VARIANT value, but not it's type.
Steve S
|
|
|
|
|
Steve S wrote:
You're setting the VARIANT value, but not it's type.
Gotcha, that makes sense. Now VB is returning a list of 0's. Not sure why I am not getting the numbers. I threw in a ::AfxMessageBox(...) to check that I am getting a value from the iterator when it is dereferenced, which it is. Am I following the correct syntax by assignment the address of the iterator to the SAFEARRAY ? Thanks again Steve.
[EDIT] I solved the problem, I had the lDimension flip-flopped, thanks again for your help. [/EDIT]
- Nick Parker My Blog
|
|
|
|
|
I am trying to write an application in C++ to implement privacy control. For that I need to know how to read a cookie. If someone knows, please let me know
Thanks,
subbu
|
|
|
|
|
Refer to MSDN articles Q241492 and Q240191.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, but I must use ATL COM...and without?
I should make an application .exe.
|
|
|
|
|
The code shown in article Q241492 (it's just COM) can be used with or without ATL.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
there are 2 buffers (size= 1 MB) in my app. one buffer is in video memory (get by DirectX), another one is in system memory (by new).
if copy from system buffer -> video buffer, time=15 ms
if copy from video buffer -> system buffer, time=180 ms
my question is:
why is it so slow from video to system memory? how to solve the problem?
thanks
includeh10
|
|
|
|
|
It's very common for reads from the video buffer to be slow. The details of why depends on your specific hardware and directx driver. In general terms the video buffer is not just another block of RAM; after you are done writing to it, it may not contain exactly what you put in yet (or ever). DirectX tries to hide these details, but when you read from video memory it has to make everything synch up so it behaves like you expected it to.
The most common workaround is to rework your application so it does not have to read from the video buffer. It's seldom absolutely necessary.
|
|
|
|
|
Hi antlers,
what i need is just "read from video memory". i don't need 'write to video memory'.
it can be assumed as a screen capture.
my process is
1. use surface->Lock to get video buffer
2. copy the buffer to system memory
u say 'it does not have to read from the video buffer', could u give me some details for re-working my app?
(the app is in realtime, speed is important, so i use DirectX)
thanks.
includeh10
|
|
|
|
|
hello
i am new to c++ (Microsoft Visual Studio .NET 7)
normally i can see all the variable and objects when i run a program through the debugger.
however i have a program which executes in an exe and when i run it through the debugger i do get output but i do see the very useful tree containing all the variables and objects.
also i receive these errors:
'mediasinkencoder.exe': Loaded 'C:\WINNT\system32\NTDLL.DLL', Cannot find or open a required DBG file.
'mediasinkencoder.exe': Loaded 'C:\WINNT\system32\KERNEL32.DLL', Cannot find or open a required DBG file.
'mediasinkencoder.exe': Loaded 'C:\stlport\lib\stlport_vc746.dll', No symbols loaded.
how do i get the objects and variables into my debugger??
thank you!
|
|
|
|
|
Those are all the system DLL and compiler DLLs. There really isn't much in those files you will need to look at. The messages are just to let you know that the debugger looked for the files. Unless you are actually debugging something in those DLLs, you can ignore the message.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks,
I found my problem. It was really silly. i needed to display the autos browser.
|
|
|
|
|
Hi All!
How can I change the title bar in a window using Win32 SDK (NO MFC, NO ATL)?
thanks!
|
|
|
|
|
you should handle WM_NCPAINT and draw your own title bar. Windows does not have default way of changing the title bar.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
If you want to just change the text in the title bar, use SetWindowText(HWND hwnd,LPCTSTR string); , where hwnd is the handle for the window, and string is a pointer to the string.
Software Zen: delete this;
|
|
|
|
|
hi,
Can anyone tell me how to have a picture (*.gif file)in my Dialog box ?
Thanks
Deepak Samuel
|
|
|
|
|
On a button? As the background? Where do you want the picture rendered?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
I want it to be displayed at one corner of my Dialog box.
Thanks,
Deepak Samuel.
|
|
|
|
|
insert WebBrowser control in the Dialog box and load the gif in it
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
Hi
I have a class called Node which is derived from CButton
now I want have associated a property sheet with it. depending on the Node windowtext I want to set the values in list boxes of all the pages related to the property sheet. How do I do it?
I believe i will attain it through overriding the OnInitDialog of the pages associated with the sheet but since these vary I cannot simply add data to the lists. How do I do it??
can somebody guide me.
Thanks in advance.
|
|
|
|
|
Not sure I quite understand what you're trying to do.. but...
why not give Node a constructor or member function that takes a pointer to a CListBox (or CListCtrl or whichever you are using) and store the pointer as a member in Node. Then the Node class can handle its own click (ClassWizard lets you do this - otherwise I forget the exact handler function) and that can access the proprety page in whatever way you like.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
I was trying to upgrade a C++/MFC project from VS6 to VS.NET 2003 and hit a linker problem that I cannot explain. Can one of you?
I was expecting the MFC linkage to occur to MFC7x, but the linkage fails with linker error "cannot find mfc42d.dll". I understand that the linker cannot find that dll (it's nowhere in the library search patch), but why does it look for it in the first place? How is the desired MFC version adjusted or determined?
There is no reference in the project preferences to that dll, or to anything else that looks remotely like "mfc42". I am building a DLL, which itself links to several DLLs via import libraries. These other DLLs are linked to MFC42, would that require the primary DLL to be linked to MFC42 as well?
Any thoughts are welcome.
TIA,
Bernd
|
|
|
|
|
Somewhere in your project is code that is still compiled for VC6. You will need to recompile everything to remove all references to MFC42D.dll. Also note that this is the debug version of the DLL.
Software Zen: delete this;
|
|
|
|
|
Thanks. The project itself has been cleaned and re-built at no avail.
You didn't mention the import libraries, but I believe these should not cause the problem anyhow. How about function libraries, thought?
Surely these must be rebuilt for MFC7, too? Hmm, that's like opening a can of worms.
I guess I can not link the application to both MFC42 and MFC71 at the same time, right?
|
|
|
|