|
Your data structures aren't VT_VARIANT, they are VT_RECORD.
You can define structures in an IDL file, and use SAFEARRAY(structname) in the IDL, just like SAFEARRAY(BSTR) or SAFEARRAY(LONG). If the base types are all oleautomation compatible, then you don't need to worry too much about marshalling.
To create and populate an array, you need stuff like this;
CComPtr<irecordinfo> spRI;
hr = GetRecordInfoFromGuids( LIBID_MyLib, 1, 0, 0x409,
__uuidof(structname), &spRI );
if (SUCCEEDED(hr))
{
SAFEARRAY* psa;
structname * pdef;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 500;
psa = SafeArrayCreateEx( VT_RECORD, 1, rgsabound, spRI );
if (psa)
{
SafeArrayAccessData(psa, (void**)&pdef);
// can now access pdef[0].xxx, pdef[1].xxx etc
SafeArrayUnaccessData(psa);
}
}
Does that help any?
Steve S
Developer for hire
|
|
|
|
|
Hello, thank you, it helped, but how to define my structure in IDL File???
|
|
|
|
|
like this:-
----------------------------------------
#ifdef __midl
typedef
[
uuid(9CB2EA23-FFFF-46e6-B718-43E57261F306),
version(1.0),
helpstring("Catalogue Info (with permissions)")
]
#else
struct __declspec(uuid("9CB2EA23-FFFF-46e6-B718-43E57261F306")) CATINFO;
typedef
#endif
struct CATINFO
{
BSTR bstrCat;
long lPerms;
}
CATINFO;
----------------------------------------
By putting this in a header file (.h) and using #include in your IDL file, you'll get a file you can use in IDL and in C++. Obviously, you need to put your own UUID values in place;
Steve S
Developer for hire
|
|
|
|
|
Hello !
I had a project with CMyFormView.
I added new form named CDocExample with base class CFormView, how can i switch to CMyFormView to CDocExample ?
Please help me.
Thanks.
|
|
|
|
|
Assuming that CMyFormView is derived from CFormView. You ought to be able to replace all instances of the text "CFormView" within CDocExample with "CMyFormView".
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
May not be a good assumption
Perhaps the original question meant "I want to switch views at run-time".
If this is the case then Q99562 in the VC++ knowledge base might help.
Steve S
Developer for hire
just think how much CP bandwidth would be saved if everyone searched the MSDN library first.
But then, how would the rest of us feel so smug?
|
|
|
|
|
Hi all,plz help me to read the *.doc files,i don't know the structure of this file so i cannot read them.Thanks a lot!
tien mkjerhk wjh
|
|
|
|
|
Can't you just use Word for this? If not, you may get lucky and find the file's format at www.wotsit.org.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Is there a way to check if file exist in c?
I have no idea
|
|
|
|
|
jinxmanh wrote:
Is there a way to check if file exist in c?
Which 'C'
Windows Based (Win32Api)-PathFileExists
In Dos Based 'C'-
here is Smmall COde
<br />
FILE *hFile=NULL;<br />
<br />
hFile=fopen(FileNamewithpath,"r" );<br />
if(hFile==NULL)<br />
{<br />
printf("file Doesnot Exists");<br />
return;<br />
}
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
ThatsAlok wrote:
FILE *hFile=NULL;
hFile=fopen(FileNamewithpath,"r" );
if(hFile==NULL)
{
printf("file Doesnot Exists");
return;
}
Not true. fopen() will return NULL on error. The error could be anything, not just that the file does not exist. ie, it could be opened in exclusive share mode by another app.
A better way is to use _access().
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
Not true. fopen() will return NULL on error. The error could be anything, not just that the file does not exist. ie, it could be opened in exclusive share mode by another app.
Sorry, I Will take Note Of it.
Thanks
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
PJ Arends wrote:
fopen() will return NULL on error
And errno will have a value of 2.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi everyone:
Can someone tell me how to enable/disable tab stop for a specified dialog control? Please don't tell me to set this in the property of the control, I need to do this through some codes. Thanks!
|
|
|
|
|
After posting the question for a while, I found the CWnd member function ModifyStyle() may realize this function by removing the WS_TABSTOP style from the specified control. Is that right?
|
|
|
|
|
yes.....
use the ModifyStyle() function...
if the optionis initially there.....
then write it as .....
ModifyStyle(WS_TABSTOP ,0);
dont see y it shouldnt work.....
try it.....
happy programmin.....
cheerz.....
|
|
|
|
|
I have a dialog, which starts modeless subdialogs. They run nicely, but they always stay on top of the parent, even when the parent has the focus (I can type in data in a control of the parent window, if I move the child enough to the side).
I trapped WM_ACTIVATE and issued SetWindowsPost(&wndTop...). This gets the control and works almost well (it moves the window If I want to), but it still remains under the children.
What else do I have to do in order to win over the children?
|
|
|
|
|
Make the subdialogs parent while creating them as the desktop window by calling GetDesktopWindow() i guess that should fix the problem.
-prakash
|
|
|
|
|
That works well (although I wanted to avoid seeing the subdialogs on the task bar, but I can solve that otherwise).
Thanks you.
I wanted to rate your response, and accidentally clicked on "1". Sorry for that.
|
|
|
|
|
"I wanted to rate your response, and accidentally clicked on "1". Sorry for that."
nevermind.
-prakash
|
|
|
|
|
I have a situation where users are trying to create large 24bit DIBs (10,000 x 10,000) or greater and CreateDIBSection is failing. The problem appears to occur when virtual memory gets low. I can create the large DIBs when I don't have a lot of memory allocated for other things. I tried using the following:
HANDLE hFileMap = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwStorageSize,NULL);
dwLE = GetLastError();
if(INVALID_HANDLE_VALUE == hFile)
hFile = NULL;
if( NULL == hFileMap)
ErrMsg( dwLE);
LPVOID pDibBits = NULL;
HBITMAP hBitmap = ::CreateDIBSection( NULL, m_bitmapinfo, DIB_RGB_COLORS, pDibBits, hFileMap, 0);
dwLE = GetLastError();
The thought was that using CreateFileMapping() to allowcate memory for the DIB bits when memory was low but it still fails and GetLastError() return 0 which does not help. Is there a way to use swap file or temporary disk files as storage space for DIB bits when processing large bitmap files?
|
|
|
|
|
Its not a question of having enough RAM, you need to have enough address space available in your process. I think you won't have this issue on a 64 bit OS and a 64 bit process. Even a 32 bit process on a 64 bit OS helps as long as the process is Large Address Aware.
|
|
|
|
|
Hey,
While executing my program the debugger states that the program "...UserInterface.exe" has exited with code -1 (0xFFFFFFFF). I'm executing this program after a period of about 4 months. It was working fine when I left it. The only thing thats changes is that I had reformatted my computer and reinstalled windows. I have changed all the path changes made in the code.
Any idea why this happens?
Regards
|
|
|
|
|
Hey,
Never mind the question. Found the bug.
Thanks...
|
|
|
|
|
Can anybody point me to some example code or give me some tipson how to get a .jpg blob from an Access database into a static (picture) control?
Thanks in advance,
John
|
|
|
|