|
Dear SnowHow,
i have observe same result.
|
|
|
|
|
Hi All,i want to capture mouse move over a CButton(Button Controls) in a dialog.Whenever i move mouse over a button i want to change the button properties eg : button color, button picture(Bitmap). Please any one have any idias or any examples, which helps me.
Thanks in Advance
|
|
|
|
|
hapyy coding with
TRACKMOUSEEVENT tme;//class member !!!
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE|TME_HOVER;
tme.dwHoverTime = 1;
_TrackMouseEvent(&tme);//
and
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
ON_MESSAGE( WM_MOUSEHOVER, OnMouseHover )
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I am working on a very large project and would like to know if their is a rule of thumb for the proper sequence for doing #includes.
I have always put my #include's in headers and done no #includes in any of my .cpp files. When my projects get large and I use a lot of the same included files I put a master header and include it in every other header.
For example:
Utils.h
#include <io.h>
#include <pgmspace.h>
#include <delay.h>
-Other helper functions that are
useful such as a custom printf()
Display.h
#include "Utils.h"
#include "ctime.h"
Display.cpp
#include Display.h
The reason I am asking is my target is VERY memory limited and I need to get things as small as possible so useless inclusions that and bulk I need to get rid of. My other method of doing things is to only include exactly what that .h/.cpp set requires and use a Globals.h with external decelerations for all cross file variables and definitions.
I still do not understand how the linker pieces objects together when their are unused functions. I would imagine that the compiler runs through your code and only generates asm for the functions and variables you use. If their is a function that uses a 10x32bit array but your not using it the compiler skips it? Then in the linker stage if it notices their are duplicate functions in each of the objects it strips out the others and only includes one? If this is the case then my above question is just semantics and I should not worry and do what is easiest to maintain and cleanest.
|
|
|
|
|
One way to make sure you include only required headers. is by using #define macros.
|
|
|
|
|
I already use the #ifndef/#define inclusion guards. If you have a function in a say 'abs.h/abs.cpp' and include it in 'part1.cpp' and 'part2.cpp' and use it in each part upon compiling 'part1.o' and 'part2.o' will each have that function. When the linker combines 'part1.o & part2.o into final.exe' will the function still be included twice or does it weed out duplicates and just point them all to one?
|
|
|
|
|
You're actually doing things a bit backwards - in C and C++ the general rule is to only include the minimum number of other files in headers. You only want declarations included that are actually going to be used by clients of that header. While C isn't as bad as C++ I've seen large (250kloc) projects have their build times cut by a factor of 100 by using these techniques. It also avoids dependency fear - "aaarggghh, I can't change this header as absolutely everything includes it directly or indirectly and everything will build, bollocks, I'll just hack something in this C file to get 'round it..."
Interestingly and generally (this depends on your compiler, most I use work this way) what you include doesn't usually have much effect on the code size. Declarations and macros don't occupy space in an object file - it's definitions that do. Exactly what the linker does depends on the linker (and how the compiler packages functions) but most modern linkers remove multiple definitions of objects with the same name. However some require command line switches to turn this on so it's a good idea to look at your compiler and linker docs and find out what all the switches do. One good rule to follow is that if your compiler is a C++ compiler it'll support multiple definition removal (saves the embarrassment of template explosion on code size), if it's just a C compiler then it may take some fiddling to do so.
Cheers,
Ash
|
|
|
|
|
I think I'm picking up what your throwing down now. For code size if you included every single c library header but didn't use a single function they provided the size of the code would not go up with every additional inclusion but because the compiler must do its job on every included file the compile time will increase will every include.
So for my projects I should only include the minimum amount of headers for each file to keep things compiling as fast as possible and make maintenance easier.
Originally my layout was:
#include <stdio.h>
#include <stdints.h>
#include <ctype.h>
#include <string.h>
#include "Utils.h"
#include "ctime.h"
#include "Utils.h"
And I should get in the habit of this way:
#include <stdints.h>
#include <stdio.h>
#include <stdints.h>
#include "Utils.h"
#include "ctime.h"
#include <stdints.h>
#include <ctype.h>
#include <string.h>
#include "Utils.h"
|
|
|
|
|
Hey, this is my code:
char szBuffer[1024];
recv(sock,szBuffer,sizeof(szBuffer),NULL);
printf("%s", szBuffer);
now the size of the websites vary, how would i allocate just enough memory for the actual content so the rest of the buffer wont be filled with junk ?
Thanks.
|
|
|
|
|
Good question ... without an answer.
The physics has its limits, and computer aren't paragnostic.
You have only two chances: know the size of what you are receiving in advance (and allocate the required) or, "guess it" and store as you can. You may waste something, or you may be required to relocate.
In both of the cases, dynamic allocation must be used (so an on-stack array cannot help).
There are dynamic memory allocation operations (search for "new and delete") or dynamic allocating classes (see std::vector).
Search for their documentation.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Depending on how you are getting the content the answer is different. Reading from a file is simple.
But, if you are getting the website content from a web server then all you have to do is parse the HTTP return headers for the Content-Length header option. This will give you the size of the buffer that is required. From here you can make the new buffer and store the rest of the web page into the newly allocated buffer, or you can take the size and resend the same request after finding out the required buffer size. Skipping the headers by looking for \r\n\r\n in the buffer and once this is found to begin storing the website contents.
So, in both cases you need to dynamically allocate the buffer as stated before, but it all depends on how you are reading the website content, from file or from a web server.
|
|
|
|
|
See the remarks section here[^], you should always check the return values of system calls to see whether they succeeded or not. In the case of recv it will tell you if the message cannot be completely transferred to the buffer. You should re-allocate your buffer to a larger size and try again until you are able to read the entire message.
It's time for a new signature.
|
|
|
|
|
Thanks for all answers and thanks to Richard, that will sure do the job for me!
|
|
|
|
|
I have a program that embeds Word through DsoFramer, but I need to know which version (2000/2003/XP/2007/2010) is installed because I need to adjust some things depending on the installed version.
Does anyone know how to do that? I have a pointer to the CApplication interface, and I can probably get any interface that's needed.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
If you can get the path to Word's executable you might try using GetFileVersionInfo[^], this is just an idea, am not sure if Word's executable(s) actually contain(s) this or not, but you can check.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
I did find an article via Google some time ago which described it, but unfortunately I cannot remember how (maybe "office registry keys" or something). However if you look at a key similar to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{91130409-6000-11D3-8CFE-0150048383C9} you can find the values. You may need to enumerate some of the keys looking for "Office" etc but it should not be too difficult.
It's time for a new signature.
|
|
|
|
|
There is 'Version' property on CApplication interface.
Moreover, DsoFramer is no longer recommended or supported by Microsoft. It has several known issues with modern office applications.
|
|
|
|
|
Thank-you kindly.
The following VBA code gives me word version as being 12 (when using office 2007)
Sub getWordVer()
Dim wordApp As Object
Set wordApp = CreateObject("Word.Application")
wordApp.Visible = True
wordVer = wordApp.Version
MsgBox ("Word version: " + Str(wordVer))
End Sub
modified on Friday, July 16, 2010 4:01 AM
|
|
|
|
|
Thanks, this seems the best solution. Can you tell me what the known issues are? I'd like to know to see if they will affect my project.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
as you know, DsoFramer appeared in msdn KB articles as a sample of OLE on office applications. Latest office applications are actually not meant to be embedded. DsoFramer was declared as dead and no longer available in msdn samples.
One way to embedd office applications is to load them inside web browser control and do some registry modifications to force IE to embedd office applications. Still i think you will be missing some features like ribbon control in Office 2007 and 2010.
modified on Wednesday, July 21, 2010 10:41 AM
|
|
|
|
|
Hi All,
I am using CreateFile to open a specific file which will be accessed by multiple instance of same process simultaneously. This time function getting failed and GetLastError() is returning the following error.
"The process cannot access the file because it is being used by another process."
This is how i called the function
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( INVALID_HANDLE_VALUE == hFile )
{
CString csErr;
csErr.Format( _T("Failed to open File**** Error code = %d"), GetLastError());
AfxMessageBox( csErr );
return bRet;
}
I need to open the same file simultaneously by different process.
Please help me.
-Cvaji
modified on Thursday, July 15, 2010 9:30 AM
|
|
|
|
|
Is one of your processes writing to the file (looking at your other question)? In that case you need to specify the sharing mode there too.
|
|
|
|
|
Cvaji wrote: hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );if( INVALID_HANDLE_VALUE == hSMPFile )
The return value of the CreateFile is stored in hFile , but you have checked the INVALID_HANDLE_VALUE aganist hSMPFile file. Is it really like that in the code or its just a typo?
|
|
|
|
|
sorry my friend..its just a mistake..
|
|
|
|
|
Even though my application is only doing the file read,
::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ|<big>FILE_SHARE_WRITE</big>, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
this made it work. Strange
|
|
|
|