|
nMinBufLength specifies the minimum size of the buffer that you can safely play with.
If you do a GetBuffer with nMinBufLength = 10, you can do whatever you want with the first 10 characters of the LPTSTR that is returned. If you do something with the 11th character, let the devil save you!!!
[newly added]Of course that's assuming the actual buffer is smaller than 10 characters. Whatever you specify for nMinBufLength , if the actual buffer is bigger, that's what is returned [/newly added]
Use nMinBufLength = 0 to get a buffer that is the current size of the underlying CString buffer
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Ok so is I'm using a CString object to store contents read from a text file, whose size is unknown yet, I'd better make it: LPTSTR lpBuffer = str.GetBuffer(A_HUGE_NUMBER_HERE); ?
|
|
|
|
|
You better Use it with
str.GetBuffer(0);
it will return all the text
|
|
|
|
|
CString has a GetSize or GetLength or something. You can get the size from that.
It's much easier to use iostreams and std::string to read in a text file, if you're saying that you're grabbing the buffer, then reading the file. That's just plain ugly.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
i have tried many things to make this function work correctly.
the problem only occurs if i have a duplicate record in the recordset.
i have a function that deletes all the records in the recordset.
if i have a duplicate log on file i get the error
"Multiple rows were updated"
is there a way i can avoid this error. Or is there a way i can call a function to delete all the records.
My limitations are - I am using a VFP table and can only open it as a snapshot.
m_pSet->MoveFirst();
if(!m_pSet->IsEOF()){
m_pSet->MoveLast();
m_pSet->GetBookmark(endbookmark);
}
if(endbookmark.m_iVal>0){
m_pSet->MoveFirst();
do{
m_pSet->Delete();
m_pSet->MoveNext();
}while(!m_pSet->IsEOF());
}
thank you.
|
|
|
|
|
You need to add a unique field to the table.
The problem that the delete method do that scannig the table, and identificating the the record to delete like a unique record, but if you have a record equal to that you want to delete, you have the problem that you said....
Only add a auntonumeric field, or a timestamp field. And that will do that the field will be unique in all the table....;)
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Algorithm void PostOrderPlus(bintree MyBinT ree )
if MyBinT ree ·is-empty then print(‘0 ’) return() endif
PostOrderPlus(MyBinT ree.lefttree )
PostOrderPlus(MyBinT ree.righttree )
print(MyBinTree.info)
end algorithm PostOrderPlus
THIS ALGORITHM creates a sequence of numbers such as:
0 0 1 0 0 3 0 0 7 4 2 0 0 8 6
I am trying to figure out a way to recreate the tree if the POST ORDER
traversal aequence is given as shown above.
This is what I am required to do:-
You will be given a sequence of symbols, and you can assume that the first symbol is the special delimiter symbol. It is then up to your program to decide whether or not the sequence is a POPS of a binary tree. If it is not a POPS, print a message to that effect. If it is a POPS, construct the binary tree and compute, for each level of the constructed tree, the number of nodes at that level. Also, find the depth of the tree, and find a node whose depth is equal to the depth of the tree (and find the right-most such node if there is more than one such node). Finally, find the frequency of the root-value in the tree: if the value is not repeated, then test to see if the binary tree happens to be a search tree. So for this project, you must design several algorithms (with supporting abstract datastructures in an algorithmic language), that solves the problem(s).
The POPS works in the following manner (reading the sequence right to
left):
1. The last number is the root
2. The previous number is the right child
- If the previous number is zero that means that there is no child
there; or if there are two zeros that the number is a leaf.
3. The number previous to the previous number (in 2.) would be th left
child to the next number that follows.
PLEASE HELP ME!!
NO
|
|
|
|
|
Given that this is your homework, you should first try and come up with an answer, then post if you have any problems. Your lecturer obviously has taught you enough to believe you can do this, so you should at least have an idea of where to start.
What is a POPS ? What does it look like ?
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
I am using WTL (please don't run away yet) and I have a derived class that from the ListView control. The listview control has a Method called AddItem which adds a row to itself.
If I create a variable that derives from my custom control I can access AddItem just like any other public member in a class. But when I try to put AddItem inside another method to enhance my custom control it gives me this error:
error C2662: 'AddItem' : cannot convert 'this' pointer from 'const class CSimpleGrid' to 'class WTL::CListViewCtrlT<class ATL::CWindow> &'
and this is my method:
class CSimpleGrid : public CWindowImpl <CSimpleGrid, CListViewCtrl>, CCustomDraw<CSimpleGrid>
...
BOOL AddRow(CString strRow) const
{
INT nCurCol = 0;
INT nCurRow = GetItemCount();
INT nStrLen = strRow.GetLength();
INT nPos = strRow.Find("\t");
if (strRow.IsEmpty())
{
return FALSE;
}
if (nPos == -1)
{
AddItem(0, nCurRow, LPCTSTR(strRow)); <- Fails on these AddItems
return TRUE;
}
while (nPos < nStrLen)
{
INT nPosEnd = strRow.Find("\t", nPos);
AddItem(nCurRow, nCurCol, LPCTSTR(strRow.Mid(nPos, nPosEnd - nPos))); <- This one too.
}
return TRUE;
}
I haven't actually tested the logic in this one so it is possible that the algorithm is incorrect but as I can't even compile that is the least of my worries.
Cheers,
Clint
|
|
|
|
|
remove the "const" from your function definition. you are modifying the internal state of the object, so you can't have a const function... right?
-c
Being just contaminates the void. --Robyn Hitchcock
|
|
|
|
|
|
What is the best way to differentiate the mouse movements I call in my program (using SendInput or SetCursorPos) from other mouse movement messages?
I'm using a system wide Mouse hook in a .dll that receives all mouse messages / movements and I want to distinguish mouse movements as a result of the physical mouse as different from the mouse movements and clicks I send to Windows through my program.
My program moves the mouse around using SendInput and SetCursorPos and clicks using mouse_event. I want my program to relinquish control of the mouse when the user moves the physical mouse. How can I tell the difference in a system wide hook?
I've tried embedding dwextrainfo into the movement and click calls that my program makes to tell them apart from the other messages, but my program calls seem to generate other, additional and simultaneous messages that do not contain the dwextrainfo. As a result, my program relinquishes control when it tries to click the mouse.
Any help? I'm sure someone has already accomplished this, but I can't seem to find any references.
-Jeff
|
|
|
|
|
I suspect you'd need to set a flag in the program you're sending messages to, so it knows they are from you.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Well, that's no help! If it were that simple, I wouldn't be asking about it.
Your signature is comical in it's irony!
What I've learned so far and what my next questions are:
_____________________________________
The short answer is that you can not distinguish messages that are a result of physical mouse movements from those that are a result of SendInput or mouse_event calls. They get the same kind of handling by the operating system. Sent and posted messages on the other hand, can be distinguished from hardware input events and mouse_event messages, as they are appended to different queues in the thread.
OK, so how should I send/post messages (instead of using SendInput/mouse_event ) to control the mouse...
And how do I distinguish the messages in my system wide mouse hook?
Or should I say system wide message hook? WH_MOUSE vs. WH_GETMESSAGE: which can access the correct information to make a determination? (How do I access the queues and thread information?)
|
|
|
|
|
carp wrote:
Well, that's no help! If it were that simple, I wouldn't be asking about it.
It IS that simple.
carp wrote:
The short answer is that you can not distinguish messages that are a result of physical mouse movements from those that are a result of SendInput or mouse_event calls. They get the same kind of handling by the operating system.
Correct - there is only one way for a program to respond to mouse movement, regardless of how the message got there.
carp wrote:
OK, so how should I send/post messages (instead of using SendInput/mouse_event ) to control the mouse...
Use ::SendMessage and create messages with values of WM_USER, WM_USER+1, etc.
carp wrote:
And how do I distinguish the messages in my system wide mouse hook?
All messages have a value, you'd #define your own.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Hi:
I would like to write a function that accepts a variable number of arguments. I have tried to use va_list and va_arg macros, but the problem with them is that they don't know where to stop (i.e., how many arguments were supplied) unless you specifically state the number of optional arguments as one of the inputs.
Any ideas?
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
And, by the way, I do not want to use any terminating values at the end of the optional arguments
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
put your arguments in an array/list?
-c
Being just contaminates the void. --Robyn Hitchcock
|
|
|
|
|
Interesting point. Thanks
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
Hi!
I keep getting linker warnings when using the directive /ALIGN:4096 or some other linker options that result in warnings but have no effect on the application. That's why I try to disable these warnings since they are quite annoying in the debug window.
The only thing that works for me is specifying /ignore:4108 in the linker options of my project. This really eliminates the warning about the /ALIGN directive. But I want to use a #pragma command instead of the /ignore command in the linker options.
I tried to put the line
#pragma warning(disable : 4108)
both in my source and header files, but this didn't remove the warnings in the debug/output window.
So what's the correct way to use this pragma directive?
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I think you'll find that #pragma warning only works for compiler warnings - to quote from the VC++ documentation...
Allows selective modification of the behavior of compiler warning messages
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
#pragma warning is only for compiler messages. For the linker use:
#pragma comment(linker, "/ignore:4108")
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks a lot! Works perfectly
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Recently I got a bug with a program I wrote under W98 and ported to XP.
Actually, I just changed the allocation of my data arrays to GlobalAlloc - instead of malloc - and the program ran fine again.
I'm happy because I found the solution but now I wonder about all the other allocations I made using either the new operator or malloc and wonder which of them I should change to GloballAlloc and which of them are good. How many of them
So, is there an article over there explaining the strategy to follow ? What are the exact rules ? Differences between Wx and NT and so on.
Thanks,
Yarp
|
|
|
|
|
In all honestly, changing the allocation to GlobalAlloc didn't fix the bug, you just changed the execution enough to where the bug didn't bite you.
IMHO, you have a memory overrun somewhere. 9x and NT/W2K/XP execute programs very differently. Their memory footprint differ. Thus memory corruption problems might only show up in one flavor of the OS.
Change your GlobalAlloc back to malloc and try to find the real problem.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|