|
Variable length arrays are a part of C99 standard. You give here a sample code for gcc 3, which support this standard. The C++ prog. language from Microsoft implements a different standard.
|
|
|
|
|
HI
Can any one help how me to create the skin for sound station
thanks and reards
BSR
BSR
|
|
|
|
|
What is sound station ? An example of code for a skinnable app is on CP, just search for mpeg.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Hi,
My question is about this following code :
char ** ValeurColonne;
ValeurColonne = (char **) malloc(sizeof(char*) * 10);
memset(ValeurColonne,0x00,sizeof(char*) * 10);
for (i=0;i<10;i++)
strcpy(ValeurColonne[i],"Some text");
First question :
How can i use new operator to replace malloc ?
Second question :
This line strcpy(ValeurColonne[i],"Some text"); seem correct but i don't understand why we can write ValeurColonne[i]. I think that ValeurColonne isn't an array.
thanks in advance
|
|
|
|
|
- Yes you can. In your particular case the replacement would look like
ValeurColonne = new (char *)[10]; The deletion is done with
delete [] ValeurColonne;
- The line is not entirely correct (except if one assumes there's additional code not showed here).
ValeurColonne is an array, namely an array of char * . That is, each element of ValeurColonne is a pointer to char .Then your line is semantically equivalent to
char * pChar=valuerColonne[i];
strcpy(pChar,"Some text"); The bug in the code is this: strcpy assumes that there's some allocated space pointed to by pChar where the string copying can be performed. As your code stands, pChar is null for all the positions of ValeurColonne , and a crash in your program is guaranteed.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am currently designing custom wrappers of ADO objects for a series of related MFC projects.
Each wrapper is just a generic C++ class with simple functions that hide much of the ADO property/method complexity. ADO objects are interfaced through #import directive.
While carefully studying the structure of *.tlh file, I noticed that all the member functions of smart pointer wrappers are __stdcall type (like Win32 API), whereas the default setting in my MFC project is __cdecl. Then I understand that smart pointer functions will be __stdcall, whereas all of my wrapper functions will be labeled __cdecl during compilation step.
Questions:
1) Do I need to explicitly label each one of them in code with __stdcall as well, or __cdecl callers of __stdcall methods do not interfere with each other?
2) Does anyone know when when exactly is it preferred to overide __cdecl with __stdcall?
3) What are the advantages of one calling convention over another?
Thanks.
Kirill
|
|
|
|
|
1) There's no interference at all. You can invoke a function having whatever calling convention from any other function with different calling convention as long as the caller knows in advance the proper calling convention of the callee.
2) 3) Nemanja Trifunovic's Calling Conventions Demystified explains it all about CCs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Just one add to the previous reply : _cdecl is the only one that allows variable argument lists.
|
|
|
|
|
Most COM functions are __stdcall. You will probably create some confusion if using __cdecl. Also note that you will only be able to connect to C/C++ clients using __cdecl, which somewhat defies the purpose of COM. I suggest you only use __cdecl if you need variable parameters, and really can't think of a way around this.
/moliate
|
|
|
|
|
This is off of the topic from the original question, but it may shed some light on why particular conventions were chosen.
The key to all COM object interfaces is that they all have to use __stdcall. That is how it becomes safe to call objects that some complete stranger wrote with this model. Everyone uses the same calling convention.
The reason why this convention was chosen over _cdecl, is that the variable length parameter lists make this format unsafe if an interface function call needs to be marshalled to another machine, the proxy code would not know how many parameters and what types they are to marshal.
|
|
|
|
|
If I create an MDI application visual C++, how can I create an openGL child window for the application?
|
|
|
|
|
Check the opengl section. There are many examples.
http://www.codeproject.com/opengl/
|
|
|
|
|
Hi,
I manage to insert one ActiveX in my word doc, using:
COleVariant vClassType = "GrAxProof.GDIGraphics";
Word::InlineShapePtr pShp = m_pWord->GetSelection()->InlineShapes->AddOLEObject(vClassType);
Now the problem, comes when I save the Word file, and I load it again, then a metafile is shown but when I press double click, it appears this message:
The server application, source file, or item cannot be found, Make sure the application is properly installed, and that it has not beed deleted, moved, or renamed.
What should I do to avoid this ?, Thanks, Bye !
Braulio
|
|
|
|
|
is it possible to create a listctrl in report view, with several columns. Where some of these columns are comboboxes?
|
|
|
|
|
There are examples of how you can manipulate the listview controls while in report view here at CP.
I don't think any of the examples use comboboxes, but there is statusbars, edit boxes...etc...I imagine the edit fields are implemented with a floating CEdit control.
You could do something similar with a combobox control i'm sure.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Of cource it is possible to create a listctrl in report view but about comboboxes it is better to check ListCtrl part in CP maybe there is something there.
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Hi All,
I have a parent window that contains an OLE object. I want the OLE object to draw on its parent's DC (for animation). This isn't too much of a problem, as I can get the parent CWnd and associated DC.
The problem is however - I have pre-written code to do the drawing that expects to start drawing at 0,0. This means the graphic is always at the top left of my parent window. What I want to do is shift the graphic to the right and down so it's above the object.
I *think* what I want to do is shift the whole parent DC to the right and down, but I'm not sure how to go about this.
Any help greatly appreciated.
Paul.
|
|
|
|
|
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cdc.3a3a.setviewportorg.asp">CDC::SetViewportOrg</a> is what you need, I guess.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
Thanks for your post.
I currently have the following code:
CRect recOLEObject; //Set using GetWindowRect when I activate
//the OLE object temporarily
CRect recApp; //Set using GetWindowRect
CPoint ptDCShift;
ptDCShift.x = recOLEObject.left - recApp.left;
ptDCShift.y = recOLEObject.top - recApp.top;
pDC->SetViewportOrg(ptDCShift);
The wierd thing is, as I start and stop the animation the amount of shift changes (never being in the right place, I should point out), and 'steps' down the screen.
Paul.
|
|
|
|
|
Sounds like you need to reset the viewport to what it was originally after you're done.
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
Now look at the code Mike Dunn (or anyone):
void CWallpaperDlg::OnButton1()
{
CoInitialize(NULL);
HRESULT hr;
IActiveDesktop *pActiveDesktop;
//Create an instance of the Active Desktop
hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (void**)&pActiveDesktop);
if(SUCCEEDED(hr))
{
hr = pActiveDesktop->SetWallpaper((LPCWSTR)"C:\\Mina dokument\\Mina bilder\\eros15.gif", 0);
if(hr != S_OK)
AfxMessageBox("Fail?");
}
else
{
AfxMessageBox("dgfd");
}
// Call the Release method
pActiveDesktop->Release();
CoUninitialize();
}
Well, as you see I check if the code is NOT S_OK but the dialog will never show up.
but how to get it Unicode? I've tried type cast it with many Unicode types but is always says "cannot conver from ... to ..."
------------------------------------
<b><I><B>Rickard Andersson</I></B></b>, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Your attempt to get a LPCWSTR by forced casting is wrong. Instead, use wide char literals like this:
hr = pActiveDesktop->SetWallpaper(L"C:\\Mina dokument\\Mina bilder\\eros15.gif", 0); Note the L prefixing the string.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
With your help and with some small "brainstorming" I'd get it to work!
I had to call ApplyChanges(...) after call of SetWallpaper to see the wallpaper.
Thank you!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Hi,
Where shall we declare an array to be assigned in a function of a class and accessed in a function of other class?
|
|
|
|
|
1. make a member variable in one of the classes.
2. when you call the function in the other class, pass it a pointer to the instance of the first class as an argument.
eg:
class bob
{
public:
int nAge;
}
class fred
{
public:
void LaughAtBobsAge(bob* bobclass);
}
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|