|
This is mostly done in the OnCtlColor handler. For example:
<br />
BEGIN_MESSAGE_MAP(CDummyDlg, CDialog)<br />
...<br />
ON_WM_CTLCOLOR()<br />
END_MESSAGE_MAP()<br />
<br />
HBRUSH CDummyDlg::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )<br />
{HBRUSH hbr = CDialog::OnCtlColor(pDC,pWnd,nCtlColor); <br />
pDC->SetTextColor(RGB(255,0,0));<br />
return hbr;<br />
}<br />
This will tell every control in the dialog (who are kind enough to ask) to paint text red. Check nCtlColor if you want the color to go somewhere special. If you want another backcolor, this is also the place to go. Make the return value into the desired brush.
/moliate
|
|
|
|
|
The simple answer is that none of that stuff will let you change text colour in a console app. That's why Bill invented Windows!
|
|
|
|
|
Hi.
I began learning and practice MFC three months ago. The first month was the toughest because I was down right lost after reading the first nine chapters from Prosise's book. However, everything changed after I first studied from Richand Jones' introduction to MFC. Everything Prosise discusses became clear and only now do I begin to appreciate the information Prosise offers in his book.
Next, I would like to move on to more specific tools i.e. networking or COM. I have no experience with COM and networking programming using C++. My ultimately goal, however, is to design and implement network programs such as an ftp server (my dream).
What is there after MFC? I am an MFC beginner, but I have confident I can work with the tools MFC offers relatively well.
I am very interested in networking programming, but COM is something that is quite popular. I saw good review on C++ Networking Programming Volumn 1 by Douglas C. Schmidt, Stephen D. Huston. What do you recommend? As for COM, I am not sure where to start. Nonetheless, COM is something I want to consider, if not now, then after networking.
Thanks,
Kuphryn
|
|
|
|
|
I'd recommend COM, because it will give you a chance to break free of MFC and learn how to live without it. Not that MFC in inherently bad, but it would be bad to find yourself tied to it. Johnothan Bates 'Building Lightweight Components Using ATL' is the best book I found for learning COM.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Okay. Thanks.
To this day I do not and cannot understand why some many programmers dislike MFC.
Kuphryn
|
|
|
|
|
yer i like it...i think its the "purists"
bryce
|
|
|
|
|
take this into consideration: there are far more help available to MFC programming and such a wonderful forum to turn to when there is any problem, I would say that I like MFC better.
|
|
|
|
|
Okay.
I decided on a network programming book.
I placed on order for this:
Network Programming for Microsoft Windows, Second Edition
by Anthony Jones.
I have considered C++ Network Programming Volume 1 by Douglas C. Schmidt and Stephen D. Huston. However, in the end I decided to go with Networking Programming for Microsoft Windows, Second Edition because my primary objective is to design and implement Windows programming using C++. I believe Jones' book will become invaluable for Windows applications.
Kuphryn
|
|
|
|
|
I have a tree control that works fine. When it reads from a file to get info it has been able to successfully get about 80( the highest i have that doesnt crash) pieces of info without freezing. However, I have 3 files that have about 200-300 pieces of info and if I try to open those it freezes up. Is this because of the large amount of info being stored in the tree or is it just another example of my bad programming skills?
-Raffi
|
|
|
|
|
I don't think TreeView is the reason.. maybe if you post some code.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
This definitely isn't a tree control problem. You can get 100,000+ items in a tree control, but I wouldn't recomend it.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
"In CEdit::OnCtlColor you can change text,backgroud color of control". <- Good idea ! But if edit has WS_DISABLED then calling CDC::SetTextColor member function you change nothing
Have anyone solution to change text color of edit while is in disable-state ??
Thanks
Wiizi
|
|
|
|
|
Are you calling this in OnCtlColor(...)?
Try call it in there, because I'm sure it's in there you're going to add it if you want to change color even if it has WS_DISABLED style!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
I think you have to do some custom painting in the disabled case. In disabled mode a CEdit uses CDC::GrayString or something like that to draw the text. OnCtlColor is not even called.
On the other hand this might confuse your users. Really need to do it?
/moliate
|
|
|
|
|
Thanks, perhaps I'll use another way to do this .
Wiizi
|
|
|
|
|
Hey~
How do you add a control to the main menu in an MFC app?
Example:
______________________________________________________
|[] My App _ [] X |
______________________________________________________
| |
| File Edit Help [control here] |
| |
|_____________________________________________________|
| |
| Toolbar here |
|_____________________________________________________|
I have no problem adding a control to the end of the toolbar... I just locate the proper coordinates and MoveWindow(). I tried that approach to display it over the menu at the right hand side (see above), but it won't display correctly... it's as if the menu is repainting itself over the control. The toolbar doesn't repaint itself over the control, though.
Thanks in advance!
thundercatzlair
|
|
|
|
|
There is an article here on CP in how to do that... sorry to give you the big job to find it!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
I am very puzzled by this one. Previously, when one wanted to have a custom enum in the typelib, he simply put it in the library section of the idl file:
library SomeLib
{
typedef enum { someval } MyEnum;
}
and voila.
But with VC.NET, and attributed C++, how do you do that??? I tried the following:
[module .....];
[export, public]
typedef enum { someval } MyEnum;
but the declaration is not part of the typelib, since it is before the library statement in the generated idl file.
Anyone have tried this before? Is it still possible to do it? Do I have to switch back to non-attributed C++???
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I wrote some nice code listening to him. You can't write code to the new crap that comes out these days.
|
|
|
|
|
|
Mike Nordell wrote:
42
43
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Mazdak wrote:
43
No, 42! It could also be three, seven or 4711, but never 43.
Btw, who was "Stale Laney"? The answer to OP's post would probably be "we all die, that's the only thing that's absolute", possibly with the addition "that's the only thing we humans have to look forward to".
|
|
|
|
|
The singer from Alice in Chains. As a person from a generation earlier, I'm of the opinion he's one of the people who *destroyed* rock music. It's still a shame he died so young though.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
The singer from Alice in Chains. As a person from a generation earlier, I'm of the opinion he's one of the people who *destroyed* rock music.
OK, then he's probably a generation or two after me (and you'd be, like, 10 years now Christian? ).
If he destroyed rock music, I'd love to know why e.g AC/DC, Sabbath, Manowar ... are still on my playlists when I go into "serious hacker" mode. That's not destroyed and never will be!
|
|
|
|
|
Mike Nordell wrote:
If he destroyed rock music, I'd love to know why e.g AC/DC, Sabbath, Manowar ... are still on my playlists when I go into "serious hacker" mode. That's not destroyed and never will be!
You and I may be waving the flag, but while ACDC & Sabbath can still fill stadiums, the same is not true of most bands from those eras.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|