|
duen wrote:
When we need the callback function?
Usually in response to a homework question.
Todd Smith
|
|
|
|
|
Usually a callback function is to do the same task over and over again but passing it different variables to get different results each time. Like enumerating which fonts are on the users computer.
But callback can be used in more ways then just this.
<><><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Hello all,
How do you create a date class that has the following date output formats--
DDD YYYY
MM/DD/YY
January 1, 2000
Thanks for the help,
Philll
|
|
|
|
|
copy CDate
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
|
CDate has all those output formats.
maybe i misunderstood the question... ?
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
Sorry. I need help creating the DATE class itself.
|
|
|
|
|
I have some undetermined number of values a field can take on. I need to gather these in an STL container, after which I have to check and see if a new value thats being added (to a database) already exists in the container. If it does, then I have to inform the user its not unique, and not add it to the db. (I'm not adding the new value to the STL container, but to a database, whose current values I've gathered in my container).
The value is a CString. Should I choose vector, or set or list (not a map for sure). I'll be checking to see if a CString exists in the container, not by index but by its name.
Suggestions?
Thanks,
ns
|
|
|
|
|
A vector is good if your array isnt changing size a lot. A list is good if your array changes size a lot. A list also costs you a tad bit more memory than a vector for the extra pointer.
If you want to do fast string searches then you need a hash. The map container is a hash. There are also some non-standard hash containers you can get. The boost library should have a few hash containers http://www.boost.org[^].
Todd Smith
|
|
|
|
|
I would choose a set.
A set will only allow one instance of the type that specify to be inserted. Use the insert member function of the set to insert the CString in the set.
The insert function returns a pair<set<CString>, bool> object to indicate if the function succeeded or not. THe iterator will contain the iter of the object that was inserted, and the bool will indicate if the insertion actually occured.
If the insertion occured then true will be returned, otherwise if the item already existed the bool will be false.
The standard implementation of a set is with a Red-Balck tree, which is a balnaced binary search tree. So you will get n log(n) lookup times. If you would rather use a hash implementation you can switch to the SGI or Boost implementations which both have hash implementations. Hash implementations have faster lookups than trees, however they require more space as well.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
kilowatt wrote:
So you will get n log(n) lookup times
Isn't that just log(n) for lookup?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Tomasz Sowinski wrote:
Isn't that just log(n) for lookup?
Your right, I confused the lookup time with the amount of time it takes to sort the entire binary tree.
Thanks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks for the ideas. I am implementing this this morning so I'm glad for some direction with your responses.
ns
|
|
|
|
|
Is this okay to do:
m_pCommand->ActiveConnection = m_pConn;
m_pCommand1->ActiveConnection = m_pConn;
So can the active connnection be reused like this?
Thanks,
ns
|
|
|
|
|
I'm pretty sure you can.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Good to know. Thats one less bit of work! I do find that I have trouble reusing the same Recordset object with different commandTexts, so generally end up creating a new rs object for each iunrealted query. For some reason, if I used it the first time with command A, the come back later and try to use it with command B, it crashes.
Thanks for the answers,
ns
|
|
|
|
|
Yes. In fact that it is the way it is supposed to work. An application should really only have one connection object per data source.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
I am using this code:
int length;
char * buffer;
ifstream is;
is.open (f2, ios::binary );
is.seekg (0, ios::end);
length = is.tellg();
is.seekg (0, ios::beg);
buffer = new char [length];
is.read (buffer,length);
is.close();
buffer[length]=0;
In the above code buffer = new char [length]; buffer is of size [length], and not [length +1] as I've seen in other code. I looked at the doc of tellg() but it doesnt say what this length is, so my question is, is this code correct? Or should I make it [length+1]?
Thanks,
ns
Of course then buffer[length+1] = 0; right?
|
|
|
|
|
I don't see why the string coming out should be null terminated for you, but overall, you should use std::string IMO, and then it will all be done for you. You can read a file using getline and build it into a string.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
The length+1 is to account for NUL terminated strings. If you aren't going to treat this data as a string, then you don't need to worry about the extra byte.
Since you are terminating the string with a NUL, then you MUST allocate the space for it.
Tim Smith
"Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution."
Hoare - 1980 ACM Turing Award Lecture
|
|
|
|
|
I recently had an issue with a timer that was assigned a value of WM_USER + 200. This introduced an intermittent bug in my document based app whenever the view was refreshed. I found that the value WM_USER+200 conflicted with the CMD_LAST in commdlg.h
<br />
#define CDM_LAST (WM_USER + 200)<br />
I started investigating and found that WM_USER houses messages that are used by dialog controls. According to MSDN:
These values cannot be used to define messages that are meaningful throughout an application, because some predefined window classes already define values in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values.
Instead, it implied that WM_APP should be used for app specific event handling. But yet in a lot of examples I've seen they always use WM_USER + X.
I changed my define to WM_APP+2 and it works great! No more phantom bug.
QUESTION: Does anyone have any insight into the difference between WM_USER and WM_APP. What should dictate which is used?
Thanks in advance for any help.
Alan Schneider
BET Inc.
|
|
|
|
|
BeavisInAz wrote:
Does anyone have any insight into the difference between WM_USER and WM_APP.
Yes, don't use WM_USER for your own messages because, as you've seen, the values can collide with values used by the common controls. That's why WM_APP is there, no built-in controls use it.
As for why sample code uses WM_USER - I guess WM_USER is more well-known for whatever reason, and the code writers got lucky and never had bugs related to the message values.
Of course, if you want to guarantee no collisions, use RegisterWindowsMessage() instead.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi Mike
WM_USER values are best used as identifiers and stuff I guess, but not as window messages. I wonder why it still exists. I mean someone should #define WM_USER to WM_APP to make them both equivalent.
I have always encountered issues when I've used WM_USER+x specially when used as tray notify messages, and was curious about why this happened and why this got resolved when I used WM_APP+x. You post reminded me of it
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Hi all,
I tried to user NetShareAdd() to create a network share remotly. I just want one user A to access this share.
but the result is not exactly what I want. The result is the network share was created and shared to this user A. But the security of this share didnot include user A. It just inherited it's parent's security. If that didnot include user A, this share can not be accessed by user A.
So How to do what I want? user A and only user A can access this share???
Thanks a lot for your help.
Code :
--------------------------------------
LookupAccountNameW(
Server,Username,pSid,&cbSid,RefDomain,&cchDomain,&peUse);
InitializeAcl(pDacl, dwAclSize, ACL_REVISION);
AddAccessAllowedAce(pDacl,ACL_REVISION,GENERIC_ALL,pSid);
InitializeSecurityDescriptor(&sd,
SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, pDacl, FALSE);
//setup share info structure //
si502.shi502_netname = (LPTSTR) Sharename;
si502.shi502_type = STYPE_DISKTREE;
si502.shi502_remark = _T("");
si502.shi502_permissions = ACCESS_ALL;
si502.shi502_max_uses =1;
si502.shi502_current_uses = 0;
si502.shi502_path = (LPTSTR) DirectoryToShare;
si502.shi502_passwd = NULL;
si502.shi502_reserved = 0;
si502.shi502_security_descriptor = &sd;
:nas = NetShareAdd((LPTSTR) Server,502,
(LPBYTE)&si502, NULL, );
--------------------------------------
|
|
|
|
|
After installing the Platform SDK rebase.exe suddenly stopped to generate .dbg files. Looking closely, the platform SDK version 5.2.3639.0 does not seem to work, it does nothing!
Any kind of clue is aprecciated
|
|
|
|