|
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
|
|
|
|
|
That is correct. As of version ".NET" Microsoft have removed the possibility to create .DBG files. Actually, they have removed CV (CodeView) creation completely. They seems to think you should switch to their PDB-handling API (which I've never seen documented anywhere, and probably never will since they will with almost 100% certainty change it for every new compiler version).
Basically, you're screwed. Better back down to VC6 again if you need DBG.
|
|
|
|
|
Microsoft does it again !
Thanks for your answer Mike, I guess I better start digging MSDN about that new API you are talking about
|
|
|
|
|
please provide the link of different comprehancive examples of com and com+
and a little help how to run it?
r00d0034@yahoo.com
|
|
|
|
|
http://www.codeproject.com/com/
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
I am running VC++ 6.0 on a WinXP-Home machine. Often a build will hang up (usually while linking). Pressing "stop build" does nothing other than depress the button. I then have to kill the process, open the workspace, and try the build again. This never happened when I was running Win2000-Pro. I have not found any reports of this problem. Has anyone conquered this problem?
Thanks.
|
|
|
|
|
No problems here at all...
I've seen a similar problem with a (unavailable) network path in the LIB environment variable, or in the lib search directories configured in VC.
Concussus surgo.
When struck I rise.
|
|
|
|
|
Daniel:
Thanks for the response.
All of my lib paths (environment var and config'd in vc++) are local and exist.
This problem also happened on another machine in the office (WinXP-Pro). In both cases the problem didn't show up the 1st couple of weeks after the machine was set up, but then slowly got worse.
|
|
|
|
|
Maybe you should clean temporary files?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Are you running (actually, have you even ever installed - running or not) some anti-virus program? If so, try uninstalling it (just disabling it won't work in many cases).
|
|
|
|
|
This compiled okay when I set
_variant_t abc = "a";
But didnt like it when I tested it like this
if (abc == "a")
also tried
if(!strcmp(abc, "a")
How do I compare a variant? Also, maybe I;m not even allowed to assign it like I did, but it did compile at the assignmentThank you,
ns
|
|
|
|
|
(_bstr_t)abc == "a"
Concussus surgo.
When struck I rise.
|
|
|
|
|
Use the _bstr_t conversion method to get the string back.
if ( (_bstr_t) abc == _bstr_t("a") )
--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
|
|
|
|
|
I have :
_bstr_t bstrFile(L"");
I want to detect later if its empty. How do I do this?
CanI say if(bstrFile == "") DoThis();
Or will it have to be a strcmp or something?
Actually I dont really know why it has to be a bstr. Heres the code thats using it. Perhaps some object in it needs a bstr:
CFileDialog pDialog1(TRUE,"*.bmp", "*.bmp", OFN_HIDEREADONLY ,"Image Files
(*.bmp;*.dib;*.gif;*.jpg;*.jpe;*.ico;*.cur)");
pDialog1.m_ofn.lpstrTitle = "Open Sketch";
if(pDialog1.DoModal() == IDOK)
{
CFile file((LPCTSTR)pDialog1.GetFileName(),CFile::modeRead);
bstrFile1 = file.GetFilePath();
}
which is then used by:
strmBlob->Type = adTypeBinary;
strmBlob->Open(vtEmpty,adModeUnknown,adOpenStreamUnspecified,bstrEmpty,bstrEmpty);
if(bstrFile strmBlob->LoadFromFile(bstrFile);
so it might be that the _StreamPtr strmBlob (__uuidof(Stream) ); needs to read in a bstr filename....
Thanks,
ns
|
|
|
|
|
ns wrote:
I want to detect later if its empty. How do I do this?
use: bstrFile.length() == 0
ÿVOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry;
16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)
|
|
|
|
|
(from MSDN) virtual CString CFile::GetFilePath( ) const;
It does not return a BSTR ! (at least in MFC7, may be true with MFC6 however).
Other question you ask is how to check if a _bstr_t is empty : you have _bstr_t::length() implemented and ready. Same question with BSTR, you must use the native WIN32 method ::SysStringLen(yourbstr),
And I swallow a small raisin.
|
|
|
|
|
Dear all,
I would like my dialog bar to be permenantly docked to the left frame. Is there anyway to do this?
Thanks.
CT
|
|
|
|
|
Call DockControlBar(pYourBar, AFX_IDW_DOCKBAR_LEFT) from your FrameWnd
ÿVOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry;
16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)
|
|
|
|