Click here to Skip to main content
15,919,613 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CPen styles Pin
alex.barylski26-Jan-02 22:34
alex.barylski26-Jan-02 22:34 
GeneralYuck: Globals and Static Data Members Pin
Swinefeaster26-Jan-02 14:05
Swinefeaster26-Jan-02 14:05 
GeneralRe: Yuck: Globals and Static Data Members Pin
alex.barylski26-Jan-02 22:03
alex.barylski26-Jan-02 22:03 
GeneralRe: Yuck: Globals and Static Data Members Pin
Swinefeaster26-Jan-02 22:21
Swinefeaster26-Jan-02 22:21 
GeneralWaitForSingleObject Pin
Sergei26-Jan-02 14:02
Sergei26-Jan-02 14:02 
GeneralRe: WaitForSingleObject Pin
Not Active26-Jan-02 16:22
mentorNot Active26-Jan-02 16:22 
Generalgrid lines Pin
A_choo26-Jan-02 13:36
A_choo26-Jan-02 13:36 
GeneralRe: grid lines Pin
alex.barylski26-Jan-02 22:23
alex.barylski26-Jan-02 22:23 
I don't think there is a DrawGrid member function in the default CView class.

You'll have to write your own.

BOOL CTestView::DrawGrid(CDC* pDC, UINT nWidth, UINT nHeight, COLORREF clrGrid)
{
	CRect rcArea;	

	GetClientRect(&rcArea);

	HPEN hPen = CreatePen(PS_SOLID, 1, clrGrid);

	SelectObject(pDC->m_hDC, hPen);

	int x, y = 0;
	
	for(y=0; y<=rcArea.bottom; y+=nHeight)
	{
		pDC->MoveTo(x, y);
		pDC->LineTo(0, y);		
		for(x=0; x<=rcArea.right; x+=nWidth)
		{
			pDC->MoveTo(x, y);
			pDC->LineTo(x, 0);		
		}					
	}

	return TRUE;
}


Your gonna probably wanna tweak this. For example
becuz i don't use the CPen class(I dunno why, i just never do) I'm pretty sure your going to want to restore the original object in your selectObject, cuz it leaks and each time you call DrawGrid which is lots cuz it's called in OnDraw you'll leak and your GDI will go for sh*ts eventually.

Anyways hope this helps

LaterzSmile | :)

"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
GeneralRe: grid lines Pin
A_choo29-Jan-02 22:45
A_choo29-Jan-02 22:45 
GeneralPointer Validation dynamic_cast<> Pin
Swinefeaster26-Jan-02 12:32
Swinefeaster26-Jan-02 12:32 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Christian Graus26-Jan-02 13:33
protectorChristian Graus26-Jan-02 13:33 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster26-Jan-02 13:37
Swinefeaster26-Jan-02 13:37 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Christian Graus26-Jan-02 13:41
protectorChristian Graus26-Jan-02 13:41 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster26-Jan-02 13:56
Swinefeaster26-Jan-02 13:56 
GeneralRe: Pointer Validation dynamic_cast<> Pin
26-Jan-02 15:25
suss26-Jan-02 15:25 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster26-Jan-02 16:08
Swinefeaster26-Jan-02 16:08 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Andrew Peace27-Jan-02 0:50
Andrew Peace27-Jan-02 0:50 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster27-Jan-02 0:51
Swinefeaster27-Jan-02 0:51 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Jamie Hale28-Jan-02 5:17
Jamie Hale28-Jan-02 5:17 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster28-Jan-02 9:32
Swinefeaster28-Jan-02 9:32 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Matt Gullett26-Jan-02 14:25
Matt Gullett26-Jan-02 14:25 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster26-Jan-02 16:05
Swinefeaster26-Jan-02 16:05 
GeneralRe: Pointer Validation dynamic_cast<> Pin
26-Jan-02 16:45
suss26-Jan-02 16:45 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Swinefeaster26-Jan-02 16:54
Swinefeaster26-Jan-02 16:54 
GeneralRe: Pointer Validation dynamic_cast<> Pin
Tim Smith26-Jan-02 17:13
Tim Smith26-Jan-02 17:13 

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.