|
im not sure your problem is this but m_font is global or no i saw if (m_font) isnt global it doesnt work i wrote a program and used like your code but font dosent change then i changed declare my variable from function to class and it worked.
whitesky
|
|
|
|
|
I am wondering if there is any standard convention or guideline to what function should call another. Suppose we have our main() function that will need to call functions setupCalculation() and calculate() in that order. Where should setupCalculation() be called from? Of course if we call it from main(), then we need to call it everytime we want to call calculate(). If we instead call it from calculate() then we may have to pass extra arguments to calculate() that setupCalculation() may require. So, does it come down to a case by case decision, or is there a standard way of going about this? Thanks for help!
|
|
|
|
|
Fame Ketover wrote: So, does it come down to a case by case decision, or is there a standard way of going about this?
No standard that I am aware of. You should strive for loose coupling, however.
"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 making the nested calls ( i Mean calling function inside other function) it grows the stack.
if you call the function seperatly then they have same hiearchy in the stack.
Now efficient way to calling is depends on the Number of paramenters pass and type Vs. Function data.
If Your function work load is large which blocks the parent function in the stack.
For e.g.
void test()
{
while(1)
{
}
};
void mehere()
{
printf("Humm");
test();
};
Here the parent function completes its work but waiting for test() to complete because compiler pops the function data from the stack when it returns and control goes into the parent function.
The point is that you call the functions seperatly which are not related.
As well as it helps to use the stack efficiently for process.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
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.
|
|
|
|
|