|
Certainly! The Mid() function has two overloads. In both cases, the first parameter is the starting index of the substring. If you pass a second parameter, it is the count of characters in the substring to return. Or if only one integer is passed, the remainder of the string is returned.
Scot Brennecke
Software Developer
VC++ MVP
|
|
|
|
|
|
|
How to change the caption for a STATIC control under a dialog box with codes? I've try sending WM_SETTEXT to the STATIC's wndhandle (obtain from ::GetDlgItem)... but it does nothing.
|
|
|
|
|
Oh. Thanks anyway. I've tested that out. We need to SET it after ShowWindow... *sigh*... is it true?
|
|
|
|
|
No, that isn't true. But you should use SetWindowText instead of WM_SETTEXT.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Yep.. I did that (both SetWindowText and WM_SETTEXT)... but no text is changed.... if I set it between Create and ShowWindow, nothings happen.
But if I set it after ShowWindow, yes it works!
And btw, I'm using the old MFC 4.21 (i.e. from VC++ 97)
|
|
|
|
|
You can associate a dialog class member with the static control. But you need to change the default control id of the static control for that.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
I already change the default id to something else (e.g. IDC_SOMEDIALOG_LABEL)
|
|
|
|
|
Hi. I am also new in templates. I wrote a template class:
template<class t=""> class CExample
Now, I asked this before but am really confused.
I know that to declare it I do:
CExample<class t=""> m_Example;
What if I want to do this using "new"?
Is it
CExample<uint>* m_pExample;
m_pExample = new CExample<uint>;
Something like this???
Then to clean up:
delete m_pExample; (Anything special)
THanks in advance.
|
|
|
|
|
You need to check the "Display as-is" checkbox so the template params show up properly.
Given this class:
template <class T> class CExample
{
public:
T increment(T t) { return ++t; }
}; you refer to the class later with CExample plus a typename which takes the place of T :
CExample<int>* pExampleInt = new CExample<int>();
pExampleInt->increment ( 123 );
delete pExampleInt;
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi Mike.
What do you mean by "Display as is?"
|
|
|
|
|
The checkbox below your post as you type it which says "Display this message as-is (no HTML)"
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Hi all,
Can I rotate a CDialog (andd all its controls 90degrees (or 270 for that matter)?
How? Is it a matter of rotating the CDialog and then all controls within it will follow or do I have to do it one control at a time?
Don't ask why and , but can I do it?
TIA, Jose
|
|
|
|
|
No.
Well, yes, you can if you handle all the drawing yourself (and now we're speaking all NC painting also), intercepting and changing x&y mouse positions and so on.
But short of that? No. It would be easier to turn the screen 90 degrees to be unable to read it normally.
I won't ask "why angry and confused" (whatever that means).
|
|
|
|
|
Theoretically, you can draw anything on your screen, just derive your own dialog class from CDialog and override all the painting related methods.
|
|
|
|
|
I have seen many documentations on cutting, copying, pasting, filenames to and from Explorer into an App... but I do not understand how it is done. I am looking for source code to demonstrate it. If someone could please point me in the right direction, coded samples would be a great help. Thank you.
<><><><><><><><><><><><><><>
Matthew R. Miller
mattrmiller@computersmarts.net
www.computersmarts.net
|
|
|
|
|
Check out my article on drag & drop in the Shell section - it uses the same data format (DROPFILES) as copy/paste.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Ok, I'm a newbe when it comes to templates, even though I've been programming C/C++ for over 25 years. I just havn't gotton around to learning templates.
What I want to do is write a template string class that supports either char* and wchar_t* (but not necessarily at the same time). I know I can do this:
template<class type="">
class UStringT
{
public:
UStringT() { sptr = NULL; }
~UStringT() {if(sptr) delete[] sptr;}
TYPE c_str() {return sptr;}
void operator=(TYPE* string);
private:
TYPE* sptr;
};
So far, so good. Now the hard part -- how to use standard C/C++ library functions functions: for example, if I want the length of the string, it needs to call strlen() it TYPE is char*, or wcslen() if TYPE is wchar_t*. How do I put that logic in the template?
** This does NOT work ***
If TYPE == char
return strlen(string)
else if TYPE == wchar_t
return wcslen(string);
|
|
|
|
|
why are you not using std::string, which does all of this ?
Anyhow, the answer is template specialisation. You can write a length function defined differently for different values of TYPE.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Thanks for the tip, Chris. I didn't know std::string could be used that way. This seems to work the way I want it to:
typedef basic_string<char> charA;
typedef basic_string<wchar_t> charW;
template<class TYPE>
class UStringT
{
public:
UStringT() { }
~UStringT() {}
const TYPE& c_str() {return sptr;}
void operator=(TYPE strng);
int length() {return sptr.length();}
private:
TYPE sptr;
};
int foo()
{
UStringT<charA> string1A;
UStringT<charW> string1W;
string1A = "Hello World";
string1W = L"Hello World";
return 0;
}
|
|
|
|
|
Yes, that is exactly how std::string works. Your class is superfluous, the two typedefs give you a wide and a narrow string. I believe there is a std::stringW ( or similar ) as well as std::string providing typedefs for the two templated types of std::basic_string already.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
That reminds me of one of my favorite "neat trick" macros:
typedef std::basic_string<TCHAR> tstring;
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
> template specialisation
is this thing supported in vc++...I remember people complaining the lack of it et al
Kannan
|
|
|
|
|
Specialization is (partially) supported. Partial specialization is however explicitly not supported at all, even in VC7.
|
|
|
|