|
I want to pass the CString name to a class. I have this:
void CForm3Page1::OnName()
{
CFormatname Dlg("ralph");
if (Dlg.DoModal() == IDOK)
{
}
}
and my class looks like this:
private:
CString thename;
public:
CFormatname(CWnd* pParent = NULL, CString); // standard constructor
CFormatname::CFormatname(CString name, CWnd* pParent /*=NULL*/)
: CDialog(name, CFormatname::IDD, pParent)
{
//{{AFX_DATA_INIT(CFormatname)
//}}AFX_DATA_INIT
thename = name;
}
But it doesn't work. I keep getting the errors:
C:\Formatname.h(25) : error C2548: 'CFormatname::CFormatname' : missing default parameter for parameter 2
C:\Formatname.h(15) : see declaration of 'CFormatname'
and other errors. I have looked in this book for quite some trying to
mimic this example. How do I pass a CString to a class?
Please any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
DanYELL wrote:
CFormatname(CWnd* pParent = NULL, CString); // standard constructor
CString is a data type, it has to be followed with a variable that represents it:
CFormatname(CWnd* pParent = NULL, CString myStr);
- Nick Parker My Blog
|
|
|
|
|
Even with that change, I still get this error:
C:\Formatname.h(25) : error C2548: 'CFormatname::CFormatname' : missing default parameter for parameter 2
and it's this line
CFormatname(CWnd* pParent = NULL, CString mystr); // standard constructor
???
|
|
|
|
|
Try
CFormatname(CWnd* pParent = NULL, CString myStr = NULL);
Thank You
Bo Hunter
|
|
|
|
|
Bo Hunter wrote:
CFormatname(CWnd* pParent = NULL, CString myStr = NULL);
Since myStr is not a pointer and NULL is a void pointer 0, the default argument isn't correct, but should be CFormatname(CWnd* pParent = NULL, CString myStr = "");.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
|
On my machine once you start default parameters from there
on out has to have defaults as well. Is this correct?
Thank You
Bo Hunter
|
|
|
|
|
Still stumped. I call the class like so:
CFormatname Dlg("ralph");
The constructor is:
CFormatname(CWnd* pParent = NULL, CString mystr = NULL); // constructor
and
CFormatname::CFormatname(CWnd* pParent /*=NULL*/, CString mystr)
: CDialog(CFormatname::IDD, pParent, mystr)
{
//{{AFX_DATA_INIT(CFormatname)
//}}AFX_DATA_INIT
thename = mystr;
}
and the errors are:
C:\Formatname.h(25) : error C2440: 'default argument' : cannot convert from 'const int' to 'class CString'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Formatname.h(25) : error C2548: 'CFormatname::CFormatname' : missing default parameter for parameter 2
C:\Formatname.cpp(20) : error C2661: 'CDialog::CDialog' : no overloaded function takes 3 parameters
What perplexes me is the information that is added to the class by
Visual C++. It automatically adds 'CWnd* pParent /*=NULL*/'
and 'CFormatname::IDD' and I try to ignore those parameters and
mimic what I see in books, but it doesn't work.
Please, please, please any response anyone can give me will be
greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
The constructor you supplied is expecting the first parameter to be a CWnd*, and you are passing a string. Either change the constructor
CFormatname(CString mystr, CWnd* pParent = NULL) or pass in a NULL pointer
CFormatname Dlg(NULL, "ralph");
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Seems so obvious now (and it works). I appreciate the reply. I kept
wanting to ignore the 'CWnd* pParent = NULL' part.
One last question. For this part of the constructor:
CFormatname::CFormatname(CWnd* pParent /*=NULL*/, CString mystr)
: CDialog(CFormatname::IDD, pParent)
{
//{{AFX_DATA_INIT(CFormatname)
//}}AFX_DATA_INIT
name = mystr;
}
what exactly is CFormatname::IDD? What am I passing to CDialog?
pParent is just NULL and I know what :: means, but CFormatname::IDD
doesn't make sense.
|
|
|
|
|
The IDD is the ID of the dialog. It is defined as a const in the class's H file.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Try This:
CFormatname(CString name,CWnd* pParent = NULL); // standard constructor
Shenthil
|
|
|
|
|
I have been using the introductory edition of MS VC++ 6.0 that came with Ivor Hortons book. What is the current latest version?
Ger
|
|
|
|
|
VC++ .NET 2003
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
In a library that I downloaded I get an error on this line:
#if WIN32 && defined(_MSC_VER) && DEBUG
The sample app that came with the library compiles fine but when I use the library in my app it fails. I belive VC define those variables. So, its probably a configuration thing that I'm missing. (I compiled both projects in the Debug Configuration.)
Thanks for any ideas,
Albert
|
|
|
|
|
AFAIK it is complaining about DEBUG. VC defines _DEBUG (note the underscore). maybe the library or sample supplied defines DEBUG itself?
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks, that was it. DEBUG was defined in the sample program's project.
|
|
|
|
|
I was wondering if there is a way to set the timeout for connecting? My app directly calls connect and if the server is OK then it will connect alright. If for example the address is wrong and it does not connect, it will hang there for many seconds.
One more thing, I am using WSAevents to signal read and etc. This is fine for me. However, I have a problem with using shutdown. It does not gracefully call the FD_CLOSE so that I can formally call closesocket. Has anyone seen this problem?
THanks in advance!
|
|
|
|
|
I have a class derived from CToolBar in a CFrame window. My problem is that I don't know how to tell if the user has closed the toolbar with the close button while it is floating. I have tried providing a OnClose message handler but it never gets called.
Any help would be greatly appreciated.
Thanks in advance.
|
|
|
|
|
Maybe handle the WM_SYSCOMMAND message, looking for the SC_CLOSE command.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi guys.
I want to draw in layers, so if anybody could give me a hint about that, I would really appreciate it. I want to be able to draw in multiple layers, so for instance if I am to erase a rectangle or any other more complex object, I would only discard a layer and repaint that object as altered, not having to redraw the background or anything else. It is something like in Photoshop when you draw on the layer and you bring it to the front, then you can delete the whole layer at any moment later.
I only need a general guidance, not the actual code.
|
|
|
|
|
Keep the layers in a vector of transparent bitmaps. draw the bitmaps on top of each other using TransparentBlt().
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Let's say I have this piece of code...
CString strWndName = "My wnd";<br />
CString strClassName = "Wnd class";<br />
HWND hwnd = ::FindWindow(strClassName,strWndName);
Would it be possible to send a packet to hwnd using PostMessage?
If yes, which type of message should I send?
Thanks for help,
~Mike
|
|
|
|
|
WM_COPYDATA[^] might fit your needs.
And if the paths that I have followed/have tread against the flow/there is no need for sorrow
I am coming home
Return, Crüxshadows
|
|
|
|