|
Interesting.
I looked at this for a while. The problem is the "strValue"
argument. The offset of the strValue parameter is used to calculate
the offset of the start of the variable-length parameter list.
If you don't pass it by reference the function works fine.
I can't figure out why the reference doesn't work - the sizeof a reference
is the same as the sizeof a CString (4 bytes on my 32-bit build), so I would
expect the same result.
I guess references are passed on the stack differently.
I don't think this old C feature was meant to deal with C++ references anyway...
Regardless, passing strValue by value instead of by reference fixes it:
void COdb::WriteAttribute( CStdioFile& fileOutput,
const CString& strTagName,
const CString& strAttribute,
const CString strValue, ... )
...
If anyone wants to analyze this further, here's the macro definitions:
#define _ADDRESSOF(v) ( &reinterpret_cast<const char &>(v) )
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
#define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define _crt_va_end(ap) ( ap = (va_list)0 )
*edit* Now that the caffeine has kicked in, I realize taking the address<br />
of a reference gives you the address of the object referenced, not the<br />
address of the reference. Yeah - those macros weren't meant to work<br />
with references
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Friday, August 29, 2008 2:09 PM
|
|
|
|
|
After converting the CString reference parameters to LPCTSTR parameters, it works, but only when the optional parameters are actually passed. When they are not passed, I still get garbage in the 1st optional parameter. So how do I determine when I have them and when I don't? I thought that if the optional arguments were not passed, the first call to va_arg would return a null, but that is not the case. I have posted my code below.
void COdb::WriteAttribute( CStdioFile& fileOutput,
LPCTSTR strTagName,
LPCTSTR strAttribute,
LPCTSTR strValue, ... )
{
va_list vl;
va_start( vl, strValue );
CString strBuffer;
strBuffer.Format( " <%s %s=\"%s\"/>",
strTagName, strAttribute, strValue );
LPCTSTR pstrOpArg = va_arg( vl, LPCTSTR );
CString strOption;
bool bAttr = true;
while ( pstrOpArg )
{
if ( bAttr )
{
strOption.Format( "%s=", pstrOpArg );
strBuffer += strOption;
bAttr = false;
}
else
{
strOption.Format( "\"%s\"", pstrOpArg );
strBuffer += strOption;
bAttr = true;
}
pstrOpArg = va_arg( vl, LPCTSTR );
}
fileOutput.WriteString( strBuffer );
}
|
|
|
|
|
Royce Fickling wrote: I thought that if the optional arguments were not passed, the first call to va_arg would return a null, but that is not the case.
Yes, that is NOT the case. You'd need to pass a NULL parameter.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
Can somebody tell me what is the best way to find number of characters and number of words of a std::wstring. Can somebody send a best example on the web if know. I search on the google but didn't find a best one.
Help really appreciate.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: I search on the google but didn't find a best one.
Yeah that makes sense
led mike
|
|
|
|
|
Why did you say that?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
As a first step, simply I found the number of spaces in a string and the length of it. So I can count number of characters there.
No I want to calculate number of words there. So I want to find a combination a space and immediately follows a character. Because that's the start of a word. How can I detect that combination? Any comments.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
you can test the value of a character like (buf[x] == 'c')
there are also C runtime functions like isdigit() that you can find in the documentation
led mike
|
|
|
|
|
|
hey im working on video processing project bt i need help in capturing
frames from an video of .dat format
*** we will specify the path of video file and den the code should access that video
and capture frames from it and den store the captured frames from dat video at
the location where we will specify.
|
|
|
|
|
You will need the specs for the .dat file...
there's lots of proprietary .dat formats - I don't
know of any standard formats.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hey mark
specs as in wat sense? i didn get wat u wana say.....
nywys even if u can tell me frame extraction for any type of video it would be
helpful to me....
|
|
|
|
|
suresh zende wrote: specs as in wat sense?
specs == specifications.
What's in the file? You can't extract frames if you
don't know where they are in the file or what format
they are in.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
im considering an sports video here bt it wont matter wat video file we r takin
we are having the video file from which we hv to extract frames
as a video file is nothing but sequence of frames..eg: 1 sec video will hv around 24/30 frames
so the task is to take snapshots of the video as the timepasses,so here we hv to take atleast
24/30 snapshots in 1 second to get good no of frames those can be processed....
hope nw the prbml is clear..plz help me for this..
|
|
|
|
|
I would start with clearly defining the steps you need to take
to accomplish your task. It's still unclear to me.
This is what I have so far:
Open the file
Loop until done:
Read a video frame
Do something with the video frame
Close the file
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
We are having an application which is interacting with the static library(Default library) and in turn this will interact with the DLL.
This is written on the application side
*****************************************
CNodeView *node_view = NULL;
node_view = m_default_mgr->GetGUI(node); (the call goes to
if (NULL == m_pMainVseqEditor)
return;
if (!IsWindow(node_view->m_hWnd))
{
CRect rectView = CRect(0,0,700,500);
// create the window
if(NULL == ((CWnd*)node_view)->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rectView , m_pMainVseqEditor, 14567))
The create function will work fine in debug mode but in release mode this return NULL.
Let me know how to resolve this issue in relesse mode.
Is there any specific project settings are there?
|
|
|
|
|
Did you check GetLastError() ? You could also check it by adding @err,hr in watch window. I hope it could give you some hint.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
lavate malllik wrote: Create(NULL, NULL,
First parameter takes the window class name for e.g. WC_EDIT , you have given nothing here, shouldn't you give your CNodeView 's class name. You must have a used RegisterClassEx or AfxRegisterWndClass for this purpose.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
What type is node_view? You use it in the IsWindow() call
like it's a CWnd*, so why do you cast it to a CWnd* when you
call the Create() method?
Is m_pMainVseqEditor->m_hWnd valid at the Create() call?
For clarity, FALSE is a better macro to use than NULL when you're
comparing a BOOL (IMO).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am using a ClistCtrl which is to be filled with the data coming from server. As it is taking some time so there is flickering of window.
I want that while the data is being fetched a dialog should appear with progress bar along with the message Downloading.
Can any one help me.
Thanks In advance
Dhiraj Kumar Saini
|
|
|
|
|
You may use a worker thread to perform the data acquisition and send messages to the progress bar window in order to update its status.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Sorry to say but i dont have any idea of creating threads
Please can you help me.
I am never worked on multithreading
Thanks
Dhiraj Kumar Saini
|
|
|
|
|
|
U can either use AfxBeginThread or CreateThread to start a new thread....For more information u can refer msdn.
Dont worry...this is how everybody learned about any new things..
|
|
|
|
|
Dhiraj kumar Saini wrote: I am using a ClistCtrl which is to be filled with the data coming from server. As it is taking some time so there is flickering of window.
Since you are frequently adding data to your list ctrl, flickering is usual. Use LockWindowUpdate() and UnLockWindowUpdate()to lock the control. Check here[^] about how to use it.
Dhiraj kumar Saini wrote: I want that while the data is being fetched a dialog should appear with progress bar along with the message Downloading.
Create a model-less dialog with progress bar and display it. Define a custom message by RegisterWindowMessage() and utilize it to update progress to ProgressDialog.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|