|
Here is what I get from the code you posted:
Open database
Open a recordset of all fields of table "vor"
Walk through all records in the recordset, doing nothing with each record
Open a file
Write the single string "rs" to the file
close the file
close the recordset
the MSDN article I linked includes a piece of sample code that:
walks through all the records of the recordset
walks each of the fields of each record
what I think you need to do is:
figure out how to write each varValue to the file
include a write to file of a cariage-return line-feed pair before the rs.MoveNext()
|
|
|
|
|
I am trying to do this like
sStr.Empty();
sStr="\n";
strcpy(TextData, sStr);
obj.Write(TextData,sStr.GetLength());
rs.MoveNext();
But its not working....
Can u told me where i am making wrong
Regard's
Kaushik
|
|
|
|
|
My code is runnign fine Thanks for Help
Regard's
Kaushik
|
|
|
|
|
Hello sir,
Although i can print the value of table field in .txt file .
in well manage order but , Now i want to show its field name at top of
its raw
I am trying it using GetFieldName() function but i am unable to fetch field name . Can u please told me how can i do this
Regard's
Kaushik
|
|
|
|
|
Could anyone tell me how to restrict a window from being dragged outside the visible screen of the desktop?
Your help would be much appreciated, thank you.
-> Demsen
|
|
|
|
|
Try handling either of the below...
1. CWnd::OnWindowPosChanged()
or
2. WM_WINDOWPOSCHANGED
Maxwell Chen
|
|
|
|
|
I've used OnWindowPosChanging already and my code looks like this:
void CSnapDialog::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{
int m_EdgeSnapGap = 1;
RECT rcScrn;
SystemParametersInfo (SPI_GETWORKAREA, 0, &rcScrn, 0);
//Snap X axis
if (abs(lpwndpos->x - rcScrn.left) <= m_EdgeSnapGap)
{
lpwndpos->x = rcScrn.left;
//???
//Code is needed here to prevent window from drifting
//outside the left edge of visible screen
}
else if (abs(lpwndpos->x + lpwndpos->cx - rcScrn.right) <= m_EdgeSnapGap)
{
lpwndpos->x = rcScrn.right - lpwndpos->cx;
//???
//Code is needed here to prevent window from drifting
//outside the right edge of the visible screen
}
//Snap Y axis
if (abs(lpwndpos->y - rcScrn.top) <= m_EdgeSnapGap)
{
lpwndpos->y = rcScrn.top;
//???
//Code is needed here to prevent window from drifting
//outside the top edge of the visible screen
}
else if (abs(lpwndpos->y + lpwndpos->cy - rcScrn.bottom) <= m_EdgeSnapGap)
{
lpwndpos->y = rcScrn.bottom - lpwndpos->cy;
//???
//Code is needed here to prevent window from drifting
//outside the bottom edge of the visible screen
}
}
Can anyone help me on what code I should supply to make this work correctly?
<div class="ForumMod">modified on Thursday, December 20, 2007 2:01:10 AM</div>
|
|
|
|
|
Hi,
The program that I am working on uses two external DLL modules.
[program.exe] uses [library.dll]
[library.dll] uses [another_library.dll]
I have stepped through the program line by line, and have used the CRT break on allocation debugging feature. Upon exiting the program in debug mode within visual studio, it reports a lot of memory leaks. However, I believe these messages to be false.
Here is basically what happens.
[program.exe]
-->CMFCApplication
---->Initialise();
------>[library.dll]
-------->AllocateSomeMemory();
---------->[another_library.dll]
------------>AllocateSomeMoreMemory();
When the application closes I have confirmed that the processes exit in the following order:
[library.dll], [another_library.dll], [program.exe].
When [library.dll] exits the 'Output' panel within visual studio indicates that there is a memory leak. The memory is then released by [another_library.dll] after the leak has been reported within the output panel.
All three modules use the /MDd (Debug) /MD (Release) switches for multi-threaded dll, so they each share exactly the same memory manager.
Is there a way which I can force the DLL processes to be terminated in the specific order:
[another_library.dll], [library.dll], [program.exe]? Because I am confident that this will resolve the issue. I understand that it is probably safe for me to ignore this warning output...but future (problemsome) memory leaks will be masked by the fake ones. This could lead to some serious problems.
Any advice would be greatly appreciated...this is driving me nuts!
Lea Hayes
|
|
|
|
|
1. Shouldn't another_library.dll be released first? Library.dll is using another_library.dll , but library.dll dies in the half way. Therefore the system has no clue to release the resources of another_library.dll currently being used by library.dll .
2. Unreleased threads (suspended) can also cause memory leak warnings. Before the program exits, you should let all the threads exit.
Maxwell Chen
modified on Wednesday, December 19, 2007 10:56:20 PM
|
|
|
|
|
Hi,
Thanks for your quick reply.
[another_library.dll] is a core library which is actively used by both [library.dll] and [program.exe].....I should have mentioned this before.
So we have [another_library.dll] which uses [library.dll]
and [program.exe] which uses [another_library.dll] as well as [library.dll].
The threads are all executing their detatch command upon program exit....just in the wrong order, in that the memory leak is warned before the offending objects even have a chance to be cleaned.
Thanks,
Lea Hayes
|
|
|
|
|
This is the primary reason why I follow Microsofts recommendation of having Initialization and Termination routines exported from the dll's that are separate from DllMain. Its basically the only way you can guarantee the calling order. Refer: DllMain Callback Function[^]
|
|
|
|
|
Hi,
Thank you for your advice, I have created an exported class object which has an initialise and deinitialise method. They are automatically called by the constructor and destructor for added security. The main application calls the global objects deinitialise method which forces the library to be cleaned upon exit, and before any modules are terminated. This appears to have solved the problem.
Many thanks!
Lea Hayes
|
|
|
|
|
Hi all,
I've create a window using CreateWindowEx windows API and do some work on it. Thats fine. But for the safer operation at the end of all the processing I want to close/destroy the window.
I've try this code, Here m_hwnd_RTFBox is the handle to the window. On the above code there is no compile error, but gives a runtime error and saying there is a unhandled exception on the first line. Where I'm going wrong. I found this from the MSDN, but it wont work.
BOOL clsWin = DestroyWindow(m_hwnd_RTFBox);
if(clsWin != 0)
{
printf("SS");
}
<pre>
I appreciate your help all the time...
Eranga
|
|
|
|
|
I've test another thing also. First send a message to the window and then try to destroy the window. Sending message is ok, but on destroy window gives a error.
BOOL sendMess = PostMessage(m_hwnd_RTFBox, WM_DESTROY, 0, 0);
if(sendMess != 0)
{
DestroyWindow(m_hwnd_RTFBox);
}
Access violation gives on the DestroyWindow() function.
I appreciate your help all the time...
Eranga
|
|
|
|
|
What do you mean it won't work?
Does the exception actually occur on that line?
As for your second post:
Do NOT send WM_DESTROY message to a window. The system does that
for you and also it won't destroy the window.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: What do you mean it won't work?
It's related to the first code which I've put there. When I use DestroyWindow(m_hwnd_RTFBox) , my window is not closed at all.
I appreciate your help all the time...
Eranga
|
|
|
|
|
If DestroyWindow() fails, then call GetLastError()....maybe the
error code will give you a clue to why it's failing.
I would guess the only way it should fail is if the passed HWND is
invalid.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I opened an existing VS 2005 VC++ project by double clicking. I have found lots of header file and .cpp file with native code(unmanaged) as well one Managed form. I am trying to add an extra Form but unable to find a suitable wizard to do it. If I click Project->AddResource, I can select/add dialog box.
Now I am trying to figure it what kind of project it it. How can I know this existing project is a Win32 or CLR or MFC (I don't see any sign of MFC).
Is the any project properties from where I can find the type of project I am working on.
Thank you.
|
|
|
|
|
Did you see WinMain in the project?
|
|
|
|
|
I have started to get, whenever I compile or build, these errors:
>c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'
1> There is no context in which this conversion is possible
1>c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
1 .............. etc etc
What order should the #include's around '#include <gdiplus.h>' be in?
How can I make my Visual C++ 2008 forget a faulty precompiled header and start again?</gdiplus.h>
|
|
|
|
|
The gdi+ header whould be included after windows.h.
If you're using a typical Visual Studio-produced pre
compiled header, then including the gdi+ header at the end works fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I was wondering if the << operator is inherited? I can't get the following to work:
class A
{
public:
A& operator << (double & arg)
{
return *this;
}
};
class B : public A
{
public:
B & operator<<(int & arg)
{
return *this;
}
};
...
B test;
test << 5.0;
with the error that no operator that takes double as argument.
|
|
|
|
|
Hi,
Class 'B' is overloading the operator '<<'. In quick mockup test I managed to get the following to work:
class A<br />
{<br />
public:<br />
A& operator << (double arg)<br />
{<br />
return *this;<br />
}<br />
};<br />
<br />
class B : public A<br />
{<br />
public:<br />
B& operator << (int arg)<br />
{<br />
return *this;<br />
}<br />
<br />
using A::operator <<;
};
I ran into difficulties when using the reference operator '&' for the two arguments.
I hope this is of use!
Lea Hayes
|
|
|
|
|
It appears that when I remove the reference operator, I don't have to specify "using". It's a shame though as I was hoping to subclass an existing implementation and just add a few of my own << operators to write my own types. Looks like I'll have to try defining the operators outside of the class.
|
|
|
|
|
Hi,
Whilst not necessarily the perfect solution, you could inline the operators.
class B : public A<br />
{<br />
...<br />
<br />
public:<br />
inline A& operator << (double & atr)<br />
{<br />
return A::operator << (atr);<br />
}<br />
};
This might be a useful workaround for your scenario.
Lea Hayes
|
|
|
|