|
I am making an overloaded function.
one has parameters of myFunct(CString m_in, UINT nType)
second one has parameters of myFunctTwo(CString m_in, int i_in1)
If I trying passing UINT nType being MB_YESNO (which is 4 of course)
The UINT nType is being taken by myFunctTwo.
What logic/method should I use to get my function to work the way I wish.
Any help Thanks
Later, JoeSox www.joeswammi.com
Load my Sig here.....
|
|
|
|
|
(I guess both functions are named myFunct and you've changed the names in your post for explanatory purposes.)
The overload case you describe seems to be OK. Maybe if you post the code where you are invoking the function the problem will be easier to locate.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
void CPBox::PBox(CString str_in1, UINT nType)<br />
{<br />
AfxMessageBox(str_in1, nType);
}<br />
<br />
void CPBox::PBox(CString str_in1, int i_in1)
{<br />
CString temp, str_i_in1;<br />
str_i_in1.Format("%d", i_in1);
temp = str_in1;<br />
temp.Replace("%d", str_i_in1);<br />
<br />
AfxMessageBox(temp);<br />
}
tRYING to do:
pb.PBox("Simple Text in, with Message_Box Types(eg. MB_YESNO)", MB_YESNO);
Which will not display the Yes/No messagebox because it is being taken being the function that takes the int
Later, JoeSox www.joeswammi.com
Load my Sig here.....
|
|
|
|
|
OK. MB_YESNO is a macro with no type of its own: without further info, it'll be taken as an int , hence your problem. Explicitly cast the macro to an UINT :
pb.PBox("Simple Text in, with Message_Box Types(eg. MB_YESNO)", (UINT)MB_YESNO);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Can I examine it in the actual function something like
void CPBox::PBox(CString str_in1, int i_in1)
{<br />
CString temp, str_i_in1;<br />
if ((i_in1 != (UINT)MB_YESNO) || ...)<br />
{<br />
<br />
str_i_in1.Format("%d", i_in1);
temp = str_in1;<br />
temp.Replace("%d", str_i_in1);<br />
}<br />
else<br />
{<br />
AfxMessageBox(str_in1, (UINT)i_in1);<br />
}<br />
<br />
AfxMessageBox(temp);<br />
}
I want the parameter calls to the function as close as AfxMessageBox as possible.
Thanks for your help
Later, JoeSox www.joeswammi.com
Load my Sig here.....
|
|
|
|
|
One solution is static_cast. What data type is MB_YESNO? Is that a Windows enum or an abstract enum you implemented? In the latter case, using the enum data type inplace of UINT.
Kuphryn
|
|
|
|
|
Hi all
I am trying to make my app a little friendlier.
I a use a dialog to set a network computer as a source for a running object.
For now the user must type in the name of the network coputer manually, for example..... \\server1
I am trying to set up a GUI like the browse folder dialog common in windows. Except it will browse computers on the network. When the user selects the computer, it's name will appears in the dialog box in one of the fields.
I can't find any info on doing this but I have seen this done many times.
Any help appreciated
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
If you are working on NT/Win2k/XP you can use the Net* functions to find computers and users on the network
Like NetServerEnum()
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have a app that is non MFC app and will use CString and CFileFind but if i #include "stdafx.h" i get a error message that say's
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> and if i remore al the #include <windows.h> files in the *.h file I still get Many errors what should I do??
\Larsson
|
|
|
|
|
As for CString , Joe O'Leary provides a clone for non-MFC apps in his article CString-clone Using Standard C++[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
CString and CFileFind are MFC classes, so they can not be used in non MFC apps. You can use std::string or TCHAR* arrays for strings. Use the FindFirstFile[Ex]() and FindNextFile() API functions instead of CFileFind (CFileFind is just a wrapper for these functions).
HTH
CPUA 0x5041
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!
|
|
|
|
|
There is not way for CFileFind to be used in API applications as far as I know (though it's very easy to be done using the API functions),
however if you are using VC++.Net you can use the CString class by inlcuding <atlstr.h<> and use it normally.
I think this might not work in VC++ 6.0
|
|
|
|
|
Just comment out that #error. Everyone does it
Don't forget that the MFC functions are just C++ wrappers for a C core. FindFirstFile, FindNextFile work the exact same way. And CString is just the stanard C functions wrapped, with a bit of magic glue.
|
|
|
|
|
One of my classes keeps a lookup-table that is based on a few constants #define in the header. If one of the constants change before a recompile the table has to be recomputed, but otherwise it is defined as a constant:
m_table[256] = {
0x00000000, 0x6750096, 0xEEEE4455, 0x45DF5C75, 0xB6662D3D, 0x23EE4521,
...
};
I have a function that computes the table and prints it to standard output, so if I change one of the #define constants I can compile, run the function, cut-and-paste the table back to my sourcefile, and finally recompile..
Is there any way to make the preprocessor do this? The table-generating function is not simple enough to make into a macro..
Any suggestions?
Thanks
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
nope, the preprocessor isn't that capable.
but, take a look here: http://www.codeproject.com/string/CXR.asp
i wrote a little system to do string encryption as part of the build process (roughly similar to your table generation). what i do is add a file to the project that causes VC to do a pre-build step. that pre-build step generates a source file (by calling off to a separate EXE), which is then compiled into the app.
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Seems like a reasonable solution.
Joaquín M López Muñoz also had an interesting suggestion. I'll first take a shot at template metaprogramming (I like to try out concepts new to me), but if that
fails I'll go with a pre-build step.
Thanks
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
If the function is not very complex, you can convert it to a constant-time template by using a technique called template metaprogramming. If you post the code maybe I can help you with it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks!
Googled for the term and found some nice pages. I'll try to do the conversion myself first - it will be a nice introduction to the concept. But I hope you don't
mind if I ask you for help if I get stuck...
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
Good luck. TMP is an amazing technique, if difficult to tackle at first. Don't hesitate to ask for help.
PS: If you're succesful, your case could be a nice introduction article to this technique here in CP.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
how do you do this?? When i make dialog boxes they minimize right above the taskbar as opposed to minimizing into the taskbar with the parent application... Do you have to change the owner of the dialog boxes?? When you call AFXMESSAGEBOX("") that dialog that is created gets put into the taskbar.. So i am asuming that when a window is created whos owner is the main application, it gets put into the taskbar upon minimization - but when a dialog is created as a child, it minimizes right above the taskbar. Ive asked this quesiton before and had no answers - has anyone had this problem before?? Can someone at least point me where to look for the answer?
thanks
-kevin
|
|
|
|
|
am i explaining myself correctly????????????????????????????????
does anyone have anyclue??
|
|
|
|
|
When you create an instance of the dialog, do you pass it a pointer to it's parent window? i.e.
CMyDialog dlg(this);
dlg.DoModal();
This may help if you're not doing it already
-Alex
|
|
|
|
|
hello @all,
i would like to build a hyperterminal into a mfc program (after i pressed a button, the hyperterminal is to appear).
how can that be done?
thank you very much
sunny
|
|
|
|
|
Try using this code:
<br />
::ShellExecute(0,0,"hypertrm.exe",0,0,SW_SHOW);<br />
|
|
|
|
|
Hmmm,
Can somebodu please help me!
Well here is the story.
In my *.h file i #include <windows.h> if i remove this or #include "stdafx.h" I get this error.
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
in one of my *.h file i use CString and must #include <afx.h> or #include "stdafx.h" but when i do that i get this error what should I do?
Please help me.
\Larsson
|
|
|
|