|
Akin Ocal wrote: lReturn = RegLoadKey(HKEY_LOCAL_MACHINE,"newhklm\\",sFileName);
Shouldn't this be:
lReturn = RegLoadKey(hHive, "newhklm\\", sFileName);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i have used CString in many places of my code. is anything harm on using this? will it leads to memory leak? pls help me
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
The whole point of a string class is to control memory leaks, by controlling assignment and deletion of character arrays.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I try to remote control my computer use my cell phone which has bluetooth function. So the simplest method may be enough.
Thanks.
|
|
|
|
|
I think I'm able to provide you a starting point in your searches. You can use BT (Bluetooth) by WinSocket or OBEX - Object Exchange.
OBEX is some protocol like HTTP but much simpler, designed for devices with limited performances (like handheld and mobile devices). It's useful especially for Object Pull and Object Push (download/upload) but you will need a server on you PC (if you want to connect your mobile to your PC). I think that this is not what you`re interested in, but just in case.
Winsock will allow you to start searching BT devices,set security settings, connect to the selected device and eventually start remotely control your device. I'm sorry I cannot provide more help for you, I've just started documenting on this topic myself, too.
|
|
|
|
|
Why No default constructor is implicitly created for a class that has any constant or reference type members?
Why copy constructor is not created for a class if any of its members or base classes have an inaccessible copy constructor?
|
|
|
|
|
If you are having constant or reference type data member than they need to be initialised. Initialisation can happen only through constructor initialisation list.
class A
{
int g&;
int s;
const int h;
public :
A():g(s), h(10) // constructor initialisation list.
{
}
};
This constructor can be default one or overloaded.
A(int k):g(s), h(10)
{
}
--------------------------------------------------------
One more General Rule :
If you are providing only overloaded constructor then default constructor
will not be provided automatically. You need to give deinition for default constructor.
--------------------------------------------------------
|
|
|
|
|
Constant members must be initialized, and reference members bound, *explicitly* in the member initializing list of the constructor.
And the behavior of the default copy constructor is to perform a memberwise copy to its sub-objects, which would become impossible is any of the sub-objects have an inaccessible copy constructor.
|
|
|
|
|
Is there an easy way to cycle through all the controls on a form. I want to be able to determine if an entry has been made in a certain control (edit box) that is a required field. These required fields can change by user.
Eric
|
|
|
|
|
Do you want this cycle for controls on your program or other programs?
|
|
|
|
|
I want to cycle through the edit boxes on my screen, without have to put in all the IDC_??? names.
Here is a sample of what I am doing:
if ((sLabelName[i]=="IDC_STATIC_COMPANY")&&(iLabelRequired[i]==1))
{
GetDlgItemText(IDC_COMPANY, sTemp);
if (sTemp.GetLength()
|
|
|
|
|
I suppose you can enumerate the child windows looking for edit controls, something like this
(I'm assuming you're using MFC, based on the code you posted):
BOOL CALLBACK MyDialogEnumChildProc(HWND hwnd, LPARAM lParam)
{
TCHAR szClassName[32];
if (::GetClassName(hwnd, szClassName, 32))
{
if (!_tcsicmp(szClassName, _T("EDIT")))
{
CMyDialog *pMyDialog = (CMyDialog *)lParam;
}
}
return TRUE;
}
...
void CMyDialog::SomeFunc()
{
::EnumChildWindows(*this, MyDialogEnumChildProc, (LPARAM)this);
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
braune wrote: I want to be able to determine if an entry has been made...
At what point are you doing this check?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to do the check when the user clcks a button to perform an operation. The first item of business for this operation would be to field validation, ie. make sure the required fields have entries and they are of a minimum length.
Eric
|
|
|
|
|
braune wrote: I want to do the check when the user clcks a button to perform an operation.
Do not enable the button until all conditions have been met. Otherwise, this just leads to confusion.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Its not quite that simply. I have multiple customers who have different requirements. Here is what I am doing: I have created an external file that I read in when the program starts. The external file contains a list of the fields that are required and the minimum length of each. When I read the file in I set all the labels for these fields to RED, so the user knows they are required fields. I set the labels using the following:
if ((sLabelName[i]=="IDC_STATIC_COMPANY")&&(iLabelRequired[i]==1))
m_stCOMPANY.SetTextColor(LIGHTRED);
if ((sLabelName[i]=="IDC_STATIC_WELLNAME")&&(iLabelRequired[i]==1))
m_stWELLNAME.SetTextColor(LIGHTRED);
I would rather cycle through all the labels on the form, rather than putting them in statically. When the user selects a button I do much the same to test, except using the editbox controls to correct if required and the minimum length.
Hope this info helps.
Eric
|
|
|
|
|
Another thought is, can I just use the variable to reference the control? ie. sLabelName[i].text, GetDlgItemText(sControlName[i], sTemp);
Eric
|
|
|
|
|
Imagine a hierarcht of two classes. Suppose the copy constructor of a derived class is called. When is the base (parent) class copy constructor called? Is it like Java and the parent constructor is called at the beginning of each constructor? Does it have to be explicit?
How does the base and derived class notion of copy constructor work here?
|
|
|
|
|
The parent constructor is called at the beginning of the initialization, but not necessarily the copy constructor. For a default copy constructor, of course the copy constructor of the base would be called. But if the copy constructor is provided in the derived class explicitly, it can be chosen that which one of the base class's constructor is to be called.
|
|
|
|
|
tom groezer wrote: Does it have to be explicit?
The best advice is to always make it explicit to avoid surprises. It can get mundane for simple classes but helps prevent some of life's little oopsies when your class manages resources.
As far as I know, if you explicitly implement the copy constructor, you should call the super class copy constructor first in your initilization list. Also remember to call the super class assignment operator in it's explicit implementation to prevent any surprises. It is best to define the copy constructor and the assignment operator to avoid what may or may not get done by the default implementations.
If you have "Effective C++ Third Edition" by Scott Meyers, there is some great, to the point, advice/information on this topic. If you don't have it, it's one of the few books that can justify the $40+ price tag.
|
|
|
|
|
tom groezer wrote: Suppose the copy constructor of a derived class is called. When is the base (parent) class copy constructor called?
Why not set a breakpoint in both, run the program, and note which breakpoint is hit first?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
A task infront of me is to develop local chat server
which will just accept data from everyone and pass it to person whom it is to be send.
Server compiles fine but as soon as I run it ,it fails. Errors come at Accept statement.
The requirement is due to internet is not allowed.
And way for instant communication is required as comapany
layout is very complecated to reach from one room to other. Official mail is too inconvenient for small messages.
//CSocket cs,cr[500]; defined in h file
// bool connected;
BOOL CChatserverDlg::OnInitDialog()
{
CDialog::OnInitDialog();
---------------
------------------
----------------
count = 0;
connected = false;
connected = cs.Create(4000,SOCK_STREAM);
SilentWork();
return TRUE;
}
void CChatserverDlg::SilentWork()
{
bool check = false;
check = cs.Listen();
for(int i = 0;i < 500;i++) //even I reduce number error comes
{
AfxBeginThread(&thread,0);
count++;
}
}
UINT thread(LPVOID p)
{
CChatserverDlg* dlg = (CChatserverDlg*)AfxGetApp()->GetMainWnd();
SOCKADDR* lpSockAddr;
dlg->cs.Accept(dlg->cr[count],lpSockAddr );
while(dlg->connected)
{
ULONG nBytesToReceive=0;
DWORD dwErr;
if( !dlg->cr[count].IOCtl(FIONREAD, &nBytesToReceive))
{
dwErr = WSAGetLastError();
}
if( nBytesToReceive==0 )
{ }
else
{
char* buff = new char[15];
try
{
dlg->cr[count].Receive(buff,15,0);
}
catch(CException e)
{
}
dlg->m_ldList1.AddString(buff);
char* data = new char[1024];
bool continueloop = true;
do
{
ULONG ToReceive=0;
if( !dlg->cr[count].IOCtl(FIONREAD, &ToReceive))
{
dwErr = WSAGetLastError();
}
if( ToReceive==0 )
{ }
else
{
dlg->cr[count].Receive(data,1023,0);
dlg->cr[count].SendTo(data,1023,4000,buff,0);
if(NULL != strstr("diconnected",data))
continueloop = false;
}
}while(continueloop);
|| ART OF LIVING ||
|
|
|
|
|
shivditya wrote: Server compiles fine but as soon as I run it ,it fails. Errors come at Accept statement.
Have you stepped into this code to determine why?
shivditya wrote: And way for instant communication is required as comapany...
Are other IM packages against company policy?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Some old people running company are against any software which is not having name of company on caption.
|| ART OF LIVING ||
|
|
|
|
|
Dear All,
I have downloded some sample projects from good articles (of Code Projects), which have makefile to build it. i have tried namke to build that cauing makefile.def not found error. In the make file makefile.def is defined as follow
!INCLUDE $(NTMAKEENV)\makefile.def
Please suggest me good articles for building project with namke and makefile.
With Regards
With Regards
Manoj
|
|
|
|