|
One solution is a class if the design fits. Otherwise, use a structure as the other members has mentioned.
Kuphryn
|
|
|
|
|
Hi Kuphryn, thanks for your reply!
Then if I use structure, since I have many "structure" for many datas in the application, i.e. Data1, Data2, Data3,etc.. How could I access individual structure? Should I use template to store these structure?
|
|
|
|
|
Given that you store the same set of class or structure objects in a file, one solution is to use read() along with seekg(sizeof(object)).
Kuphryn
|
|
|
|
|
Hi,
I have a class template defined in a file called X.h:
template<class a="defaultA," class="" b="defaultB">
class X
{
...
bool test(string args);
};
And the functions defined in X.cpp :
template <class a,="" class="" b="">
bool X<a, b="">::test(string args)
{ ...
}
But the compiler (MSVC++6.0) claims "unresolved external symbol: bool X<defaulta, defaultb="">::test(string args)" during the linking stage. It works
fine if the function definition is in the X.h file but when separated the compiler can't seem to find the template and create the correct function. Note: it works if I change the definition in X.cpp to the specialized version, e.g.:
bool X<defaulta, defaultb="">::test(string args) { ... };
If anyone has any ideas it would be appreciated,
Cheers,
Julian Churchill
|
|
|
|
|
Templates are compile time and thus the function definitions MUST be known during compiler time. Place the function definitions in the H file.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hy all,
I have a problem and I don't know how manage it in the better way.
This is the calling of Open method using the OLE DB access to Database.
hr = TheCdboSPMigrationAccessor.Open(DBSession, sqlcmd_Migration.c_str());
My sqlcmd_Migration is variable of std::string type,unfortunatly this string is very long (more or less 600 characters!!) and I think to have limitation problem using string type.
I thought to use the vector of char but I need to use the functionality like CONCATENATION, parametrization of some parts of this string ect...
Can someone suggest me how resolve this problem or eventually a good compromise???
Thanks in advance!!!
Andrea
|
|
|
|
|
Is "sqlcmd_Migration.c_str()" your attempt to pass a buffer of 600 to the function? If yes then it is a problem. ".c_str()" provides access to the buffer, but there is no magic that makes it char[600].
|
|
|
|
|
What leads you to believe that there is something wrong with std::string? It can handle a string 5 or 5,000,000 characters long.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hy Tim,
thanks in advance for your support!!!
I think so because when I debug my application and look the sqlcmd_Migration value,I see that the string is not complete,and if I try to delete some blank space in my string... I see that the string itself change format!!!
Bye
Andrea
|
|
|
|
|
In early versions of the VC6 STL, there was a bug with deleting characters from the string. However, if you have kept your compiler up to date, I think that shouldn't be an issue anymore. Also, if you use STLPort, that won't be an issue.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
In debug mode, we just see variables having length not exceeding 255 or 300 characters.
=======================
Nothing is perfect
|
|
|
|
|
Hi,
I'd like to be giving constant feedback of the operation of my program to the user via the icon in the status area. This will require manipulating the actual pixels in the icon image. Is there any way to write to a bitmap and then load THAT as the icon, or.. what is the best way to go about doing this?
Thanks,
- Jason
(SonorkID 100.611)
The Code Project - Orange makes the art grow fonder
|
|
|
|
|
You can use the CreateIcon function in the API to dynamically create icons and then put the handle into notifyicondata... But if the 'feedback' is not going to be relatively frequent, I'd recommend using balloon tips over the systray icon instead. They're much nicer imho.
|
|
|
|
|
Hello,
I am trying to create a instance of my class in case structure with the following code:
void CAppliDlg::OnOK()
{
switch (choice){
case 1:
m_Result.SetWindowText("Choice 1 is made");
//Create instance of my class here, the error comes from here.
MyClass aMyclass;
break;
case 2:
m_Result.SetWindowText("Choice 2 is made");
break;
case 3:
m_Result.SetWindowText("Choice 3 is made");
break;
default:
break;
}
}
It gives me a error:"initialization of 'MyClass' is skipped by 'case' label", can someone kindly figure out what the problem could be?
Thanks!
|
|
|
|
|
|
Thanks;)
But my purpose is to create the instance only within that case condition...
With a bracket it works now.;)
|
|
|
|
|
put brackets around the contents of "case 1" :
switch(...)
{
case 1:
{
stuff
}
break;
case 2:
break;
}
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
With brackets it works!
Thanks!
|
|
|
|
|
I have written a DLL (Win 32) which has been compiled using VC++6 on a Windows 2000 PC. The program that is using the DLL is written in TestPoint (which you probabily won't of heard of) and when I run it on a Windows 98 machine it accesses the COM port correctly.
The problem is that we have just upgraded to a Windows 2000 PC and now the DLL will not work. The DLL is called correctly but no activity on the port occurs (we have checked using a scope).
My DLL code looks like this.
extern "C" _declspec(dllexport) long int BiPhase(int comm_port, int command, int value_1, int value_2 )
{
CComms Comms;
char OutBuffer[5];
char InBuffer[5];
char *pOutBuffer;
char *pInBuffer;
short int tries;
int ierror;
int return_value;
unsigned long Bytes_Avail, timer_loop;
unsigned char Character_0, Character_1, Character_2, Character_3, Character_4;
pOutBuffer = &OutBuffer[0];
pInBuffer = &InBuffer[0];
OutBuffer[0] = 1;
OutBuffer[1] = 7;
OutBuffer[2] = command;
OutBuffer[3] = value_1;
OutBuffer[4] = value_2;
Write the 5 bytes os data using .....
Write to Port
!WriteFile(idComDev, pb, 1, &dummy, NULL)
Read the 5 bytes of Data using ...
Read Port
!ReadFile(idComDev, &szChar, 1, &bytesRead,NULL)
Character_0 = InBuffer[0]; // Not interested
Character_1 = InBuffer[1];
Character_2 = InBuffer[2];
Character_3 = InBuffer[3];
Character_4 = InBuffer[4];
return (Character_2 * 256) + Character_1;
And my Comm port is set up as follows
DCB dcb = { 0 };
dcb.DCBlength = sizeof(dcb);
dcb.BaudRate = 115200;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fBinary = TRUE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fInX = FALSE;
dcb.fOutX = FALSE;
DWORD dwInQueue = 500000;
DWORD dwOutQueue = 5000;
COMMTIMEOUTS m_TimeOuts;
m_TimeOuts.ReadIntervalTimeout = 30;
m_TimeOuts.ReadTotalTimeoutConstant = 250;
m_TimeOuts.ReadTotalTimeoutMultiplier = 2;
m_TimeOuts.WriteTotalTimeoutConstant = 250;
m_TimeOuts.WriteTotalTimeoutMultiplier = 2;
Set up Port
CString sPort;
sPort.Format(_T("\\\\.\\COM%d"), com_port);
idComDev = CreateFile(sPort, // communication port string (COMX)
GENERIC_READ | GENERIC_WRITE, // read/write types
0, // comm devices must be opened with exclusive access
NULL, // no security attributes
OPEN_EXISTING, // comm devices must use OPEN_EXISTING
FILE_FLAG_OVERLAPPED, // Async I/O
0); // template must be 0 for comm devices
Read Port
!ReadFile(idComDev, &szChar, 1, &bytesRead,NULL)
Write to Port
!WriteFile(idComDev, pb, 1, &dummy, NULL)
Any help would be greatly appreciated.
|
|
|
|
|
The obvious question "Are you sure the COM port is working?" I always use Hyperterminal and a loop back connector, a paper clip, a metal one of course;), between pins 2 & 3, hit some keys do they echo back
Checking one of my progs I use CreateFile("COM1" . . . not \\.\COM1 apart from that I can't see any possible "faults"
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
I have tested the com port by writing a Visual C++ program using the same setup as the DLL and that works.
|
|
|
|
|
In that case you have "solved" it, looks like the TestPoint program is not working on 2000 or there is a bug in it which was "ignored" by 98. Another test is to try it on XP, if it works then it is possibly a 2000 problem.
Happy hunting!
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Hi
Does anyone know how to put text on a label field into bold?
Thanks for the effort
Greetz
Jens
|
|
|
|
|
1) Create Bold Font.
2) Use SetFont to set it.
|
|
|
|
|
yes i know
i used a LOGFONT for my new font but i want it to be set on initdialog when the dialog shows, and you don't have a CDC pointer available in that function.
I have it like this:
LOGFONT logFont;
logFont.lfHeight = 8;
logFont.lfWidth = 0;
logFont.lfEscapement = 0;
logFont.lfOrientation = 0;
logFont.lfWeight = FW_BOLD;
logFont.lfItalic = 0;
logFont.lfUnderline = 0;
logFont.lfStrikeOut = 0;
logFont.lfCharSet = ANSI_CHARSET;
logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logFont.lfQuality = PROOF_QUALITY;
logFont.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
strcpy(logFont.lfFaceName, 'Times New Roman');
CFont font;
font.CreateFontIndirect(&logFont);
CFont* oldFont = pDC->SelectObject(&font);
m_FuncNedCtrl.SetWindowText("Example");
pDC->SelectObject(oldFont);
|
|
|
|