|
The first program I wrote to flex my newly acquired
programming skills many years ago was a numerical
version of the board game Mastermind :
http://www.archimedes-lab.org/mastermind.html[^]
using four-number sequences instead of colored pegs
for the "code".
I actually wrote this program in Basic, on paper,
after reading the first chapter or so of a book
whose title I've forgotten and before buying my
first computer. It ran to hundreds of lines of code.
After buying my Specravideo with 64kb of memory I
typed it in over three evenings and it ran first
time!
I later read a few more chapters of the book and
realized that I'd missed a rather important property
of "variables": I hadn't realized you could change
their value after initially assigning a value to them!
Armed with this new revelation I managed to trim my
Mastermind code down to about 40 lines.
The second program I wrote was a version of
John Conway's "The Game of Life".
http://www.math.com/students/wonders/life/life.html[^]
A good one for learning about data structures.
You could implement it as an 2-dimensional array of
check-boxes on a dialog box if you're not yet
into graphics programming.
I think both these programs would still make
pretty good beginner exercises.
Steve T
|
|
|
|
|
How about something like:
TempToFahrenheit( const double dCelcius )
{
}
TempToCelcius( const double dFahrenheit )
{
}
void main( void )
{
double dFahrenheit = TempToFahrenheit(29.2);
double dCelcius = TempToCelcius(120);
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Linked lists are always nice to fool around with.
You could create a linked list, let some user type strings, numbers or whaterver in the console, so you can add them to the list. Than you can sort it, delete items from it, and all the other things you'll do in your future career
If you'll choose to do this, you'll learn an awfull lot about memory management and pointers.
I also got the blogging virus..[^]
|
|
|
|
|
|
Hi ,
I utilize Visual C++ .NET 2003 in my project.
I have a class with a few methods. I have to delete one of these methods.
In the Class View I have selected the method to suppress.
I have tried with the del key of the numeric keypad without success. I have tried with the contextual menu but the delete option is not present.
How can I delete a method of a class with Visual C++ .NET 2003 ?
Claude
|
|
|
|
|
|
Do you think he was serious ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I change the foreground color of an edit control?
And is there a simple algorithm to determine if two colors have enough "contrast" to be distinguishible?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
peterchen wrote:
How can I change the foreground color of an edit control?
handle WM_CTLCOLOR message and call SetTextColor() on the supplied DC.
peterchen wrote:
And is there a simple algorithm to determine if two colors have enough "contrast" to be distinguishible?
I don't know about a simple algorithm, but it seems to me that the user should be able to set those kind of things for themselves, as people can have different perceptions as to what colours contrast and what colours do not. Have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnhess/html/hess10092000.asp[^].
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
handle WM_CTLCOLOR message and call SetTextColor() on the supplied DC.
That should work
PJ Arends wrote:
but it seems to me that the user should be able to set those kind of things
It is just an additional visual cue, and I'd rather disable it than making it an option. The basic idea is to disable it when COLOR_WINDOW is anything else but white, but I'd like to be more tolerating.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
|
|
peterchen wrote:
And is there a simple algorithm to determine if two colors have enough "contrast" to be distinguishible?
Yes there is, but I can't remember it or find it right now. I know one exists though. I think it was something like calculating the luminance of the two colours (HSL colour model...) and making sure the the difference between the two was above some threshold, or something like that.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I think it was a Paul Dilascia article that used this technique.
I used it in his folder tab class so that it would toggle the text color between black and white based on the color the user selects for the background color. (similar to what Excel does) I couldn't find the Dilascia article that used the code, but I still have the code kicking around in an old project:
<br />
int AfxGetLuminosity(COLORREF color)<br />
{<br />
<br />
const int HLSMAX = 240;<br />
const int RGBMAX = 255;<br />
<br />
int nRed = GetRValue(color);<br />
int nGreen = GetGValue(color);<br />
int nBlue = GetBValue(color);<br />
<br />
int nRGBMax = max(max(nRed, nGreen), nBlue);<br />
int nRGBMin = min(min(nRed, nGreen), nBlue);<br />
<br />
return (((nRGBMax + nRGBMin) * HLSMAX) + RGBMAX) / (2 * RGBMAX);<br />
}<br />
In the folder tab drawing function I have:
<br />
COLORREF crText = ((AfxGetLuminosity(m_color) > 120) ? RGB(0,0,0) : RGB(255,255,255));<br />
where m_color is the background color. I seem to remember it not being 100% fullproof, and that asking in the newsgroups resulted in a "there is no sure fire method" answer.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
I have an MFC ActiveX Full Control.
When modifying the appearance through member functions, an Invalidate() on the control (or the respective child windows) updates the control only if it has the focus.
Without focus, I'm pretty much "grounded": simulating a resize helps, but that's not really efficient.
Any idea?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
How about using RedrawWindow()? Invalidate() only invalidates the window (hence the name), but it will not redraw the window until it recieves a WM_PAINT message. RedrawWindow() invalidates the window and forces a WM_PAINT message to be sent.
[edit]
If you use the RDW_UPDATENOW flag.
[/edit]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
this doesn't work either (I think, I just killed my test case )
Further, I don't want to force a cmplete redraw each time, as there might be an otside loop over all displayed items (flicker galore)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
peterchen wrote:
updates the control only if it has the focus
Perhaps there's a bug in the control's painting logic? (It should paint the control regardless of whether or not it has focus).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It is painted completely by a child control (which contains more child windows)
Basically, I'm wrapping an MFC CWnd-based conrol in an ActiveX
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Fair enough, but perhaps the CWnd -derived object's painting logic is flawed (i.e. it paints only if it has focus)? This is just a guess.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Fair enough but ( ) this isn't the problem, calling Invalidate does not result in an WM_PAINT message when the control has no focus.
I *think* it has to do something wiht the activation state of the control, but I'm not fluent enough with the full control COM interfaces (which IMO is a mess), nor the MFC wrappers.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I think the answer may lie in calling COleControl::InvalidateControl() . See this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ah thanks! this looks more like it - will try tomorrow!
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hi all,
I want to disable functionality of mouse wheel in my application. I don't want the front end's scrollbars to scroll if user uses the mouse wheel.
Does any one how to do that. I would sincerely appreciate your help.
Thanks,
Kalyan
|
|
|
|
|
I'm curious why you would want to do that. The user has come to expect certain actions when the mouse wheel is used. For those actions to be different or non-existent in your application would seem a bit counterintuitive.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|