|
Hmm. Isn't that "#pragma once" does? Why do you have both preprocessor guards and #pragma once?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote:
Why do you have both preprocessor guards and #pragma once?
If one get fail other will do the Work .
But here both of them are failing .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
But here both of them are failing .
sure, look at his code :
#ifndef <font color=red>_x_h</font>
#define <font color=red>x_h</font>
are these the same ?
moreover, #pragma once were not supported on previous versions of VStudio, and might be not too on another compilers...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
are these the same ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello Group
Can anybody in the group Try to Explain,What are Smart pointers and what are the advantages over the pointers and exactly where are they used frequently???
VC++
|
|
|
|
|
Smart pointers can be used wherever you use raw pointers. They basically make sure that every new is paired with a matching delete and that you delete allocated memory only once. Typically, they do this by reference counting.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
First of all very thanks to S.Senthil Kumar for taking time to describe this concept.
But it is bit theoretical can i have some more information on this regarding how to use this concept
VC++
|
|
|
|
|
Take a look at CComPtr class in MSDN. This is an example of smart pointers.
"I would luv to change the world, but they wont give me the source code"
My Articles
|
|
|
|
|
...or search for std::autoPtr for C++ standard
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Is there any open source codes which can convert OpenGL rendering to HPGL format file?
|
|
|
|
|
Hi all,
I am registering a clipboard format as follows
UINT format = Registerclipboardformat(_T("FileName"));
then using the same format for setting the clipboard data
Setclipboarddata(format,hclipboarddata);
Now when i pass the file name to the handle, i could see in the memory location the path name is correct but after the execution of setclipboarddata command and after closing the clipboard when i see on the clipbook viewer, only drive letter is pasted.
Pl. answer to me ?
Thanks..
Vineet
|
|
|
|
|
In VC++ 5.0 through 7.0 creating a static library is no big deal. Any projects created can find the libraries quite easily. Now I need to use a specific library in a VC++.Net environment and am a loss as to how to.
I am a teacher at a community college and basically teach c++ console applications and the texts that I use currently contain a copy of VC++ 6.0 but our classrooms are fixed with VC++.Net
Any help would be helpful.
I am a new member and hope to submit this particular library that provides a sequre method for fetching keyboard data for all primitive types, strings and dates for console applications which obviate the not-so-secure cin.
DOC
|
|
|
|
|
|
I have an include fiel enums.h that houses off enums used
enum WordDirection
{
Right = 0,
Down,
Diag_Down,
Diag_Up
};
I have a class 'A'
private:
int _iRow;
int _iCol;
bool _bHighlight;
std::vector<cletter> _arrLetters;
WordDirection _enumDirection;
TCHAR _sWord[16];
now adding the include into the cpp seems fine. but the compile flips in the enum line of the include file and says "error C2011: 'WordDirection' : 'enum' type redefinition"
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
your file is being included more than once, so it's trying to create the enum more than once ( I reckon ). If you're using precompiled headers ( stdafx.h ), try including it in there and nowhere else in your project. The other thing is to put an inclusion guard block around your code so it will only include once. I think #pragma once is all you need to do this, at the top of the file.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I need to close IE after starting IE with Createprocess. I am using ::PostMessage to try to close IE, but it is not working. I want to use Createprocess to start IE.
LPSTR szAPP = "c:\\progra~1\\intern~1\\iexplore.exe";
(CreateProcess(NULL,szAPP, NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo));
Sleep(10000);
hWnd=FindWindow(_T("IEFrame"), NULL);
::PostMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
|
|
|
Why dont u use ExitProcess API to close it.
"I would luv to change the world, but they wont give me the source code"
My Articles
|
|
|
|
|
ZakAkili wrote:
hWnd=FindWindow(_T("IEFrame"), NULL);
Hi Mr Zak,
have you check for returned hWnd , may be it's NULL?
ZakAkili wrote:
::PostMessage(hWnd, WM_CLOSE, NULL, NULL);
Try WM_QUIT or pass ProcessInfo.hProcess returned from CreateProcess to TerminateProcess to closedown the IE
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Try:
LPCSTR szAPP = "c:\\progra~1\\intern~1\\iexplore.exe";
CreateProcess(NULL,szAPP,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo));
Sleep(10000);
TerminateProcess(ProcessInfo.hProcess, 0);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks, All of the replys have helped.
|
|
|
|
|
Hi Guys.
I was reading through one of Mike's articles on sockets. And I just CANT
seems to wrap my brain around this one:
BYTE* bp = (BYTE*)(&dataLength) + sizeof(dataLength) - cbLeftToReceive;
I got this far:
(Its a Byte)(Called bp) = (Point to Byte)(&WHAT?!?!) + Something?
Okay now I'm lost.. I simply dont get the (&dataLength), now Datalength
is just an int, so what with the (&int) what does it do?
What does the syntax here mean?
Somebody please help me out!
Shine
|
|
|
|
|
Mike who?
Which article?
Shining2005 wrote:
BYTE* bp = (BYTE*)(&dataLength) + sizeof(dataLength) - cbLeftToReceive;
BYTE* bp ==> bp is a pointer to a BYTE
(BYTE*)(&dataLength) ==> casting the address of dataLength to a BYTE pointer
+ sizeof(dataLength) ==> advance the BYTE pointer to the byte just past the end of the memory occupied by datalength
- cbLeftToReceive; ==> bring the pointer back cbLeftToReceive bytes
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hello gurus,
I'd like to know how I can convert a DWORD (32 bits) value into a byte array of four bytes (32 bits)?
<br />
DWORD dwLength=(DWORD) file.GetLength();<br />
BYTE length[4];<br />
length contains the value dwLength as a 4 bytes array.
Thanks
Best regards.
There is no spoon.
|
|
|
|
|
for (int i = 3; i >= 0; --i)
{
length[3 - i] = (dwLength & (0xff << (i * 8))) >> (i * 8);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
DWORD dwLength=(DWORD) file.GetLength();
BYTE length[sizeof(DWORD)];
*(DWORD*) &length[0] = dwLength; Keep in mind that any code doing anything with the bytes will have to account for the endian type of the CPU.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|