|
Hi;)
I'm still a beginner in vc++,me and my friends are devolopeing a network app.(instance messanger),and I need your help at the following topics:
1-making an edit box transparent.
2-creating a menu at a dialoge based app.
3-creating apopup menu.
4-adding a bitmap to a button with it's states.
note:
the project I'm working in is educational one.
finally thank you for your time.
Hatem M Nassar
|
|
|
|
|
I dont know about the first one but you will get the solutions for the others if you try search using the search option here in CP. Or navigate according to the requiremets from the mainpage.
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 have a couple global variables that I would like to use in more than one file. What I want to do is delcare the variables in one file and then be able to access them from other files/classes. So for example if I set the value of the variables in file1 I want to be able to retreive those values from the variables in file2. I thought I could do this with "extern", but I can't figure out how. Any help would be appreciated. I tried this
extern TCHAR* var1;
extern TCHAR* var2;
extern TCHAR* cvar1;
extern TCHAR* cvar2; When I compile that though I get an error that the variable has an illegal storage class.
- Aaron
|
|
|
|
|
file1.cpp
TCHAR* cvar1;
...
void somefunc()
{
cvar1 = new char[60];
....
}
-----------------------------------
in common.h
extern TCHAR* cvar1;
....
-----------------------------------
file2.cpp
#include "common.h"
....
void someanotherfunction()
{
printf("%s",cvar1);
}
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++"
|
|
|
|
|
Hi,
I have a question about the thread issue on the string class. If you do the following, would you need to put a lock around the string code?
Void ThreadFunc()
{
// Only created in each thread, not global.
String strStuff;
While (1)
{
// Do I need to put a lock around this call?
strStuff = “Hello”;
}
}
Void main (void)
{
Thread hThreadStuff[3];
For ( int I = 0; I < 3; ++i)
hThreadStuff [i] = CreathThread(…, ThreadFunc, …);
hThreadStuff.WaitonExit();
}
Thanks in advance,
Ken
|
|
|
|
|
Since strStuff is declared inside the thread routine, each thread would have their own copy. Thus, no locking is required. However, if strStuff was declared outside the routine, then you would need to place a lock around the assignment or any time you where fetching the value of the string.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
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
|
|
|
|