Forming Grid using Rectangles
-
Hi Folks! I have got a problem hope you people will definately help me.. The problem is i want to display a Grid on screen (MFC App Wizard Application), i did the following i.e. Draw severel Rectangles to accomplish the grid like look. The rectangls are drawn with white 'in' and black 'outer boundry' [code] void CSimulationView::OnDraw(CDC* pDC) { //Display Squares of width and height 40x40 int x1 = 0 ; int y1= 0; for(int i=0; i < 12; i++ ) { for(int j=0; j < 19; j++ ) { pDC->Rectangle(x1,y1,x1+40,y1+40); x1+=40; } x1=0; y1+=40; } } [/code] The question is how i can change the color of, in of the rectangle and outer boundry(say in color is red and outer boundry color is cyan). One thing more how to fix the size of my display window.i.e. i want my display window to be 700 pixels wide and 500 pixel high,i.e. user can only minimize or see the window in (700,500) size, he can not resize the display windows.. Hope you prople will sort out my problem.. Reagards, Jinbaba
-
Hi Folks! I have got a problem hope you people will definately help me.. The problem is i want to display a Grid on screen (MFC App Wizard Application), i did the following i.e. Draw severel Rectangles to accomplish the grid like look. The rectangls are drawn with white 'in' and black 'outer boundry' [code] void CSimulationView::OnDraw(CDC* pDC) { //Display Squares of width and height 40x40 int x1 = 0 ; int y1= 0; for(int i=0; i < 12; i++ ) { for(int j=0; j < 19; j++ ) { pDC->Rectangle(x1,y1,x1+40,y1+40); x1+=40; } x1=0; y1+=40; } } [/code] The question is how i can change the color of, in of the rectangle and outer boundry(say in color is red and outer boundry color is cyan). One thing more how to fix the size of my display window.i.e. i want my display window to be 700 pixels wide and 500 pixel high,i.e. user can only minimize or see the window in (700,500) size, he can not resize the display windows.. Hope you prople will sort out my problem.. Reagards, Jinbaba
jinbabaj wrote: The question is how i can change the color of, in of the rectangle and outer boundry(say in color is red and outer boundry color is cyan). The outline is drawn with the current pen, and the inside is filled with the current brush, so to change the colours, select a different pen and brush into the device context using SelectObject().
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"
-
Hi Folks! I have got a problem hope you people will definately help me.. The problem is i want to display a Grid on screen (MFC App Wizard Application), i did the following i.e. Draw severel Rectangles to accomplish the grid like look. The rectangls are drawn with white 'in' and black 'outer boundry' [code] void CSimulationView::OnDraw(CDC* pDC) { //Display Squares of width and height 40x40 int x1 = 0 ; int y1= 0; for(int i=0; i < 12; i++ ) { for(int j=0; j < 19; j++ ) { pDC->Rectangle(x1,y1,x1+40,y1+40); x1+=40; } x1=0; y1+=40; } } [/code] The question is how i can change the color of, in of the rectangle and outer boundry(say in color is red and outer boundry color is cyan). One thing more how to fix the size of my display window.i.e. i want my display window to be 700 pixels wide and 500 pixel high,i.e. user can only minimize or see the window in (700,500) size, he can not resize the display windows.. Hope you prople will sort out my problem.. Reagards, Jinbaba
Sizing - Read about WM_GETMINMAXINFO The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.
-
Hi Folks! I have got a problem hope you people will definately help me.. The problem is i want to display a Grid on screen (MFC App Wizard Application), i did the following i.e. Draw severel Rectangles to accomplish the grid like look. The rectangls are drawn with white 'in' and black 'outer boundry' [code] void CSimulationView::OnDraw(CDC* pDC) { //Display Squares of width and height 40x40 int x1 = 0 ; int y1= 0; for(int i=0; i < 12; i++ ) { for(int j=0; j < 19; j++ ) { pDC->Rectangle(x1,y1,x1+40,y1+40); x1+=40; } x1=0; y1+=40; } } [/code] The question is how i can change the color of, in of the rectangle and outer boundry(say in color is red and outer boundry color is cyan). One thing more how to fix the size of my display window.i.e. i want my display window to be 700 pixels wide and 500 pixel high,i.e. user can only minimize or see the window in (700,500) size, he can not resize the display windows.. Hope you prople will sort out my problem.. Reagards, Jinbaba
Use class CPen to create a cyan pen,such as: CPen newPen(PS_SOLID,1,RGB(...)); Then select it to DC by call SelectObject of CDC. Use class CBrush to create a red brush,such as: CBrush brush(RGB(255,0,0)); Then select it to DC by call SelectObject of CDC. Now it will be correct. Jack --------------------------------------------------------------------------------- XD++ MFC/C++ Flow/Diagram Library -- http://www.ucancode.net