|
Why on Earth would you like to call 'new double' five million times? Pointers themselves will use 20 megabytes.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Francg wrote:
I think this means, big mem allocation will cause fragments and mucho "sizeof". Am i just on the wrong track
I think if you allocate memory all at once with a single call to new the system will try and make the memory one contigous block. So I would think thats the better way to do it when trying to avoid fragmentation.
However to allocate that much memory is probably not a good idea...a better approach(IMO) would be to allocate a segment of multiples of sizeof(double) . Fill that memory and than reallocate another segment fill it up and so on. However this would be very un-efficient using new and delete so I would suggest using windows heap or virtual functions or the crt malloc/realloc/free functions.
Using the latter keeps your code more platform independent.
HTH
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
If you create massive instances of a class on the heap, it is worthwile to create an own heap for this preallocates larger blocks of memory and maybe also optimzed for the data size of your class.
To ensure a class uses an own heap for its instances, it is best to write a class level operator new and a class level operator delete. Take a look in VC help or a good C++ book for more details about overriding operator new/delete for a class.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Hi. I am trying to checkmark the nodes of a tree at start up based on whether they are present in my database already or not. Here is my code:
HTREEITEM hCategory = m_CategoryTreeControl.InsertItem(rs.Field("Category").AsString(), hAllCategories, TVI_SORT);
m_CategoryTreeControl.SetCheck(hCategory, TRUE);
This is in the OnIt function of my dialog. When I start the dialog up, the nodes don't get checkmarked. I have no idea what I am doing wrong. Any help would be appreciated.
|
|
|
|
|
From MSDN docs on TVS_CHECKBOXES:
If you want to use this style, you must set the TVS_CHECKBOXES style with SetWindowLong after you create the treeview control, and before you populate the tree. Otherwise, the checkboxes might appear unchecked, depending on timing issues.
Make sure you're not hitting these 'timing issues'.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hi,
Anybody know how to do this? I want to pop up a little menu when the user right clicks on a label in a CFormView derived view.
Thanks in Advance,
Aaron
|
|
|
|
|
WM_CONTEXTMENU ?
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Capture one of the following messages for the window...
WM_RBUTTONDBLCLK
WM_RBUTTONDOWN
WM_RBUTTONUP
Jeremy Falcon
Imputek
<nobr>"C# is the answer to a question nobody asked." - Chris Losinger
|
|
|
|
|
Static controls have to have the SS_NOTIFY style set if you want it to recieve mouse messages.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
i get the hwnd of a window of a process containing two buttons on it how will i get their hwnd and perform any action like thay clicked with out key bord and mouse event i mean programatically?
r00d0034@yahoo.com
|
|
|
|
|
look up FindWindowEx... getting the handle to the child window with a given window text
- Roman -
|
|
|
|
|
If you have the HWND of a window, you can get the child windows by (at least) a couple of methods...
GetDlgItem if you know the ID# of the child windows.
e.g.
HWND hWndChildOne = ::GetDlgItem (hWndParent, IDOK);
HWND hWndChildTwo = ::GetDlgItem (hWndParent, IDCANCEL);
////
CWnd *pChildOne = pParent->GetDlgItem (IDOK);
CWnd *pChildTwo = pParent->GetDlgItem (IDCANCEL);
or GetWindow if you know the order.
hWndChildOne = ::GetWindow (hWndParent, GW_CHILD); // Get first child
hWndChildTwo = ::GetWindow (hWndChildOne, GW_HWNDNEXT);// Get sibling
To "pretend" they were pressed, you can do something like the following:
PostMessage (hWndParent, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM) hWndChildOne);
PostMessage (hWndParent, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID (hWndChildOne), BN_CLICKED), (LPARAM) hWndChildOne);
I hope that helped.
Iain.
|
|
|
|
|
Hi,
Has any one ever had any issues with controls being repainted (controls becoming invisible at times, but data is still there) when having list controls and an OCX on the same dialog? For instance, the program's list controls that had focus when minimized would disappear when the program was restored. When I fixed the probelm by invalidating the dialog on moving the controls, the OCX control on the dialog will disappear at times. Any suggestions?
Thank you so much,
G
|
|
|
|
|
There has got to be something goofy I'm doing!
I tried SQL Insert Into like so:
OR
OR
OR
//crash
Trouble with AddNew as well:
m_pRecordset->MoveLast();
m_pRecordset->AddNew();
m_pRecordset->Fields->GetItem("Shape")->PutValue((_bstr_t)("Test text"));
m_pRecordset->Update();
AfxMessageBox((_bstr_t) m_pRecordset->Fields->GetItem("Shape")->Value);
MsgBox says I have the text put in right> record count goes up. Not visible in the Access db, and doesnt persist when the app terminates...
Thanks,
ns
|
|
|
|
|
Ever heard of "indentation"?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
My apologies. I havent developed this good trait yet - improving though. Its just that I cut and pasted so very many code attempts at figuring out AddNew(), but thats no excuse.
ns
|
|
|
|
|
Hello,
I've created a number of CEdit controls without using the Dialog or Class Wizard. How do I get notified of messages for events like EN_KILLFOCUS, and others, for these custom edit controls?
Thanks!
JennyP
|
|
|
|
|
Add ON_CONTROL entry to CYourDlg message map.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hi
When I'm drawing an image with the GDI+ function Graphics::DrawImage(Image* image, int x, int y), the drawn image appears to be about 150% of the actual size of the image. The documentation clearly states that this version of DrawImage should render an image at the specified location and with the original size, but it's not. Anyone knows why? I'm using VC++ 6.0 on WinXP.
Thanks,
bf
|
|
|
|
|
is that 150% in pixels or physical measurement (inches, cm) ?
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
That would be in pixels.
When using DrawImage(Image* image, int x, int y, int width, int height) and specifying the actual width and height of the image (in pixels), all renders ok, so I guess the correct unit is used.
/bf
|
|
|
|
|
Hey Gang,
I am on the verge of panic today because I need to quickly develop a solution for a distributed analysis program. Thanks for taking the time to respond if you get a chance.
I have an exe that uses an XML DOM to represent the status of a system. The DOM is wrapped in an ATL interface that provides some convenience routines for manipulating the data in the DOM. For discussion I am going to refer to the ATL interface as the CurrentStateInterface.
I would like to share access across computers to an instance of the CurrentStateInterface. Ideally remote systems would be able to connect to the server application through an ATL interface and request the CurrentStateInterface. Once the interface is marshalled to the remote system, the remote system could make calls to the CurrentStateInterface which would manipulate the data in the DOM on the server.
I have read a few articles from the MSDN. One article suggested several possible solutions: Singleton objects, File monikers, CoMarshlInterface/CoUnMarshalInteface, Custom class objects, Custom monikers. I know some of these would work better than others. From what I have read, the file monikers look like an appropriate solution but I would look to someone with more experience for guidance.
I am hoping that someone has done something similar and can share his/her knowledge and experience. Any good suggested reading would be appreciated also.
Thanks very much for your time!
Hawk
|
|
|
|
|
Hi,
I did post a similar help before ... but I did not mention that I failed to open it within my Visual C++ 6.0 programming!
1) I open a MS Access97 table with 1 row & 2 filed numbers
2) In Visual C++ using Classwizard to add new class using CDaoRecordset (for that .mdb)
3) Run program to open that mdb to use ---> OK!
4) Now use MS Access97 open with Exclusive & add security password ("password") on it --> Save
5) Then even I tried programming to use codes in article TN054 ... or open with:
CDaoDatabase CDao;
CDao.Open("c:\\password97.mdb",true,false,"pwd= password");
---> I failed to open it!!!
Can someone help me with some codes (at RunTime) to open that mdb file? I appreciate very much for any suggestion & advice!
Thanks,
Anh Truong
|
|
|
|
|
where's the user id? uid?
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Does anybody know how to use the shell style animations such as those used for copying files etc. Can we borrow these from the shell for use in our own apps and if so how?
Thanks - Joel
|
|
|
|