|
Thanks for the guidance.
CArray::GetSize() returns INT_PTR in MFC 7.1
This unfortunately is not a pointer so using "lp" can be confusing here since anytime I see "lp", an arrow operator is always dancing in my head.
With GetWindowLongPtr(), it returns LONG_PTR and can on occasion, such as when using GWLP_USERDATA possibly represent a pointer if the user squirreled one away in there for use in a static callback method.
I'm finding it more common anymore to come across things that use it for items of size and occasionally for pointers so I'm not sure a naming convention that mixes with a plain old pointer convention wouldn't confuse others and myself later on.
I've been toying with "np" but it just doesn't flow.
|
|
|
|
|
Just to be clear. The purpose of types like LONG_PTR is to store non pointer data that will always be the same size as a pointer so that for example reinterpret_cast<LONG_PTR>(CMyObject*) will work without changing it on both 32bit systems where sizeof(CMyobject*)==4 and on 64bit platforms where sizeof(CMyobject*)==8 . In other words it's a long that's the same size as a pointer.
This is different from the lpName convention which goes right back to the old days of memory models and far-pointers and near-pointers / long-pointers. Please don't ask me to explain it, it was before my time but you can see that np would definitely not be a good idea especially when there's oldies around. So when the API says lpData it means a full size pointer on the current system i.e. 32 bits or 64 bits and when it says LONG_PTR it means a 32 bit or 64 bit numeric that is always the same size as a pointer. void* lpData and LONG_PTR PtrData will always be the same size so conversions will maintain all the data. I hope that's cleared it up
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Why my code:
<br />
pStorage->CreateStream( lpszW, STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_FAILIFTHERE, 0, 0, &pStream) <br />
returns error STG_E_INVALIDNAME (Invalid value for pwcsName) [pwcsName => lpszW]?
I use this befor calling CreateStream:
<br />
LPWSTR lpszW = new WCHAR[255];<br />
LPTSTR lpStr = strFilePath.GetBuffer( strFilePath.GetLength() );<br />
int nLen = MultiByteToWideChar(CP_ACP, 0,lpStr, -1, NULL, NULL);<br />
MultiByteToWideChar(CP_ACP, 0, lpStr, -1, lpszW, nLen);<br />
where strFilePath is e.g. "Slika000.jpg"??
I use this for storage a file.
THX to all
|
|
|
|
|
In this case, you know the size of your WCHAR buffer so you don't need to check the result string
length. An alternative is to actually use the destination length.
Also the much-overused GetBuffer() is not necessary when you need a const TCHAR pointer to a
string
int nLen = MultiByteToWideChar(CP_ACP, 0, strFilePath, -1, NULL, 0);<br />
LPWSTR lpszW = new WCHAR[nLen];<br />
MultiByteToWideChar(CP_ACP, 0, strFilePath, -1, lpszW, nLen);
Regardless, that doesn't explain what's wrong with the string - what's in lpszW after the second
MultiByteToWideChar() call?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I get it to work anyway. I think the reason was in strFilePath which contain a '\' characters e.g. "C:\something\something_else\...\...".
What I did is I caled CFile::GetFileName() now it works!
But now I can't use this regarding directories, and I can't use listing directory for files.
You see, I'm trying to record CD using IMAPI and users should be able to select directories as well as files to record them to CD. Now it would be vainly for users to see on their CD only files and no directories as they heve selected!
Could I open a stream (put folder name) and add numerous files one by one until all files are added from directory??
THX for help
|
|
|
|
|
Were you using single backslashes in a string literal?
If you're working with files and folders then you can construct full pathnames for each file.
SHBrowseForFolder() could be used to let the user select a folder.
Once you have a path to a folder, append the filename to it for each file (which makes a full
pathname) and create the stream from that pathname.
Is that what you're trying to do?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I already use SHBrowseForFolder() for folder selection.
"Were you using single backslashes in a string literal?"Re: Backslashes are in folder/files path's. I was doing it wrong, I've used the whole path name for CreateStream calls and I think that was the reason for errors. Now I use only filenames GetFileName() and it's all OK. But there is still issue of preparing a folder storage for burning on CD.
Now I'm working on an function which will be recursive, it will go in the folder and crating streams for all files in all folder inside the root folder.
My main concern is how, and is it posible, to create that much storage and stereams to pass to those storages and at the end write such storage on CD. I know it can be done. As I understand that storage are like folders and streams like files, is that means I should use storages for folders and streams for files. On example if I had a folder 'F1' and in side folder 'F2' and two files. And in 'F2' one file.
F1-->F2-->file3<br />
->file1<br />
->file2
I should do something like this: create a storage for 'F1', go inside and search for files, find 'F2' which is a folder (recursion call) I create another storage for 'F2' and go inside, where is a file named 'file3'. Now I create stream for 'file3' and add it to storage for folder 'F2', go back add and create two streams for 'file1' and 'file2' and all that plus storage for 'F2' add to storage for 'F1'! If this is so, how can I add storage to storage?
Thanks
|
|
|
|
|
I'm not sure why you're using structured storage if you are putting the results on a disk.
All the streams go into one file so you can arrange the heirarchy of the storage object any
way you want
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
why on hell are you modifying a function of the C runtime ???
if your compilation fails, it's because of your code, not the sources provided with the compiler (even if the compiler reported the error in memcpy())
|
|
|
|
|
No No this is a question I have to answer, I am just checking to make sure the function code show doesnt cause cause any problems and it is efficient code.
|
|
|
|
|
You delete your question!?
|
|
|
|
|
Yeah they said that I didnt need to post it twice but the question basically was:
What is wrong or how can I improve this function:
void* memcpy( void* dest, void* src, size_t size )
{
byte* pTo = (byte*)dest;
byte* pFrom = (byte*)src;
assert( dest != NULL && src != NULL );
while( size-- > 0 )
*pTo++ = *pFrom++;
return (dest);
}
|
|
|
|
|
Hi Josh,
You're copying a byte at a time... it is not as efficient as it could be on architectures such as x86 which has SIMD instructions.
Jeff
|
|
|
|
|
There's absolutely no reason to post this twice.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello,
after the CFormView::OnInitialUpdate() i perform a textbox1.SetDecimal();
In this function of the CEdit derived class i make a ModifyStyle(ES_LEFT|ES_CENTER,ES_RIGHT);
followed an Invalidate() ...
But the textbox is still with an alignment to left (set to left by the designer ).
Is there a special command to applic the Style-Modification ?
Big thanks
|
|
|
|
|
See Edit Control Styles[^], particularly the part that states "After the control
has been created, these styles cannot be modified, except as noted."
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thank you for your reply.
So it isn't possible to set the alingement to right during the execution of the application.
I tried already to manipulate the CreateStruct before the OnCreate is startet, but this
also don't work.
|
|
|
|
|
Hi,
"before he OnCreate" does it mean PreCreateWindow().
if not please try CEditDerivedClass::PreCreateWindow()
|
|
|
|
|
Thanks for your answer
Is it possible that it don't stop into the CEditDerivedClass::PreCreateWindow()
with a DDX_CONTROL created Textbox ?
|
|
|
|
|
Hi,
So you are using the control already on the resource.
Would I like to know if are applying the style before
Create and I hope not change it thereafter, why don't you
set the edit control style in the resource to Align Right
|
|
|
|
|
To built views faster.
I put for example 50 textboxes on a view. 30 of them are right-align.
I need to change all styles.
During coding the view, i set all 30 textboxes to number-textboxes (labelPrice.SetDecimal() )
Now, the SetDecimal() sets different parameters to the textbox (only numbers, right-align, ... )
I must anyway write one line per textbox, so this line changes also the styles.
If i like to change something, i don't need to change all textboxes on Dialog-Ressource, but only
some line of codes ...
In future, some peoples who don't programm a lot, should design all views, so it should be so quickly and easy as possible
|
|
|
|
|
Hi,
The dialog child items are created at dialog creation.
DDX_Control will only subclass controls not creating the control.
subclassing will allow the messages to be routed to the
class we specified. but at that time the control will be created already, so you won't get oncreate or precreatewindow events for the control.
In my opinion, setting styles after DDX_Control doesnot "built views faster".
If you specify Styles in resource designer it would have assigned at creation.
But you are then interrupting the control while ModifyStyle which involves sendMessage like process.
I suggest you specify styles of controls in resource design and SetDecimal will do the initialisation of data excluding the style.
Best Regards
|
|
|
|
|
I mean by "built views faster", that the developer can design faster the views, not that the view
is faster created at runtime.
Ok, i'll set those styles at the designer.
Big thanks anyway
|
|
|
|
|
baerten wrote: So it isn't possible to set the alingement to right during the execution of the application.
Not exactly. It's just not possible to change those styles after the control has been created.
You need to specify ES_RIGHT when you create the control. If the control is on a dialog resource
(in other words, NOT being created manually at runtime) then set that style in the dialog
resource.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|