|
I have an MFC app that is having some weird issues.
When you start the program and don't move window around it works fine. But as soon as you start moving it around, an exception will occur.
Debugging this in VS, I will get a buffer overrun message or some MFC debug assertion. I'm pretty new to MFC, anyone have any ideas where I should look to fix this?
|
|
|
|
|
Paffinity wrote: I'm pretty new to MFC, anyone have any ideas where I should look to fix this?
Very close to the error message (or as last resort, you may post it here).
You should be precise to get any help.
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,
I am using AfxBeginthread in my application for reading the datas from my hardware via serial ports. after clsoing my GUI, when i try to open once again, am getting error that "exe is running". I have closed my handles related to port in destructor of the class. i suspect the Thread is not closed completely, it occupies the memory, i want to know whats the better way to close or kill the thread.
thanks in advance,
Balaji S
|
|
|
|
|
Use a flag that you set from your main thread.
In your second thread, it looks like:
while (bContinue)
{
}
Once the flag is set to false by your main thread, the loop will finish and the thread function will return, terminating nicely the thread. Of course, how to implement this depends a lot of your current design, this is just the basic principle.
|
|
|
|
|
Hi,
thanks for your reply.
now am doing by that way, after false condition am using "afxendthread" function. is it recommended to use or coming out from the while loop itself enough to close the thread.
thanks
balajsi
|
|
|
|
|
Member 4651741 wrote: now am doing by that way, after false condition am using "afxendthread" function
Never do that. Simply exit the function (but you have to be sure that you exited the function). Never close a thread by calling afxendthread.
|
|
|
|
|
Well, just return from the thread routine. Killing a thread is not recommended really...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi,
thanks,
but my concern is, whether my thread occupy memory after closing the application. thats whay i used afxendthread function
|
|
|
|
|
See here[^]. It doesn't seem to matter if you use AfxEndThread or simply return.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Member 4651741 wrote: my concern is, whether my thread occupy memory after closing the application
In the link provided by Code-o-mat, see the part about the CWinThread::m_bAutoDelete
member...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi there, i need some help here. I need to develop a standalone application using sqlite and c++...I have used sqlite browser to develop my database. So how does that get connected to c++??
Thank you.
|
|
|
|
|
Are you using MFC?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
what is MFC? I'm not sure..I'm using the normal c++ code. Don't think so it a MFC.
|
|
|
|
|
vanishaa wrote: what is MFC?
Microsoft Foundation Classes. A very nice wrapper around portions of the Windows API. Two classes of interest are CDatabase and CRecordset .
vanishaa wrote: I'm using the normal c++ code.
Then you'll need this.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Actually I'm doing a portable program which can be executed in any windows platform without any installation. Do you have any suggestions for portable database which can be connected to c++?? Currently I'm working on sqlite. But its kind of complicated.
Thank you.
|
|
|
|
|
vanishaa wrote: what is MFC?
M y F irst C program?
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]
|
|
|
|
|
You #include <sqlite3.h> in your code, link with the sqlite library and use the SQLite C++ API[^] to access the database.
|
|
|
|
|
I think she is still blur how to to use the API.. show her a simple connection program plz... i don know about database so i not sure hw to help her.. :P
Thanks
|
|
|
|
|
what does a linker error means?? When i include the #include<sqlite3.h> header file alots of linker error messages is appearing..
|
|
|
|
|
That you forgot to link to the required library. It means that the code compiles fine (there are no syntax error in the code) but when the linker tries to assemble everything together, it can't find some specific functions, because you didn't specify the library from which they are coming from.
|
|
|
|
|
Look again at this article[^]. The "Working With SQLite" section gives you instructions for how to build an import library (.LIB file) for the SQLite 3 DLL. To use it, add a line like this to your main C++ file:
#pragma comment(lib, "sqlite.lib")
This will cause the linker to look in SQLite.lib for the SQLite functions.
|
|
|
|
|
>> #pragma comment(lib, "sqlite.lib")
Use a MAKE file to direct the linker to search for functions in that particular
library(.lib) is a more portable way I think, since this directive would be unknown with some compilers other than Microsoft's.
|
|
|
|
|
6Qing88 wrote: Use a MAKE file to direct the linker to search for functions in that particular library(.lib) is a more portable way I think
Hell, yeah - but given the OP was commenting like "what's a linker", I thought this was the simplest way to get their code to build
I wish all compilers had that directive - makes building so much easier. I love the way Boost uses it, with auto-selection to decide which of 4 or 6 library variants to link with
|
|
|
|
|
This page[^] gives an example of how to connect to a SQLite database with the C/C++ bindings.
This page[^] gives you more information about what's available in the C/C++ bindings for SQLite.
This page[^] has a downloadable e-book that shows you how to use SQLite with Visual C++ (see chapter 3 for instructions about how to build your program) [edit]This is a pay-for e-book - didn't notice that before- DOH![/edit].
And then there's this CodeProject article[^] (you know, CodeProject, the site you're asking this question on) that has a C++ wrapper for SQLite.
Google is your friend...
[edit]The CodeProject article tells you all you need to get started with SQLite. I see you've commented on the article already - if you can't make progress even after reading that article, I think you need to learn some basics about how to build C++ programs with third-party libraries...[/edit]
|
|
|
|
|
hi, i have tried to code the connection. It shows 1 error message. Don't really understand what is it..below is the code and error message.
Code:
// sparta1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "sqlite3.h"
#include <iostream>
#include "SQLAPI.h"
//#include <stdio.h>
//#include "Sl3API.h"
#pragma comment (lib,"sqlite3.lib")
int main(int argc, _TCHAR* argv[])
{
SAConnection con; //create connection object
SACommand cmd; // create command object
//&SAConnection::setClient;
con.setClient(SA_SQLite_Client);
void Connect(const SAString &sDBString, const SAString &sUserID, const SAString &sPasswords,SAClient_t eSAClient);
con.Connect("WORM.sqlite", "", "","SA_SQLite_Client");
cmd.setConnection(&con);
}
error message:
1>------ Build started: Project: sparta1, Configuration: Debug Win32 ------
1>Compiling...
1>sparta1.cpp
1>c:\users\vani\documents\visual studio 2005\projects\sparta1\sparta1\sparta1.cpp(29) : error C2664: 'SAConnection::Connect' : cannot convert parameter 4 from 'const char [17]' to 'SAClient_t'
1> There is no context in which this conversion is possible
1>Build log was saved at "file://c:\Users\Vani\Documents\Visual Studio 2005\Projects\sparta1\sparta1\Debug\BuildLog.htm"
1>sparta1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|