|
Its the same as any other operator<<.
MyObj& operator<<(__int64 i64Value)
__int64 is an MS extension so that can be a problem depending on which compiler you are trying to compile on.
|
|
|
|
|
Assuming you want to emit it to an ostream (hard to tell without you telling what you want to do with it), the follwing will do.
std::ostream& operator<<(std::ostream& os, UINT64 i)
{
char sz[32];
sprintf(sz, "%I64u", i);
os << sz;
return os;
}
|
|
|
|
|
This is how I create my window:
<br />
m_hWnd=CreateWindow("STATIC",lpszName,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS,nX,nY,nWidth,nHeight,hParent,NULL,hInstance,NULL);<br />
It's a static window with a dialog as a parent.
Now I want to add a border to it, specificaly the "sunken" effect.
<br />
CWnd* pWnd=CWnd::FromHandle(m_hWnd);<br />
pWnd->ModifyStyleEx(0,WS_EX_CLIENTEDGE);<br />
The function returns TRUE, but I don't see any border around my static window.
Is this the right way to do it? Did I make an error?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Use pWnd->ModifyStyleEx(0,WS_EX_CLIENTEDGE, SWP_DRAWFRAME );
rechi
|
|
|
|
|
That's it tnx
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
I need your help
How to embbed a simple window into dialogbox (modeless) using CreateWindowEx function?.
I really need that one
|
|
|
|
|
My questions are these;
How can I ensure that a program which creates a file is the only one allowed to access that file? And furthermore how can I make windows clean up my temporary files (in case the program crashes or something)? Taking into consideration that the program which created the file has some sort of security lock on the file.
Something clever should be said, but I don't have the time
|
|
|
|
|
1. you can't do it directly in Windows. Windows does not support file locking or access validity of any form. Only access level rights of a file are checked while accessing a file, which comes from the current user's access rights and privileges.
Probable solution:
You need to put some sort of file encryption algo so that only authorize process/program can open it to read/write data from/into the file. but one draw back there in this. anyone can corrupt the file and data will be lost beyound recovery.
2. A
tmp files can be deleted by a countom made software that looks for special file name patters and if found can take appropriate action of deletion.. this SW can be put to start during Windows startup so that by teh time PC is ready to be used all tmp files are deleted.
2. B
also tmp file names can be logged in one common file with complete path. this file can be opened by a SW during Windows startup and all entries in that file can be deleted one by one. tmp file paths will be added to this log file by various processes/programs that require peroidic/auto deletion of log files.
techi !!
|
|
|
|
|
BhaskarBora wrote:
1. you can't do it directly in Windows. Windows does not support file locking or access validity of any form. Only access level rights of a file are checked while accessing a file, which comes from the current user's access rights and privileges.
What rubbish. See the dwShareMode param of CreateFile().
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp[^]
2. This is trying to clean up after the fact. Far better to prevent the problem in the first place.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
"What rubbish. See the dwShareMode param of CreateFile(). "
CreateFile will work till you have opened the file and after u close it any process can open it and read the contents.
requirement is that no other process should be able to even open or read the file, which was originally created by some other process. this can be done by encrypting the file whose descryption is known to only the creator of the file.
_________________________________________________________________
"Think big, think fast, think ahead. Ideas are no one's monopoly"
|
|
|
|
|
Raggamuffin wrote:
How can I ensure that a program which creates a file is the only one allowed to access that file?
See the dwShareMode param of CreateFile(). Sharemode can be also spec'd in some other functions that wrap CreateFile(). See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp[^]
Raggamuffin wrote:
And furthermore how can I make windows clean up my temporary files (in case the program crashes or something)?
1) Use C++ and/or Structured Exception Handling (SEH). There are several good articles here on CP about Exception Handling.
2) Use RAII to manage the file handle and simply rely on destructors to cleanup for you. Boost scoped_ptr will do this for you very nicely. See: http://www.boost.org/libs/smart_ptr/scoped_ptr.htm[^]
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hiya I have to structure and wanted to make a pointer to it WITH 10 INSTANCES.
So I have:
struct s_Test
{
char name[30];
}
struct s_Test* Test[10];
void main()
{
memcpy( Test[0]->name,"Paul",30 ); // system error here
return;
}
My problem happens when I go to access an element of the structure. I gives me the system error that the app must close.
Any ideas how to access them properly??
Thanks;
|
|
|
|
|
Try to use a std:vector of std:string . That works.
If you really cant use C++ and MUST continue to use C, then this one works:
#include "stdafx.h"
#include < memory.h >
struct s_Test
{
char name[30];
};
int main(int argc, char* argv[])
{
struct s_Test Test[10];
memcpy( Test[0].name,"Paul",30 );
return 0;
}
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Meeeep. System error. Copying 30 characters from a buffer which is only 5 characters ("Paul"+zero) long.
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
OOOPS!
But it did compile.....
That type of errors is the reason why I prefer std::vector and std::string .
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
.. and you rightly deserve an error message!
The variable Test has been defined as a pointer to the structure:
struct s_Test* Test[10]
Therefore the memory location for your structure has not been allocated as yet.
try:
<br />
..<br />
..<br />
struct s_Test Test[10];<br />
<br />
void main()<br />
{<br />
strcpy( Test[0].name, "Paul" ); <br />
return;<br />
}<br />
"Wise men talk because they have something to say; fools, because they have to say something."
Plato
|
|
|
|
|
yup Plato.. what you said is correct ! there the array is infact a array of pointers to "struct s_Test " rather then a array of "struct s_Test ".
"Think big, think fast, think ahead. Ideas are no one's monopoly"
|
|
|
|
|
1) The source buffer for memcpy is too small. It is just 5 characters ("Paul"+zero), but you specify 30. This will result in a memory access error. A valid value for memcpy source len would be strlen("Paul")+1.
2) Declare the Test array as array and not as pointer array. So instead of struct s_Test* Test[10]; do a struct s_Test Test[10];
3) If you have done step 2 you don't need a dereferenced access to the name member variable any more. So the memcpy would look like:
memcpy(Test[0].name,"Paul",strlen("Paul")+1);
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Thanks for all of those suggestions and help. I know I am being awkward but I really want to get it working using a pointer to the structure. I could do it the normal way no problem but I only want to allocate the memory as I need it. I don't want it to be a static array.
Is it not possible to have a pointer to a structure with instances aswell??
|
|
|
|
|
Sure, this is possible too:
struct s_Test
{
char name[30];
};
s_Test *Test;
void main()
{
Test = new s_Test[10];
memcpy(Test[0].name,"Paul",strlen("Paul")+1);
delete []Test;
Test = NULL;
return;
}
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
If you need a table, you need a table. How do you understand a pointer to a structure with instances as well ? To be able to point at something, you need that the something exist in the memory. It is therefor impossible to have a table without allocating some memory for it.
~RaGE();
|
|
|
|
|
Thanks, have it sorted and know the reason y it can't just do it like that.
thanks for all ur help.
grahamoj
|
|
|
|
|
What you really need is a vector or list of structures but this is a little too complicated to start off with. You can look up vector or list in the help for examples if you want. I assume that you will not know how many structures you will have at compile time and that is why you want a dynamic array. You can create a large array of pointers to your structure. This will take 4 bytes per element. Then allocate your structures when you need them. Have an integer keep track of the current number of structures. Try this:
struct s_Test
{
char name[30];
}
struct s_Test* Test[10];
int nTestCount = 0;
void main()
{
// Add a struct and initialize
Test[nTestCount] = new Test;
strcpy( Test[nTestCount]->name,"Paul");
nTestCount++;
// Add a struct and initialize
Test[nTestCount] = new Test;
strcpy( Test[nTestCount]->name,"John");
nTestCount++;
for(int i=0; i < nTestCount;i++) {
printf("%s\n",Test[i]->name);
}
return;
}
|
|
|
|
|
Hello,
Is an access to a variable with static modifier faster than a normal variable?
I have a recursive function:
void recursiveSolve(char *pszInput, int nItems)
{
int pArray[10];
} The initial contents of pArray doesn't matter, it gets overwritten in all cases. If I declare pArray as static int[], would the recursive function be faster? I don't know, perhaps a static variable has a fixed position in memory and doesn't get allocated again and again when the function calls itself recursively. Do you know?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
I think so.
Because a saying said that the more space, the less time.
When stored as static varibles the more space is needed (the none-static varibles will be freed when they won't be needed), so I think the function needs less time to run.
Do you think I am right, don't you?
LeonOrient
|
|
|
|