|
Henry miller wrote:
and your loop won't be long enough for those nano-second to add up
well, I am thinking about doing some game programming eventually, and that's one of the reasons I asked this question in the first place. Thanks for your response
int i = 2, x = 2;
int j = x + y;
sprintf("%d",j);
4.7388937 ???
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
This is something of a religious subject in that people have certain beliefs and will not change them whatever the argument. And those that do convert, tend to froth at the mouth!
However, IMHO, unless you need to do low-level access to hardware, or you have something in an extremely tight loop, assembly code should not ever be seen.
Remember, the vast majority of the life-cycle of a program is in the maintenance phase and assembly is harder to read and understand than a higher level language. And porting is an issue with assembly, even if on the same processor -- different compilers handle assembly escapes differently.
And modern compilers are pretty good. If you think about how the code is liable to be translated (or peek at the generated code), you can optimize the C/C++ code to make very good machine code. Things like using the natural size integer for a processor rather than something that needs conversion, e.g, use an int rather than a short for a number so low level conversion doesn't have to happen. Naturally, such code should be heavily commented.
As an aside, certain kinds of optimizations that programmers often use because they think they are smarter than the compiler are not needed. For instance, doing x <<= 1; in instead of x *= 2; is almost never needed. The compiler can figure this out just fine. And the first is harder to read...
|
|
|
|
|
You should be aware that this is a religious subject; people of one faith will ignore all arguments from heretics. And converts tend to be evangelistic!
IMHO, unless you need to do low-level hardware access or are in an extremely tight loop, assembly code should never be seen. And if it is, it should be heavily commented. Remember, the vast majority of the life-cycle of a piece of software is in the maintenance phase, not development -- assuming it is a successful program! And assembly is harder to read and hard to port. Even when porting from one compiler to another for the same target processor, porting can be awkward as different compilers have different assembly escapes, stack conventions, internal symbol representations, etc.
Further, modern compilers are smart. Even things like x <<=1; instead of the more readable x *= 2; don't buy you anything as the compiler understands what *= 2 means and will find the best way to accomplish this.
If you really are concerned about optimization in a tight loop, then optimize your algorithm (always your best bang for the buck) and adjust variables such that a minimum of assembly-level conversions are needed. For instance, use the machine's natural size integer (usually int ) instead of a short . If the compiler cannot determine the absolute maximum value and the processor doesn't handle short s as easily as int s, then a low-level conversion might be needed. Try peeking at the generated assembly. And heavily comment such tweaks!
|
|
|
|
|
Guys, how can I know an API constant exact value? For example, PURGE_TXABORT. Any documents?
Thanks a lot.
vigorous
|
|
|
|
|
well, in VS.Net, any windows api constant that I hover over, I get the value. Other than that:
1. put a breakpoint on your code, hover over the constant at run-time ||
2. put the constant in the watch window ||
3. put the constant in a sprintf() or TRACE macro to output the string ||
[edit] 4. right-click on the constant and choose "goto definition" [/edit]
int i = 2, x = 2;
int j = x + y;
sprintf("%d",j);
4.7388937 ???
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
multiple property pages on one sheet.
i need hide or show one page according to different cases without changing the page's index.
how to do that?
includeh10
|
|
|
|
|
Do you want the tab order the same, or must the index number remain the same (and those of the other tabs)? The latter, to the best of my knowledge, is not possible. For the former, it's probably easiest to remove all of the tabs (using RemovePage) and then add them again (using AddPage), with the page in question on a conditional statement:
void CMyDlg::OnBnClickedShowPgTwo(void)
{
UpdateData();
ResetPropPages();
}
void CMyDlg::ResetPropPages(void)
{
// remove pages - this removes all pages regardless of order or which are showing
while(m_wndPropsht.GetPageCount())
m_wndPropSht.RemovePage(m_wndPropSht.GetPage(0));
// add pages again (order important)
m_wndPropSht.AddPage(&m_wndPg1);
if(m_bShowPg2) m_wndPropSht.AddPage(&m_wndPg2);
m_wndPropSht.AddPage(&m_wndPg3);
}
If you've derived the CPropertySheet class you can do it from within that (no need for "m_wndPropSht."). It doesn't matter if you're showing the property sheet at the time or not, though you need to think about which page to show after resetting, particularly if you were showing the removed page.
|
|
|
|
|
does the code work?
as i tested, if all pages are removed from sheet, the sheet dispears - adding pages again doesn't work.
but i fixed my problem by your idea
thx
includeh10
|
|
|
|
|
sorry, yes, when I did it I always kept the first page which I didn't need to remove.
|
|
|
|
|
Hi all,
How can i know which version of service pack in installed for MSVC6.0 on my machine. and where i can get the SP3 for the MSVC60?
this is because,I am geeting similar errors which are mentioned in Q191626.
Thanks in advance,
Abhi Lahare
|
|
|
|
|
Abhi Lahare wrote:
How can i know which version of service pack in installed for MSVC6.0 on my machine.
How about:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\6.0\ServicePacks
Abhi Lahare wrote:
and where i can get the SP3 for the MSVC60?
Have you tried http://msdn.microsoft.com?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
If you are talking about the visual studio service pack, you can open visual basic and select Help>About. It shows the service pack version but if u have only visual c++ installed, I have no idea
Regards
Pradeep
Between the great things we cannot do and the small things we will not do, the danger is that we shall do nothing
|
|
|
|
|
Perhaps you meant to reply to Abhi Lahare.
david_gilmour wrote:
If you are talking about the visual studio service pack, you can open visual basic and select Help>
Why would I want to open VB to know what service pack is installed?
david_gilmour wrote:
...u have only visual c++ installed, I have no idea
Did you know read my reply in its entirety?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Help:
I'm trying to write an application on Visual Studio .NET 2003 that uses the Video for Windows AVIFile methods to read an AVI DV file and grab some frames from it. It's been working fine, except I can't seem to access the whole of a larger file. If I use AVIFileInfo after AVIFileOpen then the length of the file given (in frames) is smaller than the actual length. If I then open the video stream and use AVIStreamLength I get the actual file length. However, if I try to use AVIStreamGetFrame to extract frames it returns NULL for any requests for frames beyond the length given with AVIFileInfo!
Some messing about has shown me that the cut-off point seems to be around the 1GB mark(approx 4m45s for DV). If I encode using a different scheme (say, Cinepak codec) then it displays well beyond the 5m mark (although the file I checked this on was still less than 1GB, so I need to generate a bigger file to find if the problem resurfaces with a different codec - will do this overnight).
I can't find any reference anywhere to a restriction with reading avis with AVIFile, but can't think what else the problem could be. As far as I know both AVIFileInfo and AVIStreamLength extract data without the use of a codec so it's not a problem with the specific codec that I'm using. Having said that, I know that Video for Windows is a bit outdated and I should really be using DirectShow, so maybe it's because the software is too old...
Has anyone else had this problem or have any ideas?
jOP
|
|
|
|
|
Hi All!
I am getting debug assertion error exactly at the fourth time i open Webbrowser Control, consistently, everytime. CAN ANYONE HELP?
Any help on this regards will be appreciated !
I have two components, one is a MFC Application and the other is a Dll. I have a Webbrowser control in the dll, that is accessed by the MFC App. The following code calls the Webbrowsercontrol, which is in the dll, by the foll code:
"CWebDialog* wb;
wb = new CWebDialog();
wb->DoModal(); "
This code calls the Webbrowser control cpp, in the dll, whose Initdialog has the foll:
BOOL CWebDialog::OnInitDialog()
{
USES_CONVERSION;
CoInitialize(NULL);
try
{
hf_WriteLog("ONINITDLGWEB");
COleVariant vaURL(m_strURL);
((CWebBrowser2*)GetDlgItem(IDC_EXPLORER1))->Navigate2(vaURL, NULL, NULL, NULL, NULL);
hf_WriteLog("NAVIGATED");
VariantClear(&vaURL);
CoUninitialize();
CDialog::OnInitDialog();
}
This throws an exception, every fourth time. Is that a problem with the memory allocation of the dll.. or anything, someone could help????????
Regards
angello6
|
|
|
|
|
Hello
Can anyone please help me to write a multiple column combo box program in VC++.
Thanks
Madhavi
|
|
|
|
|
My application has to launch Notepad opening within it a file produced by itself.
I've tryed with the following code but it doesn't work correctly. Notepad is open but the file is not open within it. By the way, the same command launched within cmd.exe works fine.
CString l_cstrApp = _T("C:\\WINNT\\Notepad.exe");
CString cstrCommandToLaunch. = _T("C:\\MyFile.txt >> Notepad.exe");
CreateProcess(l_cstrApp.GetBuffer(0),
l_cstrCommandToLaunch.GetBuffer(0),
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&l_StartupInfo,
&l_ProcessInfo);
Can someone tell me how to solve this problem ??
|
|
|
|
|
l_cstrApp = _T("C:\\WINNT\\Notepad.exe C:\\MyFile.txt");
|
|
|
|
|
or better way to use
ShellExecute
ShellExecute(NULL,"open","Notepad.exe","filename.txt",NULL,SW_SHOWNORMAL);
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
"C:\\MyFile.txt >> Notepad.exe" does not work. Use the following:
CString l_cstrApp = _T("C:\\WINNT\\Notepad.exe");
CString l_cstrCommandToLaunch. = _T("C:\\WINNT\\Notepad.exe c:\\file.txt");
ARSALAN MALIK
|
|
|
|
|
OK ! Now It works!
Thanks a lot to all.
|
|
|
|
|
I want to make a program that administrates some computers in a network and I need to do a client server aplication. The computer server has a server program which accepts connections from the computers in the network. After a computer connects i create a thread for that certain socket and ip.
In order to send info to a computer so I can reveive something I have to do it in that thread so I need some way of storying some string variables somewhere from where they can be read. I don't think registry would be a good idea because I did this and after a while the registry fails to open the certain key I don't know why . . . I know it can be done with some mutex objects or something like this. Can someone give me a piece of code on how variables can be read.
Thank you.
gabby
|
|
|
|
|
I want to use API TransmitFile to build a C/S structure ,who can give me an example.I have written a program but client program has bug,client codes as below:
UINT ClientThread(LPVOID lv)
{
SOCKET s=(SOCKET)lv;
CFile f;
bool IsOpen=false;
char buf[1024*128]="";int count=0;
while (true)
{
buf[0]='\0';
int ret=recv(s,buf,sizeof(buf),0);
if(SOCKET_ERROR == ret)
{
CString s;
s.Format("%d",WSAGetLastError());
AfxGetMainWnd()->SetWindowText(s);
break;
}
else
{
CString str(buf,ret);
int i=str.Find(':');
if(-1 != i)
{
if(f.Open(str.Right(str.GetLength()-i-
1),CFile::modeCreate|CFile::modeWrite) == 0)
break;
IsOpen=true;
}
else if("FileTranferOver" == str)
break;
else if(IsOpen)
{
try
{
f.Write(buf,ret);
}
catch (...)
{
str.Format("%d",GetLastError());
MessageBox(NULL,str,"Error",MB_OK);
}
}
else
continue;
count+=ret;
}
}
if(IsOpen)
f.Close();
CString str1;
str1.Format("%d",count);
AfxGetMainWnd()->SetWindowText(str1);
return 0;
}
|
|
|
|
|
I am having a MFC Dll.
The settings are as follows
Use MFC in a Static Library
In Code Generation : Debug Mutithreaded DLL.
The error i am getting is
uafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___wargv
uafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
But when i change the Code generation option to
Debug Multithreaded,
i dont get any Link errors.
What is the difference and is it OK to have this option for a MFC dll.
Yuvaraj N
|
|
|
|
|
in my app, i resize property sheet to max size (SW_SHOWMAXIMIZED), but when i resize property pages of the sheet, they are not resizable.
do you know how to resize property pages??
thx
includeh10
|
|
|
|
|