|
strStuff is a local variable so local to the thread too, no need to put any locking,
Here is the simple formula to remember.
in Multithreading:
Local Variable : No Syncronization
Gloabl Variable : Syncronization needed.
Simple but effective way to solve multithreading problems.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Can some give me a tutorial, or walk me through how to use the Microsoft Comunications Control to open serial ports and send information through them?
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
I foud this useful explanation using MFC and MSComm32 ActiveX control 2 years ago and give you original text:
"Creating the project
Make a simple Dialog workspace in MSVC via the MFC App wizard. The options don't really matter, but make sure you check the 'ActiveX Controls' option in when the Wizard prompts you in step 2.
Adding CMSComm to your project
Open your resource editor so you can change the main dialog. Look on the toolbar, and verify that you don't already have the MSComm control there (someone else may have modified the default workspace). It looks like a little phone.
Add the control to your project. Click the Project >> Add To Project >> Components and Controls command from the menu. This command will take a while as MSVC scans the registry for registered controls. Select 'Registered ActiveX Controls' and click insert. Find the object 'Microsoft Communications Control, version 6.0.' (or another version), select it, then click insert, then Ok. At this point MSVC will prompt you for which parts of the ActiveX control you want to add. There should only be one listed, CMSComm, keep it checked. MSVC will generate a wrapper class for the object so you can use it. You can change the file names and class name if you want, but for this purpose, I'll assume you left them as is.
Close the add components dialog.
Now, look at your dialog toolbar, in it, you should see a new icon for the CMSComm object. Select it, and draw one of these onto your main form. An icon will appear, but don't worry, the control itself is invisible at run time.
Initializing the CMSComm control
All this can be done at run time, but for now, let's just set the properties at design time. Right click on the icon for the comm control in your dialog resource and pull up the properties dialog. Under the Control, Buffers, and Hardware tabs, set the properties you desire, such as buad rate, parity, port number, etc.
Add a member for the control
To use the control, you need to create a class member. Open the Class Wizard, and from the Member Variables tab, select the comm control (by default it will be called IDC_MSCOMM1) then click the 'Add Variable...' button. Create a name, I used m_comm. Double check that the variable is a control variable, and that it's of the right class (CMSComm). You can now use this member variable to communitcate with your com port.
Using the CMSComm control
Here's a quick example of how to use the control. It's important to wait until your OnInitDialog() call (or anytime after) before trying to use it because not everything will be created/initialized before this.
Code simple:
CMSComm m_comm; // MFC generated member in the .h file
#include "atlbase.h" // CComVariant support
#define COM_MS_TIMEOUT 5000 // COM1 timeout in milliseconds
// Generate an output.
CString sOut;
// Build your output...
sOut = _T("Hello world");
// Generate a variant for the output.
CComVariant vOut(sOut);
// Send the command.
m_comm.SetOutput(vOut);
// Wait for a reply.
// This is NOT a processor efficient way of doing it,
// but it gets the idea across.
DWORD dwNow, dwTimeOut, dwStart;
dwStart = GetTickCount();
dwTimeOut = COM_MS_TIMEOUT;
CString sIn, sInBuffer;
CComVariant vIn;
for (;;)
{
dwNow = GetTickCount();
if (((dwNow - dwStart) > dwTimeOut) // Timeout elapsed
|| (dwNow < dwStart)) // Happens if tick count wraps past 2^32
break;
vIn.Clear();
vIn = m_comm.GetInput();
sIn = vIn.bstrVal;
sInBuffer += sIn;
// Check a for terminating \r character.
// If we find one, break the loop, otherwise,
// more data is coming.
// The hardware you'll be interfacing with may have a
// a different terminator sequence.
if (sIn.Right(1) == _T("\r"))
break;
}
This is the easy way of doing it. If you're not using a dialog at all, it will be trickier creating the object, since it won't be done automatically by your dialog's ActveX handlers."
For more information see MSComm32 help if you mean additional details and change somethings.
'Also http://www.yes-tele.com/mscomm.html'
Regards,
|
|
|
|
|
I'm trying to get my program to acess a database(.mdb) and change the part of the field it's in.
(ie getting the field2 info for Car4). I have tried many things and I just can't seem to figure it out. Thank you for your help.
____________
|Field1|Field2|
|Car1 |Ratio1|
|Car2 |Ratio2|
|Car3 |Ratio3|
|Car4 |Ratio4|
|Car5 |Ratio5|
|
|
|
|
|
Should be something like:
Update Field2 where Field1 = Car4
Not sure about the syntax for that database.
Not sure if I was any help.
Good Luck,
Jerry
|
|
|
|
|
Have you tried using ClassWizard to derive a class from CRecordset ? It will ask you for a data source name (which is tied to your Access file). That class will then contain a member variable for each column (i.e., field) in the database. For querying the rows, the default SQL statement will effectively be SELECT * FROM . To update a row, you'll set the m_strFilter member, then call the Requery() method. At that point, the record pointer is on the row you want to change. Call Edit() , assign each of the record set's member variables their new value, and call Update() .
This is not an exact recipe, but it will get you going. Using the keywords I've shown here, search here at CP, or MSDN, for a bunch of examples.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I don't want to change the fields just get the info thats in them. So in my code if I put something like
SELECT* FROM gear
m_strFilter.Requery(variable);
right or that wouldn't work? Thank you for your help.
|
|
|
|
|
MrNiceBerG wrote:
SELECT* FROM gear
Put this as the return value from GetDefaultSQL() .
MrNiceBerG wrote:
m_strFilter.Requery(variable);
right or that wouldn't work?
No, because Requery() accepts no parameters.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hello:
When using Date Time Picker, it defaults to Dec 31, 1969. If I select a date before that, once I do a UpdateData(TRUE), I get an error Debug Assert Error - timecore.cpp line 40. ----> ASSERT(m_time != -1);
How can I limit the dates that can be selected? How can I make it default to today's date?
Thank you
CTime::CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec,
int nDST)
{
struct tm atm;
atm.tm_sec = nSec;
atm.tm_min = nMin;
atm.tm_hour = nHour;
ASSERT(nDay >= 1 && nDay <= 31);
atm.tm_mday = nDay;
ASSERT(nMonth >= 1 && nMonth <= 12);
atm.tm_mon = nMonth - 1; // tm_mon is 0 based
ASSERT(nYear >= 1900);
atm.tm_year = nYear - 1900; // tm_year is 1900 based
atm.tm_isdst = nDST;
m_time = mktime(&atm);
----> ASSERT(m_time != -1); // indicates an illegal input time
}
|
|
|
|
|
I think CDateTimeCtrl::SetRange() is what you are after.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi
It is somebody who had some problem before with this type of exception ?
EXCEPTION_IN_PAGE_ERROR
Thanks,
Florian Szoke
|
|
|
|
|
From MSDN:
The thread tried to access a page that was not present, and the system was unable to load the page. For example, this exception might occur if a network connection is lost while running a program over the network.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thank You ... but this desciption doesn't help too much... at least for me.
I am intrested for some details if somebody run over this .
|
|
|
|
|
nope cant say I have, I did a quick check in MSDN documentation and didnt find it. What kind of control sent the error? that would help determine where and why it was thrown.
|
|
|
|
|
I have an ActiveX into a VB form and after a while ( 3 or more hours ) on the right click when I want to load the menu from the resourse( ex: obj.LoadMenu(ID)) I am getting this exception. And from that moment it is happen every time you do a right click. If you will restard the app everything it is fine until it is starting again.
|
|
|
|
|
Have you tried this forum?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
Just checking. When I saw "VB" in your post, I just wanted to make sure you knew this was the VC++ forum.
Anyway, the problem needs to be narrowed down a bit before it can be effectively diagnosed. Debugging a whole application with the minimal information you've provided is akin to finding a needle in a haystack.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I am sorry but I dont need to debug my app, I was asking people who enconter that problem if they can share information
|
|
|
|
|
You are receiving an exception error in your application but you are not interested in debugging it.
What information are you wanting others to share (that does not directly lead to a bug being fixed)?
There are many reasons, including the one I provided, why that exception could be thrown. Regardless of why it gets thrown, don't you think it's something you might want to address?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Florian Szoke wrote:
sorry but I dont need to debug my app
sorry you need to do the dirty work of your own app.
Florian Szoke wrote:
I was asking people who enconter that problem if they can share information
Its a rare Case you will be extreamly lucky if you find one.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
yes , it is rare... and I did't find anything on the internet just that small definition from MSDN
|
|
|
|
|
I was typeing to fast and I mist a word "you".
I am sorry but I dont need you to debug my app, I was asking people who enconter that problem if they can share information
|
|
|
|
|
Florian Szoke wrote:
I was typeing to fast and I mist a word "you".
If you slow down little bit more you won't miss the missing letters too.;)
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I am having a problem with a control "keeping" focused.
I have a tree control. When I double click on it, and hit a node, I want to set focus to another control (an edit control), so that I can start typing and have the key strokes go to the edit control.
Just like VC does when you double click on a node in the workspace tree and it takes you to a text editor.
Except that of course this doesn't seem to work.
So I made a simple test case - ran the MFC wizard and created an explorer style app.
Add a OnLButtonDblClk handle to the tree control and in it added code to get the right pane control, and set focus to it.
Sure enough, same behaviour - the right pane temporarily gets the focus but DOES NOT RETAIN IT !!!!!
Is there some magical procedure I have to follow?
Do I need to sacrifice virgins? Goats? Call up the Evil One?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|