|
Try processing this window message:
The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.
If you set both sizes the same, I am pretty sure your window's size will not adjust. You just make its minimum and maximum size the same. I have not tested this exact behavior, however, it is just the first idea that came to mind.
|
|
|
|
|
Thanks for your response.
It will be very helpfull.
|
|
|
|
|
I am trying to make a map of a file ant then write it in another file
but I cannot do it I get an error when writing can you please tell me why ?
HANDLE hMapFile,hFile;<br />
<br />
hMapFile=CreateFile("c:\\fish.txt",<br />
GENERIC_READ|GENERIC_WRITE|0,<br />
FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE,<br />
NULL,<br />
OPEN_EXISTING,<br />
FILE_ATTRIBUTE_NORMAL,<br />
NULL);<br />
<br />
hFile = CreateFileMapping(hMapFile,
NULL,
PAGE_READWRITE,
0,
0,
"MyFileMappingObject");
<br />
if (hMapFile == NULL) <br />
{ <br />
MessageBox(NULL,"error","",MB_OK);<br />
} <br />
LPVOID file;<br />
<br />
DWORD length;<br />
length=GetFileSize(hMapFile,0);<br />
<br />
file=(char *)malloc(length);<br />
file=MapViewOfFileEx(<br />
hFile,
FILE_MAP_ALL_ACCESS,<br />
0,
0,
sizeof(hFile),
0<br />
);<br />
<br />
<br />
FILE *gabby;<br />
gabby=fopen("c:\\out.txt","w");<br />
fprintf(gabby,"%s",file);<br />
fclose(gabby);<br />
?????
gabby
|
|
|
|
|
You could always help us be telling us what the error you are getting is!
At a quick glance, you check the value of hMapFile after you use it to create a mapped object, but never check the return value of CreateFileMapping.
You may simply be using hFile & hMapFile the wrong way round in some places...
When you are debugging line by line, you can put
err,hr
in the watch window to see why functions are failing.
Iain.
|
|
|
|
|
man the thing is that there is a problem when trying to write , the rror is exactly when trying to write the lpvoid in the file. I don't know why?
WriteFile() also does not work.
but let me give you a hint first.
if write this line before writeing to the file
file=(char *)malloc(length); the code works fine but the file is full of null caracters
try the code yourself . . .see if you can do anyting
gabby
|
|
|
|
|
I´m writing an application that is communicating with an external device through the serial port (programming in VC++ .net with createfield etc). I am sending some characters to the device, end expect to get an answer. The problem is that I always get more characters back than I should.
I expect the characters “22001C” however, depending on the values of WriteTotalTimeoutMultiplier and WriteTotalTimeoutConstant I get replies like: “222001C” , “220001C” and “220011C” , always a character too much.
I think it is a problem with the timeout configurations, but I´m not sure, as I am just a beginner to c++.
Does anybody have a clue as to what might be the problem, and how to solve it ??
Best regards
doneirik
|
|
|
|
|
If there is a problem with the data reception, I doubt the problem has anything to do with the timeout values for writing.
If the received data differs depending on your writing timeout values it's more likely you have a timing problem accessing the port.
If you have opened the port non-overlapped a reading operation will prevent a writing operation until it reaches its timeout and vice versa.
Are you sure that no other signals have to be manipulated such as DTR and/or RTS? Usually they have, try with HyperTerminal which sets both RTS and DTR to active state if you select no handshaking.
This is easily done with the DCB struct and SetCommState.
To nail down the real problem, try this:
1. Do not use read/write timeouts. MSDN tells you how to set this up.
2. Connect to another PC or COM-port and open it with HyperTerminal, see if you can receive expected data sent from HT.
Alternate 2: create a loop-back by connecting Rx and Tx (pin 2 and 3) and see if you can read the data you are sending.
Hope this helps
--
Roger
|
|
|
|
|
Hi all,
Is it necessary to delete an object by calling
delete object;
or the object will be automatically deleted if there's no variable assigned to it?
Thanks in advance for your help.
|
|
|
|
|
yes.
if there's no variable assigned to it?
more so in that case ... me think that if you have allocated objects hanging around, you would need to clean them up.
how do you have them ? calling a function that allocates something and return it and you don't use it ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
if you use new you call delete ALWAYS.
Even better would be to do this:
Object *x = new Object();<br />
<br />
<br />
delete x;<br />
x = NULL;
This way you do not accidentally call x that points to something else than Object. (because the memory to which the pointer points to is overwritten)
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
V. wrote:
if you use new you call delete ALWAYS.
wrong. Windows can do it itself, but that's a very bad way to program...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ok I correct myself:
If you're a good programmerand if you use new you call delete ALWAYS
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
|
toxcct wrote:
Windows can do it itself...
Only if the application exits or is terminated. Things like services are designed to run for long periods of time so a call to delete is a requirement.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you for your help.
Another related question..
if I have the class:
class ObjectA
{
ObjectB b;
}
ObjectA a = new objectA();
When i detele ObjectA (delete a), do I have to delete ObjectB (delete b)? or is it implicitly deleted?
|
|
|
|
|
And in the following case:
I have
ObjectA a = new ObjectA();
//...
Do I have to delete a (delete a) before I create a new ObjectA and assign it to a??
a = new ObjectA();
|
|
|
|
|
It seems like you need to do some reading on memory allocation in C / C++
When you declare an object like this:-
ObjectA theObject;
It is created for you, and it will be removed automatically when it goes out of scope.
When you declare an object like this:-
ObjectA *thePointerToObject = new ObjectA();
You are doing three things:- creating a pointer (which will be removed for you), creating a new instance of ObjectA (which it is your duty to clean up), and setting your new pointer to point to the new object.
This really is basic C++. *Any* C++ tutorial book/site will explain this; go out there are read up!
using System.Beer;
|
|
|
|
|
Stack-based variables, as opposed to heap-based variables (i.e., those created with new ), are cleaned up when the variable goes out of scope.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
you should never wonder if the system will perform such operation for you. if you own the object, then take use to delete it when you don't need it anymore.
if one day you come to work on poor operating systems which don't do this for you, or worse, systems that don't have any OS, you will have serious lacks of memory !!!
think of it...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i am looking for a ftp server where i can download windows xp for free because i need to reinstall xp and dont have a copy
|
|
|
|
|
Wrong forum
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Wrong site and attitude too.
using System.Beer;
|
|
|
|
|
give me your names and address, i'll send it to you...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
HI people;),
Please help me out with this one.
I was working on a project for creating a Text Editor.
Everything was going on fine, until i serialized my data.
What i am doing is that i have an CArray of CString , so that a particular index in the array represents one line of the text-editor.
While serializing, i have to use a loop to write the CString of every index of the array to a file. But the problem with serializing is that it breaks out of the loop, when it encounters a \n . In my program, each line is ended by a \r\n .
I have even tried using Write of CArchive . But it doesn't work.
Is there any way in which i could serialize my data to the file?
Help.... SOS.....
Thanks in advance.
AslFunky
|
|
|
|
|