|
Tommy Svensson wrote:
Feels weird to develop with C++ when Delphi seems to rock the world!
Then, why are you trying to develop in C++ ?
Tommy Svensson wrote:
the memory used by the app increases violently when this line of code is executed
Did you really expect a "Hey, you won´t fool me, guy !" dialog to appear on the screen ?
Tommy Svensson wrote:
BUT, when doing exactly the same thing (not quite, i statically declare a 1000000 array) in Delphi the memory increases only by a few hundred kilobytes.
The difference is in the "not quite" and in the "array". You have actually constructed a million objects, and therefore used memory for that. Declaring an array just say the heap not to use a range of addresses which will be used to store data. Try filling your Delphi array with something, and watch how memory app increases ...
Tommy Svensson wrote:
BUT how can I report the progress of a lengthy process without slowing the process itself down too much
Do it in Delphi.
~RaGE();
|
|
|
|
|
Rage wrote:
Then, why are you trying to develop in C++ ?
I only said Delphi seemed to rock the world. I know it shouldn't but all I saw was telling me it was.
So, what I wanted you to tell me [gee, why wasn't I more clear about this], was some facts to show me just how much better VC++ are.
Cheers,
/T
|
|
|
|
|
Q2. Sounds like Delphi is doing a virtual allocation. There is code available at CP here to do the same thing in C++, I just can't find the url.
Q3. Your updating the status bar far too often. Try putting it 3 loops farther out, or an if condition that updates only every 1% increase etc. That will give a much smaller hit on performance.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Tommy,
I have developed in both languages for several years now, Delphi more than C++, so I do have an answer for you:
As you've already read, MFC applications load the MFC DLL into memory when an application starts up, verse a Delphi application that's linked to the VCL statically (which only includes the code needed to run the application). If you build your Delphi application so you have to dist the packages, you'll see the same kind of result as an MFC application. If you really want to compare "apples to apples" you need to code a WTL Dialog application and then run them side-by-side.
In terms of "speed of execution" I am afraid you are incorrect. The last time I checked performance of a MFC Application verse a Delphi application, C++ ran 50 million lines of code per second verse Delphi's 20 million per second. When Borland, now Inprise, introduced that C++ Builder / Delphi IDE integration, they screwed the execution speed some how and Delphi actually became slower ( I believe Delphi originally executed at like 30 million lines/sec). This is code execution time, not compile time; Delphi's compiler smokes the daylights out of the C++ Compiler even with Precompiled Headers, I'll give Borland that much.
Regardless of that, speed of execution is why people like John Carmack develop in C++ and not Delphi, and why I've started to develop in VC++ myself. Well, that and the fact that I can hook directly into ANY new SDK MS releases without waiting for a "port" like Delphi developers do.
It's good see that you're "trying" to develop in VC++, keep at it; I too used to have similar questions when I made made the jump from Delphi, but once you've started to really dig into C++ you'll understand why "the dark side is more powerful".
Join us Tommy ... you don't know the power of the dark side. Let go of your feelings for Delphi, give in to your hatred for Microsoft. Join us.
<insert evil="" laughter="" here="">
( I know, I need a great deal of help )
D.
|
|
|
|
|
Thx for a serious reply!
My feelings for Delphi are long gone, but an old program I hade written using Delphi needed to be re-written using VC++. It was then that I discovered the differences that appeared to be favourable on behalf of Delphi.
Cheers,
/T
|
|
|
|
|
Tommy Svensson wrote:
Q1a: Why does a dialog based MFC app take appr. 1200KB of working memory?!
Because it loads the MFC dll, so there is a big price for entry into an MFC app. A Win32 app will be leaner, but more complex to code.
Tommy Svensson wrote:
Q1b: I created an exact copy of this MFC dialog app with Delphi with the exact same functionality and it only aquires 150 KB of RAM... How come Delphi (Pascal) outperforms the living sh*t out of a regular C++ app?
It doesn't. You're just not aware of where the 1200kb came from. A 'regular' C++ app and an MFC app are two different things. Try it using WTL or Win32 and you'll see differently.
Tommy Svensson wrote:
Feels weird to develop with C++ when Delphi seems to rock the world!
HAHAHAHAHAHAHAHAHAHAHAHAA !!!!! Go develop in Delphi then.
Tommy Svensson wrote:
Can threading help me here...?
No, not really. I would be reporting outside of that inner loop - no-one needs status reports THAT quickly. I'd report at about the 'c' loop.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Hello every one !
I'd like to use a CListCtrl in my application, but the way it is displayed is not useful for me because it should be blue instead of gray.
I looked in previous posts but I haven't found what I'm looking for : getting the scrollbars from the CListCtrl with the function GetScrollBarCtrl(...) is almost impossible, according to me...
If someone has tried to do something approaching, please answer me because I don't know where I should look...
Thank you in advance
Joe
|
|
|
|
|
you can try reading this
http://msdn.microsoft.com/msdnmag/issues/01/11/c/c0111.asp
|
|
|
|
|
Thank you for your answer.
I read that and if I understand well, I shall begin a CScrollBar child class from scratch...
I think I will handle it in another way....
I actually began in this way :
A <--- This a button to scroll up
| <--- This a background bmp
|
[] <--- This a button (the box showing the current position in every scrollbar)
| <--- This the same background bmp
V <--- This another button to scroll down
It's a bit messy but I've already done that for a slider, and that works well, so why not ?...
My only problem is to get rid of those f*#@^" srollbars inside the CListCtrl
(disabling them by checking the 'No scroll' check box won't help : I won't be able to send some WM_VSCROLL to the CListCtrl...)
If anyone has any idea...
|
|
|
|
|
In my MDI application, I have a need to send a message from one open document to another (also open, but of a different class). I believe the way to do this is to get the parent frame (pointer) and then use EnumChildWindows() to get handles to all the child windows (presumably from ALL open documents) and use the callback function to analyse the titles of each window to find the correct one. My code is as follows:-
void CIRCDoc::OnTapeMove()
{
// TODO: Add your command handler code here
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
HWND hWndParent = pFrame->GetSafeHwnd();
//pFrame->SetWindowText("Hello Mum !!"); // DOES set mainframe title
BOOL bResult = FALSE;
LPARAM lParam = (LPARAM)(&bResult);
BOOL rc = EnumChildWindows(hWndParent, EnumChildProc, lParam);
}
BOOL CALLBACK CIRCDoc::EnumChildProc(HWND hwnd, LPARAM lparam)
{
TCHAR* pSaveText = new TCHAR[20+1];
BOOL rc = GetWindowText(hwnd,pSaveText,20);
DWORD wErrorResult = 0;
if(!rc)
wErrorResult = GetLastError();
delete pSaveText;
return TRUE; // keeps enumeration going
//SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"Test");
}
Although I get non-zero values for hwnd returned, the call to GetWindowText always fails and GetLastError() gives me ERROR_INVALID_PARAMETER. The other thing that I don't understand is that I get 10 calls to EnumChildProc even though there are only 2 documents open within the MDIFrame window. I'll almost certainly kick myself afterwards, but can anybody show me where I've gone wrong ?? What's wrong with my code ??
Doug
|
|
|
|
|
Use this other HWND as the root for EnumChildWindows :
void CIRCDoc::OnTapeMove()
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
HWND hWndParent = pFrame->m_hWndMDIClient;
...
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried the suggestion of using m_hwndMDIClient as the argument for EnumChildWindows(), but I still get the same failure on GetWindowText() contained within the EnumChildProc(). (For reference, the failure return by GetLastError() is ERROR_INVALID_PARAMETER).
I've checked that the GetWindowText() works O.K. on pFrame, so the error MUST be on the hwnd parameter of EnumChildWindows(). However, using m_hwndMDIClient, I now only get 4 calls to EnumChildProc() rather than the previous 10, but the value of hwnd is the same on all 4 !! What IS going wrong with the enumeration ???? (Apologies if this seems trivial, but I've never enumerated windows before !)
My updated code is as follows :-
void CIRCDoc::OnTapeMove()
{
// TODO: Add your command handler code here
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
//pFrame->SetWindowText("Hello Mum !!"); // DOES set mainframe title
BOOL bResult = FALSE;
LPARAM lParam = (LPARAM)(&bResult);
// BOOL rc = EnumChildWindows(hWndParent, EnumChildProc, lParam);
rc = EnumChildWindows(pFrame->m_hWndMDIClient, EnumChildProc, lParam);
}
BOOL CALLBACK CIRCDoc::EnumChildProc(HWND hwnd, LPARAM lparam)
{ TCHAR* pSaveText = new TCHAR[20+1];
BOOL rc = GetWindowText(hwnd,pSaveText,20);
DWORD wErrorResult = 0;
if(!rc)
wErrorResult = GetLastError();
delete pSaveText;
return TRUE; // keeps enumeration going
//SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"Test");
}
Doug
|
|
|
|
|
How I add button(text) on toolbar(IE) more than one ?
Please give me some example that using TB_ADDSTRING, TB_INSERTBUTTON.
Thanks a lot for your kindness
|
|
|
|
|
hi .. can any one tell me how to use splash screens in my programme
ive tried using class ceditview.. but to no avail.
telll me how to manage this.. and if some one could give ma the code ... dat will be great then
looking forward from all the gurus of code
|
|
|
|
|
|
take a look here
http://www.codeproject.com/dialog/index.asp#General
or more specifically
http://www.codeproject.com/dialog/splasher.asp
hope this helps.
Or u can just use a thread to close a modaless dialog box after a certain amount of time.
|
|
|
|
|
aldeba wrote:
Or u can just use a thread to close a modaless dialog box after a certain amount of time.
Actually, it's easier to just set a timer from within the modeless dialog. When the timer fires, the dialog is closed.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello,
I need to obtain the list of installed applications as it appears in "control panel/installed applications".
Is there any way to programmatically retrieve that list?
Thank you.
DL
|
|
|
|
|
The Complete List of Installed Softwares kept in Registry
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL
Enumerate all the keys under the node....
Renjith-The CPian.
|
|
|
|
|
I want something like CFormView, but instead of creating forms from resources. I've to create the child controls dynamically (by using CreateEx ). How can i do it ?
|
|
|
|
|
Take a look at my scrollbar example which creates a control dynamically in the view. The same methods applies for CEdit/CStatic etc...
http://www.codeproject.com/useritems/Scrollbar.asp
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
I use Visual Studio with C++ and I'm trying to compile a project with multiple source files. Here's what I want to know: what are the rules about linking multiple source files? How do I specify a variable as accessible throughout all functions in all source files? I thought extern was supposed to do that. How and where do I put functions, global variables, macros, universal header file #includes and everything else?
|
|
|
|
|
Anonymous wrote:
I thought extern was supposed to do that
And extern did not do it ? It works usually pretty well.
Anonymous wrote:
How and where do I put functions, global variables, macros, universal header file #includes and everything else?
Try putting the whole in this very order :
#include
macros
functions
in the .cpp
and
#include
classes
in the .h
What are global variable ?
~RaGE();
|
|
|
|
|
I don't understand how code pages work with double-byte languages (e.g. Korean). I see how every other language can fit into a code page containing 256 characters because most languages are less than 40 characters. However, I see that Korea's code page is 949 and is 256 characters. How can this be, because there are thousands of Korean ideographs? Same for Chinese: it has 10,000 characters, so how can they only use a regular code page?
|
|
|
|
|
In Win2000, we could use Active Directory and Group Policy to install and maintain softwares. But how we could create and access the group policy to deploy or publish software in VC++ programming ???
Thank a lot.
Randall
|
|
|
|