|
If you look at the documentation of CWnd::Create[^] you will see that the first parameter of Create must be either NULL or a name that is registered using the AfxRegisterWndClass function or one of the predetermined class names.
Try this -
int ret = pRulerX->Create(0, "rulerx", WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), this, 55355);
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
It works. Thank you so much.
|
|
|
|
|
Hello everybody,
My question is if it is possible for a MFC application to use a theme, different from the theme of the Windows itself e.g the application to use "Windows XP" theme (or some modified theme) and the Windows to use "Windows Classic" theme. If there is some way of doing that I would appreciate a clue or two =].
Greetings, Peter
|
|
|
|
|
There are a lot of samples in codeproject talking about this topic. Just search for it using key word "theme".
VS 2008 can generate this type of application.
|
|
|
|
|
I know how to access system Image list using this function
HIMAGELIST GetSystemImageListOfSmallIcons()const {
HIMAGELIST himl;
SHFILEINFO sfi;
himl = (HIMAGELIST) (::SHGetFileInfo( _T(""), 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_SMALLICON));
return himl;
}
but is there any way ,that i could access to special icons like "My Document" Folder icon or "Contacts" Folder Icon or even "My Computer" Icon of the operating system.
|
|
|
|
|
Hmm, maybe try with SHGetFileInfo[^] along with SHGetFolderLocation[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
So would you suggest a code which I could get My computer Icon or My network places Icon?
|
|
|
|
|
This should get you the MyComputer icon:
HICON GetMyComputerIcon()
{
HICON Icon = NULL;
LPITEMIDLIST IDPath;
if (SUCCEEDED(SHGetFolderLocation(m_hWnd, CSIDL_DRIVES, NULL, 0, &IDPath)))
{
SHFILEINFO Info = {0};
if (SHGetFileInfo((LPCTSTR)IDPath, 0, &Info, sizeof(Info), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_PIDL)) Icon = Info.hIcon;
ILFree(IDPath);
}
return Icon;
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
|
Ah, and one more thing, don't forget to delete the icon if you are done with it.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I'm sure you all know about how to overload the left-shift operator for an std::ostream in order to output the contents of a class's members using the familiar cout syntax. A refresher for those who dont;
inline friend std::ostream &operator <<(std::ostream &os, const myClass &rhs)
{
os << rhs.someMember;
return os;
}
And of course, to use this operator we simply do the following;
myClass foo;
std::cout << foo;
Now, I'm working with stringstreams and need to be able to output in a similar manner, however I can't for the life of me figure out how to get the same behaviour out of stringstreams. The code I'm trying simply won't work.
inline friend std::stringstream &operator <<(std::stringstream &ss, const myClass &rhs)
{
ss << rhs.someMember;
return ss;
}
I then do the following;
myClass foo;
std::stringstream ss;
ss << foo;
This gives me the compiler error (when attempting to use said operator) - error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'myClass' (or there is no acceptable conversion)
If that's not the correct syntax, then what is? Is it possible to do at all?
|
|
|
|
|
Sauce! wrote: inline friend std::stringstream &operator <<(std::stringstream &ss, const myClass &rhs)
Remove the friend qualifier.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thanks, that fixes it.
I'm curious though, why does the exact same syntax work for the ostream and not for the stringstream? The ostream function is declared within the class as a friend, so why can't the stringstream one?
edit: it appears I can't use this code to chain insertions of different types either - I get the same compile error again if I attempt to do the following;
myClass foo;<br />
std::stringstream ss;<br />
ss << "foo: " << foo;
That syntax works perfectly fine though with the ostream overload.
modified on Thursday, October 8, 2009 11:54 PM
|
|
|
|
|
Sauce! wrote: edit: it appears I can't use this code to chain insertions of different types either - I get the same compile error again if I attempt to do the following;
You might also have to provide:
std::stringstream &operator <<( std::stringstream &ss, const char *str )
{
ss << str;
return ss;
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
could you tell me how we get data from ms access database and display it in the listbox?
|
|
|
|
|
You could use CDatabase[^] class if you were using MFC. Search this site. There are plenty of examples.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
See rather Microsoft samples from SDK
|
|
|
|
|
Hi
I have an API function call that asks to send a TCHAR* as an argument and it will return a string on the TCHAR*
Instead of sending a TCHAR* i send it as a char array, like this
char array[12];
Now when i debug and look at it, i see
array[0] = A
array[1] = 0
array[2] = B
array[3] = 0
array[4] = C
array[5] = 0
So if am expecting an output string of "ABC". What am seeing is, everyother index in the array is set to "0".
Why's this happening?
Is it a problem with using char array in place of TCHAR?
How to use the TCHAR?
|
|
|
|
|
You should zero-terminate the string, I suppose, i.e.
array[6] = 0
array[7] = 0
Nevermind, I was a it hasty.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Thursday, October 8, 2009 1:55 PM
|
|
|
|
|
Not quite, he's sending a char* which gets filled with TCHARs. It's the old Unicode <--> ASCII confusion again! Do people not read the manuals anymore?
|
|
|
|
|
Richard,
Can you tell me how to fix this issue?
|
|
|
|
|
You're right, of course. Too much drugz, today...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Too much drugz, today
Luckeee!
|
|
|
|
|
When i try to write the "array" string into a file, all that it writes is "A", and its ignoring the remaining array indexes.
Can this be solved by null terminating?
How to do that?
|
|
|
|
|
dipuks wrote: Can this be solved by null terminating?
The short answer is, no!
You need to understand the difference between TCHAR (Unicode, 16 bit) and ASCII (8-bit) characters. You cannot store a TCHAR string into a char[] array and expect the program to make sense of it. From the small piece of code you posted you just need to define your array as TCHAR[] and use the appropriate function calls to process the text.
Take a look here in MSDN[^] for some more information.
|
|
|
|