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. Scrollbars are shown incorrectly.

Scrollbars are shown incorrectly.

Scheduled Pinned Locked Moved C / C++ / MFC
wpfhelp
7 Posts 2 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.
  • N Offline
    N Offline
    Nikz2
    wrote on last edited by
    #1

    Hi. Well... I have a trouble with scrollbars. In my (developer) computer it all looks great! BUT in any other computer it looks incorrectly. The first time, when i create the window scrollbars are painted on the border of the dialog instead of the inside of the window. And when i resize it, it repaints the window correctly with the scrollbars inside. This i wrote in OnCreate

    this->EnableScrollBar(SB\_VERT);
    this->EnableScrollBar(SB\_HORZ);
    

    And this is at OnInit

     this->SetScrollRange(SB\_HORZ,0,2\*STARTPIXELX+MAPSQUARE\*FIELDSIZE);
     this->SetScrollRange(SB\_VERT,0,2\*STARTPIXELY+MAPSQUARE\*FIELDSIZE);
     
     SCROLLINFO info;
     info.cbSize = sizeof(info);     
         info.fMask = SIF\_ALL | SIF\_DISABLENOSCROLL;     //SIF\_ALL
         info.nMin = 0;     
         info.nMax = 2\*STARTPIXELY+MAPSQUARE\*FIELDSIZE; 
         CRect rr;
         this->GetClientRect(&rr);   
         info.nPage = rr.bottom-rr.top; 
         info.nPos = 0;    
         info.nTrackPos = 0; 
         SetScrollInfo(SB\_VERT,&info);
         info.nPage = rr.right-rr.left; 
         info.nMax = 2\*STARTPIXELX+MAPSQUARE\*FIELDSIZE; 
         SetScrollInfo(SB\_HORZ,&info); 
     this->ShowScrollBar(SB\_VERT);
     this->ShowScrollBar(SB\_HORZ);
    

    My dialog has application window, Overlapped, resizing border styles. Pls help!

    N 1 Reply Last reply
    0
    • N Nikz2

      Hi. Well... I have a trouble with scrollbars. In my (developer) computer it all looks great! BUT in any other computer it looks incorrectly. The first time, when i create the window scrollbars are painted on the border of the dialog instead of the inside of the window. And when i resize it, it repaints the window correctly with the scrollbars inside. This i wrote in OnCreate

      this->EnableScrollBar(SB\_VERT);
      this->EnableScrollBar(SB\_HORZ);
      

      And this is at OnInit

       this->SetScrollRange(SB\_HORZ,0,2\*STARTPIXELX+MAPSQUARE\*FIELDSIZE);
       this->SetScrollRange(SB\_VERT,0,2\*STARTPIXELY+MAPSQUARE\*FIELDSIZE);
       
       SCROLLINFO info;
       info.cbSize = sizeof(info);     
           info.fMask = SIF\_ALL | SIF\_DISABLENOSCROLL;     //SIF\_ALL
           info.nMin = 0;     
           info.nMax = 2\*STARTPIXELY+MAPSQUARE\*FIELDSIZE; 
           CRect rr;
           this->GetClientRect(&rr);   
           info.nPage = rr.bottom-rr.top; 
           info.nPos = 0;    
           info.nTrackPos = 0; 
           SetScrollInfo(SB\_VERT,&info);
           info.nPage = rr.right-rr.left; 
           info.nMax = 2\*STARTPIXELX+MAPSQUARE\*FIELDSIZE; 
           SetScrollInfo(SB\_HORZ,&info); 
       this->ShowScrollBar(SB\_VERT);
       this->ShowScrollBar(SB\_HORZ);
      

      My dialog has application window, Overlapped, resizing border styles. Pls help!

      N Offline
      N Offline
      Nikz2
      wrote on last edited by
      #2

      Well.. A found a solution.. I don't like it, but it works.

      void MainDial::OnTimer(UINT_PTR nIDEvent)
      {
      if (theApp.First)
      {
      CRect rr;
      this->GetWindowRect(&rr);
      rr.right-=1;
      rr.bottom-=1;
      MainDial::MoveWindow(rr);
      theApp.First=false;
      }
      }

      modified on Friday, October 23, 2009 6:53 PM

      _ 1 Reply Last reply
      0
      • N Nikz2

        Well.. A found a solution.. I don't like it, but it works.

        void MainDial::OnTimer(UINT_PTR nIDEvent)
        {
        if (theApp.First)
        {
        CRect rr;
        this->GetWindowRect(&rr);
        rr.right-=1;
        rr.bottom-=1;
        MainDial::MoveWindow(rr);
        theApp.First=false;
        }
        }

        modified on Friday, October 23, 2009 6:53 PM

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        You could put this in OnSize and check.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        N 1 Reply Last reply
        0
        • _ _Superman_

          You could put this in OnSize and check.

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          N Offline
          N Offline
          Nikz2
          wrote on last edited by
          #4

          The problem is that after OnSize it shows all correct, that's why i use MoveWindow in my timer. But my problem is how to make that right after OnInit it draws correctly? I resolved it only with timer... And by the way.. WHY it's all working on MY computer and on any other not?!?! (I have VS2008 SP1 and Windows XP SP3)

          _ 1 Reply Last reply
          0
          • N Nikz2

            The problem is that after OnSize it shows all correct, that's why i use MoveWindow in my timer. But my problem is how to make that right after OnInit it draws correctly? I resolved it only with timer... And by the way.. WHY it's all working on MY computer and on any other not?!?! (I have VS2008 SP1 and Windows XP SP3)

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            You can try another method. Create a custom message and map it to a handler using ON_MESSAGE[^]. In the OnInitDialog function to a PostMessage[^] for your custom message. In the message handler you could put the code that is in the timer.

            «_Superman_» I love work. It gives me something to do between weekends.
            Microsoft MVP (Visual C++)

            N 1 Reply Last reply
            0
            • _ _Superman_

              You can try another method. Create a custom message and map it to a handler using ON_MESSAGE[^]. In the OnInitDialog function to a PostMessage[^] for your custom message. In the message handler you could put the code that is in the timer.

              «_Superman_» I love work. It gives me something to do between weekends.
              Microsoft MVP (Visual C++)

              N Offline
              N Offline
              Nikz2
              wrote on last edited by
              #6

              Solution found. LRESULT MainDial::OnMyMsg(WPARAM, LPARAM) { CRect rr; this->GetWindowRect(&rr); rr.bottom-=1; rr.right-=1; MainDial::MoveWindow(rr); return NULL; } with ON_MESSAGE use. Big thnx.

              modified on Friday, October 23, 2009 8:30 PM

              _ 1 Reply Last reply
              0
              • N Nikz2

                Solution found. LRESULT MainDial::OnMyMsg(WPARAM, LPARAM) { CRect rr; this->GetWindowRect(&rr); rr.bottom-=1; rr.right-=1; MainDial::MoveWindow(rr); return NULL; } with ON_MESSAGE use. Big thnx.

                modified on Friday, October 23, 2009 8:30 PM

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #7

                :thumbsup:

                «_Superman_» I love work. It gives me something to do between weekends.
                Microsoft MVP (Visual C++)

                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