|
Do NOT use malloc/realloc if you can at all avoid it. They are C functions, and new/delete is highly preferred, especially for complex types. The best reason for this is the fact that new/delete call constructors/destructors and the C functions do not.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
i use globalalloc() and globalfree() and globalrealloc() a lot and they work just fine if you remember to free the memory when u finished with it
whats the problem with this?
---
"every year we invent better idiot proof systems and every year they invent better idiots ... and the linux zealots still aren't being sterilized"
|
|
|
|
|
lauren wrote:
whats the problem with this?
There's no *problem* per se, but if you mix C and C++ memory allocationj calls, you need to be careful not to free something you new'd. You also don't get the benefit of constructors and destructors. If you need to realloc, you should instead use a container like vector. Your code will obviously work, but the way of doing things I am suggesting is *better*.
To read Stroustrup on this ( and I've pretty much quoted him, so you don't need to as such ), turn to page 577 of the third edition of the C++ Programming Language.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Youve all see the new napster Beta i assume, how did they create the toolbar logo. ive tried using a background bitmap but it stays in the same position when the window is resized. i wish mine to glue to the window edge so it will always be on the right hand side frame edge.
.NET or not .NET? MFC is the question......
|
|
|
|
|
I realize I am years behind the times but I am just now moving from VC 5 to VC 6. However, because of third party objects, one application will have to remain in the VC 5.0 environment.
Anyway, do any of you good people know of or have a utility to swap back and forth the debug libraries for each product?
Or maybe even a list of objects that are not compatible?
thanks
|
|
|
|
|
I have heard of such a utility, but never seen it.
If it just the one application you could put a copy of the 5.0 debug dlls in that applications debug directory. If you are running the 5.0 debug version beyond that testing environment put it in a seperate directory and put a copy of the debug 5.0 dlls there.
|
|
|
|
|
Hello all,
How do I detect a CD-RW drive? How do I read/write files onto a CD-RW? Any code or links would also be helpful.
TIA.
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|
|
I've created sdi app using mfc AppWizard and have created my own classes in a header file called game.h.
What I want to do is create an instance of that class in my CChildView (CWnd) class.
ie.
(in the file ChildView.h)
#include "game.h"
CChildView : CWnd
{
//blah blah
protected:
CGame *game;
};
When I do this though I get this error
"error C2011: 'CGame' : 'class' type redefinition"
The reason I'm trying to do this is that I need all of my CChildView functions to have access to this CGame instance and it seems like an easy way to do it.
Any suggestions?
|
|
|
|
|
The file is getting included more than once. Does your class have a #ifndef CGAME$%)(^@($% type macro wrapping it ?
Try including the header file in your .cpp file and putting a dummy class definition in the .h, as in
class CGame;
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
As we know..
MFC have the GetDlgItemText function to retrieves the string (char datatype)
and GetDlgItemInt function to translate the text into integer value. (integer datatype)
But I wonder is there any function for Float datatype?
If you know .. please explain along with the parameter within the function.
Thanks..
|
|
|
|
|
No there is not such function, but you can use atof() to convert the string you got from GetDlgItemText() to a float
hope this helps
regards
Gregor
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I would like to convert the integer value to float value.
I got some error when I used atof function.
Do u know any function that same as atof() that convert integer to float?
Thanks a lot.
Lee Teong
|
|
|
|
|
Maybe something like this:
int i = 10;
float f = 0.0;
f = (float) i;
|
|
|
|
|
I would have to say that this is one of the cases that you may want to use the DDX_ functions. One of the overrides does exactly just that.
But there are limitations to those functions so if you are hitting on those limitations, you may still have to roll your own code.
|
|
|
|
|
Hi!
Me and a friend are trying to build a robot that communicate with the computer using the parallel port.
I have used the outp() command before but I do not want to use the port address since I have experienced problems on different computers when the address are different.
So I have heard I can use WritePrinter to send data to the parallel port. But All I get when I try to use it is trouble. When it seems like I have everything right I get linker error (2001 I think not sure though). So what I need is a complete guide for how to get this to work since I am not into this win32 API stuff att all.
I use MFC visual c++, and am running Win ME.
examples are appreciated
Thanks,
hywer
|
|
|
|
|
|
thanks for the reply. I have sent you a msg but in case you didn't get it my email is o_ernstsson@iamit.com
|
|
|
|
|
I found a <http: www.codeproject.com="" script="" comments="" forums.asp?forumid="1647&app=50&kw=colors&select=98566#xx98566xx"" target="_new">thread from a few days ago about getting a CListCtrl to draw more than 16 colours from its associated CImageList.
CBitmap bitmap;
bitmap.LoadBitmap(IDB_CERT_PG);
m_pImageList = new CImageList;
m_pImageList->Create(16,16, ILC_COLORDDB | ILC_MASK, 2,2);
m_pImageList->Add(&bitmap, RGB(0,0,0));
m_pImageList->Add(&bitmap, RGB(0,0,0));
m_listctrl.SetImageList(m_pImageList, LVSIL_SMALL);
The CListCtrl draws the bitmaps in 16 colours. I have tried setting up a halftone palette, but that didn't work either. Am I going to have to override CImageList's OnDraw() to draw the bitmap myself in over 16 colours?
Simon
Nobody does chicken like MFC
Sonork ID 100.10024
|
|
|
|
|
|
That's the problem - ILC_COLOR24 doesn't work. CListView still insists on 16 colours.
Simon
Nobody does chicken like MFC
Sonork ID 100.10024
|
|
|
|
|
Hi!
I've tried to get my app to do what Start->Run does, but failed. The string entered in the Start->Run editbox must be passed to some function in a dll somewhere. Does anyone know which?
ShellExecute(), CreateProcess() and system() won't do.
|
|
|
|
|
The "Start->Run" doing nothing but simple ShellExecute() . What you mean that it isn't working? So or you passed wrong parameters to it or the path doesn't exists.
Post an example of what are you doing with ShellExecute()
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
hWnd is a common editbox
int commandLength = ::GetWindowTextLength(hWnd);
LPTSTR szCommand = new TCHAR[commandLength + 1];
::GetWindowText(hWnd, szCommand, commandLength + 1);
LPTSTR szParameters = strchr(szCommand, ' ');
if (szParameters)
{
szParameters[0] = '\0';
szParameters++;
}
::ShellExecute(NULL, NULL, szCommand, szParameters, NULL, SW_SHOWNORMAL);::SetWindowText(hWnd, TEXT(""));
delete[] szCommand;
The command is run, but if I type an errouneous command, no errormessages are displayed. I would like ShellExecute to do that for me. I've tried several different parent-window handles as parameter, but no messagebox are displayed.
|
|
|
|
|
ShellExecute doesn't do the messagebox for you.
You need to check the return value and then display a messagebox by yourself
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank god it doesn't no less!!! Would sort of make headless applications hard to write.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|