Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Forming Grid using Rectangles

Forming Grid using Rectangles

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++csstutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jinbabaj
    wrote on last edited by
    #1

    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

    R B U 3 Replies Last reply
    0
    • J jinbabaj

      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

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      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"

      1 Reply Last reply
      0
      • J jinbabaj

        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

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • J jinbabaj

          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

          U Offline
          U Offline
          ucc801
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups