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. Windows Forms
  4. Reset Control Attributes

Reset Control Attributes

Scheduled Pinned Locked Moved Windows Forms
questiongraphicsperformance
2 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.
  • Z Offline
    Z Offline
    zeos6
    wrote on last edited by
    #1

    Hi, Please forgive me as this may be a very simple question but I am a newbie at this. I have searched for this info for three days now and cannot seem to find any answers. I have two questions: Q1. How do I reset the background color of a push button. I have a standard button. In the code snippet below I also have a cursor style change. The cursor changes back to the original (default cursor) when the mouse leaves the button (without me including any cursor specific code in the MouseLeave function) but the back color does not change. I even tried to set up a pointer to store the original color and this works but after the mouse leaves the button the style of the button is chnaged to flat. Do I need to also store the FlatStyle and retrieve it on MoudeLeave? // declare an int pointer (for the exit button background color) called btnExit_default_BackColor int *btnExit_default_BackColor; // declare a boolean pointer (for the exit button UseVisualStyle background color) called btnExit_default_UseVisualStyleBackColor bool *btnExit_default_UseVisualStyleBackColor; private: System::Void btnExit_MouseEnter(System::Object^ sender, System::EventArgs^ e) { // allocate memory for an int variable and make the btnExit_default_BackColor pointer point to this new memmory btnExit_default_BackColor=new int; //assign the exit button background color to the memory allocated *btnExit_default_BackColor=btnExit->UseVisualStyleBackColor; // allocate memory for a bool variable and make the btnExit_default_UseVisualStyleBackColor pointer point to this new memmory btnExit_default_UseVisualStyleBackColor=new bool; //assign the exit button background color to the memory allocated *btnExit_default_UseVisualStyleBackColor=btnExit->UseVisualStyleBackColor; btnExit->Cursor=Cursors::Hand; // change mouse cursor to hand when over a push button // Change button outline color to 0x00FF4500 (orange red with opacity 0) System::String^ highlightColor="#0x00FF4500"; btnExit->BackColor=System::Drawing::ColorTranslator::FromHtml(highlightColor); } private: System::Void btnExit_MouseLeave(System::Object^ sender, System::EventArgs^ e) { // Change button outline color to original state before mouse hover btnExit->BackColor=System::Drawing::Color::FromArgb(*btnExit_default_BackColor); btnExit->UseVisualStyleBackColor=*btnExit_default_UseVisualStyleBackColor; delete btnExit_default_BackColor; // d

    Richard Andrew x64R 1 Reply Last reply
    0
    • Z zeos6

      Hi, Please forgive me as this may be a very simple question but I am a newbie at this. I have searched for this info for three days now and cannot seem to find any answers. I have two questions: Q1. How do I reset the background color of a push button. I have a standard button. In the code snippet below I also have a cursor style change. The cursor changes back to the original (default cursor) when the mouse leaves the button (without me including any cursor specific code in the MouseLeave function) but the back color does not change. I even tried to set up a pointer to store the original color and this works but after the mouse leaves the button the style of the button is chnaged to flat. Do I need to also store the FlatStyle and retrieve it on MoudeLeave? // declare an int pointer (for the exit button background color) called btnExit_default_BackColor int *btnExit_default_BackColor; // declare a boolean pointer (for the exit button UseVisualStyle background color) called btnExit_default_UseVisualStyleBackColor bool *btnExit_default_UseVisualStyleBackColor; private: System::Void btnExit_MouseEnter(System::Object^ sender, System::EventArgs^ e) { // allocate memory for an int variable and make the btnExit_default_BackColor pointer point to this new memmory btnExit_default_BackColor=new int; //assign the exit button background color to the memory allocated *btnExit_default_BackColor=btnExit->UseVisualStyleBackColor; // allocate memory for a bool variable and make the btnExit_default_UseVisualStyleBackColor pointer point to this new memmory btnExit_default_UseVisualStyleBackColor=new bool; //assign the exit button background color to the memory allocated *btnExit_default_UseVisualStyleBackColor=btnExit->UseVisualStyleBackColor; btnExit->Cursor=Cursors::Hand; // change mouse cursor to hand when over a push button // Change button outline color to 0x00FF4500 (orange red with opacity 0) System::String^ highlightColor="#0x00FF4500"; btnExit->BackColor=System::Drawing::ColorTranslator::FromHtml(highlightColor); } private: System::Void btnExit_MouseLeave(System::Object^ sender, System::EventArgs^ e) { // Change button outline color to original state before mouse hover btnExit->BackColor=System::Drawing::Color::FromArgb(*btnExit_default_BackColor); btnExit->UseVisualStyleBackColor=*btnExit_default_UseVisualStyleBackColor; delete btnExit_default_BackColor; // d

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      I can't answer your first question but I can explain the ^ operator: That operator is a reference to a managed object. So, if you have

      void btnExit_MouseLeave(System::Object^ sender, System::EventArgs^ e)

      That means that the function takes a reference to a System:Object and a reference to a System::EventArgs object. If you have Object* obj, it means that obj points to the object on the heap. In the same way, the ^ means that the variable points to the object on the managed heap. The ^ is used with the gcnew operator to assign a new object instance to a variable, as in:

      Object^ var = gcnew Object()

      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