locked
ProgressBar Vertical RRS feed

  • Question

  • Hello
    I have a question how to do a vertical progress bar in visual studio 17 CLI / UI C ++ I searched the forum and hard to match anything to c ++ everything I found is on the vb The sea is some ready solution? Thank you in advance for your best regards
    Friday, September 21, 2018 11:11 AM

All replies

  • A ProgressBar with PBS_VERTICAL  style is vertical...
    Friday, September 21, 2018 11:47 AM
  • Hello,

    here is an example:

    https://www.codeproject.com/Articles/8422/Vertical-ProgressBar

    Regards, Guido

    Friday, September 21, 2018 12:13 PM
  • hello, could you give an example how to use this style PBS_VERTICAL ??
    Sunday, September 23, 2018 10:22 AM
  • hello but this is the code for vs 2005 and I would like to ask for a simple solution on vs17 in advance thank you

    Sunday, September 23, 2018 10:24 AM
  • hello, could you give an example how to use this style PBS_VERTICAL ??

    In C++/CLI, you override CreateParams :

    #define PBS_VERTICAL            0x04
    
    public ref class VerticalProgressBar : ProgressBar
    {
    protected: property System::Windows::Forms::CreateParams^ CreateParams
    {
    	virtual  System::Windows::Forms::CreateParams^ get() override
    	{
    		System::Windows::Forms::CreateParams^ cp = cp = ProgressBar::CreateParams;
    
    		cp->Style |= PBS_VERTICAL; 
    
    		return cp;
    	}
    }
    };

    Sunday, September 23, 2018 1:52 PM
  • hello silly question where do I paste this piece of code in which place ?? do you have to add a class? I am a bit green in vs17 and I am asking for a more detailed description. thank you in advance for your help :)
    Sunday, September 23, 2018 5:30 PM
  • The primary use for C++/CLI is to interoperate between unmanaged C++ and managed code.  In fact, Microsoft removed the templates to create a Windows Forms Project in C++ beginning with Visual Studio 2012.  Consequently, it is not surprising that there are few examples of user interface coding in C++/CLI.

    If you want to create a user interface in managed code I suggest you consider using C# or VB.Net.

    Sunday, September 23, 2018 8:39 PM
  • do you have to add a class?

    You can add a class with Class Name = VerticalProgressBar , Base Class =  ProgressBar

    Then you can test the control in Load event of the Form :

    private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e)
    {
    		VerticalProgressBar^ progressBar1;		
    		progressBar1 = (gcnew VerticalProgressBar());	
    		progressBar1->Location = System::Drawing::Point(120, 80);
    		progressBar1->Name = L"progressBar1";
    		progressBar1->Size = System::Drawing::Size(23, 100);
    		progressBar1->TabIndex = 0;
    		progressBar1->Value = 50;
    		this->Controls->Add(progressBar1);
    }

    Monday, September 24, 2018 12:28 AM
  • t actually works, but now I have a problem with the toolbox, I can not add anything, maybe I wrote something wrong in the code? here is my whole Myform + VerticalProgressBar code.

    #pragma once
    
    namespace Testprogressbar {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    #define PBS_VERTICAL            0x04
    
    	public ref class VerticalProgressBar : ProgressBar
    	{
    	protected: property System::Windows::Forms::CreateParams^ CreateParams
    	{
    		virtual  System::Windows::Forms::CreateParams^ get() override
    		{
    			System::Windows::Forms::CreateParams^ cp = cp = ProgressBar::CreateParams;
    
    			cp->Style |= PBS_VERTICAL;
    
    			return cp;
    		}
    	}
    	};
    	/// <summary>
    	/// Podsumowanie informacji o MyForm
    	/// </summary>
    	public ref class MyForm : public System::Windows::Forms::Form
    	{
    	public:
    		MyForm(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: W tym miejscu dodaj kod konstruktora
    			//
    		}
    
    	protected:
    		/// <summary>
    		/// Wyczyść wszystkie używane zasoby.
    		/// </summary>
    		~MyForm()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
    	private:
    		/// <summary>
    		/// Wymagana zmienna projektanta.
    		/// </summary>
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Wymagana metoda obsługi projektanta — nie należy modyfikować 
    		/// zawartość tej metody z edytorem kodu.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->SuspendLayout();
    			// 
    			// MyForm
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(284, 261);
    			this->Name = L"MyForm";
    			this->Text = L"MyForm";
    			this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
    			this->ResumeLayout(false);
    
    		}
    #pragma endregion
    	private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    		VerticalProgressBar^ progressBar1;
    		progressBar1 = (gcnew VerticalProgressBar());
    		progressBar1->Location = System::Drawing::Point(120, 80);
    		progressBar1->Name = L"progressBar1";
    		progressBar1->Size = System::Drawing::Size(23, 100);
    		progressBar1->TabIndex = 0;
    		progressBar1->Value = 50;
    		this->Controls->Add(progressBar1);
    	}
    	};
    }
    

    Monday, September 24, 2018 12:38 PM
  • Hi,

    Thanks for posting here.

    I have test whole Myform + VerticalProgressBar code, seems that it works well, 
    what do you mean about having a problem with toolbox and can't add anything?
    Do you means than you can't add anything here.

    Well, you should choose the MyForm.h, and double-click it, then you can add anything you want. Here below will show the details.

    If your question is more about WinForm, I suggest you to post your question on the winform forum for better support.

    Thanks for your understanding and Cooperation.

    Best Wishes,

    Jack Zhang


    MSDN Community Support&amp;amp;amp;amp;lt;br/&amp;amp;amp;amp;gt; Please remember to click &amp;amp;amp;amp;amp;quot;Mark as Answer&amp;amp;amp;amp;amp;quot; the responses that resolved your issue, and to click &amp;amp;amp;amp;amp;quot;Unmark as Answer&amp;amp;amp;amp;amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact &amp;amp;amp;amp;lt;a href=&amp;amp;amp;amp;quot;mailto:MSDNFSF@microsoft.com&amp;amp;amp;amp;quot;&amp;amp;amp;amp;gt;MSDNFSF@microsoft.com&amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;gt;

    Thursday, September 27, 2018 6:17 AM