|
Hello
Can anybody explain to me why the following four bold lines of code yield different results to their counterparts on the line below? By my reckoning the results should be the same with the only difference being one set are printed to the console window and the other to a text file. The purple lines are definitely creating correct results because they are a product of help code for Microsoft Visual Studio .NET and the results look good. The red lines of code (my code) are definitely producing incorrect results and all four of the outputs are often identical. Am I doing some memory management incorrectly???
#include "stdafx.h"
#using
#include
#include
#include
using namespace System;
// This is the entry point for this application
int _tmain(void)
{
_int64 ctr1 = 0, ctr2 = 0, freq = 0;
int acc = 0, i = 0;
FILE *storage;
//Start timing the code
if(QueryPerformanceCounter((LARGE_INTEGER *)&ctr1) != 0)
{
storage = fopen("C:\\TestTimer.txt", "a"); //Open a file for data output
//Code segment is being timed
for(i=0; i<100; i++) acc++;
//Finish timing the code
QueryPerformanceCounter((LARGE_INTEGER *)&ctr2);
fprintf(storage, "Start Value %s\n", ctr1.ToString());Console::WriteLine("Start Value: {0}",ctr1.ToString());
fprintf(storage, "End Value %s\n", ctr2.ToString());
Console::WriteLine("End Value: {0}",ctr2.ToString());
QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
fprintf(storage, "Frequency %s\n", freq.ToString());Console::WriteLine(S"QueryPerformanceCounter minimum resolution: 1/{0} seconds.",freq.ToString());
fprintf(storage, "Time %s\n", ((ctr2-ctr1) * 1.0 / freq).ToString()); Console::WriteLine("100 Increment time: {0} seconds.",((ctr2-ctr1) * 1.0 / freq).ToString());
fclose(storage);
}
return 0;
}
|
|
|
|
|
You're mixing CLR strings with C-style strings. fprintf() expects a const char* on the stack, to be inserted where the %s is, however what you're putting on the stack is a whole System::String object, which is totally not the same thing. You need to convert that object to a C-style string (with PtrToStringChars , for example).
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
hello,
i'd like to have a progress control in each MDI document's frame, which holds a CScrollView. in particular, i'm interested in shortening the horizontal scrollbar in a CScrollView, and placing controls to the left of the scrollbar, something like the output view in MSVC 6, or like excel. i searched the articles for something like this, but couldn't find anything. does anyone have any suggestions regarding how to do this?
a simple (but, in my opinion, ugly) solution is to leave CScrollView alone, add a status bar to my CMDIChildWnd-derived frame class, and place the progress control in the status bar.
thanks,
ed
Edward H Herskovits
Noetic Systems Incorporated
www.noeticsystems.com
"When certainty is not enough."
|
|
|
|
|
You'll need to stop using the scrollbar that is part of the MDI Child window and use scrollbar controls instead. If you use MFC splitters in your MDI app then it will use scrollbar controls. You might want to have a look at that.
That said it seems strange to me to have porgress controls on the MDI windows. What is taking so long that you need a scroll bar at all, I have to wonder.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
i've developed a user interface to some number-crunching code; the user may want to analyze several documents at once without the GUI freezing, so i converted the analysis code to run in separate worker threads. i wanted to indicate progress for each document separately, rather than in the main frame's status bar, so i thought about having a progress control associated with each document/MDIChildWnd.
thanks for the advice.
ed
Edward H Herskovits
Noetic Systems Incorporated
www.noeticsystems.com
"When certainty is not enough."
|
|
|
|
|
ehh wrote:
i've developed a user interface to some number-crunching code; the user may want to analyze several documents at once without the GUI freezing, so i converted the analysis code to run in separate worker threads. i wanted to indicate progress for each document separately, rather than in the main frame's status bar, so i thought about having a progress control associated with each document/MDIChildWnd.
Ok that makes sense now. Look at the MFC CSplitterWnd code and how it uses CScrollBar. It might be easier to switch to using CSplitterWnd the you'll get the scrollbar's you need. I don't know what would be involved in reducing there size though.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
what about adding a progress control below the view in the MDIChildWnd frame? has that been done?
thanks for your advice; i'll check out CSplitterWnd....
ed
Edward H Herskovits
Noetic Systems Incorporated
www.noeticsystems.com
"When certainty is not enough."
|
|
|
|
|
ehh wrote:
what about adding a progress control below the view in the MDIChildWnd frame? has that been done?
thanks for your advice; i'll check out CSplitterWnd....
I think it would be quite difficult to do as the View window is closely bound to the MDI window. But with enough time anything is possible.
Just did a quick Google search for "CScrollbar MDI" and found:
http://www.codeproject.com/splitter/ruler.asp[^] which may be of interest.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
PS. It might be easier to create a child window that sits in a corner of the mdi window and show the progress ctrl there.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Actualy it is not that simple ... because i'm trying to learn and i don't have "Help" nor "MSDN" nor friends that know Visual C++ ...
My problem is with a Check_box .. i'm used to using Delphi ... in this case i don't have Delphi .. i must use Visual Studio C++ ... So I've banged my head in this small problem ...
I whant something like this ... when I click the Check_Box, a Edit_Box that was disabled, to be enabled ... this is what i've come up with :
<b> <code>int checkState;
CButton* pCheck = (CButton*)GetDlgItem(Check_Eagle);
if (pCheck->GetCheck() == 0) {
pCheck->SetCheck(1);}
else pCheck->SetCheck(0);
</code> </b>
When i hit a Button i whant to do the check ... if GetCheck = 1 then Edit_Eagle = Enabled ... and to enter a value in the same time ... :->:-> ...
can anyone help ?
iarta, iubeste, zimbese, exprima-te, relaxeaza-te, ajuta un batrin, accepta un compliment, ascula-ti prieteii, reia un proiect abandonat, fii intelegator cu tine si cu altii, uita-te la un album cu fotografii, picteaza un tablou, asculta tacerea, aminteste-ti intotdeauna ca nu esti singur, spune-le celor ragi cit de mult ii iubesti, imagineaza-ti ca astazi nu ai nici o grija, joaca-te cu un copil, citeste o carte buna, alege-ti o stea de pe cer, fii copil inca o data, suna-ti prietenii cu care n-ai vorbit de mult, da-ti voie sa mai si gresesti, lasai pe altii sa te ajute, renunta la ce u iti place, indeplineste-ti promisiunile, inchide ochii si imagineaza-ti ca esti pe o plaja tropicala, priveste atent o floare, cumpara-ti ceva ce iti doresti de mult, spera ca ceea ce iti doresti se va indeplini, ajuta-i pe altii, respira profund, fa-ti un cadou, iubeste !!!
|
|
|
|
|
assasin_shark wrote:
i don't have "Help" nor "MSDN"...
Actually you do. Check out http://msdn.microsoft.com[^].
When calling GetCheck() and SetCheck() , use BST_UNCHECKED and BST_CHECKED instead of 0 and 1. It has nothing to do with your problem, but it does make the code more readable.
assasin_shark wrote:
CButton* pCheck = (CButton*)GetDlgItem(Check_Eagle);
The value passed to GetDlgItem() should be the ID of the checkbox control. Is that what Check_Eagle is, or is it a (int ) variable?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
<small><b>DavidCrow wrote:</b></small>
<i>Actually you do. Check out http://msdn.microsoft.com.</i>
Actualy i was there .. but .. realy .. i didn't find what i was locking for ...
<small><b>DavidCrow wrote:</b></small>
<i>When calling GetCheck() and SetCheck(), use BST_UNCHECKED and BST_CHECKED instead of 0 and 1.</i>
u mean <code>SetCheck(BST_CHECKED)</code> ?
<small><b>DavidCrow wrote:</b></small>
<i>Is that what Check_Eagle is, or is it a (int) variable? </i>
<code>Check_Eagle</code> is the name or ID of the Check_box, yes ...
iarta, iubeste, zimbese, exprima-te, relaxeaza-te, ajuta un batrin, accepta un compliment, ascula-ti prieteii, reia un proiect abandonat, fii intelegator cu tine si cu altii, uita-te la un album cu fotografii, picteaza un tablou, asculta tacerea, aminteste-ti intotdeauna ca nu esti singur, spune-le celor ragi cit de mult ii iubesti, imagineaza-ti ca astazi nu ai nici o grija, joaca-te cu un copil, citeste o carte buna, alege-ti o stea de pe cer, fii copil inca o data, suna-ti prietenii cu care n-ai vorbit de mult, da-ti voie sa mai si gresesti, lasai pe altii sa te ajute, renunta la ce u iti place, indeplineste-ti promisiunile, inchide ochii si imagineaza-ti ca esti pe o plaja tropicala, priveste atent o floare, cumpara-ti ceva ce iti doresti de mult, spera ca ceea ce iti doresti se va indeplini, ajuta-i pe altii, respira profund, fa-ti un cadou, iubeste !!!
|
|
|
|
|
assasin_shark wrote:
i didn't find what i was locking for ...
Specify exactly what you are looking for and someone will point you in the right direction.
assasin_shark wrote:
u mean SetCheck(BST_CHECKED) ?
Exactly.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ok .. that solves one of the problems ... but the most impotant one ???
how do i do that ???
|
|
|
|
|
assasin_shark wrote:
how do i do that ???
How do you do what? You've not specified what the problem is. The code snippet in your original post appears to be syntactically correct. What part of it is in error?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
not eror ... just that i don't know how to do that ... i'll tell u again ... i whant to make an Edit_Box "Enabled" after i click the Check_Box and to enter a value also .. in te same time ... my problem is with the changing of the status of the Edit_box because of my click ... understand ?
nu prea ma fac inteles, dar incerc sa ma exprim !!!
|
|
|
|
|
Assuming your dialog class has a CEdit member variable mapped to the edit control, you can use:
m_ebEdit.Enabled(pCheck->GetCheck() == BST_CHECKED);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Actually what David meant was:
m_ebEdit.<code>EnableWindow</code> (pCheck->GetCheck() == BST_CHECKED); /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hummm, most of MSDN is on line (avialable via www). If you're developing the program using the VC++ IDE, then you should already have access to MSDN; otherwise there would be no help avialable when you hit F1. If you are using MFC (via VC++), then activating the class wizard will give you the option of setting the UI options (via command id) as follows:
void MyView::OnUpdateColortypeFill(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_Grid.GetColorType() == CGetColor::FILL);
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
guys .. i apreciate the help .. but it would be better if u would tell me were to put the sequence of code ... these are my arrors ....
<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(150) : error C2653: 'MyView' : is not a class or namespace name<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(152) : error C2065: 'm_Grid' : undeclared identifier<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(152) : error C2228: left of '.GetColorType' must have class/struct/union type<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(152) : error C2653: 'CGetColor' : is not a class or namespace name<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(152) : error C2065: 'FILL' : undeclared identifier<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(164) : error C2065: 'm_ebEdit' : undeclared identifier<br />
D:\DOCUMENTELE MELE\3\3Dlg.cpp(164) : error C2228: left of '.EnableWindow' must have class/struct/union type<br />
so .. i'm in the fog again ..
|
|
|
|
|
hello everyone...
i have a small question:
i want to intercept keyboard strokes being sent to applications...for example i want the 'a' button to send a 'b' to applications instead of 'a'...should i use hooks or subclassing...i need to know what are the appropiate APIs that should be used..
note:i want this to be done for all applications ((processes)) not only one...
|
|
|
|
|
Hook is better , just try global Keyboard hook.
saeedmalas wrote:
.i need to know what are the appropiate APIs that should be used..
SetWindowsHookEx(...) ,but for Global hook you have to create a dll.
look for more example here :-
http://www.codeproject.com/system/hooksys.asp
http://www.codeproject.com/system/Paladin.asp
http://www.codeproject.com/dll/hooks.asp
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
it looks like that using SetWindowsHookEx is only for monitoring not modifying...i actually want to prevent a message from reaching applications or modifying that message before reaching them..not just see what the message is...
|
|
|
|
|
Actually after hooking you can use GetWindowLong to to get Window procedure of any window and you can modify the charater from there.
look for that in more Detail in the link given by me in last post
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
if i'm going to do that,i think i have to get the Window procedure of all windows of all processes...i think that's a very hard work..isn't there an easier way..
|
|
|
|
|