|
Dear All,
I have alot of old functions that have 'FILE *' as a passing parameter.
Now I am using Compound File...It uses IStream (from IStorage).
Does anybody know how to convert IStream to FILE* ?
Thank's
|
|
|
|
|
Fwzklmn wrote: Does anybody know how to convert IStream to FILE* ?
In general you can't. An IStream is more abstract then a file: while some IStream implementations wrap files most will not.
Steve
|
|
|
|
|
you can use this(use from ISream only) (of course this is only a suggestion
<br />
IStream *m_StreamFile;<br />
SHCreateStreamOnFile(filename,STGM_READ,&m_StreamFile);<br />
whitesky
|
|
|
|
|
Read #1 and #9 here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
This is in my homework.
Can you do it?
|
|
|
|
|
lulu0441 wrote: Can you do it?
While the odds are in my favor, why would I want to? How does me, or anyone else, doing your homework help you at all.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
erfy wrote: how i can create a database for my program?
Microsoft SQL, Access, MySql, Oracle? be specific.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
If you are using MFC, try:
CDatabase Db;
Db.OpenEx("DRIVER={SQL Server};SERVER=(local);UID=sa; PWD=", CDatabase::noOdbcDialog);
Db.ExecuteSQL("CREATE DATABASE MyDB");
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I suggest use Access and you can see Examples from Acess in MSDN
whitesky
|
|
|
|
|
I want to write a software which can automately reply the messages for users.Who can give me some materials.Thank you!
|
|
|
|
|
Look for software related to 'Eliza'
I've seen better runs in my shorts! - Patches O'Houlihan
|
|
|
|
|
I am trying to create a color fill that will change relative to a new value being input from the "OnHScroll" function. When I input a new value for the red color variable in the RGB function and re-display, the color never changes to the new value. See code segment below. How do I change?
...
...
int a=0,b=190,c=230,x;
CMainFrame::CMainFrame()
{
//Set color frame
colorbar.CreateSolidBrush(RGB (a, b, c));
};
void CMainFrame::OnPaint()
{
CPaintDC dc(this);
dc.TextOut (5,40,"Red Color Is:");
//Output color frame
colorbar.DeleteObject();
colorbar.CreateSolidBrush(RGB(a,b,c));
dc.SelectObject(colorbar);
CRect rc(100,150,150,200);
dc.Rectangle (&rc);
}
void CMainFrame::OnHScroll(UINT nSBCode, UINT nPos, CWnd* pCtrl)
{
//Convert pointer to slider pointer
CSliderCtrl *pSld;
pSld = (CSliderCtrl*)pCtrl;
//Get new position
x = pSld->GetPos();
a = x;
CString s; s.Format("%d",x);
//Output value for red
stcred.SetWindowText(s);
}
Note that:
1.) Initialize the colorbar to have values RGB(a,b,c)
2.) Variable "a" read in from the "OnHScroll" function and set to a new value.
3.) "OnPaint" deletes the old colorbar and re-creates with new "a" variable value, should display as output with the new color but doesn't, still displays as original a,b,c values. Please advise, Sid kraft sid_kraft@msn.com Thanks in advance, Sid Kraft.
Sid
|
|
|
|
|
sidkraft wrote: //Output value for red
stcred.SetWindowText(s);
Use InvalidateRect(...) with your colorfill rect as a parameter after stcred.SetWindowText(s); which fires the Onpaint Message and you will get the result
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi!
I have an activeX control, which should send variuous arrays to the client. What I have done, is to wrap these arrays into a CComSafeArray and then send it as a pointer to a VARIANT.
How can I then on client side determine which datatypes the array consists of? Whether it is int, long, double, float and so on?
|
|
|
|
|
The variant type should tell you on the client (if your ActiveX control is putting them together correctly).
For instance, the VT of the VARIANT would be VT_ARRAY | VT_I4 for longs, VT_ARRAY | VT_I2 for shorts, etc. It could be VT_ARRRAY | VT_VARIANT, which means that each element of the array is a variant itself, which agains means you'll have to test the VT.
|
|
|
|
|
thanks for good answer!
I have some other questions as well;
1) Will memcpy be a good approach to this task? If so, how will the code look then? My array consist of approx. 15000 elements.
2) How do I send an array of user defined structure elements?
|
|
|
|
|
For question #1, maybe. It depends on how your data is stored. You can get a void * back from the safearray, then cast it to the type, the memcpy it:
void *pData;
SafeArrayAccessData(sa,&pData);
memcpy((LPBYTE)pData,pMyByteArray,sizeof(BYTE)*numElements);
or something similar.
Question 2:
This gets trickier. Different schools of thought:
1.) don't do that. Define the struct in IDL, define the interface to return those (say, maybe an Item property with an index).
2.) Someone has a gun to your head and says they'll kill you if you don't (only acceptable reason to do it this way): Create an array of variants. Each variant then in and of itself contains a safearray of bytes, which is one element in your array of structs. Version 2 of this, create a variant that is an array of bytes and memcpy the whole thing.
If this is for something production, I highly suggest doing something different than blobbing it. It's much more extensible to have a collection interface that returns interfaces for each structure your defining:
ActiveX Control
|
|----- property Item([in]long index, [out,retval] IStruct **ppIStruct)
interface IStruct
|
|--- property name
|--- property address
etc etc, mapping a property value in IStruct to the value of your structure.
If your using something like ATL, you might want to look at a tear-off interface for implementing this. Just a thought.
|
|
|
|
|
Thx!
I am very happy by your answers! But I must admit that I dont follow you all the time! I am quite new to c++.
Would you mind to give me a short example on the memcpy stuff? For instance how to do it with an array of doubles, and then send it to client?
And regarding question 2, you say; "Each variant then in and of itself contains a safearray of bytes, which is one element in your array of structs."
Why should it contain bytes and not doubles for instance?
Last question; How would a code snipp for the idl look like?
Lets say I have the following stucture:
Code:
typedef struct somePoints{
int a,b,c;
} MY_STRUCT;
I have the "somePoints" elements arranged in an array and have this get method;
Code:
MY_STRUCT *getArrayP(void)
{
return arrayP;
}
So by using CComSafeArray, how would you send this array?
So far I have been iterating through the struct elements one by one, and then inserting a, b and then c. By doing is this way I feel that I put a lot of responsibility on the client, because he has to know that element i*3+0 is my a, i*3+1 is b and i*3+2 is c.
Any way of improving this, at least making it easier for client?
Cheers
|
|
|
|
|
Well, it's extremely uncommon to have a structure with uniform data types. Most structs are more like
struct
{
int value;
float fvalue;
short somethingElse;
etc., etc.
}
Now, for your case, I'd do one of two approaches. The big question is do you have to support scripting environments?
Option 1) Using the interface
Define the structure in IDL. This looks pretty much identical to you C structure definition.
Define a method that returns these:
For instance, in your IDL
struct MY_STRUCT{
long a;
long b;
long c;
};
//as a method on your COM object
[propget, id(1)] HRESULT Item([in[ Index,[out,retval] struct MyDataType* blah);
And implement from there.
Option 2) Using a big safearray
Create a safearray of variants (one for each structure), then each variant is a safearray of VT_I4. It's up to your client to know what the order of each value means, which means that this approach is fairly brittle.
|
|
|
|
|
Thanks! This helped me a lot!
Now this is hopefully my last post to this thread!
Lets say I have the following code on client:
<br />
CComVariant varArray;<br />
<br />
my_readCtrl.getArray(&varArray);<br />
<br />
<br />
if(varArray.vt==VT_I1) {<br />
CComSafeArray <char> saFromVariant;<br />
}<br />
else if(varArray.vt==VT_R8) {<br />
CComSafeArray <double> saFromVariant;<br />
}<br />
<br />
saFromVariant.Attach (varArray.parray);<br />
This results in an compilation error since saFromVariant is not declared. That is obviously because the declarations are inside if statements. How to avoid this but still declared it correct?
Thx
|
|
|
|
|
I think I want to go for option 1 here.
Can you show me how to write the code for the idl stuff?
Thanks
|
|
|
|
|
Hello!
I wrote an application, which use one or two cameras.
This application can render the camera streams on the display,
make AVIS or make BITMAPS.
What I like to have:
- Grab n different BITMAPS
- Grab different BITMAPS from start to stop
I need an event, “new BITMAP in the camera buffer available”.
Thank you
Baumann Tobias
|
|
|
|
|
Check the documentation for the camera software to see if it sends any kind of event, or if the bitmaps are being placed into a specific location on disk, you can set up a change notifier (and poll as a fallback) to detect when new bitmaps are available.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|