|
Would someone have a simple example of a smart pointer..I want to allocate memory for structures & classes...
I have seen the examples here, but they are over my head, I'm new to VC++.
If there's one example without worrying about synchronization & Threads, I would be happy.
Thanks,
Gerry.
|
|
|
|
|
#include <memory>
std::auto_ptr<cmyobject> p = new CMyObject;
When p goes out of scope, it's automatically destroyed.
|
|
|
|
|
Will this work for C-style Structures.
I want to create an array of structures on the heap & deallocate when the function goes out of scope.
Or do I need to put the structure inside a class?
I have about 5 variables that need allocated on the heap, 4 are BSTRs & one is an array of structures.
Gerry.
|
|
|
|
|
auto_ptr doesn't work for arrays because it only calls delete rather than delete []. If you need arrays, why not use std::vector instead? For the BSTR's use bstr_t
|
|
|
|
|
I'm working on my own tooltip class and I need to find the width and height of the mouse cursor.
I've tried GetSystemMetrics with SM_CXCURSOR/SM_CYCURSOR but that only returns what looks to me to be the maximum dimentions of the mouse cursor, not the current mouse cursor width and height.
Any suggestions?
|
|
|
|
|
try
BOOL GetCursorInfo(CURSORINFO *ci);
and/or
GetClipCursor() which will give you a rectangle of its boundary
Stephen Kellett
|
|
|
|
|
Hi,
I want to use programatically the win NT command "Net send".
For example to send a message to computer named "Compsrv" i write this like :
c:\> Net send Compsrv Good morning my dear
I use following code to execute this commande under windows with visual C++ :
ShellExecute(NULL, "open", "c:\\WINNT\\System32\\Net send Compsrv Good morning my dear", NULL, NULL, SW_SHOWNORMAL);
BUT it don't work
Can anybody help me
Regards
|
|
|
|
|
I've been working on an app for the last week or two, and everything was going fine until yesterday.
I have an Access database with a handful of tables. I use the following code to (successfully) open the database:
CString sDbName = "igps3.mdb"
CDaoDatabase* m_pDB = new CDaoDatabase();
m_pDB->Open(sDbName);
Next, I open recordsets (created with ClassWizard) for some of the tables. One of the tables is now inexplicably failing in the Open() function, but I don't know why. It honestly just started happening all of a sudden. Here's the code I use in my app:
int nOpenType = AFX_DAO_USE_DEFAULT_TYPE;
CRSDrivers* m_pRSDrivers = new CRSDrivers(m_pDB);
m_pRSDrivers->Open(nOpenType, "SELECT * FROM drivers");
The table exists in the database, and it appears to be okay. I've tried recreating the table from scratch, as well as creating a completely new table. It doesn't metter whether I try to open the recordset first, last, or somewhere in between. All of the other recordsets open without complaint.
Nothing seems to matter. All of the other recordsets open without any problem.
The program stops with a C++ exception in DaoCore.cpp after an attempt is made to open the daotabledef.
This is my first database app and I'm kind of at a loss.
Any suggestions would be appreciated.
|
|
|
|
|
I wanna use the CString class in a non-MFC application, how can i do this? if this cannot be done, what can i use as a substitute? Thanks
|
|
|
|
|
|
I have a LPDIRECTDRAW that is being created fine under debug mode but not under release mode. I am linking ddraw.lib in release and debug modes. When the program runs in release mode, it asserts on my create function:
ASSERT(DirectDrawCreate(NULL,&mDD,NULL) == DD_OK);
Thanks in advance for any suggestions.
|
|
|
|
|
Here is the deal:
I have declared a class object in a function. Then I created a pointer to it right afterwords in the same function. Here is where the problem is. I try to pass that pointer to another function, and i get no errors, yet when i try to look at a data member of the class, i get all kinds of errors. Could someone tell me if this syntax for passing class pointers is correct?
(The class name is army and the object is MyArmy and the pointer to MyArmy is pMyArmy)
Pointer is declared like this:
void make_faction()
{
//creates object
army MyArmy(75, 5, 3000, 5);
//Creates a pointer to army
army* pMyArmy = 0;
//Gives the address
pMyArmy = &MyArmy;
//calling function
game_menu(pMyArmy);
}
Recieving function:
int game_menu(class army *pMyArmy)
{
return 0;
}
Is this the correct syntax? It shows no errors this way, but when i add
cout << pMyArmy->troops << endl;
to game_menu function, get errors.
|
|
|
|
|
I'm not sure about 'class army *pArmy' but normally you pass a pointer to the class by just 'army *pArmy'.
Are you sure the problem is with the pased pointer, and not with the data type you are passing to cout?
What is the type of the troops member? what compile time errors do you get?
|
|
|
|
|
One possible cause is the keyword class in the function declaration for game_menu. I also don't understand why you are creating a pointer?
Why not do it as followed?
void make_faction()
{
//creates object
army MyArmy(75, 5, 3000, 5);
//calling function
game_menu(&MyArmy);
}
int game_menu(army *pMyArmy)
{
return 0;
}
|
|
|
|
|
I want to capture the any portion of a CFormView (displayed or not).
It is possible to get the viewable area with DC tricks but how about non-displayed parts? Where it is stored?
Suha
|
|
|
|
|
http://www.fengyuan.com/article/wmprint.html
|
|
|
|
|
Is this possible. I want to be able to call functions in a DLL writen in C++, from a program writen in C.
If it is possible, is it possible to call functions within a class?
THanks for any help,
Yours
David Wulff
|
|
|
|
|
What font is used by office 2000 and 97 to paint the gui
Joel
|
|
|
|
|
Verdana is used in 200 (I don't have access to 97, so I don't know about that). Arial is used for any verticle fonts though (e.g a verticaly docked menu bar).
Size? 8 I would guess, but maybe 7.
David Wulff
|
|
|
|
|
And I thought they use Tahoma.
Uwe Keim
http://www.zeta-software.de
|
|
|
|
|
It might be... I said Verdana because i took a screenshot via PSP and zoomed in, then tried to match the text. Verdana exactly covered the text so I presumed it was Verdana.
David Wulff
|
|
|
|
|
Actually, it depends on which font you have set for the menu bars of "normal" apps. If you have it set to a bitmapped font (like MS Sans Serif), then Office uses Tahoma. If you have it set to a TrueType font, Office uses that.
The reason is that the menu bar needs to use a TTF so that the menu labels can be drawn vertically when the menu bar is docked vertically - bitmapped fonts can't be drawn rotated but TTFs can.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Verdana and Tahoma are pretty much as equal as Arial and Helvetica are. Tahoma comes with Adobe software and Verdana with Microsoft software (this is based on what I have found... I may be wrong as well).
Of course they are just a little bit different.
--memon
|
|
|
|
|
What is the proper declaration for a function to be exported from a c-style dll? Is there a way of doing it without using a .def file?
|
|
|
|
|
The func prototype should be:
extern "C" __declspec(dllexport) int YourFunction(void);
Then the actual declaration is:
int YourFunction(void)<br />
{<br />
<br />
}
--Mike--
http://home.inreach.com/mdunn/
|
|
|
|