Menu

ProgressBar??

2002-11-27
2012-09-26
  • Nobody/Anonymous

    How can i create and manage progress bars in C / Win32 API?
    I tried copying the code generated by the VC++ dialog editor, but it doesn't work.

     
    • Nobody/Anonymous

      It's cpp (part of my progress class), but you can figure it out:
      void CProgress::SetPosition(int nPos)
      {
      SendMessage(WindowHandle, PBM_SETPOS, (WPARAM)nPos, 0);
      }

      void CProgress::SetNoEdge(void)
      {
      long style;
      style = GetWindowLong (WindowHandle, GWL_EXSTYLE) ;
      style &= ~WS_EX_STATICEDGE ;
      SetWindowLong (WindowHandle, GWL_EXSTYLE, style) ;
      }

      void CProgress::Create(HINSTANCE hInst, HWND hwnd, int nLeft, int nRight, int nWidth, int nHeight)
      {

      WindowHandle = CreateWindowEx(0, //WS_EX_CLIENTEDGE,            //more or 'extended' styles
          PROGRESS_CLASS,                 //the 'class' of window to create
          NULL,                        //the window title
          WS_CHILD | WS_VISIBLE | PBS_SMOOTH, //window style: how it looks
          nLeft,                          //window position: left
          nRight,                          //window position: top
          nWidth,                         //window width
          nHeight,                          //window height
          hwnd,                        //parent window handle
          NULL,                        //handle to this windows's menu
          hInst,                     //application instance
          NULL);
         
      SendMessage(WindowHandle, PBM_SETPOS, 0, 0);

      }

      You need to call InitCommonControls beforehand and link with libcomctl32 or something like that.

      rpeter

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.