Click here to Skip to main content
15,923,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to detect GDI resource leak? Pin
bektek28-Oct-04 5:48
bektek28-Oct-04 5:48 
AnswerRe: How to detect GDI resource leak? Pin
David Crow28-Oct-04 6:30
David Crow28-Oct-04 6:30 
Generalapp's memory usage Pin
bektek28-Oct-04 5:45
bektek28-Oct-04 5:45 
GeneralRe: app's memory usage Pin
David Crow28-Oct-04 6:26
David Crow28-Oct-04 6:26 
GeneralRe: app's memory usage Pin
bektek28-Oct-04 9:15
bektek28-Oct-04 9:15 
GeneralRe: app's memory usage Pin
David Crow28-Oct-04 10:49
David Crow28-Oct-04 10:49 
GeneralWriting to an XML file Pin
wcovuaku28-Oct-04 5:39
wcovuaku28-Oct-04 5:39 
GeneralPlease Help: Driving me crazy..... Pin
...---...28-Oct-04 4:43
...---...28-Oct-04 4:43 
Here I have two problems, I only have two classes, an App and a Window.

1. I want each LETTER a different (random(switch)) color.

2. I don't want the color to change when I resize the Client Area (which it does now...)

All that happens now is that the first letter prints off the M.I.L. ("abc")
or the two menu items ("Katie", "Anna") in a diferent color...

Where have I gone wrong?

-thanks a lot



//////////////////////////////////////////////////////////////////////////////
#include <afxwin.h>
#include <cstdlib>
#include <cstdlib>
#include <ctime>
#include ".\katieapp.h"
#include ".\ckatiewin.h"
#include ".\resource.h"

CKatieWin::CKatieWin(void): m_sText("abc"), m_crColor(RGB(0,255,0))
{
Create (NULL, _T("Katie App"), WS_OVERLAPPEDWINDOW,
rectDefault, NULL, MAKEINTRESOURCE(IDR_MENU1));
CDC* pDC = GetDC();
pDC->SetBkMode(TRANSPARENT);
UpdateWindow();

}


CKatieWin::~CKatieWin(void)
{

}

BEGIN_MESSAGE_MAP(CKatieWin, CFrameWnd)
ON_WM_PAINT()
ON_COMMAND(ID_FILE_EXIT, OnFileExit)
ON_COMMAND(ID_FILE_ABOUT, OnFileAbout)
ON_COMMAND(ID_PERSON_KATIE, OnPersonKatie)
ON_COMMAND(ID_PERSON_ANNA, OnPersonAnna)
END_MESSAGE_MAP()

void CKatieWin::OnFileExit()
{
DestroyWindow();
}


void CKatieWin::OnFileAbout()
{
MessageBox("Copyright: Skunked Works 2004", "Katie App", MB_ICONEXCLAMATION);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////// MY GUESS IS THAT THE PROBLEM IS HERE SOMEWHERE..!!
void CKatieWin::OnPaint()
{

CPaintDC dc(this);
CRect rect;

CFont font;
font.CreatePointFont(2000, _T("Arial"));
dc.SelectObject(&font);
dc.SetBkColor(::GetSysColor(COLOR_WINDOW));
GetClientRect(&rect);

for(int i = 0; i < m_sText.GetLength(); i++)
{
CKatieWin::SetTextClr();
dc.SetTextColor(GetTextClr());
//dc.DrawText(m_sText[i], rect, DT_SINGLELINE);

dc.TextOut((i+1)*200, 0, m_sText.GetAt(i));
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////

TCHAR CKatieWin::GetText(int i)
{
TCHAR c = m_sText.GetAt(i);
return c;
}


void CKatieWin::SetText(CString _m_sText)
{
m_sText = _m_sText;
}

void CKatieWin::OnPersonKatie()
{
SetText("Katie");
Invalidate();
}

void CKatieWin::OnPersonAnna()
{
SetText("Anna");
Invalidate();
}


void CKatieWin::SetTextClr(void)
{
srand((unsigned)time(NULL));

int j;
j = rand() % 3;
switch(j)
{
case 0:
m_crColor = RGB(0,0,255);
break;

case 1:
m_crColor = RGB(0,255,0);
break;

case 2:
m_crColor = RGB(255,0,0);
break;
}
}

COLORREF CKatieWin::GetTextClr(void)
{
return m_crColor;
}
GeneralRe: Please Help: Driving me crazy..... Pin
Maximilien28-Oct-04 5:13
Maximilien28-Oct-04 5:13 
GeneralRe: Please Help: Driving me crazy..... Pin
Anonymous28-Oct-04 5:41
Anonymous28-Oct-04 5:41 
Generalhelp! Can't BitBlt! Pin
sagmam28-Oct-04 4:17
sagmam28-Oct-04 4:17 
GeneralRe: help! Can't BitBlt! Pin
Antony M Kancidrowski28-Oct-04 5:03
Antony M Kancidrowski28-Oct-04 5:03 
GeneralC library and C++ application Pin
[CoY0te]28-Oct-04 3:28
[CoY0te]28-Oct-04 3:28 
GeneralRe: C library and C++ application Pin
Blake Miller28-Oct-04 7:05
Blake Miller28-Oct-04 7:05 
GeneralRe: C library and C++ application Pin
John R. Shaw28-Oct-04 7:05
John R. Shaw28-Oct-04 7:05 
GeneralRe: C library and C++ application Pin
[CoY0te]29-Oct-04 0:59
[CoY0te]29-Oct-04 0:59 
Questionhow to assign a specific ip address to server and client Pin
syaks28-Oct-04 2:19
syaks28-Oct-04 2:19 
Questionget the actual selected file in windows explorer??? Pin
mightyCoCo28-Oct-04 2:18
mightyCoCo28-Oct-04 2:18 
AnswerRe: get the actual selected file in windows explorer??? Pin
David Crow28-Oct-04 3:55
David Crow28-Oct-04 3:55 
GeneralRe: get the actual selected file in windows explorer??? Pin
mightyCoCo28-Oct-04 4:17
mightyCoCo28-Oct-04 4:17 
GeneralRe: get the actual selected file in windows explorer??? Pin
David Crow28-Oct-04 5:17
David Crow28-Oct-04 5:17 
GeneralRe: get the actual selected file in windows explorer??? Pin
mightyCoCo28-Oct-04 23:43
mightyCoCo28-Oct-04 23:43 
GeneralRe: get the actual selected file in windows explorer??? Pin
mightyCoCo29-Oct-04 0:19
mightyCoCo29-Oct-04 0:19 
QuestionHelp For Memory Leak ? Pin
Amarelia28-Oct-04 1:51
Amarelia28-Oct-04 1:51 
AnswerRe: Help For Memory Leak ? Pin
jmkhael28-Oct-04 2:56
jmkhael28-Oct-04 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.